Index: trunk/phase3/includes/parser/ParserOptions.php |
— | — | @@ -1,58 +1,188 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Options for the PHP parser |
| 4 | + * \brief Options for the PHP parser |
5 | 5 | * |
6 | 6 | * @file |
7 | 7 | * @ingroup Parser |
8 | 8 | */ |
9 | 9 | |
10 | 10 | /** |
11 | | - * Set options of the Parser |
12 | | - * @todo document |
| 11 | + * \brief Set options of the Parser |
| 12 | + * |
| 13 | + * All member variables are supposed to be private in theory, although in practise this is not the case. |
| 14 | + * |
13 | 15 | * @ingroup Parser |
14 | 16 | */ |
15 | 17 | class ParserOptions { |
16 | | - # All variables are supposed to be private in theory, although in practise this is not the case. |
17 | | - var $mUseDynamicDates; # Use DateFormatter to format dates |
18 | | - var $mInterwikiMagic; # Interlanguage links are removed and returned in an array |
19 | | - var $mAllowExternalImages; # Allow external images inline |
20 | | - var $mAllowExternalImagesFrom; # If not, any exception? |
21 | | - var $mEnableImageWhitelist; # If not or it doesn't match, should we check an on-wiki whitelist? |
22 | | - var $mDateFormat = null; # Date format index |
23 | | - var $mEditSection = true; # Create "edit section" links |
24 | | - var $mAllowSpecialInclusion; # Allow inclusion of special pages |
25 | | - var $mTidy = false; # Ask for tidy cleanup |
26 | | - var $mInterfaceMessage = false; # Which lang to call for PLURAL and GRAMMAR |
27 | | - var $mTargetLanguage = null; # Overrides above setting with arbitrary language |
28 | | - var $mMaxIncludeSize; # Maximum size of template expansions, in bytes |
29 | | - var $mMaxPPNodeCount; # Maximum number of nodes touched by PPFrame::expand() |
30 | | - var $mMaxPPExpandDepth; # Maximum recursion depth in PPFrame::expand() |
31 | | - var $mMaxTemplateDepth; # Maximum recursion depth for templates within templates |
32 | | - var $mRemoveComments = true; # Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS |
33 | | - var $mTemplateCallback = # Callback for template fetching |
| 18 | + |
| 19 | + /** |
| 20 | + * Use DateFormatter to format dates |
| 21 | + */ |
| 22 | + var $mUseDynamicDates; |
| 23 | + |
| 24 | + /** |
| 25 | + * Interlanguage links are removed and returned in an array |
| 26 | + */ |
| 27 | + var $mInterwikiMagic; |
| 28 | + |
| 29 | + /** |
| 30 | + * Allow external images inline? |
| 31 | + */ |
| 32 | + var $mAllowExternalImages; |
| 33 | + |
| 34 | + /** |
| 35 | + * If not, any exception? |
| 36 | + */ |
| 37 | + var $mAllowExternalImagesFrom; |
| 38 | + |
| 39 | + /** |
| 40 | + * If not or it doesn't match, should we check an on-wiki whitelist? |
| 41 | + */ |
| 42 | + var $mEnableImageWhitelist; |
| 43 | + |
| 44 | + /** |
| 45 | + * Date format index |
| 46 | + */ |
| 47 | + var $mDateFormat = null; |
| 48 | + |
| 49 | + /** |
| 50 | + * Create "edit section" links? |
| 51 | + */ |
| 52 | + var $mEditSection = true; |
| 53 | + |
| 54 | + /** |
| 55 | + * Allow inclusion of special pages? |
| 56 | + */ |
| 57 | + var $mAllowSpecialInclusion; |
| 58 | + |
| 59 | + /** |
| 60 | + * Use tidy to cleanup output HTML? |
| 61 | + */ |
| 62 | + var $mTidy = false; |
| 63 | + |
| 64 | + /** |
| 65 | + * Which lang to call for PLURAL and GRAMMAR |
| 66 | + */ |
| 67 | + var $mInterfaceMessage = false; |
| 68 | + |
| 69 | + /** |
| 70 | + * Overrides $mInterfaceMessage with arbitrary language |
| 71 | + */ |
| 72 | + var $mTargetLanguage = null; |
| 73 | + |
| 74 | + /** |
| 75 | + * Maximum size of template expansions, in bytes |
| 76 | + */ |
| 77 | + var $mMaxIncludeSize; |
| 78 | + |
| 79 | + /** |
| 80 | + * Maximum number of nodes touched by PPFrame::expand() |
| 81 | + */ |
| 82 | + var $mMaxPPNodeCount; |
| 83 | + |
| 84 | + /** |
| 85 | + * Maximum recursion depth in PPFrame::expand() |
| 86 | + */ |
| 87 | + var $mMaxPPExpandDepth; |
| 88 | + |
| 89 | + /** |
| 90 | + * Maximum recursion depth for templates within templates |
| 91 | + */ |
| 92 | + var $mMaxTemplateDepth; |
| 93 | + |
| 94 | + /** |
| 95 | + * Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS |
| 96 | + */ |
| 97 | + var $mRemoveComments = true; |
| 98 | + |
| 99 | + /** |
| 100 | + * Callback for template fetching. Used as first argument to call_user_func(). |
| 101 | + */ |
| 102 | + var $mTemplateCallback = |
34 | 103 | array( 'Parser', 'statelessFetchTemplate' ); |
35 | | - var $mEnableLimitReport = false; # Enable limit report in an HTML comment on output |
36 | | - var $mTimestamp; # Timestamp used for {{CURRENTDAY}} etc. |
37 | | - var $mExternalLinkTarget; # Target attribute for external links |
38 | | - var $mCleanSignatures; # |
39 | | - var $mPreSaveTransform = true; # Transform wiki markup when saving the page. |
| 104 | + |
| 105 | + /** |
| 106 | + * Enable limit report in an HTML comment on output |
| 107 | + */ |
| 108 | + var $mEnableLimitReport = false; |
| 109 | + |
| 110 | + /** |
| 111 | + * Timestamp used for {{CURRENTDAY}} etc. |
| 112 | + */ |
| 113 | + var $mTimestamp; |
| 114 | + |
| 115 | + /** |
| 116 | + * Target attribute for external links |
| 117 | + */ |
| 118 | + var $mExternalLinkTarget; |
| 119 | + |
| 120 | + /** |
| 121 | + * Clean up signature texts? |
| 122 | + * |
| 123 | + * 1) Strip ~~~, ~~~~ and ~~~~~ out of signatures |
| 124 | + * 2) Substitute all transclusions |
| 125 | + */ |
| 126 | + var $mCleanSignatures; |
| 127 | + |
| 128 | + /** |
| 129 | + * Transform wiki markup when saving the page? |
| 130 | + */ |
| 131 | + var $mPreSaveTransform = true; |
40 | 132 | |
41 | | - var $mNumberHeadings; # Automatically number headings |
42 | | - var $mMath; # User math preference (as integer) |
43 | | - var $mThumbSize; # Thumb size preferred by the user. |
44 | | - private $mStubThreshold; # Maximum article size of an article to be marked as "stub" |
45 | | - var $mUserLang; # Language object of the User language. |
| 133 | + /** |
| 134 | + * Automatically number headings? |
| 135 | + */ |
| 136 | + var $mNumberHeadings; |
| 137 | + |
| 138 | + /** |
| 139 | + * User math preference (as integer). Not used (1.19) |
| 140 | + */ |
| 141 | + var $mMath; |
| 142 | + |
| 143 | + /** |
| 144 | + * Thumb size preferred by the user. |
| 145 | + */ |
| 146 | + var $mThumbSize; |
| 147 | + |
| 148 | + /** |
| 149 | + * Maximum article size of an article to be marked as "stub" |
| 150 | + */ |
| 151 | + private $mStubThreshold; |
| 152 | + |
| 153 | + /** |
| 154 | + * Language object of the User language. |
| 155 | + */ |
| 156 | + var $mUserLang; |
46 | 157 | |
47 | 158 | /** |
48 | | - * @var User |
| 159 | + * @var User |
| 160 | + * Stored user object |
49 | 161 | */ |
50 | | - var $mUser; # Stored user object |
51 | | - var $mIsPreview = false; # Parsing the page for a "preview" operation |
52 | | - var $mIsSectionPreview = false; # Parsing the page for a "preview" operation on a single section |
53 | | - var $mIsPrintable = false; # Parsing the printable version of the page |
| 162 | + var $mUser; |
| 163 | + |
| 164 | + /** |
| 165 | + * Parsing the page for a "preview" operation? |
| 166 | + */ |
| 167 | + var $mIsPreview = false; |
| 168 | + |
| 169 | + /** |
| 170 | + * Parsing the page for a "preview" operation on a single section? |
| 171 | + */ |
| 172 | + var $mIsSectionPreview = false; |
| 173 | + |
| 174 | + /** |
| 175 | + * Parsing the printable version of the page? |
| 176 | + */ |
| 177 | + var $mIsPrintable = false; |
54 | 178 | |
55 | | - var $mExtraKey = ''; # Extra key that should be present in the caching key. |
| 179 | + /** |
| 180 | + * Extra key that should be present in the caching key. |
| 181 | + */ |
| 182 | + var $mExtraKey = ''; |
56 | 183 | |
| 184 | + /** |
| 185 | + * Function to be called when an option is accessed. |
| 186 | + */ |
57 | 187 | protected $onAccessCallback = null; |
58 | 188 | |
59 | 189 | function getUseDynamicDates() { return $this->mUseDynamicDates; } |
— | — | @@ -184,6 +314,11 @@ |
185 | 315 | $this->mExtraKey .= '!' . $key; |
186 | 316 | } |
187 | 317 | |
| 318 | + /** |
| 319 | + * Constructor |
| 320 | + * @param $user User object |
| 321 | + * @param $lang Language object |
| 322 | + */ |
188 | 323 | function __construct( $user = null, $lang = null ) { |
189 | 324 | if ( $user === null ) { |
190 | 325 | global $wgUser; |
— | — | @@ -235,7 +370,12 @@ |
236 | 371 | return new ParserOptions( $context->getUser(), $context->getLanguage() ); |
237 | 372 | } |
238 | 373 | |
239 | | - /** Get user options */ |
| 374 | + /** |
| 375 | + * Get user options |
| 376 | + * |
| 377 | + * @param $user User object |
| 378 | + * @param $lang Language object |
| 379 | + */ |
240 | 380 | private function initialiseFromUser( $user, $lang ) { |
241 | 381 | global $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages, |
242 | 382 | $wgAllowExternalImagesFrom, $wgEnableImageWhitelist, $wgAllowSpecialInclusion, |
— | — | @@ -314,7 +454,7 @@ |
315 | 455 | * @since 1.17 |
316 | 456 | * @param $forOptions Array |
317 | 457 | * @param $title Title: used to get the content language of the page (since r97636) |
318 | | - * @return \string Page rendering hash |
| 458 | + * @return string Page rendering hash |
319 | 459 | */ |
320 | 460 | public function optionsHash( $forOptions, $title = null ) { |
321 | 461 | global $wgRenderHashAppend; |