Index: trunk/phase3/includes/Preferences.php |
— | — | @@ -1,5 +1,4 @@ |
2 | 2 | <?php |
3 | | - |
4 | 3 | /** |
5 | 4 | * We're now using the HTMLForm object with some customisation to generate the |
6 | 5 | * Preferences form. This object handles generic submission, CSRF protection, |
— | — | @@ -25,12 +24,12 @@ |
26 | 25 | * Once fields have been retrieved and validated, submission logic is handed |
27 | 26 | * over to the tryUISubmit static method of this class. |
28 | 27 | */ |
| 28 | + |
29 | 29 | class Preferences { |
30 | 30 | static $defaultPreferences = null; |
31 | | - static $saveFilters = |
32 | | - array( |
| 31 | + static $saveFilters = array( |
33 | 32 | 'timecorrection' => array( 'Preferences', 'filterTimezoneInput' ), |
34 | | - ); |
| 33 | + ); |
35 | 34 | |
36 | 35 | static function getPreferences( $user ) { |
37 | 36 | if ( self::$defaultPreferences ) |
— | — | @@ -64,13 +63,13 @@ |
65 | 64 | |
66 | 65 | ## Prod in defaults from the user |
67 | 66 | global $wgDefaultUserOptions; |
68 | | - foreach( $defaultPreferences as $name => &$info ) { |
| 67 | + foreach ( $defaultPreferences as $name => &$info ) { |
69 | 68 | $prefFromUser = self::getOptionFromUser( $name, $info, $user ); |
70 | 69 | $field = HTMLForm::loadInputFromParameters( $info ); // For validation |
71 | 70 | $defaultOptions = User::getDefaultOptions(); |
72 | 71 | $globalDefault = isset( $defaultOptions[$name] ) |
73 | | - ? $defaultOptions[$name] |
74 | | - : null; |
| 72 | + ? $defaultOptions[$name] |
| 73 | + : null; |
75 | 74 | |
76 | 75 | // If it validates, set it as the default |
77 | 76 | if ( isset( $info['default'] ) ) { |
— | — | @@ -79,7 +78,7 @@ |
80 | 79 | } elseif ( !is_null( $prefFromUser ) && // Make sure we're not just pulling nothing |
81 | 80 | $field->validate( $prefFromUser, $user->mOptions ) === true ) { |
82 | 81 | $info['default'] = $prefFromUser; |
83 | | - } elseif( $field->validate( $globalDefault, $user->mOptions ) === true ) { |
| 82 | + } elseif ( $field->validate( $globalDefault, $user->mOptions ) === true ) { |
84 | 83 | $info['default'] = $globalDefault; |
85 | 84 | } else { |
86 | 85 | throw new MWException( "Global default '$globalDefault' is invalid for field $name" ); |
— | — | @@ -98,13 +97,12 @@ |
99 | 98 | // Handling for array-type preferences |
100 | 99 | if ( ( isset( $info['type'] ) && $info['type'] == 'multiselect' ) || |
101 | 100 | ( isset( $info['class'] ) && $info['class'] == 'HTMLMultiSelectField' ) ) { |
102 | | - |
103 | 101 | $options = HTMLFormField::flattenOptions( $info['options'] ); |
104 | 102 | $prefix = isset( $info['prefix'] ) ? $info['prefix'] : $name; |
105 | 103 | $val = array(); |
106 | 104 | |
107 | | - foreach( $options as $label => $value ) { |
108 | | - if( $user->getOption( "$prefix$value" ) ) { |
| 105 | + foreach ( $options as $label => $value ) { |
| 106 | + if ( $user->getOption( "$prefix$value" ) ) { |
109 | 107 | $val[] = $value; |
110 | 108 | } |
111 | 109 | } |
— | — | @@ -117,27 +115,25 @@ |
118 | 116 | global $wgLang, $wgUser; |
119 | 117 | ## User info ##################################### |
120 | 118 | // Information panel |
121 | | - $defaultPreferences['username'] = |
122 | | - array( |
123 | | - 'type' => 'info', |
124 | | - 'label-message' => 'username', |
125 | | - 'default' => $user->getName(), |
126 | | - 'section' => 'personal/info', |
127 | | - ); |
| 119 | + $defaultPreferences['username'] = array( |
| 120 | + 'type' => 'info', |
| 121 | + 'label-message' => 'username', |
| 122 | + 'default' => $user->getName(), |
| 123 | + 'section' => 'personal/info', |
| 124 | + ); |
128 | 125 | |
129 | | - $defaultPreferences['userid'] = |
130 | | - array( |
131 | | - 'type' => 'info', |
132 | | - 'label-message' => 'uid', |
133 | | - 'default' => $user->getId(), |
134 | | - 'section' => 'personal/info', |
135 | | - ); |
| 126 | + $defaultPreferences['userid'] = array( |
| 127 | + 'type' => 'info', |
| 128 | + 'label-message' => 'uid', |
| 129 | + 'default' => $user->getId(), |
| 130 | + 'section' => 'personal/info', |
| 131 | + ); |
136 | 132 | |
137 | 133 | # Get groups to which the user belongs |
138 | 134 | $userEffectiveGroups = $user->getEffectiveGroups(); |
139 | 135 | $userGroups = $userMembers = array(); |
140 | | - foreach( $userEffectiveGroups as $ueg ) { |
141 | | - if( $ueg == '*' ) { |
| 136 | + foreach ( $userEffectiveGroups as $ueg ) { |
| 137 | + if ( $ueg == '*' ) { |
142 | 138 | // Skip the default * group, seems useless here |
143 | 139 | continue; |
144 | 140 | } |
— | — | @@ -150,147 +146,143 @@ |
151 | 147 | asort( $userGroups ); |
152 | 148 | asort( $userMembers ); |
153 | 149 | |
154 | | - $defaultPreferences['usergroups'] = |
155 | | - array( |
156 | | - 'type' => 'info', |
157 | | - 'label' => wfMsgExt( 'prefs-memberingroups', 'parseinline', |
158 | | - $wgLang->formatNum( count($userGroups) ) ), |
159 | | - 'default' => wfMsgExt( 'prefs-memberingroups-type', array(), |
160 | | - $wgLang->commaList( $userGroups ), |
161 | | - $wgLang->commaList( $userMembers ) |
162 | | - ), |
163 | | - 'raw' => true, |
164 | | - 'section' => 'personal/info', |
165 | | - ); |
| 150 | + $defaultPreferences['usergroups'] = array( |
| 151 | + 'type' => 'info', |
| 152 | + 'label' => wfMsgExt( |
| 153 | + 'prefs-memberingroups', 'parseinline', |
| 154 | + $wgLang->formatNum( count( $userGroups ) ) |
| 155 | + ), |
| 156 | + 'default' => wfMsgExt( |
| 157 | + 'prefs-memberingroups-type', array(), |
| 158 | + $wgLang->commaList( $userGroups ), |
| 159 | + $wgLang->commaList( $userMembers ) |
| 160 | + ), |
| 161 | + 'raw' => true, |
| 162 | + 'section' => 'personal/info', |
| 163 | + ); |
166 | 164 | |
167 | | - $defaultPreferences['editcount'] = |
168 | | - array( |
169 | | - 'type' => 'info', |
170 | | - 'label-message' => 'prefs-edits', |
171 | | - 'default' => $wgLang->formatNum( $user->getEditCount() ), |
172 | | - 'section' => 'personal/info', |
173 | | - ); |
| 165 | + $defaultPreferences['editcount'] = array( |
| 166 | + 'type' => 'info', |
| 167 | + 'label-message' => 'prefs-edits', |
| 168 | + 'default' => $wgLang->formatNum( $user->getEditCount() ), |
| 169 | + 'section' => 'personal/info', |
| 170 | + ); |
174 | 171 | |
175 | | - if( $user->getRegistration() ) { |
176 | | - $defaultPreferences['registrationdate'] = |
177 | | - array( |
178 | | - 'type' => 'info', |
179 | | - 'label-message' => 'prefs-registration', |
180 | | - 'default' => wfMsgExt( 'prefs-registration-date-time', 'parsemag', |
181 | | - $wgLang->timeanddate( $user->getRegistration(), true ), |
182 | | - $wgLang->date( $user->getRegistration(), true ), |
183 | | - $wgLang->time( $user->getRegistration(), true ) ), |
184 | | - 'section' => 'personal/info', |
185 | | - ); |
| 172 | + if ( $user->getRegistration() ) { |
| 173 | + $defaultPreferences['registrationdate'] = array( |
| 174 | + 'type' => 'info', |
| 175 | + 'label-message' => 'prefs-registration', |
| 176 | + 'default' => wfMsgExt( |
| 177 | + 'prefs-registration-date-time', 'parsemag', |
| 178 | + $wgLang->timeanddate( $user->getRegistration(), true ), |
| 179 | + $wgLang->date( $user->getRegistration(), true ), |
| 180 | + $wgLang->time( $user->getRegistration(), true ) |
| 181 | + ), |
| 182 | + 'section' => 'personal/info', |
| 183 | + ); |
186 | 184 | } |
187 | 185 | |
188 | 186 | // Actually changeable stuff |
189 | 187 | global $wgAuth; |
190 | | - $defaultPreferences['realname'] = |
191 | | - array( |
192 | | - 'type' => $wgAuth->allowPropChange( 'realname' ) ? 'text' : 'info', |
193 | | - 'default' => $user->getRealName(), |
194 | | - 'section' => 'personal/info', |
195 | | - 'label-message' => 'yourrealname', |
196 | | - 'help-message' => 'prefs-help-realname', |
197 | | - ); |
| 188 | + $defaultPreferences['realname'] = array( |
| 189 | + 'type' => $wgAuth->allowPropChange( 'realname' ) ? 'text' : 'info', |
| 190 | + 'default' => $user->getRealName(), |
| 191 | + 'section' => 'personal/info', |
| 192 | + 'label-message' => 'yourrealname', |
| 193 | + 'help-message' => 'prefs-help-realname', |
| 194 | + ); |
198 | 195 | |
199 | | - $defaultPreferences['gender'] = |
200 | | - array( |
201 | | - 'type' => 'select', |
202 | | - 'section' => 'personal/info', |
203 | | - 'options' => array( |
204 | | - wfMsg( 'gender-male' ) => 'male', |
205 | | - wfMsg( 'gender-female' ) => 'female', |
206 | | - wfMsg( 'gender-unknown' ) => 'unknown', |
207 | | - ), |
208 | | - 'label-message' => 'yourgender', |
209 | | - 'help-message' => 'prefs-help-gender', |
210 | | - ); |
| 196 | + $defaultPreferences['gender'] = array( |
| 197 | + 'type' => 'select', |
| 198 | + 'section' => 'personal/info', |
| 199 | + 'options' => array( |
| 200 | + wfMsg( 'gender-male' ) => 'male', |
| 201 | + wfMsg( 'gender-female' ) => 'female', |
| 202 | + wfMsg( 'gender-unknown' ) => 'unknown', |
| 203 | + ), |
| 204 | + 'label-message' => 'yourgender', |
| 205 | + 'help-message' => 'prefs-help-gender', |
| 206 | + ); |
211 | 207 | |
212 | | - if( $wgAuth->allowPasswordChange() ) { |
| 208 | + if ( $wgAuth->allowPasswordChange() ) { |
213 | 209 | $link = $wgUser->getSkin()->link( SpecialPage::getTitleFor( 'Resetpass' ), |
214 | 210 | wfMsgHtml( 'prefs-resetpass' ), array(), |
215 | 211 | array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' ) ) ); |
216 | 212 | |
217 | | - $defaultPreferences['password'] = |
218 | | - array( |
219 | | - 'type' => 'info', |
220 | | - 'raw' => true, |
221 | | - 'default' => $link, |
222 | | - 'label-message' => 'yourpassword', |
223 | | - 'section' => 'personal/info', |
224 | | - ); |
| 213 | + $defaultPreferences['password'] = array( |
| 214 | + 'type' => 'info', |
| 215 | + 'raw' => true, |
| 216 | + 'default' => $link, |
| 217 | + 'label-message' => 'yourpassword', |
| 218 | + 'section' => 'personal/info', |
| 219 | + ); |
225 | 220 | } |
226 | 221 | |
227 | | - $defaultPreferences['rememberpassword'] = |
228 | | - array( |
229 | | - 'type' => 'toggle', |
230 | | - 'label-message' => 'tog-rememberpassword', |
231 | | - 'section' => 'personal/info', |
232 | | - ); |
| 222 | + $defaultPreferences['rememberpassword'] = array( |
| 223 | + 'type' => 'toggle', |
| 224 | + 'label-message' => 'tog-rememberpassword', |
| 225 | + 'section' => 'personal/info', |
| 226 | + ); |
233 | 227 | |
234 | 228 | // Language |
235 | 229 | global $wgContLanguageCode; |
236 | 230 | $languages = array_reverse( Language::getLanguageNames( false ) ); |
237 | | - if( !array_key_exists( $wgContLanguageCode, $languages ) ) { |
| 231 | + if ( !array_key_exists( $wgContLanguageCode, $languages ) ) { |
238 | 232 | $languages[$wgContLanguageCode] = $wgContLanguageCode; |
239 | 233 | } |
240 | 234 | ksort( $languages ); |
241 | 235 | |
242 | 236 | $options = array(); |
243 | | - foreach( $languages as $code => $name ) { |
| 237 | + foreach ( $languages as $code => $name ) { |
244 | 238 | $display = wfBCP47( $code ) . ' - ' . $name; |
245 | 239 | $options[$display] = $code; |
246 | 240 | } |
247 | | - $defaultPreferences['language'] = |
248 | | - array( |
249 | | - 'type' => 'select', |
250 | | - 'section' => 'personal/i18n', |
251 | | - 'options' => $options, |
252 | | - 'label-message' => 'yourlanguage', |
253 | | - ); |
| 241 | + $defaultPreferences['language'] = array( |
| 242 | + 'type' => 'select', |
| 243 | + 'section' => 'personal/i18n', |
| 244 | + 'options' => $options, |
| 245 | + 'label-message' => 'yourlanguage', |
| 246 | + ); |
254 | 247 | |
255 | 248 | global $wgContLang, $wgDisableLangConversion; |
256 | 249 | global $wgDisableTitleConversion; |
257 | 250 | /* see if there are multiple language variants to choose from*/ |
258 | 251 | $variantArray = array(); |
259 | | - if( !$wgDisableLangConversion ) { |
| 252 | + if ( !$wgDisableLangConversion ) { |
260 | 253 | $variants = $wgContLang->getVariants(); |
261 | 254 | |
262 | 255 | $languages = Language::getLanguageNames( true ); |
263 | | - foreach( $variants as $v ) { |
| 256 | + foreach ( $variants as $v ) { |
264 | 257 | $v = str_replace( '_', '-', strtolower( $v ) ); |
265 | | - if( array_key_exists( $v, $languages ) ) { |
| 258 | + if ( array_key_exists( $v, $languages ) ) { |
266 | 259 | // If it doesn't have a name, we'll pretend it doesn't exist |
267 | 260 | $variantArray[$v] = $languages[$v]; |
268 | 261 | } |
269 | 262 | } |
270 | 263 | |
271 | 264 | $options = array(); |
272 | | - foreach( $variantArray as $code => $name ) { |
| 265 | + foreach ( $variantArray as $code => $name ) { |
273 | 266 | $display = wfBCP47( $code ) . ' - ' . $name; |
274 | 267 | $options[$display] = $code; |
275 | 268 | } |
276 | 269 | |
277 | | - if( count( $variantArray ) > 1 ) { |
278 | | - $defaultPreferences['variant'] = |
279 | | - array( |
280 | | - 'label-message' => 'yourvariant', |
281 | | - 'type' => 'select', |
282 | | - 'options' => $options, |
283 | | - 'section' => 'personal/i18n', |
284 | | - ); |
| 270 | + if ( count( $variantArray ) > 1 ) { |
| 271 | + $defaultPreferences['variant'] = array( |
| 272 | + 'label-message' => 'yourvariant', |
| 273 | + 'type' => 'select', |
| 274 | + 'options' => $options, |
| 275 | + 'section' => 'personal/i18n', |
| 276 | + ); |
285 | 277 | } |
286 | 278 | } |
287 | 279 | |
288 | | - if( count( $variantArray ) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion ) { |
| 280 | + if ( count( $variantArray ) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion ) { |
289 | 281 | $defaultPreferences['noconvertlink'] = |
290 | 282 | array( |
291 | | - 'type' => 'toggle', |
292 | | - 'section' => 'personal/i18n', |
293 | | - 'label-message' => 'tog-noconvertlink', |
294 | | - ); |
| 283 | + 'type' => 'toggle', |
| 284 | + 'section' => 'personal/i18n', |
| 285 | + 'label-message' => 'tog-noconvertlink', |
| 286 | + ); |
295 | 287 | } |
296 | 288 | |
297 | 289 | global $wgMaxSigChars, $wgOut, $wgParser; |
— | — | @@ -298,66 +290,62 @@ |
299 | 291 | // show a preview of the old signature first |
300 | 292 | $oldsigWikiText = $wgParser->preSaveTransform( "~~~", new Title , $user, new ParserOptions ); |
301 | 293 | $oldsigHTML = $wgOut->parseInline( $oldsigWikiText ); |
302 | | - $defaultPreferences['oldsig'] = |
303 | | - array( |
304 | | - 'type' => 'info', |
305 | | - 'raw' => true, |
306 | | - 'label-message' => 'tog-oldsig', |
307 | | - 'default' => $oldsigHTML, |
308 | | - 'section' => 'personal/signature', |
309 | | - ); |
310 | | - $defaultPreferences['nickname'] = |
311 | | - array( |
312 | | - 'type' => $wgAuth->allowPropChange( 'nickname' ) ? 'text' : 'info', |
313 | | - 'maxlength' => $wgMaxSigChars, |
314 | | - 'label-message' => 'yournick', |
315 | | - 'validation-callback' => |
316 | | - array( 'Preferences', 'validateSignature' ), |
317 | | - 'section' => 'personal/signature', |
318 | | - 'filter-callback' => array( 'Preferences', 'cleanSignature' ), |
319 | | - ); |
320 | | - $defaultPreferences['fancysig'] = |
321 | | - array( |
322 | | - 'type' => 'toggle', |
323 | | - 'label-message' => 'tog-fancysig', |
324 | | - 'help-message' => 'prefs-help-signature', // show general help about signature at the bottom of the section |
325 | | - 'section' => 'personal/signature' |
326 | | - ); |
327 | | - |
| 294 | + $defaultPreferences['oldsig'] = array( |
| 295 | + 'type' => 'info', |
| 296 | + 'raw' => true, |
| 297 | + 'label-message' => 'tog-oldsig', |
| 298 | + 'default' => $oldsigHTML, |
| 299 | + 'section' => 'personal/signature', |
| 300 | + ); |
| 301 | + $defaultPreferences['nickname'] = array( |
| 302 | + 'type' => $wgAuth->allowPropChange( 'nickname' ) ? 'text' : 'info', |
| 303 | + 'maxlength' => $wgMaxSigChars, |
| 304 | + 'label-message' => 'yournick', |
| 305 | + 'validation-callback' => array( 'Preferences', 'validateSignature' ), |
| 306 | + 'section' => 'personal/signature', |
| 307 | + 'filter-callback' => array( 'Preferences', 'cleanSignature' ), |
| 308 | + ); |
| 309 | + $defaultPreferences['fancysig'] = array( |
| 310 | + 'type' => 'toggle', |
| 311 | + 'label-message' => 'tog-fancysig', |
| 312 | + 'help-message' => 'prefs-help-signature', // show general help about signature at the bottom of the section |
| 313 | + 'section' => 'personal/signature' |
| 314 | + ); |
| 315 | + |
328 | 316 | ## Email stuff |
329 | | - |
| 317 | + |
330 | 318 | global $wgEnableEmail; |
331 | | - if ($wgEnableEmail) { |
332 | | - |
| 319 | + if ( $wgEnableEmail ) { |
333 | 320 | global $wgEmailConfirmToEdit; |
334 | | - |
335 | | - $defaultPreferences['emailaddress'] = |
336 | | - array( |
337 | | - 'type' => $wgAuth->allowPropChange( 'emailaddress' ) ? 'email' : 'info', |
338 | | - 'default' => $user->getEmail(), |
339 | | - 'section' => 'personal/email', |
340 | | - 'label-message' => 'youremail', |
341 | | - 'help-message' => $wgEmailConfirmToEdit |
342 | | - ? 'prefs-help-email-required' |
343 | | - : 'prefs-help-email', |
344 | | - 'validation-callback' => array( 'Preferences', 'validateEmail' ), |
345 | | - ); |
346 | | - |
| 321 | + |
| 322 | + $defaultPreferences['emailaddress'] = array( |
| 323 | + 'type' => $wgAuth->allowPropChange( 'emailaddress' ) ? 'email' : 'info', |
| 324 | + 'default' => $user->getEmail(), |
| 325 | + 'section' => 'personal/email', |
| 326 | + 'label-message' => 'youremail', |
| 327 | + 'help-message' => $wgEmailConfirmToEdit |
| 328 | + ? 'prefs-help-email-required' |
| 329 | + : 'prefs-help-email', |
| 330 | + 'validation-callback' => array( 'Preferences', 'validateEmail' ), |
| 331 | + ); |
| 332 | + |
347 | 333 | global $wgEnableUserEmail, $wgEmailAuthentication; |
348 | | - |
| 334 | + |
349 | 335 | $disableEmailPrefs = false; |
350 | | - |
| 336 | + |
351 | 337 | if ( $wgEmailAuthentication ) { |
352 | 338 | if ( $user->getEmail() ) { |
353 | | - if( $user->getEmailAuthenticationTimestamp() ) { |
| 339 | + if ( $user->getEmailAuthenticationTimestamp() ) { |
354 | 340 | // date and time are separate parameters to facilitate localisation. |
355 | 341 | // $time is kept for backward compat reasons. |
356 | 342 | // 'emailauthenticated' is also used in SpecialConfirmemail.php |
357 | 343 | $time = $wgLang->timeAndDate( $user->getEmailAuthenticationTimestamp(), true ); |
358 | 344 | $d = $wgLang->date( $user->getEmailAuthenticationTimestamp(), true ); |
359 | 345 | $t = $wgLang->time( $user->getEmailAuthenticationTimestamp(), true ); |
360 | | - $emailauthenticated = wfMsgExt( 'emailauthenticated', 'parseinline', |
361 | | - array($time, $d, $t ) ) . '<br />'; |
| 346 | + $emailauthenticated = wfMsgExt( |
| 347 | + 'emailauthenticated', 'parseinline', |
| 348 | + array( $time, $d, $t ) |
| 349 | + ) . '<br />'; |
362 | 350 | $disableEmailPrefs = false; |
363 | 351 | } else { |
364 | 352 | $disableEmailPrefs = true; |
— | — | @@ -375,73 +363,67 @@ |
376 | 364 | $disableEmailPrefs = true; |
377 | 365 | $emailauthenticated = wfMsgHtml( 'noemailprefs' ); |
378 | 366 | } |
379 | | - |
380 | | - $defaultPreferences['emailauthentication'] = |
381 | | - array( |
382 | | - 'type' => 'info', |
383 | | - 'raw' => true, |
384 | | - 'section' => 'personal/email', |
385 | | - 'label-message' => 'prefs-emailconfirm-label', |
386 | | - 'default' => $emailauthenticated, |
387 | | - ); |
388 | | - |
| 367 | + |
| 368 | + $defaultPreferences['emailauthentication'] = array( |
| 369 | + 'type' => 'info', |
| 370 | + 'raw' => true, |
| 371 | + 'section' => 'personal/email', |
| 372 | + 'label-message' => 'prefs-emailconfirm-label', |
| 373 | + 'default' => $emailauthenticated, |
| 374 | + ); |
| 375 | + |
389 | 376 | } |
390 | | - |
391 | | - if( $wgEnableUserEmail && $user->isAllowed( 'sendemail' ) ) { |
392 | | - $defaultPreferences['disablemail'] = |
393 | | - array( |
394 | | - 'type' => 'toggle', |
395 | | - 'invert' => true, |
396 | | - 'section' => 'personal/email', |
397 | | - 'label-message' => 'allowemail', |
398 | | - 'disabled' => $disableEmailPrefs, |
399 | | - ); |
400 | | - $defaultPreferences['ccmeonemails'] = |
401 | | - array( |
402 | | - 'type' => 'toggle', |
403 | | - 'section' => 'personal/email', |
404 | | - 'label-message' => 'tog-ccmeonemails', |
405 | | - 'disabled' => $disableEmailPrefs, |
406 | | - ); |
| 377 | + |
| 378 | + if ( $wgEnableUserEmail && $user->isAllowed( 'sendemail' ) ) { |
| 379 | + $defaultPreferences['disablemail'] = array( |
| 380 | + 'type' => 'toggle', |
| 381 | + 'invert' => true, |
| 382 | + 'section' => 'personal/email', |
| 383 | + 'label-message' => 'allowemail', |
| 384 | + 'disabled' => $disableEmailPrefs, |
| 385 | + ); |
| 386 | + $defaultPreferences['ccmeonemails'] = array( |
| 387 | + 'type' => 'toggle', |
| 388 | + 'section' => 'personal/email', |
| 389 | + 'label-message' => 'tog-ccmeonemails', |
| 390 | + 'disabled' => $disableEmailPrefs, |
| 391 | + ); |
407 | 392 | } |
408 | | - |
| 393 | + |
409 | 394 | global $wgEnotifWatchlist; |
410 | 395 | if ( $wgEnotifWatchlist ) { |
411 | | - $defaultPreferences['enotifwatchlistpages'] = |
412 | | - array( |
413 | | - 'type' => 'toggle', |
414 | | - 'section' => 'personal/email', |
415 | | - 'label-message' => 'tog-enotifwatchlistpages', |
416 | | - 'disabled' => $disableEmailPrefs, |
417 | | - ); |
| 396 | + $defaultPreferences['enotifwatchlistpages'] = array( |
| 397 | + 'type' => 'toggle', |
| 398 | + 'section' => 'personal/email', |
| 399 | + 'label-message' => 'tog-enotifwatchlistpages', |
| 400 | + 'disabled' => $disableEmailPrefs, |
| 401 | + ); |
418 | 402 | } |
419 | 403 | global $wgEnotifUserTalk; |
420 | | - if( $wgEnotifUserTalk ) { |
421 | | - $defaultPreferences['enotifusertalkpages'] = |
422 | | - array( |
423 | | - 'type' => 'toggle', |
424 | | - 'section' => 'personal/email', |
425 | | - 'label-message' => 'tog-enotifusertalkpages', |
426 | | - 'disabled' => $disableEmailPrefs, |
427 | | - ); |
| 404 | + if ( $wgEnotifUserTalk ) { |
| 405 | + $defaultPreferences['enotifusertalkpages'] = array( |
| 406 | + 'type' => 'toggle', |
| 407 | + 'section' => 'personal/email', |
| 408 | + 'label-message' => 'tog-enotifusertalkpages', |
| 409 | + 'disabled' => $disableEmailPrefs, |
| 410 | + ); |
428 | 411 | } |
429 | | - if( $wgEnotifUserTalk || $wgEnotifWatchlist ) { |
430 | | - $defaultPreferences['enotifminoredits'] = |
431 | | - array( |
432 | | - 'type' => 'toggle', |
433 | | - 'section' => 'personal/email', |
434 | | - 'label-message' => 'tog-enotifminoredits', |
435 | | - 'disabled' => $disableEmailPrefs, |
436 | | - ); |
| 412 | + if ( $wgEnotifUserTalk || $wgEnotifWatchlist ) { |
| 413 | + $defaultPreferences['enotifminoredits'] = array( |
| 414 | + 'type' => 'toggle', |
| 415 | + 'section' => 'personal/email', |
| 416 | + 'label-message' => 'tog-enotifminoredits', |
| 417 | + 'disabled' => $disableEmailPrefs, |
| 418 | + ); |
| 419 | + |
437 | 420 | global $wgEnotifRevealEditorAddress; |
438 | 421 | if ( $wgEnotifRevealEditorAddress ) { |
439 | | - $defaultPreferences['enotifrevealaddr'] = |
440 | | - array( |
441 | | - 'type' => 'toggle', |
442 | | - 'section' => 'personal/email', |
443 | | - 'label-message' => 'tog-enotifrevealaddr', |
444 | | - 'disabled' => $disableEmailPrefs, |
445 | | - ); |
| 422 | + $defaultPreferences['enotifrevealaddr'] = array( |
| 423 | + 'type' => 'toggle', |
| 424 | + 'section' => 'personal/email', |
| 425 | + 'label-message' => 'tog-enotifrevealaddr', |
| 426 | + 'disabled' => $disableEmailPrefs, |
| 427 | + ); |
446 | 428 | } |
447 | 429 | } |
448 | 430 | } |
— | — | @@ -451,84 +433,81 @@ |
452 | 434 | ## Skin ##################################### |
453 | 435 | global $wgLang, $wgAllowUserCss, $wgAllowUserJs; |
454 | 436 | |
455 | | - $defaultPreferences['skin'] = |
456 | | - array( |
457 | | - 'type' => 'radio', |
458 | | - 'options' => self::generateSkinOptions( $user ), |
459 | | - 'label' => ' ', |
460 | | - 'section' => 'rendering/skin', |
461 | | - ); |
| 437 | + $defaultPreferences['skin'] = array( |
| 438 | + 'type' => 'radio', |
| 439 | + 'options' => self::generateSkinOptions( $user ), |
| 440 | + 'label' => ' ', |
| 441 | + 'section' => 'rendering/skin', |
| 442 | + ); |
462 | 443 | |
463 | 444 | # Create links to user CSS/JS pages for all skins |
464 | 445 | # This code is basically copied from generateSkinOptions(). It'd |
465 | | - # be nice to somehow merge this back in there to avoid redundancy. |
466 | | - if( $wgAllowUserCss || $wgAllowUserJs ) { |
| 446 | + # be nice to somehow merge this back in there to avoid redundancy. |
| 447 | + if ( $wgAllowUserCss || $wgAllowUserJs ) { |
467 | 448 | $sk = $user->getSkin(); |
468 | 449 | $linkTools = array(); |
469 | | - if( $wgAllowUserCss ) { |
| 450 | + |
| 451 | + if ( $wgAllowUserCss ) { |
470 | 452 | $cssPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/common.css' ); |
471 | 453 | $linkTools[] = $sk->link( $cssPage, wfMsgHtml( 'prefs-custom-css' ) ); |
472 | 454 | } |
473 | | - if( $wgAllowUserJs ) { |
| 455 | + |
| 456 | + if ( $wgAllowUserJs ) { |
474 | 457 | $jsPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/common.js' ); |
475 | 458 | $linkTools[] = $sk->link( $jsPage, wfMsgHtml( 'prefs-custom-js' ) ); |
476 | 459 | } |
477 | | - $defaultPreferences['commoncssjs'] = |
478 | | - array( |
479 | | - 'type' => 'info', |
480 | | - 'raw' => true, |
481 | | - 'default' => $wgLang->pipeList( $linkTools ), |
482 | | - 'label-message' => 'prefs-common-css-js', |
483 | | - 'section' => 'rendering/skin', |
484 | | - ); |
| 460 | + |
| 461 | + $defaultPreferences['commoncssjs'] = array( |
| 462 | + 'type' => 'info', |
| 463 | + 'raw' => true, |
| 464 | + 'default' => $wgLang->pipeList( $linkTools ), |
| 465 | + 'label-message' => 'prefs-common-css-js', |
| 466 | + 'section' => 'rendering/skin', |
| 467 | + ); |
485 | 468 | } |
486 | 469 | |
487 | 470 | $selectedSkin = $user->getOption( 'skin' ); |
488 | 471 | if ( in_array( $selectedSkin, array( 'cologneblue', 'standard' ) ) ) { |
489 | 472 | global $wgLang; |
| 473 | + |
490 | 474 | $settings = array_flip( $wgLang->getQuickbarSettings() ); |
491 | 475 | |
492 | | - $defaultPreferences['quickbar'] = |
493 | | - array( |
494 | | - 'type' => 'radio', |
495 | | - 'options' => $settings, |
496 | | - 'section' => 'rendering/skin', |
497 | | - 'label-message' => 'qbsettings', |
498 | | - ); |
| 476 | + $defaultPreferences['quickbar'] = array( |
| 477 | + 'type' => 'radio', |
| 478 | + 'options' => $settings, |
| 479 | + 'section' => 'rendering/skin', |
| 480 | + 'label-message' => 'qbsettings', |
| 481 | + ); |
499 | 482 | } |
500 | 483 | } |
501 | 484 | |
502 | 485 | static function mathPreferences( $user, &$defaultPreferences ) { |
503 | 486 | ## Math ##################################### |
504 | 487 | global $wgUseTeX, $wgLang; |
505 | | - if( $wgUseTeX ) { |
506 | | - $defaultPreferences['math'] = |
507 | | - array( |
508 | | - 'type' => 'radio', |
509 | | - 'options' => |
510 | | - array_flip( array_map( 'wfMsgHtml', $wgLang->getMathNames() ) ), |
511 | | - 'label' => ' ', |
512 | | - 'section' => 'rendering/math', |
513 | | - ); |
| 488 | + if ( $wgUseTeX ) { |
| 489 | + $defaultPreferences['math'] = array( |
| 490 | + 'type' => 'radio', |
| 491 | + 'options' => array_flip( array_map( 'wfMsgHtml', $wgLang->getMathNames() ) ), |
| 492 | + 'label' => ' ', |
| 493 | + 'section' => 'rendering/math', |
| 494 | + ); |
514 | 495 | } |
515 | 496 | } |
516 | 497 | |
517 | 498 | static function filesPreferences( $user, &$defaultPreferences ) { |
518 | 499 | ## Files ##################################### |
519 | | - $defaultPreferences['imagesize'] = |
520 | | - array( |
521 | | - 'type' => 'select', |
522 | | - 'options' => self::getImageSizes(), |
523 | | - 'label-message' => 'imagemaxsize', |
524 | | - 'section' => 'rendering/files', |
525 | | - ); |
526 | | - $defaultPreferences['thumbsize'] = |
527 | | - array( |
528 | | - 'type' => 'select', |
529 | | - 'options' => self::getThumbSizes(), |
530 | | - 'label-message' => 'thumbsize', |
531 | | - 'section' => 'rendering/files', |
532 | | - ); |
| 500 | + $defaultPreferences['imagesize'] = array( |
| 501 | + 'type' => 'select', |
| 502 | + 'options' => self::getImageSizes(), |
| 503 | + 'label-message' => 'imagemaxsize', |
| 504 | + 'section' => 'rendering/files', |
| 505 | + ); |
| 506 | + $defaultPreferences['thumbsize'] = array( |
| 507 | + 'type' => 'select', |
| 508 | + 'options' => self::getThumbSizes(), |
| 509 | + 'label-message' => 'thumbsize', |
| 510 | + 'section' => 'rendering/files', |
| 511 | + ); |
533 | 512 | } |
534 | 513 | |
535 | 514 | static function datetimePreferences( $user, &$defaultPreferences ) { |
— | — | @@ -536,14 +515,13 @@ |
537 | 516 | |
538 | 517 | ## Date and time ##################################### |
539 | 518 | $dateOptions = self::getDateOptions(); |
540 | | - if( $dateOptions ) { |
541 | | - $defaultPreferences['date'] = |
542 | | - array( |
543 | | - 'type' => 'radio', |
544 | | - 'options' => $dateOptions, |
545 | | - 'label' => ' ', |
546 | | - 'section' => 'datetime/dateformat', |
547 | | - ); |
| 519 | + if ( $dateOptions ) { |
| 520 | + $defaultPreferences['date'] = array( |
| 521 | + 'type' => 'radio', |
| 522 | + 'options' => $dateOptions, |
| 523 | + 'label' => ' ', |
| 524 | + 'section' => 'datetime/dateformat', |
| 525 | + ); |
548 | 526 | } |
549 | 527 | |
550 | 528 | // Info |
— | — | @@ -552,368 +530,339 @@ |
553 | 531 | $nowserver = $wgLang->time( $now, false ) . |
554 | 532 | Xml::hidden( 'wpServerTime', substr( $now, 8, 2 ) * 60 + substr( $now, 10, 2 ) ); |
555 | 533 | |
556 | | - $defaultPreferences['nowserver'] = |
557 | | - array( |
558 | | - 'type' => 'info', |
559 | | - 'raw' => 1, |
560 | | - 'label-message' => 'servertime', |
561 | | - 'default' => $nowserver, |
562 | | - 'section' => 'datetime/timeoffset', |
563 | | - ); |
| 534 | + $defaultPreferences['nowserver'] = array( |
| 535 | + 'type' => 'info', |
| 536 | + 'raw' => 1, |
| 537 | + 'label-message' => 'servertime', |
| 538 | + 'default' => $nowserver, |
| 539 | + 'section' => 'datetime/timeoffset', |
| 540 | + ); |
564 | 541 | |
565 | | - $defaultPreferences['nowlocal'] = |
566 | | - array( |
567 | | - 'type' => 'info', |
568 | | - 'raw' => 1, |
569 | | - 'label-message' => 'localtime', |
570 | | - 'default' => $nowlocal, |
571 | | - 'section' => 'datetime/timeoffset', |
572 | | - ); |
| 542 | + $defaultPreferences['nowlocal'] = array( |
| 543 | + 'type' => 'info', |
| 544 | + 'raw' => 1, |
| 545 | + 'label-message' => 'localtime', |
| 546 | + 'default' => $nowlocal, |
| 547 | + 'section' => 'datetime/timeoffset', |
| 548 | + ); |
573 | 549 | |
574 | 550 | // Grab existing pref. |
575 | 551 | $tzOffset = $user->getOption( 'timecorrection' ); |
576 | 552 | $tz = explode( '|', $tzOffset, 2 ); |
577 | 553 | |
578 | 554 | $tzSetting = $tzOffset; |
579 | | - if( count( $tz ) > 1 && $tz[0] == 'Offset' ) { |
| 555 | + if ( count( $tz ) > 1 && $tz[0] == 'Offset' ) { |
580 | 556 | $minDiff = $tz[1]; |
581 | | - $tzSetting = sprintf( '%+03d:%02d', floor( $minDiff/60 ), abs( $minDiff )%60 ); |
| 557 | + $tzSetting = sprintf( '%+03d:%02d', floor( $minDiff / 60 ), abs( $minDiff ) % 60 ); |
582 | 558 | } |
583 | 559 | |
584 | | - $defaultPreferences['timecorrection'] = |
585 | | - array( |
586 | | - 'class' => 'HTMLSelectOrOtherField', |
587 | | - 'label-message' => 'timezonelegend', |
588 | | - 'options' => self::getTimezoneOptions(), |
589 | | - 'default' => $tzSetting, |
590 | | - 'size' => 20, |
591 | | - 'section' => 'datetime/timeoffset', |
592 | | - ); |
| 560 | + $defaultPreferences['timecorrection'] = array( |
| 561 | + 'class' => 'HTMLSelectOrOtherField', |
| 562 | + 'label-message' => 'timezonelegend', |
| 563 | + 'options' => self::getTimezoneOptions(), |
| 564 | + 'default' => $tzSetting, |
| 565 | + 'size' => 20, |
| 566 | + 'section' => 'datetime/timeoffset', |
| 567 | + ); |
593 | 568 | } |
594 | 569 | |
595 | 570 | static function renderingPreferences( $user, &$defaultPreferences ) { |
596 | 571 | ## Page Rendering ############################## |
597 | 572 | global $wgAllowUserCssPrefs; |
598 | | - if( $wgAllowUserCssPrefs ){ |
599 | | - $defaultPreferences['underline'] = |
600 | | - array( |
601 | | - 'type' => 'select', |
602 | | - 'options' => array( |
603 | | - wfMsg( 'underline-never' ) => 0, |
604 | | - wfMsg( 'underline-always' ) => 1, |
605 | | - wfMsg( 'underline-default' ) => 2, |
606 | | - ), |
607 | | - 'label-message' => 'tog-underline', |
608 | | - 'section' => 'rendering/advancedrendering', |
609 | | - ); |
| 573 | + if ( $wgAllowUserCssPrefs ) { |
| 574 | + $defaultPreferences['underline'] = array( |
| 575 | + 'type' => 'select', |
| 576 | + 'options' => array( |
| 577 | + wfMsg( 'underline-never' ) => 0, |
| 578 | + wfMsg( 'underline-always' ) => 1, |
| 579 | + wfMsg( 'underline-default' ) => 2, |
| 580 | + ), |
| 581 | + 'label-message' => 'tog-underline', |
| 582 | + 'section' => 'rendering/advancedrendering', |
| 583 | + ); |
610 | 584 | } |
611 | 585 | |
612 | 586 | $stubThresholdValues = array( 0, 50, 100, 500, 1000, 2000, 5000, 10000 ); |
613 | 587 | $stubThresholdOptions = array(); |
614 | | - foreach( $stubThresholdValues as $value ) { |
| 588 | + foreach ( $stubThresholdValues as $value ) { |
615 | 589 | $stubThresholdOptions[wfMsg( 'size-bytes', $value )] = $value; |
616 | 590 | } |
617 | 591 | |
618 | | - $defaultPreferences['stubthreshold'] = |
619 | | - array( |
620 | | - 'type' => 'selectorother', |
621 | | - 'section' => 'rendering/advancedrendering', |
622 | | - 'options' => $stubThresholdOptions, |
623 | | - 'size' => 20, |
624 | | - 'label' => wfMsg( 'stub-threshold' ), // Raw HTML message. Yay? |
625 | | - ); |
626 | | - if( $wgAllowUserCssPrefs ){ |
627 | | - $defaultPreferences['highlightbroken'] = |
628 | | - array( |
629 | | - 'type' => 'toggle', |
630 | | - 'section' => 'rendering/advancedrendering', |
631 | | - 'label' => wfMsg( 'tog-highlightbroken' ), // Raw HTML |
632 | | - ); |
633 | | - $defaultPreferences['showtoc'] = |
634 | | - array( |
635 | | - 'type' => 'toggle', |
636 | | - 'section' => 'rendering/advancedrendering', |
637 | | - 'label-message' => 'tog-showtoc', |
638 | | - ); |
| 592 | + $defaultPreferences['stubthreshold'] = array( |
| 593 | + 'type' => 'selectorother', |
| 594 | + 'section' => 'rendering/advancedrendering', |
| 595 | + 'options' => $stubThresholdOptions, |
| 596 | + 'size' => 20, |
| 597 | + 'label' => wfMsg( 'stub-threshold' ), // Raw HTML message. Yay? |
| 598 | + ); |
| 599 | + |
| 600 | + if ( $wgAllowUserCssPrefs ) { |
| 601 | + $defaultPreferences['highlightbroken'] = array( |
| 602 | + 'type' => 'toggle', |
| 603 | + 'section' => 'rendering/advancedrendering', |
| 604 | + 'label' => wfMsg( 'tog-highlightbroken' ), // Raw HTML |
| 605 | + ); |
| 606 | + $defaultPreferences['showtoc'] = array( |
| 607 | + 'type' => 'toggle', |
| 608 | + 'section' => 'rendering/advancedrendering', |
| 609 | + 'label-message' => 'tog-showtoc', |
| 610 | + ); |
639 | 611 | } |
640 | | - $defaultPreferences['nocache'] = |
641 | | - array( |
642 | | - 'type' => 'toggle', |
643 | | - 'label-message' => 'tog-nocache', |
644 | | - 'section' => 'rendering/advancedrendering', |
645 | | - ); |
646 | | - $defaultPreferences['showhiddencats'] = |
647 | | - array( |
648 | | - 'type' => 'toggle', |
649 | | - 'section' => 'rendering/advancedrendering', |
650 | | - 'label-message' => 'tog-showhiddencats' |
651 | | - ); |
652 | | - $defaultPreferences['showjumplinks'] = |
653 | | - array( |
654 | | - 'type' => 'toggle', |
655 | | - 'section' => 'rendering/advancedrendering', |
656 | | - 'label-message' => 'tog-showjumplinks', |
657 | | - ); |
658 | | - if( $wgAllowUserCssPrefs ){ |
659 | | - $defaultPreferences['justify'] = |
660 | | - array( |
661 | | - 'type' => 'toggle', |
662 | | - 'section' => 'rendering/advancedrendering', |
663 | | - 'label-message' => 'tog-justify', |
664 | | - ); |
| 612 | + $defaultPreferences['nocache'] = array( |
| 613 | + 'type' => 'toggle', |
| 614 | + 'label-message' => 'tog-nocache', |
| 615 | + 'section' => 'rendering/advancedrendering', |
| 616 | + ); |
| 617 | + $defaultPreferences['showhiddencats'] = array( |
| 618 | + 'type' => 'toggle', |
| 619 | + 'section' => 'rendering/advancedrendering', |
| 620 | + 'label-message' => 'tog-showhiddencats' |
| 621 | + ); |
| 622 | + $defaultPreferences['showjumplinks'] = array( |
| 623 | + 'type' => 'toggle', |
| 624 | + 'section' => 'rendering/advancedrendering', |
| 625 | + 'label-message' => 'tog-showjumplinks', |
| 626 | + ); |
| 627 | + |
| 628 | + if ( $wgAllowUserCssPrefs ) { |
| 629 | + $defaultPreferences['justify'] = array( |
| 630 | + 'type' => 'toggle', |
| 631 | + 'section' => 'rendering/advancedrendering', |
| 632 | + 'label-message' => 'tog-justify', |
| 633 | + ); |
665 | 634 | } |
666 | | - $defaultPreferences['numberheadings'] = |
667 | | - array( |
668 | | - 'type' => 'toggle', |
669 | | - 'section' => 'rendering/advancedrendering', |
670 | | - 'label-message' => 'tog-numberheadings', |
671 | | - ); |
| 635 | + |
| 636 | + $defaultPreferences['numberheadings'] = array( |
| 637 | + 'type' => 'toggle', |
| 638 | + 'section' => 'rendering/advancedrendering', |
| 639 | + 'label-message' => 'tog-numberheadings', |
| 640 | + ); |
672 | 641 | } |
673 | 642 | |
674 | 643 | static function editingPreferences( $user, &$defaultPreferences ) { |
675 | 644 | global $wgUseExternalEditor, $wgLivePreview, $wgAllowUserCssPrefs; |
676 | 645 | |
677 | 646 | ## Editing ##################################### |
678 | | - $defaultPreferences['cols'] = |
679 | | - array( |
680 | | - 'type' => 'int', |
681 | | - 'label-message' => 'columns', |
682 | | - 'section' => 'editing/textboxsize', |
683 | | - 'min' => 4, |
684 | | - 'max' => 1000, |
685 | | - ); |
686 | | - $defaultPreferences['rows'] = |
687 | | - array( |
688 | | - 'type' => 'int', |
689 | | - 'label-message' => 'rows', |
690 | | - 'section' => 'editing/textboxsize', |
691 | | - 'min' => 4, |
692 | | - 'max' => 1000, |
693 | | - ); |
694 | | - if( $wgAllowUserCssPrefs ){ |
695 | | - $defaultPreferences['editfont'] = |
696 | | - array( |
697 | | - 'type' => 'select', |
698 | | - 'section' => 'editing/advancedediting', |
699 | | - 'label-message' => 'editfont-style', |
700 | | - 'options' => array( |
701 | | - wfMsg( 'editfont-default' ) => 'default', |
702 | | - wfMsg( 'editfont-monospace' ) => 'monospace', |
703 | | - wfMsg( 'editfont-sansserif' ) => 'sans-serif', |
704 | | - wfMsg( 'editfont-serif' ) => 'serif', |
705 | | - ) |
706 | | - ); |
| 647 | + $defaultPreferences['cols'] = array( |
| 648 | + 'type' => 'int', |
| 649 | + 'label-message' => 'columns', |
| 650 | + 'section' => 'editing/textboxsize', |
| 651 | + 'min' => 4, |
| 652 | + 'max' => 1000, |
| 653 | + ); |
| 654 | + $defaultPreferences['rows'] = array( |
| 655 | + 'type' => 'int', |
| 656 | + 'label-message' => 'rows', |
| 657 | + 'section' => 'editing/textboxsize', |
| 658 | + 'min' => 4, |
| 659 | + 'max' => 1000, |
| 660 | + ); |
| 661 | + |
| 662 | + if ( $wgAllowUserCssPrefs ) { |
| 663 | + $defaultPreferences['editfont'] = array( |
| 664 | + 'type' => 'select', |
| 665 | + 'section' => 'editing/advancedediting', |
| 666 | + 'label-message' => 'editfont-style', |
| 667 | + 'options' => array( |
| 668 | + wfMsg( 'editfont-default' ) => 'default', |
| 669 | + wfMsg( 'editfont-monospace' ) => 'monospace', |
| 670 | + wfMsg( 'editfont-sansserif' ) => 'sans-serif', |
| 671 | + wfMsg( 'editfont-serif' ) => 'serif', |
| 672 | + ) |
| 673 | + ); |
707 | 674 | } |
708 | | - $defaultPreferences['previewontop'] = |
709 | | - array( |
710 | | - 'type' => 'toggle', |
711 | | - 'section' => 'editing/advancedediting', |
712 | | - 'label-message' => 'tog-previewontop', |
713 | | - ); |
714 | | - $defaultPreferences['previewonfirst'] = |
715 | | - array( |
716 | | - 'type' => 'toggle', |
717 | | - 'section' => 'editing/advancedediting', |
718 | | - 'label-message' => 'tog-previewonfirst', |
719 | | - ); |
720 | | - if( $wgAllowUserCssPrefs ){ |
721 | | - $defaultPreferences['editsection'] = |
722 | | - array( |
723 | | - 'type' => 'toggle', |
724 | | - 'section' => 'editing/advancedediting', |
725 | | - 'label-message' => 'tog-editsection', |
726 | | - ); |
| 675 | + $defaultPreferences['previewontop'] = array( |
| 676 | + 'type' => 'toggle', |
| 677 | + 'section' => 'editing/advancedediting', |
| 678 | + 'label-message' => 'tog-previewontop', |
| 679 | + ); |
| 680 | + $defaultPreferences['previewonfirst'] = array( |
| 681 | + 'type' => 'toggle', |
| 682 | + 'section' => 'editing/advancedediting', |
| 683 | + 'label-message' => 'tog-previewonfirst', |
| 684 | + ); |
| 685 | + |
| 686 | + if ( $wgAllowUserCssPrefs ) { |
| 687 | + $defaultPreferences['editsection'] = array( |
| 688 | + 'type' => 'toggle', |
| 689 | + 'section' => 'editing/advancedediting', |
| 690 | + 'label-message' => 'tog-editsection', |
| 691 | + ); |
727 | 692 | } |
728 | | - $defaultPreferences['editsectiononrightclick'] = |
729 | | - array( |
730 | | - 'type' => 'toggle', |
731 | | - 'section' => 'editing/advancedediting', |
732 | | - 'label-message' => 'tog-editsectiononrightclick', |
733 | | - ); |
734 | | - $defaultPreferences['editondblclick'] = |
735 | | - array( |
736 | | - 'type' => 'toggle', |
737 | | - 'section' => 'editing/advancedediting', |
738 | | - 'label-message' => 'tog-editondblclick', |
739 | | - ); |
740 | | - $defaultPreferences['showtoolbar'] = |
741 | | - array( |
742 | | - 'type' => 'toggle', |
743 | | - 'section' => 'editing/advancedediting', |
744 | | - 'label-message' => 'tog-showtoolbar', |
745 | | - ); |
746 | | - $defaultPreferences['minordefault'] = |
747 | | - array( |
748 | | - 'type' => 'toggle', |
749 | | - 'section' => 'editing/advancedediting', |
750 | | - 'label-message' => 'tog-minordefault', |
751 | | - ); |
| 693 | + $defaultPreferences['editsectiononrightclick'] = array( |
| 694 | + 'type' => 'toggle', |
| 695 | + 'section' => 'editing/advancedediting', |
| 696 | + 'label-message' => 'tog-editsectiononrightclick', |
| 697 | + ); |
| 698 | + $defaultPreferences['editondblclick'] = array( |
| 699 | + 'type' => 'toggle', |
| 700 | + 'section' => 'editing/advancedediting', |
| 701 | + 'label-message' => 'tog-editondblclick', |
| 702 | + ); |
| 703 | + $defaultPreferences['showtoolbar'] = array( |
| 704 | + 'type' => 'toggle', |
| 705 | + 'section' => 'editing/advancedediting', |
| 706 | + 'label-message' => 'tog-showtoolbar', |
| 707 | + ); |
| 708 | + $defaultPreferences['minordefault'] = array( |
| 709 | + 'type' => 'toggle', |
| 710 | + 'section' => 'editing/advancedediting', |
| 711 | + 'label-message' => 'tog-minordefault', |
| 712 | + ); |
752 | 713 | |
753 | 714 | if ( $wgUseExternalEditor ) { |
754 | | - $defaultPreferences['externaleditor'] = |
755 | | - array( |
756 | | - 'type' => 'toggle', |
757 | | - 'section' => 'editing/advancedediting', |
758 | | - 'label-message' => 'tog-externaleditor', |
759 | | - ); |
760 | | - $defaultPreferences['externaldiff'] = |
761 | | - array( |
762 | | - 'type' => 'toggle', |
763 | | - 'section' => 'editing/advancedediting', |
764 | | - 'label-message' => 'tog-externaldiff', |
765 | | - ); |
| 715 | + $defaultPreferences['externaleditor'] = array( |
| 716 | + 'type' => 'toggle', |
| 717 | + 'section' => 'editing/advancedediting', |
| 718 | + 'label-message' => 'tog-externaleditor', |
| 719 | + ); |
| 720 | + $defaultPreferences['externaldiff'] = array( |
| 721 | + 'type' => 'toggle', |
| 722 | + 'section' => 'editing/advancedediting', |
| 723 | + 'label-message' => 'tog-externaldiff', |
| 724 | + ); |
766 | 725 | } |
767 | 726 | |
768 | | - $defaultPreferences['forceeditsummary'] = |
769 | | - array( |
770 | | - 'type' => 'toggle', |
771 | | - 'section' => 'editing/advancedediting', |
772 | | - 'label-message' => 'tog-forceeditsummary', |
773 | | - ); |
| 727 | + $defaultPreferences['forceeditsummary'] = array( |
| 728 | + 'type' => 'toggle', |
| 729 | + 'section' => 'editing/advancedediting', |
| 730 | + 'label-message' => 'tog-forceeditsummary', |
| 731 | + ); |
| 732 | + |
774 | 733 | if ( $wgLivePreview ) { |
775 | | - $defaultPreferences['uselivepreview'] = |
776 | | - array( |
777 | | - 'type' => 'toggle', |
778 | | - 'section' => 'editing/advancedediting', |
779 | | - 'label-message' => 'tog-uselivepreview', |
780 | | - ); |
| 734 | + $defaultPreferences['uselivepreview'] = array( |
| 735 | + 'type' => 'toggle', |
| 736 | + 'section' => 'editing/advancedediting', |
| 737 | + 'label-message' => 'tog-uselivepreview', |
| 738 | + ); |
781 | 739 | } |
782 | 740 | } |
783 | 741 | |
784 | 742 | static function rcPreferences( $user, &$defaultPreferences ) { |
785 | 743 | global $wgRCMaxAge, $wgUseRCPatrol, $wgLang; |
| 744 | + |
786 | 745 | ## RecentChanges ##################################### |
787 | | - $defaultPreferences['rcdays'] = |
788 | | - array( |
789 | | - 'type' => 'float', |
790 | | - 'label-message' => 'recentchangesdays', |
791 | | - 'section' => 'rc/display', |
792 | | - 'min' => 1, |
793 | | - 'max' => ceil( $wgRCMaxAge / ( 3600*24 ) ), |
794 | | - 'help' => wfMsgExt( 'recentchangesdays-max', array( 'parsemag' ), $wgLang->formatNum( ceil( $wgRCMaxAge / ( 3600*24 ) ) ) ), |
795 | | - ); |
796 | | - $defaultPreferences['rclimit'] = |
797 | | - array( |
798 | | - 'type' => 'int', |
799 | | - 'label-message' => 'recentchangescount', |
800 | | - 'help-message' => 'prefs-help-recentchangescount', |
801 | | - 'section' => 'rc/display', |
802 | | - ); |
803 | | - $defaultPreferences['usenewrc'] = |
804 | | - array( |
805 | | - 'type' => 'toggle', |
806 | | - 'label-message' => 'tog-usenewrc', |
807 | | - 'section' => 'rc/advancedrc', |
808 | | - ); |
809 | | - $defaultPreferences['hideminor'] = |
810 | | - array( |
811 | | - 'type' => 'toggle', |
812 | | - 'label-message' => 'tog-hideminor', |
813 | | - 'section' => 'rc/advancedrc', |
814 | | - ); |
| 746 | + $defaultPreferences['rcdays'] = array( |
| 747 | + 'type' => 'float', |
| 748 | + 'label-message' => 'recentchangesdays', |
| 749 | + 'section' => 'rc/display', |
| 750 | + 'min' => 1, |
| 751 | + 'max' => ceil( $wgRCMaxAge / ( 3600 * 24 ) ), |
| 752 | + 'help' => wfMsgExt( |
| 753 | + 'recentchangesdays-max', |
| 754 | + array( 'parsemag' ), |
| 755 | + $wgLang->formatNum( ceil( $wgRCMaxAge / ( 3600 * 24 ) ) ) |
| 756 | + ) |
| 757 | + ); |
| 758 | + $defaultPreferences['rclimit'] = array( |
| 759 | + 'type' => 'int', |
| 760 | + 'label-message' => 'recentchangescount', |
| 761 | + 'help-message' => 'prefs-help-recentchangescount', |
| 762 | + 'section' => 'rc/display', |
| 763 | + ); |
| 764 | + $defaultPreferences['usenewrc'] = array( |
| 765 | + 'type' => 'toggle', |
| 766 | + 'label-message' => 'tog-usenewrc', |
| 767 | + 'section' => 'rc/advancedrc', |
| 768 | + ); |
| 769 | + $defaultPreferences['hideminor'] = array( |
| 770 | + 'type' => 'toggle', |
| 771 | + 'label-message' => 'tog-hideminor', |
| 772 | + 'section' => 'rc/advancedrc', |
| 773 | + ); |
815 | 774 | |
816 | | - if( $wgUseRCPatrol ) { |
817 | | - $defaultPreferences['hidepatrolled'] = |
818 | | - array( |
819 | | - 'type' => 'toggle', |
820 | | - 'section' => 'rc/advancedrc', |
821 | | - 'label-message' => 'tog-hidepatrolled', |
822 | | - ); |
823 | | - $defaultPreferences['newpageshidepatrolled'] = |
824 | | - array( |
825 | | - 'type' => 'toggle', |
826 | | - 'section' => 'rc/advancedrc', |
827 | | - 'label-message' => 'tog-newpageshidepatrolled', |
828 | | - ); |
| 775 | + if ( $wgUseRCPatrol ) { |
| 776 | + $defaultPreferences['hidepatrolled'] = array( |
| 777 | + 'type' => 'toggle', |
| 778 | + 'section' => 'rc/advancedrc', |
| 779 | + 'label-message' => 'tog-hidepatrolled', |
| 780 | + ); |
| 781 | + $defaultPreferences['newpageshidepatrolled'] = array( |
| 782 | + 'type' => 'toggle', |
| 783 | + 'section' => 'rc/advancedrc', |
| 784 | + 'label-message' => 'tog-newpageshidepatrolled', |
| 785 | + ); |
829 | 786 | } |
830 | 787 | |
831 | 788 | global $wgRCShowWatchingUsers; |
832 | | - if( $wgRCShowWatchingUsers ) { |
833 | | - $defaultPreferences['shownumberswatching'] = |
834 | | - array( |
835 | | - 'type' => 'toggle', |
836 | | - 'section' => 'rc/advancedrc', |
837 | | - 'label-message' => 'tog-shownumberswatching', |
838 | | - ); |
| 789 | + if ( $wgRCShowWatchingUsers ) { |
| 790 | + $defaultPreferences['shownumberswatching'] = array( |
| 791 | + 'type' => 'toggle', |
| 792 | + 'section' => 'rc/advancedrc', |
| 793 | + 'label-message' => 'tog-shownumberswatching', |
| 794 | + ); |
839 | 795 | } |
840 | 796 | } |
841 | 797 | |
842 | 798 | static function watchlistPreferences( $user, &$defaultPreferences ) { |
843 | 799 | global $wgUseRCPatrol, $wgEnableAPI; |
| 800 | + |
844 | 801 | ## Watchlist ##################################### |
845 | | - $defaultPreferences['watchlistdays'] = |
846 | | - array( |
847 | | - 'type' => 'float', |
848 | | - 'min' => 0, |
849 | | - 'max' => 7, |
850 | | - 'section' => 'watchlist/display', |
851 | | - 'help' => wfMsgHtml( 'prefs-watchlist-days-max' ), |
852 | | - 'label-message' => 'prefs-watchlist-days', |
853 | | - ); |
854 | | - $defaultPreferences['wllimit'] = |
855 | | - array( |
856 | | - 'type' => 'int', |
857 | | - 'min' => 0, |
858 | | - 'max' => 1000, |
859 | | - 'label-message' => 'prefs-watchlist-edits', |
860 | | - 'help' => wfMsgHtml( 'prefs-watchlist-edits-max' ), |
861 | | - 'section' => 'watchlist/display', |
862 | | - ); |
863 | | - $defaultPreferences['extendwatchlist'] = |
864 | | - array( |
865 | | - 'type' => 'toggle', |
866 | | - 'section' => 'watchlist/advancedwatchlist', |
867 | | - 'label-message' => 'tog-extendwatchlist', |
868 | | - ); |
869 | | - $defaultPreferences['watchlisthideminor'] = |
870 | | - array( |
871 | | - 'type' => 'toggle', |
872 | | - 'section' => 'watchlist/advancedwatchlist', |
873 | | - 'label-message' => 'tog-watchlisthideminor', |
874 | | - ); |
875 | | - $defaultPreferences['watchlisthidebots'] = |
876 | | - array( |
877 | | - 'type' => 'toggle', |
878 | | - 'section' => 'watchlist/advancedwatchlist', |
879 | | - 'label-message' => 'tog-watchlisthidebots', |
880 | | - ); |
881 | | - $defaultPreferences['watchlisthideown'] = |
882 | | - array( |
883 | | - 'type' => 'toggle', |
884 | | - 'section' => 'watchlist/advancedwatchlist', |
885 | | - 'label-message' => 'tog-watchlisthideown', |
886 | | - ); |
887 | | - $defaultPreferences['watchlisthideanons'] = |
888 | | - array( |
889 | | - 'type' => 'toggle', |
890 | | - 'section' => 'watchlist/advancedwatchlist', |
891 | | - 'label-message' => 'tog-watchlisthideanons', |
892 | | - ); |
893 | | - $defaultPreferences['watchlisthideliu'] = |
894 | | - array( |
895 | | - 'type' => 'toggle', |
896 | | - 'section' => 'watchlist/advancedwatchlist', |
897 | | - 'label-message' => 'tog-watchlisthideliu', |
898 | | - ); |
| 802 | + $defaultPreferences['watchlistdays'] = array( |
| 803 | + 'type' => 'float', |
| 804 | + 'min' => 0, |
| 805 | + 'max' => 7, |
| 806 | + 'section' => 'watchlist/display', |
| 807 | + 'help' => wfMsgHtml( 'prefs-watchlist-days-max' ), |
| 808 | + 'label-message' => 'prefs-watchlist-days', |
| 809 | + ); |
| 810 | + $defaultPreferences['wllimit'] = array( |
| 811 | + 'type' => 'int', |
| 812 | + 'min' => 0, |
| 813 | + 'max' => 1000, |
| 814 | + 'label-message' => 'prefs-watchlist-edits', |
| 815 | + 'help' => wfMsgHtml( 'prefs-watchlist-edits-max' ), |
| 816 | + 'section' => 'watchlist/display', |
| 817 | + ); |
| 818 | + $defaultPreferences['extendwatchlist'] = array( |
| 819 | + 'type' => 'toggle', |
| 820 | + 'section' => 'watchlist/advancedwatchlist', |
| 821 | + 'label-message' => 'tog-extendwatchlist', |
| 822 | + ); |
| 823 | + $defaultPreferences['watchlisthideminor'] = array( |
| 824 | + 'type' => 'toggle', |
| 825 | + 'section' => 'watchlist/advancedwatchlist', |
| 826 | + 'label-message' => 'tog-watchlisthideminor', |
| 827 | + ); |
| 828 | + $defaultPreferences['watchlisthidebots'] = array( |
| 829 | + 'type' => 'toggle', |
| 830 | + 'section' => 'watchlist/advancedwatchlist', |
| 831 | + 'label-message' => 'tog-watchlisthidebots', |
| 832 | + ); |
| 833 | + $defaultPreferences['watchlisthideown'] = array( |
| 834 | + 'type' => 'toggle', |
| 835 | + 'section' => 'watchlist/advancedwatchlist', |
| 836 | + 'label-message' => 'tog-watchlisthideown', |
| 837 | + ); |
| 838 | + $defaultPreferences['watchlisthideanons'] = array( |
| 839 | + 'type' => 'toggle', |
| 840 | + 'section' => 'watchlist/advancedwatchlist', |
| 841 | + 'label-message' => 'tog-watchlisthideanons', |
| 842 | + ); |
| 843 | + $defaultPreferences['watchlisthideliu'] = array( |
| 844 | + 'type' => 'toggle', |
| 845 | + 'section' => 'watchlist/advancedwatchlist', |
| 846 | + 'label-message' => 'tog-watchlisthideliu', |
| 847 | + ); |
| 848 | + |
899 | 849 | if ( $wgEnableAPI ) { |
900 | 850 | # Some random gibberish as a proposed default |
901 | 851 | $hash = sha1( mt_rand() . microtime( true ) ); |
902 | | - $defaultPreferences['watchlisttoken'] = |
903 | | - array( |
904 | | - 'type' => 'text', |
905 | | - 'section' => 'watchlist/advancedwatchlist', |
906 | | - 'label-message' => 'prefs-watchlist-token', |
907 | | - 'help' => wfMsgHtml( 'prefs-help-watchlist-token', $hash ) |
908 | | - ); |
| 852 | + |
| 853 | + $defaultPreferences['watchlisttoken'] = array( |
| 854 | + 'type' => 'text', |
| 855 | + 'section' => 'watchlist/advancedwatchlist', |
| 856 | + 'label-message' => 'prefs-watchlist-token', |
| 857 | + 'help' => wfMsgHtml( 'prefs-help-watchlist-token', $hash ) |
| 858 | + ); |
909 | 859 | } |
910 | 860 | |
911 | 861 | if ( $wgUseRCPatrol ) { |
912 | | - $defaultPreferences['watchlisthidepatrolled'] = |
913 | | - array( |
914 | | - 'type' => 'toggle', |
915 | | - 'section' => 'watchlist/advancedwatchlist', |
916 | | - 'label-message' => 'tog-watchlisthidepatrolled', |
917 | | - ); |
| 862 | + $defaultPreferences['watchlisthidepatrolled'] = array( |
| 863 | + 'type' => 'toggle', |
| 864 | + 'section' => 'watchlist/advancedwatchlist', |
| 865 | + 'label-message' => 'tog-watchlisthidepatrolled', |
| 866 | + ); |
918 | 867 | } |
919 | 868 | |
920 | 869 | $watchTypes = array( |
— | — | @@ -923,11 +872,11 @@ |
924 | 873 | ); |
925 | 874 | |
926 | 875 | // Kinda hacky |
927 | | - if( $user->isAllowed( 'createpage' ) || $user->isAllowed( 'createtalk' ) ) { |
| 876 | + if ( $user->isAllowed( 'createpage' ) || $user->isAllowed( 'createtalk' ) ) { |
928 | 877 | $watchTypes['read'] = 'watchcreations'; |
929 | 878 | } |
930 | 879 | |
931 | | - foreach( $watchTypes as $action => $pref ) { |
| 880 | + foreach ( $watchTypes as $action => $pref ) { |
932 | 881 | if ( $user->isAllowed( $action ) ) { |
933 | 882 | $defaultPreferences[$pref] = array( |
934 | 883 | 'type' => 'toggle', |
— | — | @@ -942,95 +891,93 @@ |
943 | 892 | global $wgContLang; |
944 | 893 | |
945 | 894 | ## Search ##################################### |
946 | | - $defaultPreferences['searchlimit'] = |
947 | | - array( |
948 | | - 'type' => 'int', |
949 | | - 'label-message' => 'resultsperpage', |
950 | | - 'section' => 'searchoptions/display', |
951 | | - 'min' => 0, |
952 | | - ); |
953 | | - $defaultPreferences['contextlines'] = |
954 | | - array( |
955 | | - 'type' => 'int', |
956 | | - 'label-message' => 'contextlines', |
957 | | - 'section' => 'searchoptions/display', |
958 | | - 'min' => 0, |
959 | | - ); |
960 | | - $defaultPreferences['contextchars'] = |
961 | | - array( |
962 | | - 'type' => 'int', |
963 | | - 'label-message' => 'contextchars', |
964 | | - 'section' => 'searchoptions/display', |
965 | | - 'min' => 0, |
966 | | - ); |
| 895 | + $defaultPreferences['searchlimit'] = array( |
| 896 | + 'type' => 'int', |
| 897 | + 'label-message' => 'resultsperpage', |
| 898 | + 'section' => 'searchoptions/display', |
| 899 | + 'min' => 0, |
| 900 | + ); |
| 901 | + $defaultPreferences['contextlines'] = array( |
| 902 | + 'type' => 'int', |
| 903 | + 'label-message' => 'contextlines', |
| 904 | + 'section' => 'searchoptions/display', |
| 905 | + 'min' => 0, |
| 906 | + ); |
| 907 | + $defaultPreferences['contextchars'] = array( |
| 908 | + 'type' => 'int', |
| 909 | + 'label-message' => 'contextchars', |
| 910 | + 'section' => 'searchoptions/display', |
| 911 | + 'min' => 0, |
| 912 | + ); |
| 913 | + |
967 | 914 | global $wgEnableMWSuggest; |
968 | | - if( $wgEnableMWSuggest ) { |
969 | | - $defaultPreferences['disablesuggest'] = |
970 | | - array( |
971 | | - 'type' => 'toggle', |
972 | | - 'label-message' => 'mwsuggest-disable', |
973 | | - 'section' => 'searchoptions/display', |
974 | | - ); |
| 915 | + if ( $wgEnableMWSuggest ) { |
| 916 | + $defaultPreferences['disablesuggest'] = array( |
| 917 | + 'type' => 'toggle', |
| 918 | + 'label-message' => 'mwsuggest-disable', |
| 919 | + 'section' => 'searchoptions/display', |
| 920 | + ); |
975 | 921 | } |
976 | 922 | |
977 | | - $defaultPreferences['searcheverything'] = |
978 | | - array( |
979 | | - 'type' => 'toggle', |
980 | | - 'label-message' => 'searcheverything-enable', |
981 | | - 'section' => 'searchoptions/advancedsearchoptions', |
982 | | - ); |
| 923 | + $defaultPreferences['searcheverything'] = array( |
| 924 | + 'type' => 'toggle', |
| 925 | + 'label-message' => 'searcheverything-enable', |
| 926 | + 'section' => 'searchoptions/advancedsearchoptions', |
| 927 | + ); |
983 | 928 | |
984 | 929 | // Searchable namespaces back-compat with old format |
985 | 930 | $searchableNamespaces = SearchEngine::searchableNamespaces(); |
986 | 931 | |
987 | 932 | $nsOptions = array(); |
988 | | - foreach( $wgContLang->getNamespaces() as $ns => $name ) { |
989 | | - if( $ns < 0 ) continue; |
| 933 | + |
| 934 | + foreach ( $wgContLang->getNamespaces() as $ns => $name ) { |
| 935 | + if ( $ns < 0 ) { |
| 936 | + continue; |
| 937 | + } |
| 938 | + |
990 | 939 | $displayNs = str_replace( '_', ' ', $name ); |
991 | 940 | |
992 | | - if( !$displayNs ) $displayNs = wfMsg( 'blanknamespace' ); |
| 941 | + if ( !$displayNs ) { |
| 942 | + $displayNs = wfMsg( 'blanknamespace' ); |
| 943 | + } |
993 | 944 | |
994 | 945 | $displayNs = htmlspecialchars( $displayNs ); |
995 | 946 | $nsOptions[$displayNs] = $ns; |
996 | 947 | } |
997 | 948 | |
998 | | - $defaultPreferences['searchnamespaces'] = |
999 | | - array( |
1000 | | - 'type' => 'multiselect', |
1001 | | - 'label-message' => 'defaultns', |
1002 | | - 'options' => $nsOptions, |
1003 | | - 'section' => 'searchoptions/advancedsearchoptions', |
1004 | | - 'prefix' => 'searchNs', |
1005 | | - ); |
| 949 | + $defaultPreferences['searchnamespaces'] = array( |
| 950 | + 'type' => 'multiselect', |
| 951 | + 'label-message' => 'defaultns', |
| 952 | + 'options' => $nsOptions, |
| 953 | + 'section' => 'searchoptions/advancedsearchoptions', |
| 954 | + 'prefix' => 'searchNs', |
| 955 | + ); |
1006 | 956 | } |
1007 | 957 | |
1008 | 958 | static function miscPreferences( $user, &$defaultPreferences ) { |
1009 | 959 | ## Misc ##################################### |
1010 | | - $defaultPreferences['diffonly'] = |
1011 | | - array( |
1012 | | - 'type' => 'toggle', |
1013 | | - 'section' => 'misc/diffs', |
1014 | | - 'label-message' => 'tog-diffonly', |
1015 | | - ); |
1016 | | - $defaultPreferences['norollbackdiff'] = |
1017 | | - array( |
1018 | | - 'type' => 'toggle', |
1019 | | - 'section' => 'misc/diffs', |
1020 | | - 'label-message' => 'tog-norollbackdiff', |
1021 | | - ); |
| 960 | + $defaultPreferences['diffonly'] = array( |
| 961 | + 'type' => 'toggle', |
| 962 | + 'section' => 'misc/diffs', |
| 963 | + 'label-message' => 'tog-diffonly', |
| 964 | + ); |
| 965 | + $defaultPreferences['norollbackdiff'] = array( |
| 966 | + 'type' => 'toggle', |
| 967 | + 'section' => 'misc/diffs', |
| 968 | + 'label-message' => 'tog-norollbackdiff', |
| 969 | + ); |
1022 | 970 | |
1023 | 971 | // Stuff from Language::getExtraUserToggles() |
1024 | 972 | global $wgContLang; |
1025 | 973 | |
1026 | 974 | $toggles = $wgContLang->getExtraUserToggles(); |
1027 | 975 | |
1028 | | - foreach( $toggles as $toggle ) { |
1029 | | - $defaultPreferences[$toggle] = |
1030 | | - array( |
1031 | | - 'type' => 'toggle', |
1032 | | - 'section' => 'personal/i18n', |
1033 | | - 'label-message' => "tog-$toggle", |
1034 | | - ); |
| 976 | + foreach ( $toggles as $toggle ) { |
| 977 | + $defaultPreferences[$toggle] = array( |
| 978 | + 'type' => 'toggle', |
| 979 | + 'section' => 'personal/i18n', |
| 980 | + 'label-message' => "tog-$toggle", |
| 981 | + ); |
1035 | 982 | } |
1036 | 983 | } |
1037 | 984 | |
— | — | @@ -1044,9 +991,11 @@ |
1045 | 992 | |
1046 | 993 | $mptitle = Title::newMainPage(); |
1047 | 994 | $previewtext = wfMsgHtml( 'skin-preview' ); |
| 995 | + |
1048 | 996 | # Only show members of Skin::getSkinNames() rather than |
1049 | 997 | # $skinNames (skins is all skin names from Language.php) |
1050 | 998 | $validSkinNames = Skin::getUsableSkins(); |
| 999 | + |
1051 | 1000 | # Sort by UI skin name. First though need to update validSkinNames as sometimes |
1052 | 1001 | # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI). |
1053 | 1002 | foreach ( $validSkinNames as $skinkey => &$skinname ) { |
— | — | @@ -1059,11 +1008,11 @@ |
1060 | 1009 | asort( $validSkinNames ); |
1061 | 1010 | $sk = $user->getSkin(); |
1062 | 1011 | |
1063 | | - foreach( $validSkinNames as $skinkey => $sn ) { |
| 1012 | + foreach ( $validSkinNames as $skinkey => $sn ) { |
1064 | 1013 | $linkTools = array(); |
1065 | 1014 | |
1066 | 1015 | # Mark the default skin |
1067 | | - if( $skinkey == $wgDefaultSkin ) { |
| 1016 | + if ( $skinkey == $wgDefaultSkin ) { |
1068 | 1017 | $linkTools[] = wfMsgHtml( 'default' ); |
1069 | 1018 | } |
1070 | 1019 | |
— | — | @@ -1072,11 +1021,12 @@ |
1073 | 1022 | $linkTools[] = "<a target='_blank' href=\"$mplink\">$previewtext</a>"; |
1074 | 1023 | |
1075 | 1024 | # Create links to user CSS/JS pages |
1076 | | - if( $wgAllowUserCss ) { |
| 1025 | + if ( $wgAllowUserCss ) { |
1077 | 1026 | $cssPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/' . $skinkey . '.css' ); |
1078 | 1027 | $linkTools[] = $sk->link( $cssPage, wfMsgHtml( 'prefs-custom-css' ) ); |
1079 | 1028 | } |
1080 | | - if( $wgAllowUserJs ) { |
| 1029 | + |
| 1030 | + if ( $wgAllowUserJs ) { |
1081 | 1031 | $jsPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/' . $skinkey . '.js' ); |
1082 | 1032 | $linkTools[] = $sk->link( $jsPage, wfMsgHtml( 'prefs-custom-js' ) ); |
1083 | 1033 | } |
— | — | @@ -1094,11 +1044,12 @@ |
1095 | 1045 | |
1096 | 1046 | $ret = array(); |
1097 | 1047 | |
1098 | | - if( $dateopts ) { |
| 1048 | + if ( $dateopts ) { |
1099 | 1049 | if ( !in_array( 'default', $dateopts ) ) { |
1100 | 1050 | $dateopts[] = 'default'; // Make sure default is always valid |
1101 | 1051 | // Bug 19237 |
1102 | 1052 | } |
| 1053 | + |
1103 | 1054 | // KLUGE: site default might not be valid for user language |
1104 | 1055 | global $wgDefaultUserOptions; |
1105 | 1056 | if ( !in_array( $wgDefaultUserOptions['date'], $dateopts ) ) { |
— | — | @@ -1107,8 +1058,8 @@ |
1108 | 1059 | |
1109 | 1060 | $idCnt = 0; |
1110 | 1061 | $epoch = wfTimestampNow(); |
1111 | | - foreach( $dateopts as $key ) { |
1112 | | - if( $key == 'default' ) { |
| 1062 | + foreach ( $dateopts as $key ) { |
| 1063 | + if ( $key == 'default' ) { |
1113 | 1064 | $formatted = wfMsgHtml( 'datedefault' ); |
1114 | 1065 | } else { |
1115 | 1066 | $formatted = htmlspecialchars( $wgLang->timeanddate( $epoch, false, $key ) ); |
— | — | @@ -1147,14 +1098,13 @@ |
1148 | 1099 | |
1149 | 1100 | static function validateSignature( $signature, $alldata ) { |
1150 | 1101 | global $wgParser, $wgMaxSigChars, $wgLang; |
1151 | | - if( mb_strlen( $signature ) > $wgMaxSigChars ) { |
1152 | | - return |
1153 | | - Xml::element( 'span', array( 'class' => 'error' ), |
1154 | | - wfMsgExt( 'badsiglength', 'parsemag', |
1155 | | - $wgLang->formatNum( $wgMaxSigChars ) |
1156 | | - ) |
1157 | | - ); |
1158 | | - } elseif( !empty( $alldata['fancysig'] ) && |
| 1102 | + if ( mb_strlen( $signature ) > $wgMaxSigChars ) { |
| 1103 | + return Xml::element( 'span', array( 'class' => 'error' ), |
| 1104 | + wfMsgExt( 'badsiglength', 'parsemag', |
| 1105 | + $wgLang->formatNum( $wgMaxSigChars ) |
| 1106 | + ) |
| 1107 | + ); |
| 1108 | + } elseif ( !empty( $alldata['fancysig'] ) && |
1159 | 1109 | false === $wgParser->validateSig( $signature ) ) { |
1160 | 1110 | return Xml::element( 'span', array( 'class' => 'error' ), wfMsg( 'badsig' ) ); |
1161 | 1111 | } else { |
— | — | @@ -1164,7 +1114,7 @@ |
1165 | 1115 | |
1166 | 1116 | static function cleanSignature( $signature, $alldata ) { |
1167 | 1117 | global $wgParser; |
1168 | | - if( $alldata['fancysig'] ) { |
| 1118 | + if ( $alldata['fancysig'] ) { |
1169 | 1119 | $signature = $wgParser->cleanSig( $signature ); |
1170 | 1120 | } else { |
1171 | 1121 | // When no fancy sig used, make sure ~{3,5} get removed. |
— | — | @@ -1180,7 +1130,7 @@ |
1181 | 1131 | } |
1182 | 1132 | |
1183 | 1133 | global $wgEmailConfirmToEdit; |
1184 | | - if( $wgEmailConfirmToEdit && !$email ) { |
| 1134 | + if ( $wgEmailConfirmToEdit && !$email ) { |
1185 | 1135 | return wfMsgExt( 'noemailtitle', 'parseinline' ); |
1186 | 1136 | } |
1187 | 1137 | return true; |
— | — | @@ -1234,19 +1184,20 @@ |
1235 | 1185 | $z = explode( '/', $tz, 2 ); |
1236 | 1186 | |
1237 | 1187 | # timezone_identifiers_list() returns a number of |
1238 | | - # backwards-compatibility entries. This filters them out of the |
| 1188 | + # backwards-compatibility entries. This filters them out of the |
1239 | 1189 | # list presented to the user. |
1240 | | - if ( count( $z ) != 2 || !array_key_exists( $z[0], $tzRegions ) ) |
| 1190 | + if ( count( $z ) != 2 || !array_key_exists( $z[0], $tzRegions ) ) { |
1241 | 1191 | continue; |
| 1192 | + } |
1242 | 1193 | |
1243 | 1194 | # Localize region |
1244 | 1195 | $z[0] = $tzRegions[$z[0]]; |
1245 | 1196 | |
1246 | 1197 | $minDiff = floor( timezone_offset_get( timezone_open( $tz ), $now ) / 60 ); |
1247 | | - |
| 1198 | + |
1248 | 1199 | $display = str_replace( '_', ' ', $z[0] . '/' . $z[1] ); |
1249 | 1200 | $value = "ZoneInfo|$minDiff|$tz"; |
1250 | | - |
| 1201 | + |
1251 | 1202 | $opt[$z[0]][$display] = $value; |
1252 | 1203 | } |
1253 | 1204 | } |
— | — | @@ -1262,11 +1213,11 @@ |
1263 | 1214 | default: |
1264 | 1215 | $data = explode( ':', $tz, 2 ); |
1265 | 1216 | $minDiff = 0; |
1266 | | - if( count( $data ) == 2 ) { |
| 1217 | + if ( count( $data ) == 2 ) { |
1267 | 1218 | $data[0] = intval( $data[0] ); |
1268 | 1219 | $data[1] = intval( $data[1] ); |
1269 | 1220 | $minDiff = abs( $data[0] ) * 60 + $data[1]; |
1270 | | - if ( $data[0] < 0 ) $minDiff = -$minDiff; |
| 1221 | + if ( $data[0] < 0 ) $minDiff = - $minDiff; |
1271 | 1222 | } else { |
1272 | 1223 | $minDiff = intval( $data[0] ) * 60; |
1273 | 1224 | } |
— | — | @@ -1274,18 +1225,18 @@ |
1275 | 1226 | # Max is +14:00 and min is -12:00, see: |
1276 | 1227 | # http://en.wikipedia.org/wiki/Timezone |
1277 | 1228 | $minDiff = min( $minDiff, 840 ); # 14:00 |
1278 | | - $minDiff = max( $minDiff, -720 ); # -12:00 |
1279 | | - return 'Offset|'.$minDiff; |
| 1229 | + $minDiff = max( $minDiff, - 720 ); # -12:00 |
| 1230 | + return 'Offset|' . $minDiff; |
1280 | 1231 | } |
1281 | 1232 | } |
1282 | | - |
| 1233 | + |
1283 | 1234 | static function tryFormSubmit( $formData, $entryPoint = 'internal' ) { |
1284 | 1235 | global $wgUser, $wgEmailAuthentication, $wgEnableEmail; |
1285 | 1236 | |
1286 | 1237 | $result = true; |
1287 | 1238 | |
1288 | 1239 | // Filter input |
1289 | | - foreach( array_keys( $formData ) as $name ) { |
| 1240 | + foreach ( array_keys( $formData ) as $name ) { |
1290 | 1241 | if ( isset( self::$saveFilters[$name] ) ) { |
1291 | 1242 | $formData[$name] = |
1292 | 1243 | call_user_func( self::$saveFilters[$name], $formData[$name], $formData ); |
— | — | @@ -1298,29 +1249,29 @@ |
1299 | 1250 | 'emailaddress', |
1300 | 1251 | ); |
1301 | 1252 | |
1302 | | - if( $wgEnableEmail ) { |
| 1253 | + if ( $wgEnableEmail ) { |
1303 | 1254 | $newaddr = $formData['emailaddress']; |
1304 | 1255 | $oldaddr = $wgUser->getEmail(); |
1305 | | - if( ( $newaddr != '' ) && ( $newaddr != $oldaddr ) ) { |
| 1256 | + if ( ( $newaddr != '' ) && ( $newaddr != $oldaddr ) ) { |
1306 | 1257 | # the user has supplied a new email address on the login page |
1307 | 1258 | # new behaviour: set this new emailaddr from login-page into user database record |
1308 | 1259 | $wgUser->setEmail( $newaddr ); |
1309 | 1260 | # but flag as "dirty" = unauthenticated |
1310 | 1261 | $wgUser->invalidateEmail(); |
1311 | | - if( $wgEmailAuthentication ) { |
| 1262 | + if ( $wgEmailAuthentication ) { |
1312 | 1263 | # Mail a temporary password to the dirty address. |
1313 | 1264 | # User can come back through the confirmation URL to re-enable email. |
1314 | 1265 | $result = $wgUser->sendConfirmationMail( $oldaddr != '' ); |
1315 | | - if( WikiError::isError( $result ) ) { |
| 1266 | + if ( WikiError::isError( $result ) ) { |
1316 | 1267 | return wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) ); |
1317 | | - } elseif( $entryPoint == 'ui' ) { |
| 1268 | + } elseif ( $entryPoint == 'ui' ) { |
1318 | 1269 | $result = 'eauth'; |
1319 | 1270 | } |
1320 | 1271 | } |
1321 | 1272 | } else { |
1322 | 1273 | $wgUser->setEmail( $newaddr ); |
1323 | 1274 | } |
1324 | | - if( $oldaddr != $newaddr ) { |
| 1275 | + if ( $oldaddr != $newaddr ) { |
1325 | 1276 | wfRunHooks( 'PrefsEmailAudit', array( $wgUser, $oldaddr, $newaddr ) ); |
1326 | 1277 | } |
1327 | 1278 | } |
— | — | @@ -1332,14 +1283,15 @@ |
1333 | 1284 | $wgUser->setRealName( $realName ); |
1334 | 1285 | } |
1335 | 1286 | |
1336 | | - foreach( $saveBlacklist as $b ) |
| 1287 | + foreach ( $saveBlacklist as $b ) { |
1337 | 1288 | unset( $formData[$b] ); |
| 1289 | + } |
1338 | 1290 | |
1339 | 1291 | // Keeps old preferences from interfering due to back-compat |
1340 | 1292 | // code, etc. |
1341 | 1293 | $wgUser->resetOptions(); |
1342 | 1294 | |
1343 | | - foreach( $formData as $key => $value ) { |
| 1295 | + foreach ( $formData as $key => $value ) { |
1344 | 1296 | $wgUser->setOption( $key, $value ); |
1345 | 1297 | } |
1346 | 1298 | |
— | — | @@ -1351,14 +1303,17 @@ |
1352 | 1304 | public static function tryUISubmit( $formData ) { |
1353 | 1305 | $res = self::tryFormSubmit( $formData, 'ui' ); |
1354 | 1306 | |
1355 | | - if( $res ) { |
| 1307 | + if ( $res ) { |
1356 | 1308 | $urlOptions = array( 'success' ); |
1357 | | - if( $res === 'eauth' ) |
| 1309 | + |
| 1310 | + if ( $res === 'eauth' ) { |
1358 | 1311 | $urlOptions[] = 'eauth'; |
| 1312 | + } |
1359 | 1313 | |
1360 | 1314 | $queryString = implode( '&', $urlOptions ); |
1361 | 1315 | |
1362 | 1316 | $url = SpecialPage::getTitleFor( 'Preferences' )->getFullURL( $queryString ); |
| 1317 | + |
1363 | 1318 | global $wgOut; |
1364 | 1319 | $wgOut->redirect( $url ); |
1365 | 1320 | } |
— | — | @@ -1371,8 +1326,8 @@ |
1372 | 1327 | // Back compat with old format |
1373 | 1328 | $arr = array(); |
1374 | 1329 | |
1375 | | - foreach( $searchableNamespaces as $ns => $name ) { |
1376 | | - if( $user->getOption( 'searchNs' . $ns ) ) { |
| 1330 | + foreach ( $searchableNamespaces as $ns => $name ) { |
| 1331 | + if ( $user->getOption( 'searchNs' . $ns ) ) { |
1377 | 1332 | $arr[] = $ns; |
1378 | 1333 | } |
1379 | 1334 | } |
— | — | @@ -1383,7 +1338,6 @@ |
1384 | 1339 | |
1385 | 1340 | /** Some tweaks to allow js prefs to work */ |
1386 | 1341 | class PreferencesForm extends HTMLForm { |
1387 | | - |
1388 | 1342 | function wrapForm( $html ) { |
1389 | 1343 | $html = Xml::tags( 'div', array( 'id' => 'preferences' ), $html ); |
1390 | 1344 | |
— | — | @@ -1408,13 +1362,13 @@ |
1409 | 1363 | function filterDataForSubmit( $data ) { |
1410 | 1364 | // Support for separating MultiSelect preferences into multiple preferences |
1411 | 1365 | // Due to lack of array support. |
1412 | | - foreach( $this->mFlatFields as $fieldname => $field ) { |
| 1366 | + foreach ( $this->mFlatFields as $fieldname => $field ) { |
1413 | 1367 | $info = $field->mParams; |
1414 | | - if( $field instanceof HTMLMultiSelectField ) { |
| 1368 | + if ( $field instanceof HTMLMultiSelectField ) { |
1415 | 1369 | $options = HTMLFormField::flattenOptions( $info['options'] ); |
1416 | 1370 | $prefix = isset( $info['prefix'] ) ? $info['prefix'] : $fieldname; |
1417 | 1371 | |
1418 | | - foreach( $options as $opt ) { |
| 1372 | + foreach ( $options as $opt ) { |
1419 | 1373 | $data["$prefix$opt"] = in_array( $opt, $data[$fieldname] ); |
1420 | 1374 | } |
1421 | 1375 | |