Merge "Fix GUI for Special:Tags if a user has deletechangetags permission only"
[lhc/web/wiklou.git] / includes / specials / SpecialTrackingCategories.php
index 7684c05..b13f27b 100644 (file)
@@ -36,13 +36,31 @@ class SpecialTrackingCategories extends SpecialPage {
                parent::__construct( 'TrackingCategories' );
        }
 
+       /**
+        * Tracking categories that exist in core
+        *
+        * @var array
+        */
+       private static $coreTrackingCategories = [
+               'index-category',
+               'noindex-category',
+               'duplicate-args-category',
+               'expensive-parserfunction-category',
+               'post-expand-template-argument-category',
+               'post-expand-template-inclusion-category',
+               'hidden-category-category',
+               'broken-file-category',
+               'node-count-exceeded-category',
+               'expansion-depth-exceeded-category',
+       ];
+
        function execute( $par ) {
                $this->setHeaders();
                $this->outputHeader();
                $this->getOutput()->allowClickjacking();
                $this->getOutput()->addHTML(
-                       Html::openElement( 'table', array( 'class' => 'mw-datatable',
-                               'id' => 'mw-trackingcategories-table' ) ) . "\n" .
+                       Html::openElement( 'table', [ 'class' => 'mw-datatable',
+                               'id' => 'mw-trackingcategories-table' ] ) . "\n" .
                        "<thead><tr>
                        <th>" .
                                $this->msg( 'trackingcategories-msg' )->escaped() . "
@@ -68,7 +86,7 @@ class SpecialTrackingCategories extends SpecialPage {
                $batch->execute();
 
                foreach ( $trackingCategories as $catMsg => $data ) {
-                       $allMsgs = array();
+                       $allMsgs = [];
                        $catDesc = $catMsg . '-desc';
 
                        $catMsgTitleText = Linker::link(
@@ -100,13 +118,13 @@ class SpecialTrackingCategories extends SpecialPage {
 
                        $this->getOutput()->addHTML(
                                Html::openElement( 'tr' ) .
-                               Html::openElement( 'td', array( 'class' => 'mw-trackingcategories-name' ) ) .
+                               Html::openElement( 'td', [ 'class' => 'mw-trackingcategories-name' ] ) .
                                        $this->getLanguage()->commaList( array_unique( $allMsgs ) ) .
                                Html::closeElement( 'td' ) .
-                               Html::openElement( 'td', array( 'class' => 'mw-trackingcategories-msg' ) ) .
+                               Html::openElement( 'td', [ 'class' => 'mw-trackingcategories-msg' ] ) .
                                        $catMsgTitleText .
                                Html::closeElement( 'td' ) .
-                               Html::openElement( 'td', array( 'class' => 'mw-trackingcategories-desc' ) ) .
+                               Html::openElement( 'td', [ 'class' => 'mw-trackingcategories-desc' ] ) .
                                        $descMsg->parse() .
                                Html::closeElement( 'td' ) .
                                Html::closeElement( 'tr' )
@@ -120,15 +138,20 @@ class SpecialTrackingCategories extends SpecialPage {
         * @return array Array( 'msg' => Title, 'cats' => Title[] )
         */
        private function prepareTrackingCategoriesData() {
-               $trackingCategories = array();
-               foreach ( $this->getConfig()->get( 'TrackingCategories' ) as $catMsg ) {
+               $categories = array_merge(
+                       self::$coreTrackingCategories,
+                       ExtensionRegistry::getInstance()->getAttribute( 'TrackingCategories' ),
+                       $this->getConfig()->get( 'TrackingCategories' ) // deprecated
+               );
+               $trackingCategories = [];
+               foreach ( $categories as $catMsg ) {
                        /*
                         * Check if the tracking category varies by namespace
                         * Otherwise only pages in the current namespace will be displayed
                         * If it does vary, show pages considering all namespaces
                         */
                        $msgObj = $this->msg( $catMsg )->inContentLanguage();
-                       $allCats = array();
+                       $allCats = [];
                        $catMsgTitle = Title::makeTitleSafe( NS_MEDIAWIKI, $catMsg );
                        if ( !$catMsgTitle ) {
                                continue;
@@ -162,10 +185,10 @@ class SpecialTrackingCategories extends SpecialPage {
                                        }
                                }
                        }
-                       $trackingCategories[$catMsg] = array(
+                       $trackingCategories[$catMsg] = [
                                'cats' => $allCats,
                                'msg' => $catMsgTitle,
-                       );
+                       ];
                }
 
                return $trackingCategories;