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 $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.
33 var $mUser; # Stored user object, just used to initialise the skin
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 getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion
; }
43 function getTidy() { return $this->mTidy
; }
44 function getInterfaceMessage() { return $this->mInterfaceMessage
; }
45 function getTargetLanguage() { return $this->mTargetLanguage
; }
46 function getMaxIncludeSize() { return $this->mMaxIncludeSize
; }
47 function getMaxPPNodeCount() { return $this->mMaxPPNodeCount
; }
48 function getMaxTemplateDepth() { return $this->mMaxTemplateDepth
; }
49 function getRemoveComments() { return $this->mRemoveComments
; }
50 function getTemplateCallback() { return $this->mTemplateCallback
; }
51 function getEnableLimitReport() { return $this->mEnableLimitReport
; }
52 function getCleanSignatures() { return $this->mCleanSignatures
; }
55 if ( !isset( $this->mSkin
) ) {
56 $this->mSkin
= $this->mUser
->getSkin();
61 function getDateFormat() {
62 if ( !isset( $this->mDateFormat
) ) {
63 $this->mDateFormat
= $this->mUser
->getDatePreference();
65 return $this->mDateFormat
;
68 function getTimestamp() {
69 if ( !isset( $this->mTimestamp
) ) {
70 $this->mTimestamp
= wfTimestampNow();
72 return $this->mTimestamp
;
75 function setUseTeX( $x ) { return wfSetVar( $this->mUseTeX
, $x ); }
76 function setUseDynamicDates( $x ) { return wfSetVar( $this->mUseDynamicDates
, $x ); }
77 function setInterwikiMagic( $x ) { return wfSetVar( $this->mInterwikiMagic
, $x ); }
78 function setAllowExternalImages( $x ) { return wfSetVar( $this->mAllowExternalImages
, $x ); }
79 function setAllowExternalImagesFrom( $x ) { return wfSetVar( $this->mAllowExternalImagesFrom
, $x ); }
80 function setDateFormat( $x ) { return wfSetVar( $this->mDateFormat
, $x ); }
81 function setEditSection( $x ) { return wfSetVar( $this->mEditSection
, $x ); }
82 function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings
, $x ); }
83 function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion
, $x ); }
84 function setTidy( $x ) { return wfSetVar( $this->mTidy
, $x); }
85 function setSkin( $x ) { $this->mSkin
= $x; }
86 function setInterfaceMessage( $x ) { return wfSetVar( $this->mInterfaceMessage
, $x); }
87 function setTargetLanguage( $x ) { return wfSetVar( $this->mTargetLanguage
, $x); }
88 function setMaxIncludeSize( $x ) { return wfSetVar( $this->mMaxIncludeSize
, $x ); }
89 function setMaxPPNodeCount( $x ) { return wfSetVar( $this->mMaxPPNodeCount
, $x ); }
90 function setMaxTemplateDepth( $x ) { return wfSetVar( $this->mMaxTemplateDepth
, $x ); }
91 function setRemoveComments( $x ) { return wfSetVar( $this->mRemoveComments
, $x ); }
92 function setTemplateCallback( $x ) { return wfSetVar( $this->mTemplateCallback
, $x ); }
93 function enableLimitReport( $x = true ) { return wfSetVar( $this->mEnableLimitReport
, $x ); }
94 function setTimestamp( $x ) { return wfSetVar( $this->mTimestamp
, $x ); }
95 function setCleanSignatures( $x ) { return wfSetVar( $this->mCleanSignatures
, $x ); }
97 function __construct( $user = null ) {
98 $this->initialiseFromUser( $user );
105 static function newFromUser( $user ) {
106 return new ParserOptions( $user );
109 /** Get user options */
110 function initialiseFromUser( $userInput ) {
111 global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
112 global $wgAllowExternalImagesFrom, $wgAllowSpecialInclusion, $wgMaxArticleSize;
113 global $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth, $wgCleanSignatures;
114 $fname = 'ParserOptions::initialiseFromUser';
115 wfProfileIn( $fname );
118 if ( isset( $wgUser ) ) {
127 $this->mUser
= $user;
129 $this->mUseTeX
= $wgUseTeX;
130 $this->mUseDynamicDates
= $wgUseDynamicDates;
131 $this->mInterwikiMagic
= $wgInterwikiMagic;
132 $this->mAllowExternalImages
= $wgAllowExternalImages;
133 $this->mAllowExternalImagesFrom
= $wgAllowExternalImagesFrom;
134 $this->mSkin
= null; # Deferred
135 $this->mDateFormat
= null; # Deferred
136 $this->mEditSection
= true;
137 $this->mNumberHeadings
= $user->getOption( 'numberheadings' );
138 $this->mAllowSpecialInclusion
= $wgAllowSpecialInclusion;
139 $this->mTidy
= false;
140 $this->mInterfaceMessage
= false;
141 $this->mTargetLanguage
= null; // default depends on InterfaceMessage setting
142 $this->mMaxIncludeSize
= $wgMaxArticleSize * 1024;
143 $this->mMaxPPNodeCount
= $wgMaxPPNodeCount;
144 $this->mMaxPPExpandDepth
= $wgMaxPPExpandDepth;
145 $this->mMaxTemplateDepth
= $wgMaxTemplateDepth;
146 $this->mRemoveComments
= true;
147 $this->mTemplateCallback
= array( 'Parser', 'statelessFetchTemplate' );
148 $this->mEnableLimitReport
= false;
149 $this->mCleanSignatures
= $wgCleanSignatures;
150 wfProfileOut( $fname );