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 $mMaxIncludeSize; # Maximum size of template expansions, in bytes
24 var $mMaxPPNodeCount; # Maximum number of nodes touched by PPFrame::expand()
25 var $mMaxTemplateDepth; # Maximum recursion depth for templates within templates
26 var $mRemoveComments; # Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
27 var $mTemplateCallback; # Callback for template fetching
28 var $mEnableLimitReport; # Enable limit report in an HTML comment on output
29 var $mTimestamp; # Timestamp used for {{CURRENTDAY}} etc.
31 var $mUser; # Stored user object, just used to initialise the skin
33 function getUseTeX() { return $this->mUseTeX
; }
34 function getUseDynamicDates() { return $this->mUseDynamicDates
; }
35 function getInterwikiMagic() { return $this->mInterwikiMagic
; }
36 function getAllowExternalImages() { return $this->mAllowExternalImages
; }
37 function getAllowExternalImagesFrom() { return $this->mAllowExternalImagesFrom
; }
38 function getEditSection() { return $this->mEditSection
; }
39 function getNumberHeadings() { return $this->mNumberHeadings
; }
40 function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion
; }
41 function getTidy() { return $this->mTidy
; }
42 function getInterfaceMessage() { return $this->mInterfaceMessage
; }
43 function getMaxIncludeSize() { return $this->mMaxIncludeSize
; }
44 function getMaxPPNodeCount() { return $this->mMaxPPNodeCount
; }
45 function getMaxTemplateDepth() { return $this->mMaxTemplateDepth
; }
46 function getRemoveComments() { return $this->mRemoveComments
; }
47 function getTemplateCallback() { return $this->mTemplateCallback
; }
48 function getEnableLimitReport() { return $this->mEnableLimitReport
; }
51 if ( !isset( $this->mSkin
) ) {
52 $this->mSkin
= $this->mUser
->getSkin();
57 function getDateFormat() {
58 if ( !isset( $this->mDateFormat
) ) {
59 $this->mDateFormat
= $this->mUser
->getDatePreference();
61 return $this->mDateFormat
;
64 function getTimestamp() {
65 if ( !isset( $this->mTimestamp
) ) {
66 $this->mTimestamp
= wfTimestampNow();
68 return $this->mTimestamp
;
71 function setUseTeX( $x ) { return wfSetVar( $this->mUseTeX
, $x ); }
72 function setUseDynamicDates( $x ) { return wfSetVar( $this->mUseDynamicDates
, $x ); }
73 function setInterwikiMagic( $x ) { return wfSetVar( $this->mInterwikiMagic
, $x ); }
74 function setAllowExternalImages( $x ) { return wfSetVar( $this->mAllowExternalImages
, $x ); }
75 function setAllowExternalImagesFrom( $x ) { return wfSetVar( $this->mAllowExternalImagesFrom
, $x ); }
76 function setDateFormat( $x ) { return wfSetVar( $this->mDateFormat
, $x ); }
77 function setEditSection( $x ) { return wfSetVar( $this->mEditSection
, $x ); }
78 function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings
, $x ); }
79 function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion
, $x ); }
80 function setTidy( $x ) { return wfSetVar( $this->mTidy
, $x); }
81 function setSkin( $x ) { $this->mSkin
= $x; }
82 function setInterfaceMessage( $x ) { return wfSetVar( $this->mInterfaceMessage
, $x); }
83 function setMaxIncludeSize( $x ) { return wfSetVar( $this->mMaxIncludeSize
, $x ); }
84 function setMaxPPNodeCount( $x ) { return wfSetVar( $this->mMaxPPNodeCount
, $x ); }
85 function setMaxTemplateDepth( $x ) { return wfSetVar( $this->mMaxTemplateDepth
, $x ); }
86 function setRemoveComments( $x ) { return wfSetVar( $this->mRemoveComments
, $x ); }
87 function setTemplateCallback( $x ) { return wfSetVar( $this->mTemplateCallback
, $x ); }
88 function enableLimitReport( $x = true ) { return wfSetVar( $this->mEnableLimitReport
, $x ); }
89 function setTimestamp( $x ) { return wfSetVar( $this->mTimestamp
, $x ); }
91 function __construct( $user = null ) {
92 $this->initialiseFromUser( $user );
99 static function newFromUser( $user ) {
100 return new ParserOptions( $user );
103 /** Get user options */
104 function initialiseFromUser( $userInput ) {
105 global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
106 global $wgAllowExternalImagesFrom, $wgAllowSpecialInclusion, $wgMaxArticleSize;
107 global $wgMaxPPNodeCount, $wgMaxTemplateDepth;
108 $fname = 'ParserOptions::initialiseFromUser';
109 wfProfileIn( $fname );
112 if ( isset( $wgUser ) ) {
121 $this->mUser
= $user;
123 $this->mUseTeX
= $wgUseTeX;
124 $this->mUseDynamicDates
= $wgUseDynamicDates;
125 $this->mInterwikiMagic
= $wgInterwikiMagic;
126 $this->mAllowExternalImages
= $wgAllowExternalImages;
127 $this->mAllowExternalImagesFrom
= $wgAllowExternalImagesFrom;
128 $this->mSkin
= null; # Deferred
129 $this->mDateFormat
= null; # Deferred
130 $this->mEditSection
= true;
131 $this->mNumberHeadings
= $user->getOption( 'numberheadings' );
132 $this->mAllowSpecialInclusion
= $wgAllowSpecialInclusion;
133 $this->mTidy
= false;
134 $this->mInterfaceMessage
= false;
135 $this->mMaxIncludeSize
= $wgMaxArticleSize * 1024;
136 $this->mMaxPPNodeCount
= $wgMaxPPNodeCount;
137 $this->mMaxTemplateDepth
= $wgMaxTemplateDepth;
138 $this->mRemoveComments
= true;
139 $this->mTemplateCallback
= array( 'Parser', 'statelessFetchTemplate' );
140 $this->mEnableLimitReport
= false;
141 wfProfileOut( $fname );