r108988 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108987‎ | r108988 | r108989 >
Date:16:05, 15 January 2012
Author:jeroendedauw
Status:ok
Tags:
Comment:
fix display of object names in log for mw 1.19; not caring about 1.18 for now
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPLogFormatter.php (added) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/includes/EPLogFormatter.php
@@ -0,0 +1,42 @@
 2+<?php
 3+
 4+/**
 5+ * Class for logging changes to objects managed by the Education Program extension.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file EPLogFormatter.php
 10+ * @ingroup EducationProgram
 11+ *
 12+ * @licence GNU GPL v3 or later
 13+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 14+ */
 15+class EPLogFormatter extends LogFormatter {
 16+
 17+ /**
 18+ * (non-PHPdoc)
 19+ * @see LogFormatter::makePageLink()
 20+ *
 21+ * @since 0.1
 22+ *
 23+ * This is overriden to change the link text to only include the name of the object,
 24+ * rather then the full name of it's page.
 25+ */
 26+ protected function makePageLink( Title $title = null, $parameters = array() ) {
 27+ if ( !$title instanceof Title ) {
 28+ throw new MWException( "Expected title, got null" );
 29+ }
 30+
 31+ $text = explode( '/', $title->getText(), 2 );
 32+ $text = $text[count( $text ) - 1];
 33+
 34+ if ( !$this->plaintext ) {
 35+ $link = Linker::link( $title, htmlspecialchars( $text ), array(), $parameters );
 36+ } else {
 37+
 38+ $link = '[[' . $title->getPrefixedText() . '|' . $text . ']]';
 39+ }
 40+ return $link;
 41+ }
 42+
 43+}
Property changes on: trunk/extensions/EducationProgram/includes/EPLogFormatter.php
___________________________________________________________________
Added: svn:eol-style
144 + native
Index: trunk/extensions/EducationProgram/EducationProgram.php
@@ -63,6 +63,7 @@
6464 $wgAutoloadClasses['EPCourse'] = dirname( __FILE__ ) . '/includes/EPCourse.php';
6565 $wgAutoloadClasses['EPCoursePager'] = dirname( __FILE__ ) . '/includes/EPCoursePager.php';
6666 $wgAutoloadClasses['EPDBObject'] = dirname( __FILE__ ) . '/includes/EPDBObject.php';
 67+$wgAutoloadClasses['EPLogFormatter'] = dirname( __FILE__ ) . '/includes/EPLogFormatter.php';
6768 $wgAutoloadClasses['EPMentor'] = dirname( __FILE__ ) . '/includes/EPMentor.php';
6869 $wgAutoloadClasses['EPMentorPager'] = dirname( __FILE__ ) . '/includes/EPMentorPager.php';
6970 $wgAutoloadClasses['EPOrg'] = dirname( __FILE__ ) . '/includes/EPOrg.php';
@@ -153,13 +154,13 @@
154155 $wgLogTypes[] = 'ambassador';
155156 $wgLogTypes[] = 'instructor';
156157
157 -if ( array_key_exists( 'LogFormatter', $wgAutoloadClasses ) ) {
158 - $wgLogActionsHandlers['institution/*'] = 'LogFormatter';
159 - $wgLogActionsHandlers['course/*'] = 'LogFormatter';
160 - $wgLogActionsHandlers['term/*'] = 'LogFormatter';
161 - $wgLogActionsHandlers['student/*'] = 'LogFormatter';
162 - $wgLogActionsHandlers['ambassador/*'] = 'LogFormatter';
163 - $wgLogActionsHandlers['instructor/*'] = 'LogFormatter';
 158+if ( array_key_exists( 'LogFormatter', $wgAutoloadLocalClasses ) ) {
 159+ $wgLogActionsHandlers['institution/*'] = 'EPLogFormatter';
 160+ $wgLogActionsHandlers['course/*'] = 'EPLogFormatter';
 161+ $wgLogActionsHandlers['term/*'] = 'EPLogFormatter';
 162+ $wgLogActionsHandlers['student/*'] = 'EPLogFormatter';
 163+ $wgLogActionsHandlers['ambassador/*'] = 'EPLogFormatter';
 164+ $wgLogActionsHandlers['instructor/*'] = 'EPLogFormatter';
164165 }
165166 else {
166167 // Compatibility with MediaWiki 1.18.

Status & tagging log