4 * Set options of the Parser
10 # All variables are supposed to be private in theory, although in practise this is not the case.
11 var $mUseTeX; # Use texvc to expand <math> tags
12 var $mUseDynamicDates; # Use DateFormatter to format dates
13 var $mInterwikiMagic; # Interlanguage links are removed and returned in an array
14 var $mAllowExternalImages; # Allow external images inline
15 var $mAllowExternalImagesFrom; # If not, any exception?
16 var $mEnableImageWhitelist; # If not or it doesn't match, should we check an on-wiki whitelist?
17 var $mSkin; # Reference to the preferred skin
18 var $mDateFormat; # Date format index
19 var $mEditSection; # Create "edit section" links
20 var $mNumberHeadings; # Automatically number headings
21 var $mAllowSpecialInclusion; # Allow inclusion of special pages
22 var $mTidy; # Ask for tidy cleanup
23 var $mInterfaceMessage; # Which lang to call for PLURAL and GRAMMAR
24 var $mTargetLanguage; # Overrides above setting with arbitrary language
25 var $mMaxIncludeSize; # Maximum size of template expansions, in bytes
26 var $mMaxPPNodeCount; # Maximum number of nodes touched by PPFrame::expand()
27 var $mMaxPPExpandDepth; # Maximum recursion depth in PPFrame::expand()
28 var $mMaxTemplateDepth; # Maximum recursion depth for templates within templates
29 var $mRemoveComments; # Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
30 var $mTemplateCallback; # Callback for template fetching
31 var $mEnableLimitReport; # Enable limit report in an HTML comment on output
32 var $mTimestamp; # Timestamp used for {{CURRENTDAY}} etc.
33 var $mExternalLinkTarget; # Target attribute for external links
35 var $mUser; # Stored user object, just used to initialise the skin
37 function getUseTeX() { return $this->mUseTeX
; }
38 function getUseDynamicDates() { return $this->mUseDynamicDates
; }
39 function getInterwikiMagic() { return $this->mInterwikiMagic
; }
40 function getAllowExternalImages() { return $this->mAllowExternalImages
; }
41 function getAllowExternalImagesFrom() { return $this->mAllowExternalImagesFrom
; }
42 function getEnableImageWhitelist() { return $this->mEnableImageWhitelist
; }
43 function getEditSection() { return $this->mEditSection
; }
44 function getNumberHeadings() { return $this->mNumberHeadings
; }
45 function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion
; }
46 function getTidy() { return $this->mTidy
; }
47 function getInterfaceMessage() { return $this->mInterfaceMessage
; }
48 function getTargetLanguage() { return $this->mTargetLanguage
; }
49 function getMaxIncludeSize() { return $this->mMaxIncludeSize
; }
50 function getMaxPPNodeCount() { return $this->mMaxPPNodeCount
; }
51 function getMaxTemplateDepth() { return $this->mMaxTemplateDepth
; }
52 function getRemoveComments() { return $this->mRemoveComments
; }
53 function getTemplateCallback() { return $this->mTemplateCallback
; }
54 function getEnableLimitReport() { return $this->mEnableLimitReport
; }
55 function getCleanSignatures() { return $this->mCleanSignatures
; }
56 function getExternalLinkTarget() { return $this->mExternalLinkTarget
; }
59 if ( !isset( $this->mSkin
) ) {
60 $this->mSkin
= $this->mUser
->getSkin();
65 function getDateFormat() {
66 if ( !isset( $this->mDateFormat
) ) {
67 $this->mDateFormat
= $this->mUser
->getDatePreference();
69 return $this->mDateFormat
;
72 function getTimestamp() {
73 if ( !isset( $this->mTimestamp
) ) {
74 $this->mTimestamp
= wfTimestampNow();
76 return $this->mTimestamp
;
79 function setUseTeX( $x ) { return wfSetVar( $this->mUseTeX
, $x ); }
80 function setUseDynamicDates( $x ) { return wfSetVar( $this->mUseDynamicDates
, $x ); }
81 function setInterwikiMagic( $x ) { return wfSetVar( $this->mInterwikiMagic
, $x ); }
82 function setAllowExternalImages( $x ) { return wfSetVar( $this->mAllowExternalImages
, $x ); }
83 function setAllowExternalImagesFrom( $x ) { return wfSetVar( $this->mAllowExternalImagesFrom
, $x ); }
84 function setEnableImageWhitelist( $x ) { return wfSetVar( $this->mEnableImageWhitelist
, $x ); }
85 function setDateFormat( $x ) { return wfSetVar( $this->mDateFormat
, $x ); }
86 function setEditSection( $x ) { return wfSetVar( $this->mEditSection
, $x ); }
87 function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings
, $x ); }
88 function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion
, $x ); }
89 function setTidy( $x ) { return wfSetVar( $this->mTidy
, $x); }
90 function setSkin( $x ) { $this->mSkin
= $x; }
91 function setInterfaceMessage( $x ) { return wfSetVar( $this->mInterfaceMessage
, $x); }
92 function setTargetLanguage( $x ) { return wfSetVar( $this->mTargetLanguage
, $x); }
93 function setMaxIncludeSize( $x ) { return wfSetVar( $this->mMaxIncludeSize
, $x ); }
94 function setMaxPPNodeCount( $x ) { return wfSetVar( $this->mMaxPPNodeCount
, $x ); }
95 function setMaxTemplateDepth( $x ) { return wfSetVar( $this->mMaxTemplateDepth
, $x ); }
96 function setRemoveComments( $x ) { return wfSetVar( $this->mRemoveComments
, $x ); }
97 function setTemplateCallback( $x ) { return wfSetVar( $this->mTemplateCallback
, $x ); }
98 function enableLimitReport( $x = true ) { return wfSetVar( $this->mEnableLimitReport
, $x ); }
99 function setTimestamp( $x ) { return wfSetVar( $this->mTimestamp
, $x ); }
100 function setCleanSignatures( $x ) { return wfSetVar( $this->mCleanSignatures
, $x ); }
101 function setExternalLinkTarget( $x ) { return wfSetVar( $this->mExternalLinkTarget
, $x ); }
103 function __construct( $user = null ) {
104 $this->initialiseFromUser( $user );
111 static function newFromUser( $user ) {
112 return new ParserOptions( $user );
115 /** Get user options */
116 function initialiseFromUser( $userInput ) {
117 global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
118 global $wgAllowExternalImagesFrom, $wgEnableImageWhitelist, $wgAllowSpecialInclusion, $wgMaxArticleSize;
119 global $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth, $wgCleanSignatures;
120 global $wgExternalLinkTarget;
121 $fname = 'ParserOptions::initialiseFromUser';
122 wfProfileIn( $fname );
125 if ( isset( $wgUser ) ) {
134 $this->mUser
= $user;
136 $this->mUseTeX
= $wgUseTeX;
137 $this->mUseDynamicDates
= $wgUseDynamicDates;
138 $this->mInterwikiMagic
= $wgInterwikiMagic;
139 $this->mAllowExternalImages
= $wgAllowExternalImages;
140 $this->mAllowExternalImagesFrom
= $wgAllowExternalImagesFrom;
141 $this->mEnableImageWhitelist
= $wgEnableImageWhitelist;
142 $this->mSkin
= null; # Deferred
143 $this->mDateFormat
= null; # Deferred
144 $this->mEditSection
= true;
145 $this->mNumberHeadings
= $user->getOption( 'numberheadings' );
146 $this->mAllowSpecialInclusion
= $wgAllowSpecialInclusion;
147 $this->mTidy
= false;
148 $this->mInterfaceMessage
= false;
149 $this->mTargetLanguage
= null; // default depends on InterfaceMessage setting
150 $this->mMaxIncludeSize
= $wgMaxArticleSize * 1024;
151 $this->mMaxPPNodeCount
= $wgMaxPPNodeCount;
152 $this->mMaxPPExpandDepth
= $wgMaxPPExpandDepth;
153 $this->mMaxTemplateDepth
= $wgMaxTemplateDepth;
154 $this->mRemoveComments
= true;
155 $this->mTemplateCallback
= array( 'Parser', 'statelessFetchTemplate' );
156 $this->mEnableLimitReport
= false;
157 $this->mCleanSignatures
= $wgCleanSignatures;
158 $this->mExternalLinkTarget
= $wgExternalLinkTarget;
159 wfProfileOut( $fname );