X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=blobdiff_plain;f=includes%2Fparser%2FParser.php;h=7dbb202a2e2040037c90de52bae13a6c9241b1e2;hb=21c1c7d025365540f17be4f7ae19184e1ccca4cc;hp=3376734a8d47ba795d6d8fe77e7779c4a78b334f;hpb=160d4fbea38f6366f4e9128e69bdff9915e39f06;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index 3376734a8d..7dbb202a2e 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -115,6 +115,10 @@ class Parser {
# Marker Suffix needs to be accessible staticly.
const MARKER_SUFFIX = "-QINU\x7f";
+ # Markers used for wrapping the table of contents
+ const TOC_START = '
mUniqPrefix . '-pre|<\\/li|<\\/ul|<\\/ol|<\\/dl|<\\/?center)/iS', $t ); if ( $openmatch or $closematch ) { $paragraphStack = false; # TODO bug 5718: paragraph closed @@ -2904,6 +2915,13 @@ class Parser { wfDebug( __METHOD__ . ": {{REVISIONUSER}} used, setting vary-revision...\n" ); $value = $this->getRevisionUser(); break; + case 'revisionsize': + # Let the edit saving system know we should parse the page + # *after* a revision ID has been assigned. This is for null edits. + $this->mOutput->setFlag( 'vary-revision' ); + wfDebug( __METHOD__ . ": {{REVISIONSIZE}} used, setting vary-revision...\n" ); + $value = $this->getRevisionSize(); + break; case 'namespace': $value = str_replace( '_', ' ', $wgContLang->getNsText( $this->mTitle->getNamespace() ) ); break; @@ -4436,7 +4454,8 @@ class Parser { # Add the section to the section tree # Find the DOM node for this header - while ( $node && !$isTemplate ) { + $noOffset = ( $isTemplate || $sectionIndex === false ); + while ( $node && !$noOffset ) { if ( $node->getName() === 'h' ) { $bits = $node->splitHeading(); if ( $bits['i'] == $sectionIndex ) { @@ -4454,7 +4473,7 @@ class Parser { 'number' => $numbering, 'index' => ( $isTemplate ? 'T-' : '' ) . $sectionIndex, 'fromtitle' => $titleText, - 'byteoffset' => ( $isTemplate ? null : $byteOffset ), + 'byteoffset' => ( $noOffset ? null : $byteOffset ), 'anchor' => $anchor, ); @@ -4505,6 +4524,7 @@ class Parser { } $toc = Linker::tocList( $toc, $this->mOptions->getUserLangObj() ); $this->mOutput->setTOCHTML( $toc ); + $toc = self::TOC_START . $toc . self::TOC_END; } if ( $isMain ) { @@ -5803,6 +5823,27 @@ class Parser { return $this->mRevisionUser; } + /** + * Get the size of the revision + * + * @return int|null revision size + */ + function getRevisionSize() { + if ( is_null( $this->mRevisionSize ) ) { + $revObject = $this->getRevisionObject(); + + # if this variable is subst: the revision id will be blank, + # so just use the parser input size, because the own substituation + # will change the size. + if ( $revObject ) { + $this->mRevisionSize = $revObject->getSize(); + } elseif ( $this->ot['wiki'] || $this->mOptions->getIsPreview() ) { + $this->mRevisionSize = $this->mInputSize; + } + } + return $this->mRevisionSize; + } + /** * Mutator for $mDefaultSort * |