Postgres: make sure ar_len is added when updating, alpha stuff in updaters.inc
[lhc/web/wiklou.git] / includes / ParserOptions.php
1 <?php
2
3 /**
4 * Set options of the Parser
5 * @todo document
6 */
7 class ParserOptions
8 {
9 # All variables are supposed to be private in theory, although in practise this is not the case.
10 var $mUseTeX; # Use texvc to expand <math> tags
11 var $mUseDynamicDates; # Use DateFormatter to format dates
12 var $mInterwikiMagic; # Interlanguage links are removed and returned in an array
13 var $mAllowExternalImages; # Allow external images inline
14 var $mAllowExternalImagesFrom; # If not, any exception?
15 var $mSkin; # Reference to the preferred skin
16 var $mDateFormat; # Date format index
17 var $mEditSection; # Create "edit section" links
18 var $mNumberHeadings; # Automatically number headings
19 var $mAllowSpecialInclusion; # Allow inclusion of special pages
20 var $mTidy; # Ask for tidy cleanup
21 var $mInterfaceMessage; # Which lang to call for PLURAL and GRAMMAR
22 var $mMaxIncludeSize; # Maximum size of template expansions, in bytes
23 var $mRemoveComments; # Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
24
25 var $mUser; # Stored user object, just used to initialise the skin
26
27 function getUseTeX() { return $this->mUseTeX; }
28 function getUseDynamicDates() { return $this->mUseDynamicDates; }
29 function getInterwikiMagic() { return $this->mInterwikiMagic; }
30 function getAllowExternalImages() { return $this->mAllowExternalImages; }
31 function getAllowExternalImagesFrom() { return $this->mAllowExternalImagesFrom; }
32 function getEditSection() { return $this->mEditSection; }
33 function getNumberHeadings() { return $this->mNumberHeadings; }
34 function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion; }
35 function getTidy() { return $this->mTidy; }
36 function getInterfaceMessage() { return $this->mInterfaceMessage; }
37 function getMaxIncludeSize() { return $this->mMaxIncludeSize; }
38 function getRemoveComments() { return $this->mRemoveComments; }
39
40 function getSkin() {
41 if ( !isset( $this->mSkin ) ) {
42 $this->mSkin = $this->mUser->getSkin();
43 }
44 return $this->mSkin;
45 }
46
47 function getDateFormat() {
48 if ( !isset( $this->mDateFormat ) ) {
49 $this->mDateFormat = $this->mUser->getDatePreference();
50 }
51 return $this->mDateFormat;
52 }
53
54 function setUseTeX( $x ) { return wfSetVar( $this->mUseTeX, $x ); }
55 function setUseDynamicDates( $x ) { return wfSetVar( $this->mUseDynamicDates, $x ); }
56 function setInterwikiMagic( $x ) { return wfSetVar( $this->mInterwikiMagic, $x ); }
57 function setAllowExternalImages( $x ) { return wfSetVar( $this->mAllowExternalImages, $x ); }
58 function setAllowExternalImagesFrom( $x ) { return wfSetVar( $this->mAllowExternalImagesFrom, $x ); }
59 function setDateFormat( $x ) { return wfSetVar( $this->mDateFormat, $x ); }
60 function setEditSection( $x ) { return wfSetVar( $this->mEditSection, $x ); }
61 function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings, $x ); }
62 function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion, $x ); }
63 function setTidy( $x ) { return wfSetVar( $this->mTidy, $x); }
64 function setSkin( $x ) { $this->mSkin = $x; }
65 function setInterfaceMessage( $x ) { return wfSetVar( $this->mInterfaceMessage, $x); }
66 function setMaxIncludeSize( $x ) { return wfSetVar( $this->mMaxIncludeSize, $x ); }
67 function setRemoveComments( $x ) { return wfSetVar( $this->mRemoveComments, $x ); }
68
69 function __construct( $user = null ) {
70 $this->initialiseFromUser( $user );
71 }
72
73 /**
74 * Get parser options
75 * @static
76 */
77 static function newFromUser( $user ) {
78 return new ParserOptions( $user );
79 }
80
81 /** Get user options */
82 function initialiseFromUser( $userInput ) {
83 global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
84 global $wgAllowExternalImagesFrom, $wgAllowSpecialInclusion, $wgMaxArticleSize;
85 $fname = 'ParserOptions::initialiseFromUser';
86 wfProfileIn( $fname );
87 if ( !$userInput ) {
88 global $wgUser;
89 if ( isset( $wgUser ) ) {
90 $user = $wgUser;
91 } else {
92 $user = new User;
93 }
94 } else {
95 $user =& $userInput;
96 }
97
98 $this->mUser = $user;
99
100 $this->mUseTeX = $wgUseTeX;
101 $this->mUseDynamicDates = $wgUseDynamicDates;
102 $this->mInterwikiMagic = $wgInterwikiMagic;
103 $this->mAllowExternalImages = $wgAllowExternalImages;
104 $this->mAllowExternalImagesFrom = $wgAllowExternalImagesFrom;
105 $this->mSkin = null; # Deferred
106 $this->mDateFormat = null; # Deferred
107 $this->mEditSection = true;
108 $this->mNumberHeadings = $user->getOption( 'numberheadings' );
109 $this->mAllowSpecialInclusion = $wgAllowSpecialInclusion;
110 $this->mTidy = false;
111 $this->mInterfaceMessage = false;
112 $this->mMaxIncludeSize = $wgMaxArticleSize * 1024;
113 $this->mRemoveComments = true;
114 wfProfileOut( $fname );
115 }
116 }
117
118 ?>