* Updated initStats maintenance script
* (bug 5767) Fix date formats in Vietnamese locale
* (bug 361) URL in URL, they were almost fixed. Now they are.
+* (bug 4876) Add __NEWSECTIONLINK__ magic word to force the "new section" link/tab to
+ show up on specific pages on demand
== Compatibility ==
'MAG_SUBJECTPAGENAMEE',
'MAG_NUMBEROFUSERS',
'MAG_RAWSUFFIX',
+ 'MAG_NEWSECTIONLINK',
);
if ( ! defined( 'MEDIAWIKI_INSTALL' ) )
wfRunHooks( 'MagicWordMagicWords', array( &$magicWords ) );
MAG_SUBJECTPAGENAMEE,
MAG_NUMBEROFUSERS,
MAG_RAWSUFFIX,
+ MAG_NEWSECTIONLINK,
);
if ( ! defined( 'MEDIAWIKI_INSTALL' ) )
wfRunHooks( 'MagicWordwgVariableIDs', array( &$wgVariableIDs ) );
var $mShowFeedLinks = false;
var $mEnableClientCache = true;
var $mArticleBodyOnly = false;
+
+ var $mNewSectionLink = false;
/**
* Constructor
$this->mScripts = '';
$this->mETag = false;
$this->mRevisionId = null;
+ $this->mNewSectionLink = false;
}
function addHeader( $name, $val ) { array_push( $this->mHeaders, $name.': '.$val ); }
function addParserOutputNoText( &$parserOutput ) {
$this->mLanguageLinks += $parserOutput->getLanguageLinks();
$this->addCategoryLinks( $parserOutput->getCategories() );
+ $this->mNewSectionLink = $parserOutput->getNewSection();
$this->addKeywords( $parserOutput );
if ( $parserOutput->getCacheTime() == -1 ) {
$this->enableClientCache( false );
$this->mLanguageLinks += $parserOutput->getLanguageLinks();
$this->addCategoryLinks( $parserOutput->getCategories() );
$this->addKeywords( $parserOutput );
+ $this->mNewSectionLink = $parserOutput->getNewSection();
$text = $parserOutput->getText();
wfRunHooks( 'OutputPageBeforeHTML', array( &$this, &$text ) );
$this->addHTML( $text );
'Sorry, the server has encountered an internal error. ' .
'Please wait a moment and hit "refresh" to submit the request again.' );
}
+
+ /**
+ * Show an "add new section" link?
+ *
+ * @return bool True if the parser output instructs us to add one
+ */
+ function showNewSectionLink() {
+ return $this->mNewSectionLink;
+ }
}
?>
* changes in an incompatible way, so the parser cache
* can automatically discard old data.
*/
-define( 'MW_PARSER_VERSION', '1.6.0' );
+define( 'MW_PARSER_VERSION', '1.6.1' );
/**
* Variable substitution O(N^2) attack
$doShowToc = false;
}
+ # Allow user to stipulate that a page should have a "new section"
+ # link added via __NEWSECTIONLINK__
+ $mw =& MagicWord::get( MAG_NEWSECTIONLINK );
+ if( $mw->matchAndRemove( $text ) )
+ $this->mOutput->setNewSection( true );
+
# if the string __TOC__ (not case-sensitive) occurs in the HTML,
# override above conditions and always show TOC at that place
$mImages, # DB keys of the images used, in the array key only
$mExternalLinks, # External link URLs, in the key only
$mHTMLtitle, # Display HTML title
- $mSubtitle; # Additional subtitle
+ $mSubtitle, # Additional subtitle
+ $mNewSection; # Show a new section link?
function ParserOutput( $text = '', $languageLinks = array(), $categoryLinks = array(),
$containsOldMagic = false, $titletext = '' )
$this->mExternalLinks = array();
$this->mHTMLtitle = "" ;
$this->mSubtitle = "" ;
+ $this->mNewSection = false;
}
function getText() { return $this->mText; }
function addImage( $name ) { $this->mImages[$name] = 1; }
function addLanguageLink( $t ) { $this->mLanguageLinks[] = $t; }
function addExternalLink( $url ) { $this->mExternalLinks[$url] = 1; }
+
+ function setNewSection( $value ) {
+ $this->mNewSection = (bool)$value;
+ }
+ function getNewSection() {
+ return (bool)$this->mNewSection;
+ }
function addLink( $title, $id ) {
$ns = $title->getNamespace();
}
function commentLink() {
- global $wgTitle;
+ global $wgTitle, $wgOut;
if ( $wgTitle->getNamespace() == NS_SPECIAL ) {
return '';
}
- return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
- wfMsg( 'postcomment' ), 'action=edit§ion=new' );
+
+ # __NEWSECTIONLINK___ changes behaviour here
+ # If it's present, the link points to this page, otherwise
+ # it points to the talk page
+ if( $wgTitle->isTalkPage() ) {
+ $title =& $wgTitle;
+ } elseif( $wgOut->showNewSectionLink() ) {
+ $title =& $wgTitle;
+ } else {
+ $title =& $wgTitle->getTalkPage();
+ }
+
+ return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
}
/* these are used extensively in SkinTemplate, but also some other places */
* @private
*/
function buildContentActionUrls () {
- global $wgContLang;
+ global $wgContLang, $wgOut;
$fname = 'SkinTemplate::buildContentActionUrls';
wfProfileIn( $fname );
'href' => $this->mTitle->getLocalUrl( $this->editUrlOptions() )
);
- if ( $istalk ) {
+ if ( $istalk || $wgOut->showNewSectionLink() ) {
$content_actions['addsection'] = array(
'class' => $section == 'new'?'selected':false,
'text' => wfMsg('addsection'),
MAG_RAW => array( 0, 'RAW:' ),
MAG_DISPLAYTITLE => array( 1, 'DISPLAYTITLE' ),
MAG_RAWSUFFIX => array( 1, 'R' ),
+ MAG_NEWSECTIONLINK => array( 1, '__NEWSECTIONLINK__' ),
);
if (!$wgCachedMessageArrays) {
}
-
- if( $tns%2 && $action!='edit' && !$wpPreview) {
- $s.= '<br />'.$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('postcomment'),'action=edit§ion=new');
- }
+ # "Post a comment" link
+ if( ( $tns % 2 || $wgOut->showNewSectionLink() ) && $action != 'edit' && !$wpPreview )
+ $s .= '<br />' . $this->makeKnownLinkObj( $wgTitle, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
+
+ #if( $tns%2 && $action!='edit' && !$wpPreview) {
+ #$s.= '<br />'.$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('postcomment'),'action=edit§ion=new');
+ #}
/*
watching could cause problems in edit mode: