X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialTrackingCategories.php;h=73bdbd6ac6642f2b40d05b629a29c34581b1ec3a;hb=eeead079979e37e276e2b5411dd82b67988ad357;hp=8a32ba98da52841da270cc51b5382ad7c61183ee;hpb=4f08c6760dd4a1b238efdb8f4717ad3b3a310125;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialTrackingCategories.php b/includes/specials/SpecialTrackingCategories.php index 8a32ba98da..73bdbd6ac6 100644 --- a/includes/specials/SpecialTrackingCategories.php +++ b/includes/specials/SpecialTrackingCategories.php @@ -59,7 +59,7 @@ class SpecialTrackingCategories extends SpecialPage { " ); - foreach( $wgTrackingCategories as $catMsg ) { + foreach ( $wgTrackingCategories as $catMsg ) { /* * Check if the tracking category varies by namespace * Otherwise only pages in the current namespace will be displayed @@ -69,18 +69,42 @@ class SpecialTrackingCategories extends SpecialPage { $allMsgs = array(); $catDesc = $catMsg . '-desc'; $catMsgTitle = Title::makeTitleSafe( NS_MEDIAWIKI, $catMsg ); + if ( !$catMsgTitle ) { + continue; + } $catMsgTitleText = Linker::link( $catMsgTitle, htmlspecialchars( $catMsg ) ); - if ( strpos( $msgObj->plain(), '{{NAMESPACE}}' ) !== false ) { + // Match things like {{NAMESPACE}} and {{NAMESPACENUMBER}}. + // False positives are ok, this is just an efficiency shortcut + if ( strpos( $msgObj->plain(), '{{' ) !== false ) { $ns = MWNamespace::getValidNamespaces(); foreach ( $ns as $namesp ) { $tempTitle = Title::makeTitleSafe( $namesp, $catMsg ); + if ( !$tempTitle ) { + continue; + } $catName = $msgObj->title( $tempTitle )->text(); - if ( !$msgObj->isDisabled() ) { + # Allow tracking categories to be disabled by setting them to "-" + if ( $catName !== '-' ) { $catTitle = Title::makeTitleSafe( NS_CATEGORY, $catName ); + if ( $catTitle ) { + $catTitleText = Linker::link( + $catTitle, + htmlspecialchars( $catName ) + ); + $allMsgs[] = $catTitleText; + } + } + } + } else { + $catName = $msgObj->text(); + # Allow tracking categories to be disabled by setting them to "-" + if ( $catName !== '-' ) { + $catTitle = Title::makeTitleSafe( NS_CATEGORY, $catName ); + if ( $catTitle ) { $catTitleText = Linker::link( $catTitle, htmlspecialchars( $catName ) @@ -88,18 +112,11 @@ class SpecialTrackingCategories extends SpecialPage { $allMsgs[] = $catTitleText; } } - } else { - $catName = $msgObj->text(); - if ( !$msgObj->isDisabled() ) { - $catTitle = Title::makeTitleSafe( NS_CATEGORY, $catName ); - $catTitleText = Linker::link( - $catTitle, - htmlspecialchars( $catName ) - ); - } else { - $catTitleText = $this->msg( 'trackingcategories-disabled' )->parse(); - } - $allMsgs[] = $catTitleText; + } + + # Extra message, when no category was found + if ( !count( $allMsgs ) ) { + $allMsgs[] = $this->msg( 'trackingcategories-disabled' )->parse(); } /*