r89457 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89456‎ | r89457 | r89458 >
Date:09:29, 4 June 2011
Author:nikerabbit
Status:deferred
Tags:
Comment:
Hack for making Special:MyLanguage links red if target doesn't exists
Modified paths:
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/specials/SpecialMyLanguage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/Translate.php
@@ -116,6 +116,8 @@
117117 $wgHooks['SpecialSearchProfileForm'][] = 'TranslateEditAddons::searchProfileForm';
118118 $wgHooks['SpecialSearchSetupEngine'][] = 'TranslateEditAddons::searchProfileSetupEngine';
119119
 120+$wgHooks['LinkBegin'][] = 'SpecialMyLanguage::linkfix';
 121+
120122 // New rights
121123 $wgAvailableRights[] = 'translate';
122124 $wgAvailableRights[] = 'translate-import';
Index: trunk/extensions/Translate/specials/SpecialMyLanguage.php
@@ -50,4 +50,26 @@
5151
5252 $wgOut->redirect( $title->getLocalURL() );
5353 }
 54+
 55+ /**
 56+ * Make Special:MyLanguage links red if the target page doesn't exists.
 57+ * A bit hacky because the core code is not so flexible.
 58+ */
 59+ public static function linkfix( $dummy, $target, &$html, &$customAttribs, &$query, &$options, &$ret ) {
 60+ if ( $target->getNamespace() == NS_SPECIAL ) {
 61+ list( $name, $subpage ) = SpecialPage::resolveAlias( $target->getDBkey() );
 62+ if ( $name === 'MyLanguage' ) {
 63+ $realTarget = Title::newFromText( $subpage );
 64+ if ( !$realTarget->exists() ) {
 65+ $options[] = 'broken';
 66+ $index = array_search( 'known', $options, true );
 67+ if ( $index !== false ) unset( $options[$index] );
 68+
 69+ $index = array_search( 'noclasses', $options, true );
 70+ if ( $index !== false ) unset( $options[$index] );
 71+ }
 72+ }
 73+ }
 74+ return true;
 75+ }
5476 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r89458Fix for r89457.nikerabbit09:32, 4 June 2011

Status & tagging log