Bug 6031 (feature request for __NOGALLERY__ on category pages) fixed
authorMagnus Manske <magnusmanske@users.mediawiki.org>
Tue, 13 Jun 2006 11:37:09 +0000 (11:37 +0000)
committerMagnus Manske <magnusmanske@users.mediawiki.org>
Tue, 13 Jun 2006 11:37:09 +0000 (11:37 +0000)
includes/Article.php
includes/CategoryPage.php
includes/MagicWord.php
includes/OutputPage.php
includes/Parser.php
languages/Language.php

index 2b31493..d3c9ca2 100644 (file)
@@ -863,7 +863,6 @@ class Article {
                                $wgOut->addPrimaryWikiText( $text, $this );
                        } else {
                                # Display content, don't attempt to save to parser cache
-
                                # Don't show section-edit links on old revisions... this way lies madness.
                                if( !$this->isCurrent() ) {
                                        $oldEditSectionSetting = $wgOut->mParserOptions->setEditSection( false );
@@ -881,7 +880,7 @@ class Article {
                if( empty( $t ) ) {
                        $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
                }
-               
+
                # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
                if( $ns == NS_USER_TALK &&
                        User::isIP( $this->mTitle->getText() ) ) {
index 790838f..a27e6cd 100644 (file)
@@ -40,7 +40,12 @@ class CategoryPage extends Article {
                global $wgOut, $wgRequest;
                $from = $wgRequest->getVal( 'from' );
                $until = $wgRequest->getVal( 'until' );
+               
+               global $wgCategoryMagicGallery;
+               $cmg = $wgCategoryMagicGallery;
+               $wgCategoryMagicGallery = !$wgOut->mNoGallery;
                $wgOut->addHTML( $this->doCategoryMagic( $from, $until ) );
+               $wgCategoryMagicGallery = $cmg;
        }
 
        /**
index a68407c..b5a58c2 100644 (file)
@@ -94,6 +94,7 @@ $magicWords = array(
        'MAG_LANGUAGE',
        'MAG_CONTENTLANGUAGE',
        'MAG_PAGESINNAMESPACE',
+       'MAG_NOGALLERY',
 );
 if ( ! defined( 'MEDIAWIKI_INSTALL' ) )
        wfRunHooks( 'MagicWordMagicWords', array( &$magicWords ) );
index b717292..0dd8526 100644 (file)
@@ -327,6 +327,7 @@ class OutputPage {
 
                $this->addParserOutputNoText( $parserOutput );
                $text = $parserOutput->getText();
+               $this->mNoGallery = $parserOutput->getNoGallery();
                wfRunHooks( 'OutputPageBeforeHTML',array( &$this, &$text ) );
                $parserOutput->setText( $text );
                $this->addHTML( $parserOutput->getText() );
@@ -380,6 +381,7 @@ class OutputPage {
                        $this->addCategoryLinks( $parserOutput->getCategories() );
                        $this->addKeywords( $parserOutput );
                        $this->mNewSectionLink = $parserOutput->getNewSection();
+                       $this->mNoGallery = $parserOutput->getNoGallery();
                        $text = $parserOutput->getText();
                        wfRunHooks( 'OutputPageBeforeHTML', array( &$this, &$text ) );
                        $this->addHTML( $text );
index 82e2211..ed808d9 100644 (file)
@@ -843,6 +843,7 @@ class Parser
                $text = preg_replace( '/(^|\n)-----*/', '\\1<hr />', $text );
 
                $text = $this->stripToc( $text );
+               $this->stripNoGallery( $text );
                $text = $this->doHeadings( $text );
                if($this->mOptions->getUseDynamicDates()) {
                        $df =& DateFormatter::getInstance();
@@ -3172,6 +3173,16 @@ class Parser
                }
        }
 
+       /**
+        * Detect __NOGALLERY__ magic word and set a placeholder
+        */
+       function stripNoGallery( &$text ) {
+               # if the string __NOGALLERY__ (not case-sensitive) occurs in the HTML,
+               # do not add TOC
+               $mw = MagicWord::get( MAG_NOGALLERY );
+               $this->mOutput->mNoGallery = $mw->matchAndRemove( $text ) ;
+       }
+
        /**
         * Detect __TOC__ magic word and set a placeholder
         */
@@ -4424,7 +4435,8 @@ class ParserOutput
                $mExternalLinks,    # External link URLs, in the key only
                $mHTMLtitle,            # Display HTML title
                $mSubtitle,                     # Additional subtitle
-               $mNewSection;           # Show a new section link?
+               $mNewSection,           # Show a new section link?
+               $mNoGallery;            # No gallery on category page? (__NOGALLERY__)
 
        function ParserOutput( $text = '', $languageLinks = array(), $categoryLinks = array(),
                $containsOldMagic = false, $titletext = '' )
@@ -4443,6 +4455,7 @@ class ParserOutput
                $this->mHTMLtitle = "" ;
                $this->mSubtitle = "" ;
                $this->mNewSection = false;
+               $this->mNoGallery = false;
        }
 
        function getText()                   { return $this->mText; }
@@ -4455,6 +4468,7 @@ class ParserOutput
        function &getTemplates()             { return $this->mTemplates; }
        function &getImages()                { return $this->mImages; }
        function &getExternalLinks()         { return $this->mExternalLinks; }
+       function getNoGallery()              { return $this->mNoGallery; }
 
        function containsOldMagic()          { return $this->mContainsOldMagic; }
        function setText( $text )            { return wfSetVar( $this->mText, $text ); }
index 30d9044..9d8c159 100644 (file)
@@ -213,6 +213,7 @@ $wgLanguageNamesEn =& $wgLanguageNames;
 #   ID                                 CASE  SYNONYMS
        MAG_REDIRECT             => array( 0,    '#REDIRECT'              ),
        MAG_NOTOC                => array( 0,    '__NOTOC__'              ),
+       MAG_NOGALLERY                    => array( 0,    '__NOGALLERY__'          ),
        MAG_FORCETOC             => array( 0,    '__FORCETOC__'           ),
        MAG_TOC                  => array( 0,    '__TOC__'                ),
        MAG_NOEDITSECTION        => array( 0,    '__NOEDITSECTION__'      ),