extension
* Add HTML ID's mw-read-only-warning and mw-anon-edit-warning to warnings when
editing to allow CSS styling.
+* Parser now returns list of sections
=== Bug fixes in 1.12 ===
* (bug 12321) API list=blocks reveals private data
* Fix output of wfSajaxSearch
* (bug 12413) meta=userinfo missing <query> tag
+* Add list of sections to action=parse output
=== Languages updated in 1.12 ===
* changes in an incompatible way, so the parser cache
* can automatically discard old data.
*/
- const VERSION = '1.6.2';
+ const VERSION = '1.6.3';
# Flags for Parser::setFunctionHook
# Also available as global constants from Defines.php
$prevtoclevel = 0;
$markerRegex = "{$this->mUniqPrefix}-h-(\d+)-{$this->mMarkerSuffix}";
$baseTitleText = $this->mTitle->getPrefixedDBkey();
+ $tocraw = array();
foreach( $matches[3] as $headline ) {
$isTemplate = false;
}
if( $enoughToc && ( !isset($wgMaxTocLevel) || $toclevel<$wgMaxTocLevel ) ) {
$toc .= $sk->tocLine($anchor, $tocline, $numbering, $toclevel);
+ $tocraw[] = array( 'toclevel' => $toclevel, 'level' => $level, 'line' => $tocline, 'number' => $numbering );
}
# give headline the correct <h#> tag
if( $showEditLink && $sectionIndex !== false ) {
$headlineCount++;
}
+ $this->mOutput->setSections( $tocraw );
+
# Never ever show TOC if no headers
if( $numVisible < 1 ) {
$enoughToc = false;
$mNoGallery, # No gallery on category page? (__NOGALLERY__)
$mHeadItems, # Items to put in the <head> section
$mOutputHooks, # Hook tags as per $wgParserOutputHooks
- $mWarnings; # Warning text to be returned to the user. Wikitext formatted.
+ $mWarnings, # Warning text to be returned to the user. Wikitext formatted.
+ $mSections; # Table of contents
/**
* Overridden title for display
$this->mCacheTime = '';
$this->mVersion = Parser::VERSION;
$this->mTitleText = $titletext;
+ $this->mSections = '';
$this->mLinks = array();
$this->mTemplates = array();
$this->mImages = array();
function &getCategories() { return $this->mCategories; }
function getCacheTime() { return $this->mCacheTime; }
function getTitleText() { return $this->mTitleText; }
+ function getSections() { return $this->mSections; }
function &getLinks() { return $this->mLinks; }
function &getTemplates() { return $this->mTemplates; }
function &getImages() { return $this->mImages; }
function setCategoryLinks( $cl ) { return wfSetVar( $this->mCategories, $cl ); }
function setContainsOldMagic( $com ) { return wfSetVar( $this->mContainsOldMagic, $com ); }
function setCacheTime( $t ) { return wfSetVar( $this->mCacheTime, $t ); }
- function setTitleText( $t ) { return wfSetVar($this->mTitleText, $t); }
+ function setTitleText( $t ) { return wfSetVar( $this->mTitleText, $t ); }
+ function setSections( $toc ) { return wfSetVar( $this->mSections, $toc ); }
function addCategory( $c, $sort ) { $this->mCategories[$c] = $sort; }
function addLanguageLink( $t ) { $this->mLanguageLinks[] = $t; }
'templates' => $this->formatLinks( $p_result->getTemplates() ),
'images' => array_keys( $p_result->getImages() ),
'externallinks' => array_keys( $p_result->getExternalLinks() ),
+ 'sections' => $p_result->getSections(),
);
$result_mapping = array(
'langlinks' => 'll',
'templates' => 'tl',
'images' => 'img',
'externallinks' => 'el',
+ 'sections' => 's',
);
$this->setIndexedTagNames( $result_array, $result_mapping );
$result->setContent( $result_array['text'], $p_result->getText() );