f4ed78db3748b90d3ff46f4e2b99e20cc9e460be
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
28 var $mUser; # Stored user object, just used to initialise the skin
30 function getUseTeX() { return $this->mUseTeX
; }
31 function getUseDynamicDates() { return $this->mUseDynamicDates
; }
32 function getInterwikiMagic() { return $this->mInterwikiMagic
; }
33 function getAllowExternalImages() { return $this->mAllowExternalImages
; }
34 function getAllowExternalImagesFrom() { return $this->mAllowExternalImagesFrom
; }
35 function getEditSection() { return $this->mEditSection
; }
36 function getNumberHeadings() { return $this->mNumberHeadings
; }
37 function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion
; }
38 function getTidy() { return $this->mTidy
; }
39 function getInterfaceMessage() { return $this->mInterfaceMessage
; }
40 function getMaxIncludeSize() { return $this->mMaxIncludeSize
; }
41 function getMaxPPNodeCount() { return $this->mMaxPPNodeCount
; }
42 function getRemoveComments() { return $this->mRemoveComments
; }
43 function getTemplateCallback() { return $this->mTemplateCallback
; }
46 if ( !isset( $this->mSkin
) ) {
47 $this->mSkin
= $this->mUser
->getSkin();
52 function getDateFormat() {
53 if ( !isset( $this->mDateFormat
) ) {
54 $this->mDateFormat
= $this->mUser
->getDatePreference();
56 return $this->mDateFormat
;
59 function setUseTeX( $x ) { return wfSetVar( $this->mUseTeX
, $x ); }
60 function setUseDynamicDates( $x ) { return wfSetVar( $this->mUseDynamicDates
, $x ); }
61 function setInterwikiMagic( $x ) { return wfSetVar( $this->mInterwikiMagic
, $x ); }
62 function setAllowExternalImages( $x ) { return wfSetVar( $this->mAllowExternalImages
, $x ); }
63 function setAllowExternalImagesFrom( $x ) { return wfSetVar( $this->mAllowExternalImagesFrom
, $x ); }
64 function setDateFormat( $x ) { return wfSetVar( $this->mDateFormat
, $x ); }
65 function setEditSection( $x ) { return wfSetVar( $this->mEditSection
, $x ); }
66 function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings
, $x ); }
67 function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion
, $x ); }
68 function setTidy( $x ) { return wfSetVar( $this->mTidy
, $x); }
69 function setSkin( $x ) { $this->mSkin
= $x; }
70 function setInterfaceMessage( $x ) { return wfSetVar( $this->mInterfaceMessage
, $x); }
71 function setMaxIncludeSize( $x ) { return wfSetVar( $this->mMaxIncludeSize
, $x ); }
72 function setMaxPPNodeCount( $x ) { return wfSetVar( $this->mMaxPPNodeCount
, $x ); }
73 function setRemoveComments( $x ) { return wfSetVar( $this->mRemoveComments
, $x ); }
74 function setTemplateCallback( $x ) { return wfSetVar( $this->mTemplateCallback
, $x ); }
76 function __construct( $user = null ) {
77 $this->initialiseFromUser( $user );
84 static function newFromUser( $user ) {
85 return new ParserOptions( $user );
88 /** Get user options */
89 function initialiseFromUser( $userInput ) {
90 global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
91 global $wgAllowExternalImagesFrom, $wgAllowSpecialInclusion, $wgMaxArticleSize;
92 global $wgMaxPPNodeCount;
93 $fname = 'ParserOptions::initialiseFromUser';
94 wfProfileIn( $fname );
97 if ( isset( $wgUser ) ) {
106 $this->mUser
= $user;
108 $this->mUseTeX
= $wgUseTeX;
109 $this->mUseDynamicDates
= $wgUseDynamicDates;
110 $this->mInterwikiMagic
= $wgInterwikiMagic;
111 $this->mAllowExternalImages
= $wgAllowExternalImages;
112 $this->mAllowExternalImagesFrom
= $wgAllowExternalImagesFrom;
113 $this->mSkin
= null; # Deferred
114 $this->mDateFormat
= null; # Deferred
115 $this->mEditSection
= true;
116 $this->mNumberHeadings
= $user->getOption( 'numberheadings' );
117 $this->mAllowSpecialInclusion
= $wgAllowSpecialInclusion;
118 $this->mTidy
= false;
119 $this->mInterfaceMessage
= false;
120 $this->mMaxIncludeSize
= $wgMaxArticleSize * 1024;
121 $this->mMaxPPNodeCount
= $wgMaxPPNodeCount;
122 $this->mRemoveComments
= true;
123 $this->mTemplateCallback
= array( 'Parser', 'statelessFetchTemplate' );
124 wfProfileOut( $fname );