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
25 * Overridden title for display
27 private $displayTitle = false;
29 function ParserOutput( $text = '', $languageLinks = array(), $categoryLinks = array(),
30 $containsOldMagic = false, $titletext = '' )
33 $this->mLanguageLinks
= $languageLinks;
34 $this->mCategories
= $categoryLinks;
35 $this->mContainsOldMagic
= $containsOldMagic;
36 $this->mCacheTime
= '';
37 $this->mVersion
= Parser
::VERSION
;
38 $this->mTitleText
= $titletext;
39 $this->mLinks
= array();
40 $this->mTemplates
= array();
41 $this->mImages
= array();
42 $this->mExternalLinks
= array();
43 $this->mNewSection
= false;
44 $this->mNoGallery
= false;
45 $this->mHeadItems
= array();
46 $this->mTemplateIds
= array();
49 function getText() { return $this->mText
; }
50 function &getLanguageLinks() { return $this->mLanguageLinks
; }
51 function getCategoryLinks() { return array_keys( $this->mCategories
); }
52 function &getCategories() { return $this->mCategories
; }
53 function getCacheTime() { return $this->mCacheTime
; }
54 function getTitleText() { return $this->mTitleText
; }
55 function &getLinks() { return $this->mLinks
; }
56 function &getTemplates() { return $this->mTemplates
; }
57 function &getImages() { return $this->mImages
; }
58 function &getExternalLinks() { return $this->mExternalLinks
; }
59 function getNoGallery() { return $this->mNoGallery
; }
60 function getSubtitle() { return $this->mSubtitle
; }
62 function containsOldMagic() { return $this->mContainsOldMagic
; }
63 function setText( $text ) { return wfSetVar( $this->mText
, $text ); }
64 function setLanguageLinks( $ll ) { return wfSetVar( $this->mLanguageLinks
, $ll ); }
65 function setCategoryLinks( $cl ) { return wfSetVar( $this->mCategories
, $cl ); }
66 function setContainsOldMagic( $com ) { return wfSetVar( $this->mContainsOldMagic
, $com ); }
67 function setCacheTime( $t ) { return wfSetVar( $this->mCacheTime
, $t ); }
68 function setTitleText( $t ) { return wfSetVar($this->mTitleText
, $t); }
70 function addCategory( $c, $sort ) { $this->mCategories
[$c] = $sort; }
71 function addLanguageLink( $t ) { $this->mLanguageLinks
[] = $t; }
72 function addExternalLink( $url ) { $this->mExternalLinks
[$url] = 1; }
74 function setNewSection( $value ) {
75 $this->mNewSection
= (bool)$value;
77 function getNewSection() {
78 return (bool)$this->mNewSection
;
81 function addLink( $title, $id = null ) {
82 $ns = $title->getNamespace();
83 $dbk = $title->getDBkey();
84 if ( !isset( $this->mLinks
[$ns] ) ) {
85 $this->mLinks
[$ns] = array();
87 if ( is_null( $id ) ) {
88 $id = $title->getArticleID();
90 $this->mLinks
[$ns][$dbk] = $id;
93 function addImage( $name ) {
94 $this->mImages
[$name] = 1;
97 function addTemplate( $title, $page_id, $rev_id ) {
98 $ns = $title->getNamespace();
99 $dbk = $title->getDBkey();
100 if ( !isset( $this->mTemplates
[$ns] ) ) {
101 $this->mTemplates
[$ns] = array();
103 $this->mTemplates
[$ns][$dbk] = $page_id;
104 if ( !isset( $this->mTemplateIds
[$ns] ) ) {
105 $this->mTemplateIds
[$ns] = array();
107 $this->mTemplateIds
[$ns][$dbk] = $rev_id; // For versioning
111 * Return true if this cached output object predates the global or
112 * per-article cache invalidation timestamps, or if it comes from
113 * an incompatible older version.
115 * @param string $touched the affected article's last touched timestamp
119 function expired( $touched ) {
120 global $wgCacheEpoch;
121 return $this->getCacheTime() == -1 ||
// parser says it's uncacheable
122 $this->getCacheTime() < $touched ||
123 $this->getCacheTime() <= $wgCacheEpoch ||
124 !isset( $this->mVersion
) ||
125 version_compare( $this->mVersion
, Parser
::VERSION
, "lt" );
129 * Add some text to the <head>.
130 * If $tag is set, the section with that tag will only be included once
133 function addHeadItem( $section, $tag = false ) {
134 if ( $tag !== false ) {
135 $this->mHeadItems
[$tag] = $section;
137 $this->mHeadItems
[] = $section;
142 * Override the title to be used for display
143 * -- this is assumed to have been validated
144 * (check equal normalisation, etc.)
146 * @param string $text Desired title text
148 public function setDisplayTitle( $text ) {
149 $this->displayTitle
= $text;
153 * Get the title to be used for display
157 public function getDisplayTitle() {
158 return $this->displayTitle
;