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
26 * Overridden title for display
28 private $displayTitle = false;
30 function ParserOutput( $text = '', $languageLinks = array(), $categoryLinks = array(),
31 $containsOldMagic = false, $titletext = '' )
34 $this->mLanguageLinks
= $languageLinks;
35 $this->mCategories
= $categoryLinks;
36 $this->mContainsOldMagic
= $containsOldMagic;
37 $this->mCacheTime
= '';
38 $this->mVersion
= Parser
::VERSION
;
39 $this->mTitleText
= $titletext;
40 $this->mLinks
= array();
41 $this->mTemplates
= array();
42 $this->mImages
= array();
43 $this->mExternalLinks
= array();
44 $this->mNewSection
= false;
45 $this->mNoGallery
= false;
46 $this->mHeadItems
= array();
47 $this->mTemplateIds
= array();
48 $this->mOutputHooks
= array();
51 function getText() { return $this->mText
; }
52 function &getLanguageLinks() { return $this->mLanguageLinks
; }
53 function getCategoryLinks() { return array_keys( $this->mCategories
); }
54 function &getCategories() { return $this->mCategories
; }
55 function getCacheTime() { return $this->mCacheTime
; }
56 function getTitleText() { return $this->mTitleText
; }
57 function &getLinks() { return $this->mLinks
; }
58 function &getTemplates() { return $this->mTemplates
; }
59 function &getImages() { return $this->mImages
; }
60 function &getExternalLinks() { return $this->mExternalLinks
; }
61 function getNoGallery() { return $this->mNoGallery
; }
62 function getSubtitle() { return $this->mSubtitle
; }
63 function getOutputHooks() { return (array)$this->mOutputHooks
; }
65 function containsOldMagic() { return $this->mContainsOldMagic
; }
66 function setText( $text ) { return wfSetVar( $this->mText
, $text ); }
67 function setLanguageLinks( $ll ) { return wfSetVar( $this->mLanguageLinks
, $ll ); }
68 function setCategoryLinks( $cl ) { return wfSetVar( $this->mCategories
, $cl ); }
69 function setContainsOldMagic( $com ) { return wfSetVar( $this->mContainsOldMagic
, $com ); }
70 function setCacheTime( $t ) { return wfSetVar( $this->mCacheTime
, $t ); }
71 function setTitleText( $t ) { return wfSetVar($this->mTitleText
, $t); }
73 function addCategory( $c, $sort ) { $this->mCategories
[$c] = $sort; }
74 function addLanguageLink( $t ) { $this->mLanguageLinks
[] = $t; }
75 function addExternalLink( $url ) { $this->mExternalLinks
[$url] = 1; }
77 function addOutputHook( $hook, $data = false ) {
78 $this->mOutputHooks
[] = array( $hook, $data );
81 function setNewSection( $value ) {
82 $this->mNewSection
= (bool)$value;
84 function getNewSection() {
85 return (bool)$this->mNewSection
;
88 function addLink( $title, $id = null ) {
89 $ns = $title->getNamespace();
90 $dbk = $title->getDBkey();
91 if ( !isset( $this->mLinks
[$ns] ) ) {
92 $this->mLinks
[$ns] = array();
94 if ( is_null( $id ) ) {
95 $id = $title->getArticleID();
97 $this->mLinks
[$ns][$dbk] = $id;
100 function addImage( $name ) {
101 $this->mImages
[$name] = 1;
104 function addTemplate( $title, $page_id, $rev_id ) {
105 $ns = $title->getNamespace();
106 $dbk = $title->getDBkey();
107 if ( !isset( $this->mTemplates
[$ns] ) ) {
108 $this->mTemplates
[$ns] = array();
110 $this->mTemplates
[$ns][$dbk] = $page_id;
111 if ( !isset( $this->mTemplateIds
[$ns] ) ) {
112 $this->mTemplateIds
[$ns] = array();
114 $this->mTemplateIds
[$ns][$dbk] = $rev_id; // For versioning
118 * Return true if this cached output object predates the global or
119 * per-article cache invalidation timestamps, or if it comes from
120 * an incompatible older version.
122 * @param string $touched the affected article's last touched timestamp
126 function expired( $touched ) {
127 global $wgCacheEpoch;
128 return $this->getCacheTime() == -1 ||
// parser says it's uncacheable
129 $this->getCacheTime() < $touched ||
130 $this->getCacheTime() <= $wgCacheEpoch ||
131 !isset( $this->mVersion
) ||
132 version_compare( $this->mVersion
, Parser
::VERSION
, "lt" );
136 * Add some text to the <head>.
137 * If $tag is set, the section with that tag will only be included once
140 function addHeadItem( $section, $tag = false ) {
141 if ( $tag !== false ) {
142 $this->mHeadItems
[$tag] = $section;
144 $this->mHeadItems
[] = $section;
149 * Override the title to be used for display
150 * -- this is assumed to have been validated
151 * (check equal normalisation, etc.)
153 * @param string $text Desired title text
155 public function setDisplayTitle( $text ) {
156 $this->displayTitle
= $text;
160 * Get the title to be used for display
164 public function getDisplayTitle() {
165 return $this->displayTitle
;