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 $mImages, # DB keys of the images used, in the array key only
18 $mExternalLinks, # External link URLs, in the key only
19 $mHTMLtitle, # Display HTML title
20 $mSubtitle, # Additional subtitle
21 $mNewSection, # Show a new section link?
22 $mNoGallery; # No gallery on category page? (__NOGALLERY__)
24 function ParserOutput( $text = '', $languageLinks = array(), $categoryLinks = array(),
25 $containsOldMagic = false, $titletext = '' )
28 $this->mLanguageLinks
= $languageLinks;
29 $this->mCategories
= $categoryLinks;
30 $this->mContainsOldMagic
= $containsOldMagic;
31 $this->mCacheTime
= '';
32 $this->mVersion
= MW_PARSER_VERSION
;
33 $this->mTitleText
= $titletext;
34 $this->mLinks
= array();
35 $this->mTemplates
= array();
36 $this->mImages
= array();
37 $this->mExternalLinks
= array();
38 $this->mHTMLtitle
= "" ;
39 $this->mSubtitle
= "" ;
40 $this->mNewSection
= false;
41 $this->mNoGallery
= false;
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 &getLinks() { return $this->mLinks
; }
51 function &getTemplates() { return $this->mTemplates
; }
52 function &getImages() { return $this->mImages
; }
53 function &getExternalLinks() { return $this->mExternalLinks
; }
54 function getNoGallery() { return $this->mNoGallery
; }
55 function getSubtitle() { return $this->mSubtitle
; }
57 function containsOldMagic() { return $this->mContainsOldMagic
; }
58 function setText( $text ) { return wfSetVar( $this->mText
, $text ); }
59 function setLanguageLinks( $ll ) { return wfSetVar( $this->mLanguageLinks
, $ll ); }
60 function setCategoryLinks( $cl ) { return wfSetVar( $this->mCategories
, $cl ); }
61 function setContainsOldMagic( $com ) { return wfSetVar( $this->mContainsOldMagic
, $com ); }
62 function setCacheTime( $t ) { return wfSetVar( $this->mCacheTime
, $t ); }
63 function setTitleText( $t ) { return wfSetVar($this->mTitleText
, $t); }
64 function setSubtitle( $st ) { return wfSetVar( $this->mSubtitle
, $st ); }
66 function addCategory( $c, $sort ) { $this->mCategories
[$c] = $sort; }
67 function addImage( $name ) { $this->mImages
[$name] = 1; }
68 function addLanguageLink( $t ) { $this->mLanguageLinks
[] = $t; }
69 function addExternalLink( $url ) { $this->mExternalLinks
[$url] = 1; }
71 function setNewSection( $value ) {
72 $this->mNewSection
= (bool)$value;
74 function getNewSection() {
75 return (bool)$this->mNewSection
;
78 function addLink( $title, $id = null ) {
79 $ns = $title->getNamespace();
80 $dbk = $title->getDBkey();
81 if ( !isset( $this->mLinks
[$ns] ) ) {
82 $this->mLinks
[$ns] = array();
84 if ( is_null( $id ) ) {
85 $id = $title->getArticleID();
87 $this->mLinks
[$ns][$dbk] = $id;
90 function addTemplate( $title, $id ) {
91 $ns = $title->getNamespace();
92 $dbk = $title->getDBkey();
93 if ( !isset( $this->mTemplates
[$ns] ) ) {
94 $this->mTemplates
[$ns] = array();
96 $this->mTemplates
[$ns][$dbk] = $id;
100 * Return true if this cached output object predates the global or
101 * per-article cache invalidation timestamps, or if it comes from
102 * an incompatible older version.
104 * @param string $touched the affected article's last touched timestamp
108 function expired( $touched ) {
109 global $wgCacheEpoch;
110 return $this->getCacheTime() == -1 ||
// parser says it's uncacheable
111 $this->getCacheTime() < $touched ||
112 $this->getCacheTime() <= $wgCacheEpoch ||
113 !isset( $this->mVersion
) ||
114 version_compare( $this->mVersion
, MW_PARSER_VERSION
, "lt" );