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 $mEnableImageWhitelist; # If not or it doesn't match, should we check an on-wiki whitelist?
16 var $mSkin; # Reference to the preferred skin
17 var $mDateFormat; # Date format index
18 var $mEditSection; # Create "edit section" links
19 var $mNumberHeadings; # Automatically number headings
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.
32 var $mExternalLinkTarget; # Target attribute for external links
34 var $mUser; # Stored user object, just used to initialise the skin
35 var $mIsPreview; # Parsing the page for a "preview" operation
36 var $mIsSectionPreview; # Parsing the page for a "preview" operation on a single section
37 var $mIsPrintable; # Parsing the printable version of the page
39 function getUseTeX() { return $this->mUseTeX
; }
40 function getUseDynamicDates() { return $this->mUseDynamicDates
; }
41 function getInterwikiMagic() { return $this->mInterwikiMagic
; }
42 function getAllowExternalImages() { return $this->mAllowExternalImages
; }
43 function getAllowExternalImagesFrom() { return $this->mAllowExternalImagesFrom
; }
44 function getEnableImageWhitelist() { return $this->mEnableImageWhitelist
; }
45 function getEditSection() { return $this->mEditSection
; }
46 function getNumberHeadings() { return $this->mNumberHeadings
; }
47 function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion
; }
48 function getTidy() { return $this->mTidy
; }
49 function getInterfaceMessage() { return $this->mInterfaceMessage
; }
50 function getTargetLanguage() { return $this->mTargetLanguage
; }
51 function getMaxIncludeSize() { return $this->mMaxIncludeSize
; }
52 function getMaxPPNodeCount() { return $this->mMaxPPNodeCount
; }
53 function getMaxTemplateDepth() { return $this->mMaxTemplateDepth
; }
54 function getRemoveComments() { return $this->mRemoveComments
; }
55 function getTemplateCallback() { return $this->mTemplateCallback
; }
56 function getEnableLimitReport() { return $this->mEnableLimitReport
; }
57 function getCleanSignatures() { return $this->mCleanSignatures
; }
58 function getExternalLinkTarget() { return $this->mExternalLinkTarget
; }
59 function getIsPreview() { return $this->mIsPreview
; }
60 function getIsSectionPreview() { return $this->mIsSectionPreview
; }
61 function getIsPrintable() { return $this->mIsPrintable
; }
64 if ( !isset( $this->mSkin
) ) {
65 $this->mSkin
= $this->mUser
->getSkin();
70 function getDateFormat() {
71 if ( !isset( $this->mDateFormat
) ) {
72 $this->mDateFormat
= $this->mUser
->getDatePreference();
74 return $this->mDateFormat
;
77 function getTimestamp() {
78 if ( !isset( $this->mTimestamp
) ) {
79 $this->mTimestamp
= wfTimestampNow();
81 return $this->mTimestamp
;
84 function setUseTeX( $x ) { return wfSetVar( $this->mUseTeX
, $x ); }
85 function setUseDynamicDates( $x ) { return wfSetVar( $this->mUseDynamicDates
, $x ); }
86 function setInterwikiMagic( $x ) { return wfSetVar( $this->mInterwikiMagic
, $x ); }
87 function setAllowExternalImages( $x ) { return wfSetVar( $this->mAllowExternalImages
, $x ); }
88 function setAllowExternalImagesFrom( $x ) { return wfSetVar( $this->mAllowExternalImagesFrom
, $x ); }
89 function setEnableImageWhitelist( $x ) { return wfSetVar( $this->mEnableImageWhitelist
, $x ); }
90 function setDateFormat( $x ) { return wfSetVar( $this->mDateFormat
, $x ); }
91 function setEditSection( $x ) { return wfSetVar( $this->mEditSection
, $x ); }
92 function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings
, $x ); }
93 function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion
, $x ); }
94 function setTidy( $x ) { return wfSetVar( $this->mTidy
, $x); }
95 function setSkin( $x ) { $this->mSkin
= $x; }
96 function setInterfaceMessage( $x ) { return wfSetVar( $this->mInterfaceMessage
, $x); }
97 function setTargetLanguage( $x ) { return wfSetVar( $this->mTargetLanguage
, $x); }
98 function setMaxIncludeSize( $x ) { return wfSetVar( $this->mMaxIncludeSize
, $x ); }
99 function setMaxPPNodeCount( $x ) { return wfSetVar( $this->mMaxPPNodeCount
, $x ); }
100 function setMaxTemplateDepth( $x ) { return wfSetVar( $this->mMaxTemplateDepth
, $x ); }
101 function setRemoveComments( $x ) { return wfSetVar( $this->mRemoveComments
, $x ); }
102 function setTemplateCallback( $x ) { return wfSetVar( $this->mTemplateCallback
, $x ); }
103 function enableLimitReport( $x = true ) { return wfSetVar( $this->mEnableLimitReport
, $x ); }
104 function setTimestamp( $x ) { return wfSetVar( $this->mTimestamp
, $x ); }
105 function setCleanSignatures( $x ) { return wfSetVar( $this->mCleanSignatures
, $x ); }
106 function setExternalLinkTarget( $x ) { return wfSetVar( $this->mExternalLinkTarget
, $x ); }
107 function setIsPreview( $x ) { return wfSetVar( $this->mIsPreview
, $x ); }
108 function setIsSectionPreview( $x ) { return wfSetVar( $this->mIsSectionPreview
, $x ); }
109 function setIsPrintable( $x ) { return wfSetVar( $this->mIsPrintable
, $x ); }
111 function __construct( $user = null ) {
112 $this->initialiseFromUser( $user );
119 static function newFromUser( $user ) {
120 return new ParserOptions( $user );
123 /** Get user options */
124 function initialiseFromUser( $userInput ) {
125 global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
126 global $wgAllowExternalImagesFrom, $wgEnableImageWhitelist, $wgAllowSpecialInclusion, $wgMaxArticleSize;
127 global $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth, $wgCleanSignatures;
128 global $wgExternalLinkTarget;
130 wfProfileIn( __METHOD__
);
134 if ( isset( $wgUser ) ) {
143 $this->mUser
= $user;
145 $this->mUseTeX
= $wgUseTeX;
146 $this->mUseDynamicDates
= $wgUseDynamicDates;
147 $this->mInterwikiMagic
= $wgInterwikiMagic;
148 $this->mAllowExternalImages
= $wgAllowExternalImages;
149 $this->mAllowExternalImagesFrom
= $wgAllowExternalImagesFrom;
150 $this->mEnableImageWhitelist
= $wgEnableImageWhitelist;
151 $this->mSkin
= null; # Deferred
152 $this->mDateFormat
= null; # Deferred
153 $this->mEditSection
= true;
154 $this->mNumberHeadings
= $user->getOption( 'numberheadings' );
155 $this->mAllowSpecialInclusion
= $wgAllowSpecialInclusion;
156 $this->mTidy
= false;
157 $this->mInterfaceMessage
= false;
158 $this->mTargetLanguage
= null; // default depends on InterfaceMessage setting
159 $this->mMaxIncludeSize
= $wgMaxArticleSize * 1024;
160 $this->mMaxPPNodeCount
= $wgMaxPPNodeCount;
161 $this->mMaxPPExpandDepth
= $wgMaxPPExpandDepth;
162 $this->mMaxTemplateDepth
= $wgMaxTemplateDepth;
163 $this->mRemoveComments
= true;
164 $this->mTemplateCallback
= array( 'Parser', 'statelessFetchTemplate' );
165 $this->mEnableLimitReport
= false;
166 $this->mCleanSignatures
= $wgCleanSignatures;
167 $this->mExternalLinkTarget
= $wgExternalLinkTarget;
168 $this->mIsPreview
= false;
169 $this->mIsSectionPreview
= false;
171 wfProfileOut( __METHOD__
);