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.
27 * Overridden title for display
29 private $displayTitle = false;
31 function ParserOutput( $text = '', $languageLinks = array(), $categoryLinks = array(),
32 $containsOldMagic = false, $titletext = '' )
35 $this->mLanguageLinks
= $languageLinks;
36 $this->mCategories
= $categoryLinks;
37 $this->mContainsOldMagic
= $containsOldMagic;
38 $this->mCacheTime
= '';
39 $this->mVersion
= Parser
::VERSION
;
40 $this->mTitleText
= $titletext;
41 $this->mLinks
= array();
42 $this->mTemplates
= array();
43 $this->mImages
= array();
44 $this->mExternalLinks
= array();
45 $this->mNewSection
= false;
46 $this->mNoGallery
= false;
47 $this->mHeadItems
= array();
48 $this->mTemplateIds
= array();
49 $this->mOutputHooks
= array();
50 $this->mWarnings
= array();
53 function getText() { return $this->mText
; }
54 function &getLanguageLinks() { return $this->mLanguageLinks
; }
55 function getCategoryLinks() { return array_keys( $this->mCategories
); }
56 function &getCategories() { return $this->mCategories
; }
57 function getCacheTime() { return $this->mCacheTime
; }
58 function getTitleText() { return $this->mTitleText
; }
59 function &getLinks() { return $this->mLinks
; }
60 function &getTemplates() { return $this->mTemplates
; }
61 function &getImages() { return $this->mImages
; }
62 function &getExternalLinks() { return $this->mExternalLinks
; }
63 function getNoGallery() { return $this->mNoGallery
; }
64 function getSubtitle() { return $this->mSubtitle
; }
65 function getOutputHooks() { return (array)$this->mOutputHooks
; }
66 function getWarnings() { return isset( $this->mWarnings
) ?
$this->mWarnings
: array(); }
68 function containsOldMagic() { return $this->mContainsOldMagic
; }
69 function setText( $text ) { return wfSetVar( $this->mText
, $text ); }
70 function setLanguageLinks( $ll ) { return wfSetVar( $this->mLanguageLinks
, $ll ); }
71 function setCategoryLinks( $cl ) { return wfSetVar( $this->mCategories
, $cl ); }
72 function setContainsOldMagic( $com ) { return wfSetVar( $this->mContainsOldMagic
, $com ); }
73 function setCacheTime( $t ) { return wfSetVar( $this->mCacheTime
, $t ); }
74 function setTitleText( $t ) { return wfSetVar($this->mTitleText
, $t); }
76 function addCategory( $c, $sort ) { $this->mCategories
[$c] = $sort; }
77 function addLanguageLink( $t ) { $this->mLanguageLinks
[] = $t; }
78 function addExternalLink( $url ) { $this->mExternalLinks
[$url] = 1; }
79 function addWarning( $s ) { $this->mWarnings
[] = $s; }
81 function addOutputHook( $hook, $data = false ) {
82 $this->mOutputHooks
[] = array( $hook, $data );
85 function setNewSection( $value ) {
86 $this->mNewSection
= (bool)$value;
88 function getNewSection() {
89 return (bool)$this->mNewSection
;
92 function addLink( $title, $id = null ) {
93 $ns = $title->getNamespace();
94 $dbk = $title->getDBkey();
95 if ( !isset( $this->mLinks
[$ns] ) ) {
96 $this->mLinks
[$ns] = array();
98 if ( is_null( $id ) ) {
99 $id = $title->getArticleID();
101 $this->mLinks
[$ns][$dbk] = $id;
104 function addImage( $name ) {
105 $this->mImages
[$name] = 1;
108 function addTemplate( $title, $page_id, $rev_id ) {
109 $ns = $title->getNamespace();
110 $dbk = $title->getDBkey();
111 if ( !isset( $this->mTemplates
[$ns] ) ) {
112 $this->mTemplates
[$ns] = array();
114 $this->mTemplates
[$ns][$dbk] = $page_id;
115 if ( !isset( $this->mTemplateIds
[$ns] ) ) {
116 $this->mTemplateIds
[$ns] = array();
118 $this->mTemplateIds
[$ns][$dbk] = $rev_id; // For versioning
122 * Return true if this cached output object predates the global or
123 * per-article cache invalidation timestamps, or if it comes from
124 * an incompatible older version.
126 * @param string $touched the affected article's last touched timestamp
130 function expired( $touched ) {
131 global $wgCacheEpoch;
132 return $this->getCacheTime() == -1 ||
// parser says it's uncacheable
133 $this->getCacheTime() < $touched ||
134 $this->getCacheTime() <= $wgCacheEpoch ||
135 !isset( $this->mVersion
) ||
136 version_compare( $this->mVersion
, Parser
::VERSION
, "lt" );
140 * Add some text to the <head>.
141 * If $tag is set, the section with that tag will only be included once
144 function addHeadItem( $section, $tag = false ) {
145 if ( $tag !== false ) {
146 $this->mHeadItems
[$tag] = $section;
148 $this->mHeadItems
[] = $section;
153 * Override the title to be used for display
154 * -- this is assumed to have been validated
155 * (check equal normalisation, etc.)
157 * @param string $text Desired title text
159 public function setDisplayTitle( $text ) {
160 $this->displayTitle
= $text;
164 * Get the title to be used for display
168 public function getDisplayTitle() {
169 return $this->displayTitle
;
173 * Fairly generic flag setter thingy.
175 public function setFlag( $flag ) {
176 $this->mFlags
[$flag] = true;
179 public function getFlag( $flag ) {
180 return isset( $this->mFlags
[$flag] );