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 $mRemoveComments; # Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
26 var $mUser; # Stored user object, just used to initialise the skin
28 function getUseTeX() { return $this->mUseTeX
; }
29 function getUseDynamicDates() { return $this->mUseDynamicDates
; }
30 function getInterwikiMagic() { return $this->mInterwikiMagic
; }
31 function getAllowExternalImages() { return $this->mAllowExternalImages
; }
32 function getAllowExternalImagesFrom() { return $this->mAllowExternalImagesFrom
; }
33 function getEditSection() { return $this->mEditSection
; }
34 function getNumberHeadings() { return $this->mNumberHeadings
; }
35 function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion
; }
36 function getTidy() { return $this->mTidy
; }
37 function getInterfaceMessage() { return $this->mInterfaceMessage
; }
38 function getMaxIncludeSize() { return $this->mMaxIncludeSize
; }
39 function getRemoveComments() { return $this->mRemoveComments
; }
42 if ( !isset( $this->mSkin
) ) {
43 $this->mSkin
= $this->mUser
->getSkin();
48 function getDateFormat() {
49 if ( !isset( $this->mDateFormat
) ) {
50 $this->mDateFormat
= $this->mUser
->getDatePreference();
52 return $this->mDateFormat
;
55 function setUseTeX( $x ) { return wfSetVar( $this->mUseTeX
, $x ); }
56 function setUseDynamicDates( $x ) { return wfSetVar( $this->mUseDynamicDates
, $x ); }
57 function setInterwikiMagic( $x ) { return wfSetVar( $this->mInterwikiMagic
, $x ); }
58 function setAllowExternalImages( $x ) { return wfSetVar( $this->mAllowExternalImages
, $x ); }
59 function setAllowExternalImagesFrom( $x ) { return wfSetVar( $this->mAllowExternalImagesFrom
, $x ); }
60 function setDateFormat( $x ) { return wfSetVar( $this->mDateFormat
, $x ); }
61 function setEditSection( $x ) { return wfSetVar( $this->mEditSection
, $x ); }
62 function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings
, $x ); }
63 function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion
, $x ); }
64 function setTidy( $x ) { return wfSetVar( $this->mTidy
, $x); }
65 function setSkin( $x ) { $this->mSkin
= $x; }
66 function setInterfaceMessage( $x ) { return wfSetVar( $this->mInterfaceMessage
, $x); }
67 function setMaxIncludeSize( $x ) { return wfSetVar( $this->mMaxIncludeSize
, $x ); }
68 function setRemoveComments( $x ) { return wfSetVar( $this->mRemoveComments
, $x ); }
70 function __construct( $user = null ) {
71 $this->initialiseFromUser( $user );
78 static function newFromUser( $user ) {
79 return new ParserOptions( $user );
82 /** Get user options */
83 function initialiseFromUser( $userInput ) {
84 global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
85 global $wgAllowExternalImagesFrom, $wgAllowSpecialInclusion, $wgMaxArticleSize;
86 $fname = 'ParserOptions::initialiseFromUser';
87 wfProfileIn( $fname );
90 if ( isset( $wgUser ) ) {
101 $this->mUseTeX
= $wgUseTeX;
102 $this->mUseDynamicDates
= $wgUseDynamicDates;
103 $this->mInterwikiMagic
= $wgInterwikiMagic;
104 $this->mAllowExternalImages
= $wgAllowExternalImages;
105 $this->mAllowExternalImagesFrom
= $wgAllowExternalImagesFrom;
106 $this->mSkin
= null; # Deferred
107 $this->mDateFormat
= null; # Deferred
108 $this->mEditSection
= true;
109 $this->mNumberHeadings
= $user->getOption( 'numberheadings' );
110 $this->mAllowSpecialInclusion
= $wgAllowSpecialInclusion;
111 $this->mTidy
= false;
112 $this->mInterfaceMessage
= false;
113 $this->mMaxIncludeSize
= $wgMaxArticleSize * 1024;
114 $this->mRemoveComments
= true;
115 wfProfileOut( $fname );