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 $mTitleText, # title text of the chosen language variant
13 $mCacheTime = '', # Time when this object was generated, or -1 for uncacheable. Used in ParserCache.
14 $mVersion = Parser
::VERSION
, # Compatibility check
15 $mLinks = array(), # 2-D map of NS/DBK to ID for the links in the document. ID=zero for broken.
16 $mTemplates = array(), # 2-D map of NS/DBK to ID for the template references. ID=zero for broken.
17 $mTemplateIds = array(), # 2-D map of NS/DBK to rev ID for the template references. ID=zero for broken.
18 $mImages = array(), # DB keys of the images used, in the array key only
19 $mExternalLinks = array(), # External link URLs, in the key only
20 $mNewSection = false, # Show a new section link?
21 $mNoGallery = false, # No gallery on category page? (__NOGALLERY__)
22 $mHeadItems = array(), # Items to put in the <head> section
23 $mOutputHooks = array(), # Hook tags as per $wgParserOutputHooks
24 $mWarnings = array(), # Warning text to be returned to the user. Wikitext formatted, in the key only
25 $mSections = array(), # Table of contents
26 $mProperties = array(); # 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->mTitleText
= $titletext;
44 function getText() { return $this->mText
; }
45 function &getLanguageLinks() { return $this->mLanguageLinks
; }
46 function getCategoryLinks() { return array_keys( $this->mCategories
); }
47 function &getCategories() { return $this->mCategories
; }
48 function getCacheTime() { return $this->mCacheTime
; }
49 function getTitleText() { return $this->mTitleText
; }
50 function getSections() { return $this->mSections
; }
51 function &getLinks() { return $this->mLinks
; }
52 function &getTemplates() { return $this->mTemplates
; }
53 function &getImages() { return $this->mImages
; }
54 function &getExternalLinks() { return $this->mExternalLinks
; }
55 function getNoGallery() { return $this->mNoGallery
; }
56 function getSubtitle() { return $this->mSubtitle
; }
57 function getOutputHooks() { return (array)$this->mOutputHooks
; }
58 function getWarnings() { return array_keys( $this->mWarnings
); }
59 function getIndexPolicy() { return $this->mIndexPolicy
; }
61 function containsOldMagic() { return $this->mContainsOldMagic
; }
62 function setText( $text ) { return wfSetVar( $this->mText
, $text ); }
63 function setLanguageLinks( $ll ) { return wfSetVar( $this->mLanguageLinks
, $ll ); }
64 function setCategoryLinks( $cl ) { return wfSetVar( $this->mCategories
, $cl ); }
65 function setContainsOldMagic( $com ) { return wfSetVar( $this->mContainsOldMagic
, $com ); }
66 function setCacheTime( $t ) { return wfSetVar( $this->mCacheTime
, $t ); }
67 function setTitleText( $t ) { return wfSetVar( $this->mTitleText
, $t ); }
68 function setSections( $toc ) { return wfSetVar( $this->mSections
, $toc ); }
69 function setIndexPolicy( $policy ) { return wfSetVar( $this->mIndexPolicy
, $policy ); }
71 function addCategory( $c, $sort ) { $this->mCategories
[$c] = $sort; }
72 function addLanguageLink( $t ) { $this->mLanguageLinks
[] = $t; }
73 function addExternalLink( $url ) { $this->mExternalLinks
[$url] = 1; }
74 function addWarning( $s ) { $this->mWarnings
[$s] = 1; }
76 function addOutputHook( $hook, $data = false ) {
77 $this->mOutputHooks
[] = array( $hook, $data );
80 function setNewSection( $value ) {
81 $this->mNewSection
= (bool)$value;
83 function getNewSection() {
84 return (bool)$this->mNewSection
;
87 function addLink( $title, $id = null ) {
88 $ns = $title->getNamespace();
89 $dbk = $title->getDBkey();
90 if ( !isset( $this->mLinks
[$ns] ) ) {
91 $this->mLinks
[$ns] = array();
93 if ( is_null( $id ) ) {
94 $id = $title->getArticleID();
96 $this->mLinks
[$ns][$dbk] = $id;
99 function addImage( $name ) {
100 $this->mImages
[$name] = 1;
103 function addTemplate( $title, $page_id, $rev_id ) {
104 $ns = $title->getNamespace();
105 $dbk = $title->getDBkey();
106 if ( !isset( $this->mTemplates
[$ns] ) ) {
107 $this->mTemplates
[$ns] = array();
109 $this->mTemplates
[$ns][$dbk] = $page_id;
110 if ( !isset( $this->mTemplateIds
[$ns] ) ) {
111 $this->mTemplateIds
[$ns] = array();
113 $this->mTemplateIds
[$ns][$dbk] = $rev_id; // For versioning
117 * Return true if this cached output object predates the global or
118 * per-article cache invalidation timestamps, or if it comes from
119 * an incompatible older version.
121 * @param string $touched the affected article's last touched timestamp
125 function expired( $touched ) {
126 global $wgCacheEpoch;
127 return $this->getCacheTime() == -1 ||
// parser says it's uncacheable
128 $this->getCacheTime() < $touched ||
129 $this->getCacheTime() <= $wgCacheEpoch ||
130 !isset( $this->mVersion
) ||
131 version_compare( $this->mVersion
, Parser
::VERSION
, "lt" );
135 * Add some text to the <head>.
136 * If $tag is set, the section with that tag will only be included once
139 function addHeadItem( $section, $tag = false ) {
140 if ( $tag !== false ) {
141 $this->mHeadItems
[$tag] = $section;
143 $this->mHeadItems
[] = $section;
148 * Override the title to be used for display
149 * -- this is assumed to have been validated
150 * (check equal normalisation, etc.)
152 * @param string $text Desired title text
154 public function setDisplayTitle( $text ) {
155 $this->displayTitle
= $text;
159 * Get the title to be used for display
163 public function getDisplayTitle() {
164 return $this->displayTitle
;
168 * Fairly generic flag setter thingy.
170 public function setFlag( $flag ) {
171 $this->mFlags
[$flag] = true;
174 public function getFlag( $flag ) {
175 return isset( $this->mFlags
[$flag] );
179 * Set a property to be cached in the DB
181 public function setProperty( $name, $value ) {
182 $this->mProperties
[$name] = $value;
185 public function getProperty( $name ){
186 return isset( $this->mProperties
[$name] ) ?
$this->mProperties
[$name] : false;
189 public function getProperties() {
190 if ( !isset( $this->mProperties
) ) {
191 $this->mProperties
= array();
193 return $this->mProperties
;