4 * Set options of the Parser
9 # All variables are supposed to be private in theory, although in practise this is not the case.
10 var $mUseTeX; //!< Use texvc to expand <math> tags
11 var $mUseDynamicDates; //!< Use DateFormatter to format dates
12 var $mInterwikiMagic; //!< Interlanguage links are removed and returned in an array
13 var $mAllowExternalImages; //!< Allow external images inline
14 var $mAllowExternalImagesFrom; //!< If not, any exception?
15 var $mSkin; //!< Reference to the preferred skin
16 var $mDateFormat; //!< Date format index
17 var $mEditSection; //!< Create "edit section" links
18 var $mNumberHeadings; //!< Automatically number headings
19 var $mStubThreshold; //!< Treshold for marking pages as "stub"
20 var $mAllowSpecialInclusion; //!< Allow inclusion of special pages
21 var $mTidy; //!< Ask for tidy cleanup
22 var $mInterfaceMessage; //!< Which lang to call for PLURAL and GRAMMAR
23 var $mTargetLanguage; //!< Overrides above setting with arbitrary language
24 var $mMaxIncludeSize; //!< Maximum size of template expansions, in bytes
25 var $mMaxPPNodeCount; //!< Maximum number of nodes touched by PPFrame::expand()
26 var $mMaxPPExpandDepth; //!< Maximum recursion depth in PPFrame::expand()
27 var $mMaxTemplateDepth; //!< Maximum recursion depth for templates within templates
28 var $mRemoveComments; //!< Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
29 var $mTemplateCallback; //!< Callback for template fetching
30 var $mEnableLimitReport; //!< Enable limit report in an HTML comment on output
31 var $mTimestamp; //!< Timestamp used for {{CURRENTDAY}} etc.
33 var $mUser; //!< Stored user object
35 function getUseTeX() { return $this->mUseTeX
; }
36 function getUseDynamicDates() { return $this->mUseDynamicDates
; }
37 function getInterwikiMagic() { return $this->mInterwikiMagic
; }
38 function getAllowExternalImages() { return $this->mAllowExternalImages
; }
39 function getAllowExternalImagesFrom() { return $this->mAllowExternalImagesFrom
; }
40 function getEditSection() { return $this->mEditSection
; }
41 function getNumberHeadings() { return $this->mNumberHeadings
; }
42 function getStubThreshold() { return $this->mStubThreshold
; }
43 function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion
; }
44 function getTidy() { return $this->mTidy
; }
45 function getInterfaceMessage() { return $this->mInterfaceMessage
; }
46 function getTargetLanguage() { return $this->mTargetLanguage
; }
47 function getMaxIncludeSize() { return $this->mMaxIncludeSize
; }
48 function getMaxPPNodeCount() { return $this->mMaxPPNodeCount
; }
49 function getMaxTemplateDepth() { return $this->mMaxTemplateDepth
; }
50 function getRemoveComments() { return $this->mRemoveComments
; }
51 function getTemplateCallback() { return $this->mTemplateCallback
; }
52 function getEnableLimitReport() { return $this->mEnableLimitReport
; }
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 setDateFormat( $x ) { return wfSetVar( $this->mDateFormat
, $x ); }
85 function setEditSection( $x ) { return wfSetVar( $this->mEditSection
, $x ); }
86 function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings
, $x ); }
87 function setStubThreshold( $x ) { return wfSetVar( $this->mStubThreshold
, $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 ); }
101 function __construct( $user = null ) {
102 $this->initialiseFromUser( $user );
109 static function newFromUser( $user ) {
110 return new ParserOptions( $user );
113 /** Get user options */
114 function initialiseFromUser( $userInput ) {
115 global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
116 global $wgAllowExternalImagesFrom, $wgAllowSpecialInclusion, $wgMaxArticleSize;
117 global $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth;
119 wfProfileIn( __METHOD__
);
123 if ( isset( $wgUser ) ) {
132 $this->mUser
= $user;
134 $this->mUseTeX
= $wgUseTeX;
135 $this->mUseDynamicDates
= $wgUseDynamicDates;
136 $this->mInterwikiMagic
= $wgInterwikiMagic;
137 $this->mAllowExternalImages
= $wgAllowExternalImages;
138 $this->mAllowExternalImagesFrom
= $wgAllowExternalImagesFrom;
139 $this->mSkin
= null; # Deferred
140 $this->mDateFormat
= null; # Deferred
141 $this->mEditSection
= true;
142 $this->mNumberHeadings
= $user->getOption( 'numberheadings' );
143 $this->mStubThreshold
= $user->getOption( 'stubthreshold' );
144 $this->mAllowSpecialInclusion
= $wgAllowSpecialInclusion;
145 $this->mTidy
= false;
146 $this->mInterfaceMessage
= false;
147 $this->mTargetLanguage
= null; // default depends on InterfaceMessage setting
148 $this->mMaxIncludeSize
= $wgMaxArticleSize * 1024;
149 $this->mMaxPPNodeCount
= $wgMaxPPNodeCount;
150 $this->mMaxPPExpandDepth
= $wgMaxPPExpandDepth;
151 $this->mMaxTemplateDepth
= $wgMaxTemplateDepth;
152 $this->mRemoveComments
= true;
153 $this->mTemplateCallback
= array( 'Parser', 'statelessFetchTemplate' );
154 $this->mEnableLimitReport
= false;
156 wfProfileOut( __METHOD__
);