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 $mRemoveComments; # Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
26 var $mTemplateCallback; # Callback for template fetching
27 var $mEnableLimitReport; # Enable limit report in an HTML comment on output
29 var $mUser; # Stored user object, just used to initialise the skin
31 function getUseTeX() { return $this->mUseTeX
; }
32 function getUseDynamicDates() { return $this->mUseDynamicDates
; }
33 function getInterwikiMagic() { return $this->mInterwikiMagic
; }
34 function getAllowExternalImages() { return $this->mAllowExternalImages
; }
35 function getAllowExternalImagesFrom() { return $this->mAllowExternalImagesFrom
; }
36 function getEditSection() { return $this->mEditSection
; }
37 function getNumberHeadings() { return $this->mNumberHeadings
; }
38 function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion
; }
39 function getTidy() { return $this->mTidy
; }
40 function getInterfaceMessage() { return $this->mInterfaceMessage
; }
41 function getMaxIncludeSize() { return $this->mMaxIncludeSize
; }
42 function getMaxPPNodeCount() { return $this->mMaxPPNodeCount
; }
43 function getRemoveComments() { return $this->mRemoveComments
; }
44 function getTemplateCallback() { return $this->mTemplateCallback
; }
45 function getEnableLimitReport() { return $this->mEnableLimitReport
; }
48 if ( !isset( $this->mSkin
) ) {
49 $this->mSkin
= $this->mUser
->getSkin();
54 function getDateFormat() {
55 if ( !isset( $this->mDateFormat
) ) {
56 $this->mDateFormat
= $this->mUser
->getDatePreference();
58 return $this->mDateFormat
;
61 function setUseTeX( $x ) { return wfSetVar( $this->mUseTeX
, $x ); }
62 function setUseDynamicDates( $x ) { return wfSetVar( $this->mUseDynamicDates
, $x ); }
63 function setInterwikiMagic( $x ) { return wfSetVar( $this->mInterwikiMagic
, $x ); }
64 function setAllowExternalImages( $x ) { return wfSetVar( $this->mAllowExternalImages
, $x ); }
65 function setAllowExternalImagesFrom( $x ) { return wfSetVar( $this->mAllowExternalImagesFrom
, $x ); }
66 function setDateFormat( $x ) { return wfSetVar( $this->mDateFormat
, $x ); }
67 function setEditSection( $x ) { return wfSetVar( $this->mEditSection
, $x ); }
68 function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings
, $x ); }
69 function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion
, $x ); }
70 function setTidy( $x ) { return wfSetVar( $this->mTidy
, $x); }
71 function setSkin( $x ) { $this->mSkin
= $x; }
72 function setInterfaceMessage( $x ) { return wfSetVar( $this->mInterfaceMessage
, $x); }
73 function setMaxIncludeSize( $x ) { return wfSetVar( $this->mMaxIncludeSize
, $x ); }
74 function setMaxPPNodeCount( $x ) { return wfSetVar( $this->mMaxPPNodeCount
, $x ); }
75 function setRemoveComments( $x ) { return wfSetVar( $this->mRemoveComments
, $x ); }
76 function setTemplateCallback( $x ) { return wfSetVar( $this->mTemplateCallback
, $x ); }
77 function enableLimitReport( $x = true ) { return wfSetVar( $this->mEnableLimitReport
, $x ); }
79 function __construct( $user = null ) {
80 $this->initialiseFromUser( $user );
87 static function newFromUser( $user ) {
88 return new ParserOptions( $user );
91 /** Get user options */
92 function initialiseFromUser( $userInput ) {
93 global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
94 global $wgAllowExternalImagesFrom, $wgAllowSpecialInclusion, $wgMaxArticleSize;
95 global $wgMaxPPNodeCount;
96 $fname = 'ParserOptions::initialiseFromUser';
97 wfProfileIn( $fname );
100 if ( isset( $wgUser ) ) {
109 $this->mUser
= $user;
111 $this->mUseTeX
= $wgUseTeX;
112 $this->mUseDynamicDates
= $wgUseDynamicDates;
113 $this->mInterwikiMagic
= $wgInterwikiMagic;
114 $this->mAllowExternalImages
= $wgAllowExternalImages;
115 $this->mAllowExternalImagesFrom
= $wgAllowExternalImagesFrom;
116 $this->mSkin
= null; # Deferred
117 $this->mDateFormat
= null; # Deferred
118 $this->mEditSection
= true;
119 $this->mNumberHeadings
= $user->getOption( 'numberheadings' );
120 $this->mAllowSpecialInclusion
= $wgAllowSpecialInclusion;
121 $this->mTidy
= false;
122 $this->mInterfaceMessage
= false;
123 $this->mMaxIncludeSize
= $wgMaxArticleSize * 1024;
124 $this->mMaxPPNodeCount
= $wgMaxPPNodeCount;
125 $this->mRemoveComments
= true;
126 $this->mTemplateCallback
= array( 'Parser', 'statelessFetchTemplate' );
127 $this->mEnableLimitReport
= false;
128 wfProfileOut( $fname );