r47522 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47521‎ | r47522 | r47523 >
Date:22:14, 19 February 2009
Author:brion
Status:ok
Tags:
Comment:
* (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.
Modified paths:
  • /trunk/phase3/CREDITS (modified) (history)
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/MagicWord.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/includes/parser/ParserOutput.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SkinTemplate.php
@@ -690,11 +690,13 @@
691691 );
692692
693693 if ( $istalk || $wgOut->showNewSectionLink() ) {
694 - $content_actions['addsection'] = array(
695 - 'class' => $section == 'new'?'selected':false,
696 - 'text' => wfMsg('addsection'),
697 - 'href' => $this->mTitle->getLocalUrl( 'action=edit&section=new' )
698 - );
 694+ if ( !$wgOut->forceHideNewSectionLink() ) {
 695+ $content_actions['addsection'] = array(
 696+ 'class' => $section == 'new' ? 'selected' : false,
 697+ 'text' => wfMsg('addsection'),
 698+ 'href' => $this->mTitle->getLocalUrl( 'action=edit&section=new' )
 699+ );
 700+ }
699701 }
700702 } elseif ( $this->mTitle->isKnown() ) {
701703 $content_actions['viewsource'] = array(
Index: trunk/phase3/includes/MagicWord.php
@@ -92,6 +92,7 @@
9393 'numberofusers',
9494 'numberofactiveusers',
9595 'newsectionlink',
 96+ 'nonewsectionlink',
9697 'numberofpages',
9798 'currentversion',
9899 'basepagename',
@@ -160,6 +161,7 @@
161162 'toc',
162163 'noeditsection',
163164 'newsectionlink',
 165+ 'nonewsectionlink',
164166 'hiddencat',
165167 'index',
166168 'noindex',
Index: trunk/phase3/includes/parser/Parser.php
@@ -3388,6 +3388,12 @@
33893389 $this->mOutput->setNewSection( true );
33903390 }
33913391
 3392+ # Allow user to remove the "new section"
 3393+ # link via __NONEWSECTIONLINK__
 3394+ if ( isset( $this->mDoubleUnderscores['nonewsectionlink'] ) ) {
 3395+ $this->mOutput->hideNewSection( true );
 3396+ }
 3397+
33923398 # if the string __FORCETOC__ (not case-sensitive) occurs in the HTML,
33933399 # override above conditions and always show TOC above first header
33943400 if ( isset( $this->mDoubleUnderscores['forcetoc'] ) ) {
Index: trunk/phase3/includes/parser/ParserOutput.php
@@ -18,6 +18,7 @@
1919 $mImages = array(), # DB keys of the images used, in the array key only
2020 $mExternalLinks = array(), # External link URLs, in the key only
2121 $mNewSection = false, # Show a new section link?
 22+ $mHideNewSection = false, # Hide the new section link?
2223 $mNoGallery = false, # No gallery on category page? (__NOGALLERY__)
2324 $mHeadItems = array(), # Items to put in the <head> section
2425 $mOutputHooks = array(), # Hook tags as per $wgParserOutputHooks
@@ -80,6 +81,12 @@
8182 function setNewSection( $value ) {
8283 $this->mNewSection = (bool)$value;
8384 }
 85+ function hideNewSection ( $value ) {
 86+ $this->mHideNewSection = (bool)$value;
 87+ }
 88+ function getHideNewSection () {
 89+ return (bool)$this->mHideNewSection;
 90+ }
8491 function getNewSection() {
8592 return (bool)$this->mNewSection;
8693 }
Index: trunk/phase3/includes/OutputPage.php
@@ -29,6 +29,7 @@
3030 var $mArticleBodyOnly = false;
3131
3232 var $mNewSectionLink = false;
 33+ var $mHideNewSectionLink = false;
3334 var $mNoGallery = false;
3435 var $mPageTitleActionText = '';
3536 var $mParseWarnings = array();
@@ -516,6 +517,7 @@
517518 $this->mLanguageLinks += $parserOutput->getLanguageLinks();
518519 $this->addCategoryLinks( $parserOutput->getCategories() );
519520 $this->mNewSectionLink = $parserOutput->getNewSection();
 521+ $this->mHideNewSectionLink = $parserOutput->getHideNewSection();
520522
521523 if( is_null( $wgExemptFromUserRobotsControl ) ) {
522524 $bannedNamespaces = $wgContentNamespaces;
@@ -1778,6 +1780,15 @@
17791781 }
17801782
17811783 /**
 1784+ * Forcibly hide the new section link?
 1785+ *
 1786+ * @return bool
 1787+ */
 1788+ public function forceHideNewSectionLink() {
 1789+ return $this->mHideNewSectionLink;
 1790+ }
 1791+
 1792+ /**
17821793 * Show a warning about slave lag
17831794 *
17841795 * If the lag is higher than $wgSlaveLagCritical seconds,
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -311,6 +311,7 @@
312312 'displaytitle' => array( 1, 'DISPLAYTITLE' ),
313313 'rawsuffix' => array( 1, 'R' ),
314314 'newsectionlink' => array( 1, '__NEWSECTIONLINK__' ),
 315+ 'nonewsectionlink' => array( 1, '__NONEWSECTIONLINK__' ),
315316 'currentversion' => array( 1, 'CURRENTVERSION' ),
316317 'urlencode' => array( 0, 'URLENCODE:' ),
317318 'anchorencode' => array( 0, 'ANCHORENCODE' ),
Index: trunk/phase3/RELEASE-NOTES
@@ -197,6 +197,7 @@
198198 * ForeignApiRepos now fetch MIME types, rather than trying to figure it locally
199199 * (bug 17570) $wgMaxRedirects is now correctly respected when following
200200 redirects (was previously one more than $wgMaxRedirects)
 201+* (bug 16335) __NONEWSECTIONLINK__ magic word to suppress new section link.
201202
202203 == API changes in 1.15 ==
203204 * (bug 16858) Revamped list=deletedrevs to make listing deleted contributions
Index: trunk/phase3/CREDITS
@@ -59,6 +59,7 @@
6060 * Brad Jorsch
6161 * Brent G
6262 * Brianna Laugher
 63+* Carlin
6364 * Daniel Arnold
6465 * Danny B.
6566 * FunPika

Status & tagging log