577d51f33d0a059551579124c967e2074ddca241
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
36 var $mIsPreview; # Parsing the page for a "preview" operation
37 var $mIsSectionPreview; # Parsing the page for a "preview" operation on a single section
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
; }
63 if ( !isset( $this->mSkin
) ) {
64 $this->mSkin
= $this->mUser
->getSkin();
69 function getDateFormat() {
70 if ( !isset( $this->mDateFormat
) ) {
71 $this->mDateFormat
= $this->mUser
->getDatePreference();
73 return $this->mDateFormat
;
76 function getTimestamp() {
77 if ( !isset( $this->mTimestamp
) ) {
78 $this->mTimestamp
= wfTimestampNow();
80 return $this->mTimestamp
;
83 function setUseTeX( $x ) { return wfSetVar( $this->mUseTeX
, $x ); }
84 function setUseDynamicDates( $x ) { return wfSetVar( $this->mUseDynamicDates
, $x ); }
85 function setInterwikiMagic( $x ) { return wfSetVar( $this->mInterwikiMagic
, $x ); }
86 function setAllowExternalImages( $x ) { return wfSetVar( $this->mAllowExternalImages
, $x ); }
87 function setAllowExternalImagesFrom( $x ) { return wfSetVar( $this->mAllowExternalImagesFrom
, $x ); }
88 function setEnableImageWhitelist( $x ) { return wfSetVar( $this->mEnableImageWhitelist
, $x ); }
89 function setDateFormat( $x ) { return wfSetVar( $this->mDateFormat
, $x ); }
90 function setEditSection( $x ) { return wfSetVar( $this->mEditSection
, $x ); }
91 function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings
, $x ); }
92 function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion
, $x ); }
93 function setTidy( $x ) { return wfSetVar( $this->mTidy
, $x); }
94 function setSkin( $x ) { $this->mSkin
= $x; }
95 function setInterfaceMessage( $x ) { return wfSetVar( $this->mInterfaceMessage
, $x); }
96 function setTargetLanguage( $x ) { return wfSetVar( $this->mTargetLanguage
, $x); }
97 function setMaxIncludeSize( $x ) { return wfSetVar( $this->mMaxIncludeSize
, $x ); }
98 function setMaxPPNodeCount( $x ) { return wfSetVar( $this->mMaxPPNodeCount
, $x ); }
99 function setMaxTemplateDepth( $x ) { return wfSetVar( $this->mMaxTemplateDepth
, $x ); }
100 function setRemoveComments( $x ) { return wfSetVar( $this->mRemoveComments
, $x ); }
101 function setTemplateCallback( $x ) { return wfSetVar( $this->mTemplateCallback
, $x ); }
102 function enableLimitReport( $x = true ) { return wfSetVar( $this->mEnableLimitReport
, $x ); }
103 function setTimestamp( $x ) { return wfSetVar( $this->mTimestamp
, $x ); }
104 function setCleanSignatures( $x ) { return wfSetVar( $this->mCleanSignatures
, $x ); }
105 function setExternalLinkTarget( $x ) { return wfSetVar( $this->mExternalLinkTarget
, $x ); }
106 function setIsPreview( $x ) { return wfSetVar( $this->mIsPreview
, $x ); }
107 function setIsSectionPreview( $x ) { return wfSetVar( $this->mIsSectionPreview
, $x ); }
109 function __construct( $user = null ) {
110 $this->initialiseFromUser( $user );
117 static function newFromUser( $user ) {
118 return new ParserOptions( $user );
121 /** Get user options */
122 function initialiseFromUser( $userInput ) {
123 global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
124 global $wgAllowExternalImagesFrom, $wgEnableImageWhitelist, $wgAllowSpecialInclusion, $wgMaxArticleSize;
125 global $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth, $wgCleanSignatures;
126 global $wgExternalLinkTarget;
127 $fname = 'ParserOptions::initialiseFromUser';
128 wfProfileIn( $fname );
131 if ( isset( $wgUser ) ) {
140 $this->mUser
= $user;
142 $this->mUseTeX
= $wgUseTeX;
143 $this->mUseDynamicDates
= $wgUseDynamicDates;
144 $this->mInterwikiMagic
= $wgInterwikiMagic;
145 $this->mAllowExternalImages
= $wgAllowExternalImages;
146 $this->mAllowExternalImagesFrom
= $wgAllowExternalImagesFrom;
147 $this->mEnableImageWhitelist
= $wgEnableImageWhitelist;
148 $this->mSkin
= null; # Deferred
149 $this->mDateFormat
= null; # Deferred
150 $this->mEditSection
= true;
151 $this->mNumberHeadings
= $user->getOption( 'numberheadings' );
152 $this->mAllowSpecialInclusion
= $wgAllowSpecialInclusion;
153 $this->mTidy
= false;
154 $this->mInterfaceMessage
= false;
155 $this->mTargetLanguage
= null; // default depends on InterfaceMessage setting
156 $this->mMaxIncludeSize
= $wgMaxArticleSize * 1024;
157 $this->mMaxPPNodeCount
= $wgMaxPPNodeCount;
158 $this->mMaxPPExpandDepth
= $wgMaxPPExpandDepth;
159 $this->mMaxTemplateDepth
= $wgMaxTemplateDepth;
160 $this->mRemoveComments
= true;
161 $this->mTemplateCallback
= array( 'Parser', 'statelessFetchTemplate' );
162 $this->mEnableLimitReport
= false;
163 $this->mCleanSignatures
= $wgCleanSignatures;
164 $this->mExternalLinkTarget
= $wgExternalLinkTarget;
165 $this->mIsPreview
= false;
166 $this->mIsSectionPreview
= false;
167 wfProfileOut( $fname );