r110237 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110236‎ | r110237 | r110238 >
Date:12:39, 29 January 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
follow up to r110234; also fix the actual link and made it work for the talk pages
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/EducationProgram.hooks.php
@@ -227,11 +227,20 @@
228228 }
229229
230230 protected static function displayTabs( SkinTemplate &$sktemplate, array &$links, Title $title ) {
231 - $classes = array(
 231+ $classes = array(
232232 EP_NS_INSTITUTION => 'EPOrg',
233233 EP_NS_COURSE => 'EPCourse',
234234 );
235235
 236+ $ns = array(
 237+ EP_NS_COURSE,
 238+ EP_NS_COURSE_TALK,
 239+ EP_NS_INSTITUTION,
 240+ EP_NS_INSTITUTION_TALK,
 241+ );
 242+
 243+ $exists = null;
 244+
236245 if ( array_key_exists( $title->getNamespace(), $classes ) ) {
237246 $links['views'] = array();
238247 $links['actions'] = array();
@@ -277,14 +286,23 @@
278287 }
279288 }
280289 }
 290+ }
 291+
 292+ if ( in_array( $title->getNamespace(), $ns ) ) {
 293+ $subjectTitle = $title->getSubjectPage();
281294
 295+ if ( is_null( $exists ) ) {
 296+ $class = $classes[$subjectTitle->getNamespace()];
 297+ $exists = $class::hasIdentifier( $title->getText() );
 298+ }
 299+
282300 $tab = array_shift( $links['namespaces'] );
283 - self::fixNewClass( $tab, $exists );
 301+ self::fixRedlinking( $tab, $exists, $subjectTitle );
284302 array_unshift( $links['namespaces'], $tab );
285 - }
 303+ }
286304 }
287305
288 - protected static function fixNewClass( &$tab, $exists ) {
 306+ protected static function fixRedlinking( array &$tab, $exists, Title $title ) {
289307 $classes = explode( ' ', $tab['class'] );
290308 $classes = array_flip( $classes );
291309
@@ -299,6 +317,15 @@
300318 }
301319
302320 $tab['class'] = implode( ' ', $classes );
 321+
 322+ $query = array();
 323+
 324+ if ( !$exists ) {
 325+ $query['action'] = 'edit';
 326+ $query['redlink'] = '1';
 327+ }
 328+
 329+ $tab['href'] = $title->getLocalURL( $query );
303330 }
304331
305332 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r110234fix class of main tabjeroendedauw12:13, 29 January 2012

Status & tagging log