From: Brion Vibber Date: Thu, 19 Feb 2009 22:14:59 +0000 (+0000) Subject: * (bug 16335) __NONEWSECTIONLINK__ magic word to suppress new section link. X-Git-Tag: 1.31.0-rc.0~42783 X-Git-Url: https://git.cyclocoop.org//%22?a=commitdiff_plain;h=92079d3b1c977fa577bd64883f2016a4b2a15788;p=lhc%2Fweb%2Fwiklou.git * (bug 16335) __NONEWSECTIONLINK__ magic word to suppress new section link. Patch by Carlin: https://bugzilla.wikimedia.org/attachment.cgi?id=5680 With slight whitespace tweaks. --- diff --git a/CREDITS b/CREDITS index 119f243425..718e500eb5 100644 --- 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 diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 3ee34d3f46..5c65070674 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 diff --git a/includes/MagicWord.php b/includes/MagicWord.php index b3ebf6e86a..fcd6b0343d 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -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', diff --git a/includes/OutputPage.php b/includes/OutputPage.php index acf798650d..3862e3f516 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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 * diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index ea26d8d2d9..bf6fad3fce 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -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§ion=new' ) - ); + if ( !$wgOut->forceHideNewSectionLink() ) { + $content_actions['addsection'] = array( + 'class' => $section == 'new' ? 'selected' : false, + 'text' => wfMsg('addsection'), + 'href' => $this->mTitle->getLocalUrl( 'action=edit§ion=new' ) + ); + } } } elseif ( $this->mTitle->isKnown() ) { $content_actions['viewsource'] = array( diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index f5b351bb81..f60ed17523 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -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'] ) ) { diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index 4ad252a7a7..22c1dfba2a 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -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 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; } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index a35f8481ae..96e82e8290 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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' ),