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.
25 $mSections, # Table of contents
26 $mProperties; # Name/value pairs to be cached in the DB
29 * Overridden title for display
31 private $displayTitle = false;
33 function ParserOutput( $text = '', $languageLinks = array(), $categoryLinks = array(),
34 $containsOldMagic = false, $titletext = '' )
37 $this->mLanguageLinks
= $languageLinks;
38 $this->mCategories
= $categoryLinks;
39 $this->mContainsOldMagic
= $containsOldMagic;
40 $this->mCacheTime
= '';
41 $this->mVersion
= Parser
::VERSION
;
42 $this->mTitleText
= $titletext;
43 $this->mSections
= array();
44 $this->mLinks
= array();
45 $this->mTemplates
= array();
46 $this->mImages
= array();
47 $this->mExternalLinks
= array();
48 $this->mNewSection
= false;
49 $this->mNoGallery
= false;
50 $this->mHeadItems
= array();
51 $this->mTemplateIds
= array();
52 $this->mOutputHooks
= array();
53 $this->mWarnings
= array();
54 $this->mProperties
= array();
57 function getText() { return $this->mText
; }
58 function &getLanguageLinks() { return $this->mLanguageLinks
; }
59 function getCategoryLinks() { return array_keys( $this->mCategories
); }
60 function &getCategories() { return $this->mCategories
; }
61 function getCacheTime() { return $this->mCacheTime
; }
62 function getTitleText() { return $this->mTitleText
; }
63 function getSections() { return $this->mSections
; }
64 function &getLinks() { return $this->mLinks
; }
65 function &getTemplates() { return $this->mTemplates
; }
66 function &getImages() { return $this->mImages
; }
67 function &getExternalLinks() { return $this->mExternalLinks
; }
68 function getNoGallery() { return $this->mNoGallery
; }
69 function getSubtitle() { return $this->mSubtitle
; }
70 function getOutputHooks() { return (array)$this->mOutputHooks
; }
71 function getWarnings() { return isset( $this->mWarnings
) ?
$this->mWarnings
: array(); }
73 function containsOldMagic() { return $this->mContainsOldMagic
; }
74 function setText( $text ) { return wfSetVar( $this->mText
, $text ); }
75 function setLanguageLinks( $ll ) { return wfSetVar( $this->mLanguageLinks
, $ll ); }
76 function setCategoryLinks( $cl ) { return wfSetVar( $this->mCategories
, $cl ); }
77 function setContainsOldMagic( $com ) { return wfSetVar( $this->mContainsOldMagic
, $com ); }
78 function setCacheTime( $t ) { return wfSetVar( $this->mCacheTime
, $t ); }
79 function setTitleText( $t ) { return wfSetVar( $this->mTitleText
, $t ); }
80 function setSections( $toc ) { return wfSetVar( $this->mSections
, $toc ); }
82 function addCategory( $c, $sort ) { $this->mCategories
[$c] = $sort; }
83 function addLanguageLink( $t ) { $this->mLanguageLinks
[] = $t; }
84 function addExternalLink( $url ) { $this->mExternalLinks
[$url] = 1; }
85 function addWarning( $s ) { $this->mWarnings
[] = $s; }
87 function addOutputHook( $hook, $data = false ) {
88 $this->mOutputHooks
[] = array( $hook, $data );
91 function setNewSection( $value ) {
92 $this->mNewSection
= (bool)$value;
94 function getNewSection() {
95 return (bool)$this->mNewSection
;
98 function addLink( $title, $id = null ) {
99 $ns = $title->getNamespace();
100 $dbk = $title->getDBkey();
101 if ( !isset( $this->mLinks
[$ns] ) ) {
102 $this->mLinks
[$ns] = array();
104 if ( is_null( $id ) ) {
105 $id = $title->getArticleID();
107 $this->mLinks
[$ns][$dbk] = $id;
110 function addImage( $name ) {
111 $this->mImages
[$name] = 1;
114 function addTemplate( $title, $page_id, $rev_id ) {
115 $ns = $title->getNamespace();
116 $dbk = $title->getDBkey();
117 if ( !isset( $this->mTemplates
[$ns] ) ) {
118 $this->mTemplates
[$ns] = array();
120 $this->mTemplates
[$ns][$dbk] = $page_id;
121 if ( !isset( $this->mTemplateIds
[$ns] ) ) {
122 $this->mTemplateIds
[$ns] = array();
124 $this->mTemplateIds
[$ns][$dbk] = $rev_id; // For versioning
128 * Return true if this cached output object predates the global or
129 * per-article cache invalidation timestamps, or if it comes from
130 * an incompatible older version.
132 * @param string $touched the affected article's last touched timestamp
136 function expired( $touched ) {
137 global $wgCacheEpoch;
138 return $this->getCacheTime() == -1 ||
// parser says it's uncacheable
139 $this->getCacheTime() < $touched ||
140 $this->getCacheTime() <= $wgCacheEpoch ||
141 !isset( $this->mVersion
) ||
142 version_compare( $this->mVersion
, Parser
::VERSION
, "lt" );
146 * Add some text to the <head>.
147 * If $tag is set, the section with that tag will only be included once
150 function addHeadItem( $section, $tag = false ) {
151 if ( $tag !== false ) {
152 $this->mHeadItems
[$tag] = $section;
154 $this->mHeadItems
[] = $section;
159 * Override the title to be used for display
160 * -- this is assumed to have been validated
161 * (check equal normalisation, etc.)
163 * @param string $text Desired title text
165 public function setDisplayTitle( $text ) {
166 $this->displayTitle
= $text;
170 * Get the title to be used for display
174 public function getDisplayTitle() {
175 return $this->displayTitle
;
179 * Fairly generic flag setter thingy.
181 public function setFlag( $flag ) {
182 $this->mFlags
[$flag] = true;
185 public function getFlag( $flag ) {
186 return isset( $this->mFlags
[$flag] );
190 * Set a property to be cached in the DB
192 public function setProperty( $name, $value ) {
193 $this->mProperties
[$name] = $value;
196 public function getProperty( $name ){
197 return isset( $this->mProperties
[$name] ) ?
$this->mProperties
[$name] : false;
200 public function getProperties() {
201 if ( !isset( $this->mProperties
) ) {
202 $this->mProperties
= array();
204 return $this->mProperties
;