* (bug 16335) __NONEWSECTIONLINK__ magic word to suppress new section link.
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 19 Feb 2009 22:14:59 +0000 (22:14 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 19 Feb 2009 22:14:59 +0000 (22:14 +0000)
Patch by Carlin: https://bugzilla.wikimedia.org/attachment.cgi?id=5680
With slight whitespace tweaks.

CREDITS
RELEASE-NOTES
includes/MagicWord.php
includes/OutputPage.php
includes/SkinTemplate.php
includes/parser/Parser.php
includes/parser/ParserOutput.php
languages/messages/MessagesEn.php

diff --git a/CREDITS b/CREDITS
index 119f243..718e500 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -59,6 +59,7 @@ following names for their contribution to the product.
 * Brad Jorsch
 * Brent G
 * Brianna Laugher
+* Carlin
 * Daniel Arnold
 * Danny B.
 * FunPika
index 3ee34d3..5c65070 100644 (file)
@@ -197,6 +197,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * ForeignApiRepos now fetch MIME types, rather than trying to figure it locally
 * (bug 17570) $wgMaxRedirects is now correctly respected when following
   redirects (was previously one more than $wgMaxRedirects)
+* (bug 16335) __NONEWSECTIONLINK__ magic word to suppress new section link.
 
 == API changes in 1.15 ==
 * (bug 16858) Revamped list=deletedrevs to make listing deleted contributions
index b3ebf6e..fcd6b03 100644 (file)
@@ -92,6 +92,7 @@ class MagicWord {
                'numberofusers',
                'numberofactiveusers',
                'newsectionlink',
+               'nonewsectionlink',
                'numberofpages',
                'currentversion',
                'basepagename',
@@ -160,6 +161,7 @@ class MagicWord {
                'toc',
                'noeditsection',
                'newsectionlink',
+               'nonewsectionlink',
                'hiddencat',
                'index',
                'noindex',
index acf7986..3862e3f 100644 (file)
@@ -29,6 +29,7 @@ class OutputPage {
        var $mArticleBodyOnly = false;
 
        var $mNewSectionLink = false;
+       var $mHideNewSectionLink = false;
        var $mNoGallery = false;
        var $mPageTitleActionText = '';
        var $mParseWarnings = array();
@@ -516,6 +517,7 @@ class OutputPage {
                $this->mLanguageLinks += $parserOutput->getLanguageLinks();
                $this->addCategoryLinks( $parserOutput->getCategories() );
                $this->mNewSectionLink = $parserOutput->getNewSection();
+               $this->mHideNewSectionLink = $parserOutput->getHideNewSection();
 
                if( is_null( $wgExemptFromUserRobotsControl ) ) {
                        $bannedNamespaces = $wgContentNamespaces;
@@ -1777,6 +1779,15 @@ class OutputPage {
                return $this->mNewSectionLink;
        }
 
+       /**
+       * Forcibly hide the new section link?
+       *
+       * @return bool
+       */
+       public function forceHideNewSectionLink() {
+               return $this->mHideNewSectionLink;
+       }
+
        /**
         * Show a warning about slave lag
         *
index ea26d8d..bf6fad3 100644 (file)
@@ -690,11 +690,13 @@ class SkinTemplate extends Skin {
                                );
 
                                if ( $istalk || $wgOut->showNewSectionLink() ) {
-                                       $content_actions['addsection'] = array(
-                                               'class' => $section == 'new'?'selected':false,
-                                               'text' => wfMsg('addsection'),
-                                               'href' => $this->mTitle->getLocalUrl( 'action=edit&section=new' )
-                                       );
+                                       if ( !$wgOut->forceHideNewSectionLink() ) {
+                                               $content_actions['addsection'] = array(
+                                                       'class' => $section == 'new' ? 'selected' : false,
+                                                       'text' => wfMsg('addsection'),
+                                                       'href' => $this->mTitle->getLocalUrl( 'action=edit&section=new' )
+                                               );
+                                       }
                                }
                        } elseif ( $this->mTitle->isKnown() ) {
                                $content_actions['viewsource'] = array(
index f5b351b..f60ed17 100644 (file)
@@ -3388,6 +3388,12 @@ class Parser
                        $this->mOutput->setNewSection( true );
                }
 
+               # Allow user to remove the "new section"
+               # link via __NONEWSECTIONLINK__
+               if ( isset( $this->mDoubleUnderscores['nonewsectionlink'] ) ) {
+                       $this->mOutput->hideNewSection( true );
+               }
+
                # if the string __FORCETOC__ (not case-sensitive) occurs in the HTML,
                # override above conditions and always show TOC above first header
                if ( isset( $this->mDoubleUnderscores['forcetoc'] ) ) {
index 4ad252a..22c1dfb 100644 (file)
@@ -18,6 +18,7 @@ class ParserOutput
                $mImages = array(),           # DB keys of the images used, in the array key only
                $mExternalLinks = array(),    # External link URLs, in the key only
                $mNewSection = false,         # Show a new section link?
+               $mHideNewSection = false,     # Hide the new section link?
                $mNoGallery = false,          # No gallery on category page? (__NOGALLERY__)
                $mHeadItems = array(),        # Items to put in the <head> section
                $mOutputHooks = array(),      # Hook tags as per $wgParserOutputHooks
@@ -80,6 +81,12 @@ class ParserOutput
        function setNewSection( $value ) {
                $this->mNewSection = (bool)$value;
        }
+       function hideNewSection ( $value ) {
+               $this->mHideNewSection = (bool)$value;
+       }
+       function getHideNewSection () {
+               return (bool)$this->mHideNewSection;
+       }
        function getNewSection() {
                return (bool)$this->mNewSection;
        }
index a35f848..96e82e8 100644 (file)
@@ -311,6 +311,7 @@ $magicWords = array(
        'displaytitle'           => array( 1,    'DISPLAYTITLE'           ),
        'rawsuffix'              => array( 1,    'R'                      ),
        'newsectionlink'         => array( 1,    '__NEWSECTIONLINK__'     ),
+       'nonewsectionlink'       => array( 1,    '__NONEWSECTIONLINK__'   ),
        'currentversion'         => array( 1,    'CURRENTVERSION'         ),
        'urlencode'              => array( 0,    'URLENCODE:'             ),
        'anchorencode'           => array( 0,    'ANCHORENCODE'           ),