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 ( $ns == NS_MEDIA
) {
91 // Normalize this pseudo-alias if it makes it down here...
93 } elseif( $ns == NS_SPECIAL
) {
94 // We don't record Special: links currently
95 // It might actually be wise to, but we'd need to do some normalization.
98 if ( !isset( $this->mLinks
[$ns] ) ) {
99 $this->mLinks
[$ns] = array();
101 if ( is_null( $id ) ) {
102 $id = $title->getArticleID();
104 $this->mLinks
[$ns][$dbk] = $id;
107 function addImage( $name ) {
108 $this->mImages
[$name] = 1;
111 function addTemplate( $title, $page_id, $rev_id ) {
112 $ns = $title->getNamespace();
113 $dbk = $title->getDBkey();
114 if ( !isset( $this->mTemplates
[$ns] ) ) {
115 $this->mTemplates
[$ns] = array();
117 $this->mTemplates
[$ns][$dbk] = $page_id;
118 if ( !isset( $this->mTemplateIds
[$ns] ) ) {
119 $this->mTemplateIds
[$ns] = array();
121 $this->mTemplateIds
[$ns][$dbk] = $rev_id; // For versioning
125 * Return true if this cached output object predates the global or
126 * per-article cache invalidation timestamps, or if it comes from
127 * an incompatible older version.
129 * @param string $touched the affected article's last touched timestamp
133 function expired( $touched ) {
134 global $wgCacheEpoch;
135 return $this->getCacheTime() == -1 ||
// parser says it's uncacheable
136 $this->getCacheTime() < $touched ||
137 $this->getCacheTime() <= $wgCacheEpoch ||
138 !isset( $this->mVersion
) ||
139 version_compare( $this->mVersion
, Parser
::VERSION
, "lt" );
143 * Add some text to the <head>.
144 * If $tag is set, the section with that tag will only be included once
147 function addHeadItem( $section, $tag = false ) {
148 if ( $tag !== false ) {
149 $this->mHeadItems
[$tag] = $section;
151 $this->mHeadItems
[] = $section;
156 * Override the title to be used for display
157 * -- this is assumed to have been validated
158 * (check equal normalisation, etc.)
160 * @param string $text Desired title text
162 public function setDisplayTitle( $text ) {
163 $this->displayTitle
= $text;
167 * Get the title to be used for display
171 public function getDisplayTitle() {
172 return $this->displayTitle
;
176 * Fairly generic flag setter thingy.
178 public function setFlag( $flag ) {
179 $this->mFlags
[$flag] = true;
182 public function getFlag( $flag ) {
183 return isset( $this->mFlags
[$flag] );
187 * Set a property to be cached in the DB
189 public function setProperty( $name, $value ) {
190 $this->mProperties
[$name] = $value;
193 public function getProperty( $name ){
194 return isset( $this->mProperties
[$name] ) ?
$this->mProperties
[$name] : false;
197 public function getProperties() {
198 if ( !isset( $this->mProperties
) ) {
199 $this->mProperties
= array();
201 return $this->mProperties
;