Index: trunk/extensions/Translate/Translate.php |
— | — | @@ -116,6 +116,8 @@ |
117 | 117 | $wgHooks['SpecialSearchProfileForm'][] = 'TranslateEditAddons::searchProfileForm'; |
118 | 118 | $wgHooks['SpecialSearchSetupEngine'][] = 'TranslateEditAddons::searchProfileSetupEngine'; |
119 | 119 | |
| 120 | +$wgHooks['LinkBegin'][] = 'SpecialMyLanguage::linkfix'; |
| 121 | + |
120 | 122 | // New rights |
121 | 123 | $wgAvailableRights[] = 'translate'; |
122 | 124 | $wgAvailableRights[] = 'translate-import'; |
Index: trunk/extensions/Translate/specials/SpecialMyLanguage.php |
— | — | @@ -50,4 +50,26 @@ |
51 | 51 | |
52 | 52 | $wgOut->redirect( $title->getLocalURL() ); |
53 | 53 | } |
| 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 | + } |
54 | 76 | } |