(bug16979) Add tracking categories for __INDEX__ and __NOINDEX__.
authorHappy-melon <happy-melon@users.mediawiki.org>
Sun, 20 Sep 2009 22:14:09 +0000 (22:14 +0000)
committerHappy-melon <happy-melon@users.mediawiki.org>
Sun, 20 Sep 2009 22:14:09 +0000 (22:14 +0000)
RELEASE-NOTES
includes/parser/Parser.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messages.inc

index de0437b..e95dd3e 100644 (file)
@@ -238,6 +238,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * A new permission, 'root', is created.  Analogous to root users on Unix systems,
   the root permission effectively grants all other permissions on a wiki.  Useful
   for debugging and administration.
+* (bug 16979) Tracking categories for __INDEX__ and __NOINDEX__
 
 === Bug fixes in 1.16 ===
 
index 20af1c6..9c8cae1 100644 (file)
@@ -3332,25 +3332,39 @@ class Parser
                }
                if ( isset( $this->mDoubleUnderscores['hiddencat'] ) && $this->mTitle->getNamespace() == NS_CATEGORY ) {
                        $this->mOutput->setProperty( 'hiddencat', 'y' );
-
-                       $containerCategory = Title::makeTitleSafe( NS_CATEGORY, wfMsgForContent( 'hidden-category-category' ) );
-                       if ( $containerCategory ) {
-                               $this->mOutput->addCategory( $containerCategory->getDBkey(), $this->getDefaultSort() );
-                       } else {
-                               wfDebug( __METHOD__.": [[MediaWiki:hidden-category-category]] is not a valid title!\n" );
-                       }
+                       $this->addTrackingCategory( 'hidden-category-category' );
                }
                # (bug 8068) Allow control over whether robots index a page.
                #
                # FIXME (bug 14899): __INDEX__ always overrides __NOINDEX__ here!  This
                # is not desirable, the last one on the page should win.
-               if( isset( $this->mDoubleUnderscores['noindex'] ) ) {
+               if( isset( $this->mDoubleUnderscores['noindex'] ) && $this->mTitle->canUseNoindex() ) {
                        $this->mOutput->setIndexPolicy( 'noindex' );
-               } elseif( isset( $this->mDoubleUnderscores['index'] ) ) {
+                       $this->addTrackingCategory( 'noindex-category' );
+               }
+               if( isset( $this->mDoubleUnderscores['index'] ) && $this->mTitle->canUseNoindex() ){
                        $this->mOutput->setIndexPolicy( 'index' );
+                       $this->addTrackingCategory( 'index-category' );
                }
                wfProfileOut( __METHOD__ );
                return $text;
+       }       
+       
+       /**
+        * Add a tracking category, getting the title from a system message,
+        * or print a debug message if the title is invalid.
+        * @param $msg String message key
+        * @return Bool whether the addition was successful
+        */
+       protected function addTrackingCategory( $msg ){
+               $containerCategory = Title::makeTitleSafe( NS_CATEGORY, wfMsgForContent( $msg ) );
+               if ( $containerCategory ) {
+                       $this->mOutput->addCategory( $containerCategory->getDBkey(), $this->getDefaultSort() );
+                       return true;
+               } else {
+                       wfDebug( __METHOD__.": [[MediaWiki:$msg]] is not a valid title!\n" );
+                       return false;
+               }
        }
 
        /**
index b70f684..f8fff4f 100644 (file)
@@ -735,6 +735,8 @@ XHTML id names.
 'category-file-count'            => '{{PLURAL:$2|This category contains only the following file.|The following {{PLURAL:$1|file is|$1 files are}} in this category, out of $2 total.}}',
 'category-file-count-limited'    => 'The following {{PLURAL:$1|file is|$1 files are}} in the current category.',
 'listingcontinuesabbrev'         => 'cont.',
+'index-category'                 => 'Indexed pages',
+'noindex-category'               => 'Noindexed pages',
 
 'linkprefix'        => '/^(.*?)([a-zA-Z\\x80-\\xff]+)$/sD', # only translate this message to other languages if you have to change it
 'mainpagetext'      => "<big>'''MediaWiki has been successfully installed.'''</big>",
index 1fcc1c5..f87b743 100644 (file)
@@ -236,6 +236,8 @@ This is the toolbar: [[Image:Toolbar.png]]",
 * $1: number of files shown',
 'listingcontinuesabbrev'         => 'Shown in contiuation of each first letter group.
 See http://test.wikipedia.org/wiki/Category:Test_ko?uselang={{SUBPAGENAME}}, for example.',
+'index-category'                 => 'Name of the category where pages with the <nowiki>__INDEX__</nowiki> behaviour switch are listed',
+'noindex-category'               => 'Name of the category where pages with the <nowiki>__NOINDEX__</nowiki> behaviour switch are listed',
 
 'linkprefix'        => '{{optional}}',
 'mainpagetext'      => 'Along with {{msg|mainpagedocfooter}}, the text you will see on the Main Page when your wiki is installed.',
index 4e73868..b7ee901 100644 (file)
@@ -141,6 +141,8 @@ $wgMessageStructure = array(
                'category-file-count',
                'category-file-count-limited',
                'listingcontinuesabbrev',
+               'index-category',
+               'noindex-category',
        ),
        'mainpage' => array(
                'linkprefix',