a15a71d4ac94ed091800dfed4f393d6bc0ab4435
8 var $mText, # The output text
9 $mLanguageLinks, # List of the full text of language links, in the order they appear
10 $mCategories, # Map of category names to sort keys
11 $mContainsOldMagic, # Boolean variable indicating if the input contained variables like {{CURRENTDAY}}
12 $mCacheTime, # Time when this object was generated, or -1 for uncacheable. Used in ParserCache.
13 $mVersion, # Compatibility check
14 $mTitleText, # title text of the chosen language variant
15 $mLinks, # 2-D map of NS/DBK to ID for the links in the document. ID=zero for broken.
16 $mTemplates, # 2-D map of NS/DBK to ID for the template references. ID=zero for broken.
17 $mTemplateIds, # 2-D map of NS/DBK to rev ID for the template references. ID=zero for broken.
18 $mImages, # DB keys of the images used, in the array key only
19 $mExternalLinks, # External link URLs, in the key only
20 $mNewSection, # Show a new section link?
21 $mNoGallery, # No gallery on category page? (__NOGALLERY__)
22 $mHeadItems, # Items to put in the <head> section
23 $mOutputHooks, # Hook tags as per $wgParserOutputHooks
24 $mWarnings, # Warning text to be returned to the user. Wikitext formatted, in the key only
25 $mSections, # Table of contents
26 $mProperties; # Name/value pairs to be cached in the DB
27 private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change.
30 * Overridden title for display
32 private $displayTitle = false;
34 function ParserOutput( $text = '', $languageLinks = array(), $categoryLinks = array(),
35 $containsOldMagic = false, $titletext = '' )
38 $this->mLanguageLinks
= $languageLinks;
39 $this->mCategories
= $categoryLinks;
40 $this->mContainsOldMagic
= $containsOldMagic;
41 $this->mCacheTime
= '';
42 $this->mVersion
= Parser
::VERSION
;
43 $this->mTitleText
= $titletext;
44 $this->mSections
= array();
45 $this->mLinks
= array();
46 $this->mTemplates
= array();
47 $this->mImages
= array();
48 $this->mExternalLinks
= array();
49 $this->mNewSection
= false;
50 $this->mNoGallery
= false;
51 $this->mHeadItems
= array();
52 $this->mTemplateIds
= array();
53 $this->mOutputHooks
= array();
54 $this->mWarnings
= array();
55 $this->mProperties
= array();
58 function getText() { return $this->mText
; }
59 function &getLanguageLinks() { return $this->mLanguageLinks
; }
60 function getCategoryLinks() { return array_keys( $this->mCategories
); }
61 function &getCategories() { return $this->mCategories
; }
62 function getCacheTime() { return $this->mCacheTime
; }
63 function getTitleText() { return $this->mTitleText
; }
64 function getSections() { return $this->mSections
; }
65 function &getLinks() { return $this->mLinks
; }
66 function &getTemplates() { return $this->mTemplates
; }
67 function &getImages() { return $this->mImages
; }
68 function &getExternalLinks() { return $this->mExternalLinks
; }
69 function getNoGallery() { return $this->mNoGallery
; }
70 function getSubtitle() { return $this->mSubtitle
; }
71 function getOutputHooks() { return (array)$this->mOutputHooks
; }
72 function getWarnings() { return array_keys( $this->mWarnings
); }
73 function getIndexPolicy() { return $this->mIndexPolicy
; }
75 function containsOldMagic() { return $this->mContainsOldMagic
; }
76 function setText( $text ) { return wfSetVar( $this->mText
, $text ); }
77 function setLanguageLinks( $ll ) { return wfSetVar( $this->mLanguageLinks
, $ll ); }
78 function setCategoryLinks( $cl ) { return wfSetVar( $this->mCategories
, $cl ); }
79 function setContainsOldMagic( $com ) { return wfSetVar( $this->mContainsOldMagic
, $com ); }
80 function setCacheTime( $t ) { return wfSetVar( $this->mCacheTime
, $t ); }
81 function setTitleText( $t ) { return wfSetVar( $this->mTitleText
, $t ); }
82 function setSections( $toc ) { return wfSetVar( $this->mSections
, $toc ); }
83 function setIndexPolicy( $policy ) { return wfSetVar( $this->mIndexPolicy
, $policy ); }
85 function addCategory( $c, $sort ) { $this->mCategories
[$c] = $sort; }
86 function addLanguageLink( $t ) { $this->mLanguageLinks
[] = $t; }
87 function addExternalLink( $url ) { $this->mExternalLinks
[$url] = 1; }
88 function addWarning( $s ) { $this->mWarnings
[$s] = 1; }
90 function addOutputHook( $hook, $data = false ) {
91 $this->mOutputHooks
[] = array( $hook, $data );
94 function setNewSection( $value ) {
95 $this->mNewSection
= (bool)$value;
97 function getNewSection() {
98 return (bool)$this->mNewSection
;
101 function addLink( $title, $id = null ) {
102 $ns = $title->getNamespace();
103 $dbk = $title->getDBkey();
104 if ( !isset( $this->mLinks
[$ns] ) ) {
105 $this->mLinks
[$ns] = array();
107 if ( is_null( $id ) ) {
108 $id = $title->getArticleID();
110 $this->mLinks
[$ns][$dbk] = $id;
113 function addImage( $name ) {
114 $this->mImages
[$name] = 1;
117 function addTemplate( $title, $page_id, $rev_id ) {
118 $ns = $title->getNamespace();
119 $dbk = $title->getDBkey();
120 if ( !isset( $this->mTemplates
[$ns] ) ) {
121 $this->mTemplates
[$ns] = array();
123 $this->mTemplates
[$ns][$dbk] = $page_id;
124 if ( !isset( $this->mTemplateIds
[$ns] ) ) {
125 $this->mTemplateIds
[$ns] = array();
127 $this->mTemplateIds
[$ns][$dbk] = $rev_id; // For versioning
131 * Return true if this cached output object predates the global or
132 * per-article cache invalidation timestamps, or if it comes from
133 * an incompatible older version.
135 * @param string $touched the affected article's last touched timestamp
139 function expired( $touched ) {
140 global $wgCacheEpoch;
141 return $this->getCacheTime() == -1 ||
// parser says it's uncacheable
142 $this->getCacheTime() < $touched ||
143 $this->getCacheTime() <= $wgCacheEpoch ||
144 !isset( $this->mVersion
) ||
145 version_compare( $this->mVersion
, Parser
::VERSION
, "lt" );
149 * Add some text to the <head>.
150 * If $tag is set, the section with that tag will only be included once
153 function addHeadItem( $section, $tag = false ) {
154 if ( $tag !== false ) {
155 $this->mHeadItems
[$tag] = $section;
157 $this->mHeadItems
[] = $section;
162 * Override the title to be used for display
163 * -- this is assumed to have been validated
164 * (check equal normalisation, etc.)
166 * @param string $text Desired title text
168 public function setDisplayTitle( $text ) {
169 $this->displayTitle
= $text;
173 * Get the title to be used for display
177 public function getDisplayTitle() {
178 return $this->displayTitle
;
182 * Fairly generic flag setter thingy.
184 public function setFlag( $flag ) {
185 $this->mFlags
[$flag] = true;
188 public function getFlag( $flag ) {
189 return isset( $this->mFlags
[$flag] );
193 * Set a property to be cached in the DB
195 public function setProperty( $name, $value ) {
196 $this->mProperties
[$name] = $value;
199 public function getProperty( $name ){
200 return isset( $this->mProperties
[$name] ) ?
$this->mProperties
[$name] : false;
203 public function getProperties() {
204 if ( !isset( $this->mProperties
) ) {
205 $this->mProperties
= array();
207 return $this->mProperties
;