X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fparser%2FParserOutput.php;h=f0528125b01938350f8878802dd63a4d6671c61c;hb=7abf23c194b6fc87bcb3da2453747638cbea64c5;hp=40c67dd78532cd5e81d3c58c9091ded6912afbc1;hpb=b5906606e1aa1a795231fb813b766818b1dd6c25;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index 40c67dd785..f0528125b0 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -188,9 +188,7 @@ class ParserOutput extends CacheTime { */ private $mExtensionData = []; - /** - * @var array $mLimitReportData Parser limit report data. - */ + /** @var array $mLimitReportData Parser limit report data. */ private $mLimitReportData = []; /** @@ -208,6 +206,9 @@ class ParserOutput extends CacheTime { */ private $mFlags = []; + /** @var integer|null Assumed rev ID for {{REVISIONID}} if no revision is set */ + private $mSpeculativeRevId; + const EDITSECTION_REGEX = '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)())#'; @@ -272,6 +273,19 @@ class ParserOutput extends CacheTime { return $text; } + /** + * @param integer $id + * @since 1.28 + */ + public function setSpeculativeRevIdUsed( $id ) { + $this->mSpeculativeRevId = $id; + } + + /** @since 1.28 */ + public function getSpeculativeRevIdUsed() { + return $this->mSpeculativeRevId; + } + public function &getLanguageLinks() { return $this->mLanguageLinks; } @@ -351,15 +365,6 @@ class ParserOutput extends CacheTime { return $this->mModuleStyles; } - /** - * @deprecated since 1.26 Obsolete - * @return array - */ - public function getModuleMessages() { - wfDeprecated( __METHOD__, '1.26' ); - return []; - } - /** @since 1.23 */ public function getJsConfigVars() { return $this->mJsConfigVars; @@ -381,6 +386,9 @@ class ParserOutput extends CacheTime { return $this->mTOCHTML; } + /** + * @return string|null TS_MW timestamp of the revision content + */ public function getTimestamp() { return $this->mTimestamp; } @@ -625,14 +633,6 @@ class ParserOutput extends CacheTime { $this->mModuleStyles = array_merge( $this->mModuleStyles, (array)$modules ); } - /** - * @deprecated since 1.26 Use addModules() instead - * @param string|array $modules - */ - public function addModuleMessages( $modules ) { - wfDeprecated( __METHOD__, '1.26' ); - } - /** * Add one or more variables to be set in mw.config in JavaScript. * @@ -979,24 +979,34 @@ class ParserOutput extends CacheTime { /** * Sets parser limit report data for a key * - * The key is used as the prefix for various messages used for formatting: - * - $key: The label for the field in the limit report - * - $key-value-text: Message used to format the value in the "NewPP limit - * report" HTML comment. If missing, uses $key-format. - * - $key-value-html: Message used to format the value in the preview - * limit report table. If missing, uses $key-format. - * - $key-value: Message used to format the value. If missing, uses "$1". - * - * Note that all values are interpreted as wikitext, and so should be - * encoded with htmlspecialchars() as necessary, but should avoid complex - * HTML for sanity of display in the "NewPP limit report" comment. + * If $value consist of a list of two floats, it will be interpreted as + * (actual value, maximum allowed value). The presence of a "-" in $key will cause + * the first part of the key to be interpreted as a namespace. * * @since 1.22 - * @param string $key Message key - * @param mixed $value Appropriate for Message::params() + * @param string $key Data key + * @param mixed $value Data value One of (float, string, bool, JSON serializable array) */ public function setLimitReportData( $key, $value ) { - $this->mLimitReportData[$key] = $value; + if ( is_array( $value ) ) { + if ( array_keys( $value ) === [ 0, 1 ] + && is_numeric( $value[0] ) + && is_numeric( $value[1] ) + ) { + $data = [ 'value' => $value[0], 'limit' => $value[1] ]; + } else { + $data = $value; + } + } else { + $data = $value; + } + + if ( strpos( $key, '-' ) ) { + list( $ns, $name ) = explode( '-', $key, 2 ); + $this->mLimitReportData[$ns][$name] = $data; + } else { + $this->mLimitReportData[$key] = $data; + } } /**