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
30 var $mUser; # Stored user object, just used to initialise the skin
32 function getUseTeX() { return $this->mUseTeX
; }
33 function getUseDynamicDates() { return $this->mUseDynamicDates
; }
34 function getInterwikiMagic() { return $this->mInterwikiMagic
; }
35 function getAllowExternalImages() { return $this->mAllowExternalImages
; }
36 function getAllowExternalImagesFrom() { return $this->mAllowExternalImagesFrom
; }
37 function getEditSection() { return $this->mEditSection
; }
38 function getNumberHeadings() { return $this->mNumberHeadings
; }
39 function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion
; }
40 function getTidy() { return $this->mTidy
; }
41 function getInterfaceMessage() { return $this->mInterfaceMessage
; }
42 function getMaxIncludeSize() { return $this->mMaxIncludeSize
; }
43 function getMaxPPNodeCount() { return $this->mMaxPPNodeCount
; }
44 function getMaxTemplateDepth() { return $this->mMaxTemplateDepth
; }
45 function getRemoveComments() { return $this->mRemoveComments
; }
46 function getTemplateCallback() { return $this->mTemplateCallback
; }
47 function getEnableLimitReport() { return $this->mEnableLimitReport
; }
50 if ( !isset( $this->mSkin
) ) {
51 $this->mSkin
= $this->mUser
->getSkin();
56 function getDateFormat() {
57 if ( !isset( $this->mDateFormat
) ) {
58 $this->mDateFormat
= $this->mUser
->getDatePreference();
60 return $this->mDateFormat
;
63 function setUseTeX( $x ) { return wfSetVar( $this->mUseTeX
, $x ); }
64 function setUseDynamicDates( $x ) { return wfSetVar( $this->mUseDynamicDates
, $x ); }
65 function setInterwikiMagic( $x ) { return wfSetVar( $this->mInterwikiMagic
, $x ); }
66 function setAllowExternalImages( $x ) { return wfSetVar( $this->mAllowExternalImages
, $x ); }
67 function setAllowExternalImagesFrom( $x ) { return wfSetVar( $this->mAllowExternalImagesFrom
, $x ); }
68 function setDateFormat( $x ) { return wfSetVar( $this->mDateFormat
, $x ); }
69 function setEditSection( $x ) { return wfSetVar( $this->mEditSection
, $x ); }
70 function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings
, $x ); }
71 function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion
, $x ); }
72 function setTidy( $x ) { return wfSetVar( $this->mTidy
, $x); }
73 function setSkin( $x ) { $this->mSkin
= $x; }
74 function setInterfaceMessage( $x ) { return wfSetVar( $this->mInterfaceMessage
, $x); }
75 function setMaxIncludeSize( $x ) { return wfSetVar( $this->mMaxIncludeSize
, $x ); }
76 function setMaxPPNodeCount( $x ) { return wfSetVar( $this->mMaxPPNodeCount
, $x ); }
77 function setMaxTemplateDepth( $x ) { return wfSetVar( $this->mMaxTemplateDepth
, $x ); }
78 function setRemoveComments( $x ) { return wfSetVar( $this->mRemoveComments
, $x ); }
79 function setTemplateCallback( $x ) { return wfSetVar( $this->mTemplateCallback
, $x ); }
80 function enableLimitReport( $x = true ) { return wfSetVar( $this->mEnableLimitReport
, $x ); }
82 function __construct( $user = null ) {
83 $this->initialiseFromUser( $user );
90 static function newFromUser( $user ) {
91 return new ParserOptions( $user );
94 /** Get user options */
95 function initialiseFromUser( $userInput ) {
96 global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
97 global $wgAllowExternalImagesFrom, $wgAllowSpecialInclusion, $wgMaxArticleSize;
98 global $wgMaxPPNodeCount, $wgMaxTemplateDepth;
99 $fname = 'ParserOptions::initialiseFromUser';
100 wfProfileIn( $fname );
103 if ( isset( $wgUser ) ) {
112 $this->mUser
= $user;
114 $this->mUseTeX
= $wgUseTeX;
115 $this->mUseDynamicDates
= $wgUseDynamicDates;
116 $this->mInterwikiMagic
= $wgInterwikiMagic;
117 $this->mAllowExternalImages
= $wgAllowExternalImages;
118 $this->mAllowExternalImagesFrom
= $wgAllowExternalImagesFrom;
119 $this->mSkin
= null; # Deferred
120 $this->mDateFormat
= null; # Deferred
121 $this->mEditSection
= true;
122 $this->mNumberHeadings
= $user->getOption( 'numberheadings' );
123 $this->mAllowSpecialInclusion
= $wgAllowSpecialInclusion;
124 $this->mTidy
= false;
125 $this->mInterfaceMessage
= false;
126 $this->mMaxIncludeSize
= $wgMaxArticleSize * 1024;
127 $this->mMaxPPNodeCount
= $wgMaxPPNodeCount;
128 $this->mMaxTemplateDepth
= $wgMaxTemplateDepth;
129 $this->mRemoveComments
= true;
130 $this->mTemplateCallback
= array( 'Parser', 'statelessFetchTemplate' );
131 $this->mEnableLimitReport
= false;
132 wfProfileOut( $fname );