r44464 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44463‎ | r44464 | r44465 >
Date:20:08, 11 December 2008
Author:ialex
Status:deferred
Tags:
Comment:
* API support for $wgAutopromote
* drop some more 1.13 compat
Modified paths:
  • /trunk/extensions/Configure/Configure.api.php (modified) (history)
  • /trunk/extensions/Configure/Configure.diff.php (modified) (history)
  • /trunk/extensions/Configure/Configure.func.php (modified) (history)
  • /trunk/extensions/Configure/Configure.page.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Configure/Configure.api.php
@@ -251,8 +251,50 @@
252252 $result->setIndexedTagName( $arr, 'group' );
253253 $settingRet['values'][] = $arr;
254254 }
 255+ break;
 256+ case 'promotion-conds':
 257+ $opToName = array_flip( array( 'or' => '|', 'and' => '&', 'xor' => '^', 'not' => '!' ) );
 258+ $condsName = array( 1 => 'editcount', 2 => 'age', 3 => 'emailconfirmed', 4 => 'in-groups' );
 259+ $validOps = array_keys( $opToName );
 260+
 261+ $settingRet['values'] = array();
 262+ $result->setIndexedTagName( $settingRet['values'], 'group' );
 263+
 264+ foreach( $settingVal as $group => $conds ) {
 265+ $retConds = array( 'group' => $group );
 266+ $result->setIndexedTagName( $retConds, 'condition' );
 267+ do {
 268+ if ( !is_array( $conds ) ) {
 269+ $retConds[] = array( 'name' => $condsName[$conds] );
 270+ continue;
 271+ }
 272+ if ( count( $conds ) == 0 ) {
 273+ continue;
 274+ }
 275+ if ( count( $conds ) > 1 && in_array( $conds[0], $validOps ) ) {
 276+ $boolop = array_shift( $conds );
 277+ $boolop = $opToName[$boolop];
 278+ $retConds['operator'] = $boolop;
 279+ } else {
 280+ $conds = array( $conds );
 281+ }
 282+ // Analyse each individual one...
 283+ foreach( $conds as $cond ) {
 284+ if ( $cond == array( APCOND_AGE, -1 ) ) {
 285+ continue;
 286+ }
 287+ if( !is_array( $cond ) ) {
 288+ $cond = array( $cond );
 289+ }
 290+ $name = array_shift( $cond );
 291+ $argSummary = implode( ', ', $cond );
 292+ $retConds[] = array( 'name' => $condsName[$name], 'value' => $argSummary );
 293+ }
 294+ } while( false );
 295+ $settingRet['values'][] = $retConds;
 296+ }
 297+ break;
255298 }
256 - break;
257299 default:
258300 if ( is_array( $type ) ) {
259301 $allowed = array();
Index: trunk/extensions/Configure/Configure.page.php
@@ -880,18 +880,9 @@
881881 */
882882 protected function injectScriptsAndStyles() {
883883 global $wgOut, $wgScriptPath, $wgUseAjax, $wgJsMimeType, $wgConfigureStyleVersion;
884 - $href = "{$wgScriptPath}/extensions/Configure/Configure.css?{$wgConfigureStyleVersion}";
885 - if ( is_callable( array( $wgOut, 'addExtensionStyle' ) ) ) { # 1.14+
886 - $wgOut->addExtensionStyle( $href );
887 - } else {
888 - $wgOut->addLink(
889 - array(
890 - 'rel' => 'stylesheet',
891 - 'type' => 'text/css',
892 - 'href' => $href,
893 - )
894 - );
895 - }
 884+
 885+ $wgOut->addExtensionStyle( "{$wgScriptPath}/extensions/Configure/Configure.css?{$wgConfigureStyleVersion}" );
 886+
896887 $add = Xml::encodeJsVar( wfMsg( 'configure-js-add' ) );
897888 $remove = Xml::encodeJsVar( wfMsg( 'configure-js-remove' ) );
898889 $removeRow = Xml::encodeJsVar( wfMsg( 'configure-js-remove-row' ) );
Index: trunk/extensions/Configure/Configure.diff.php
@@ -273,7 +273,7 @@
274274 list( $count, $period ) = $limit;
275275 if ($count == 0 || $period == 0)
276276 continue;
277 -
 277+
278278 $val[] = "$action, $group: " . wfMsg( 'configure-throttle-summary', $count, $period );
279279 }
280280 }
@@ -281,10 +281,10 @@
282282 } else if ( $arrType == 'promotion-conds' ) {
283283 ## For each group, print out the full conditions.
284284 $val = array();
285 -
 285+
286286 $opToName = array_flip( array( 'or' => '|', 'and' => '&', 'xor' => '^', 'not' => '!' ) );
287287 $validOps = array_keys( $opToName );
288 -
 288+
289289 foreach( $setting as $group => $conds ) {
290290 if ( !is_array( $conds ) ) {
291291 $val[] = "$group: ".wfMsg( "configure-condition-description-$conds" );
@@ -294,31 +294,31 @@
295295 $val[] = "$group: ".wfMsg( 'configure-autopromote-noconds' );
296296 continue;
297297 }
298 -
 298+
299299 if ( count( $conds ) > 1 && in_array( $conds[0], $validOps ) ) {
300300 $boolop = array_shift( $conds );
301301 $boolop = $opToName[$boolop];
302 -
 302+
303303 $val[] = "$group: ".wfMsg( "configure-boolop-description-$boolop" );
304304 } else {
305305 $conds = array( $conds );
306306 }
307 -
 307+
308308 // Analyse each individual one...
309309 foreach( $conds as $cond ) {
310310 if ($cond == array( APCOND_AGE, -1 ) ) {
311311 $val[] = "$group: ".wfMsg( 'configure-autopromote-noconds' );
312312 continue;
313313 }
314 -
 314+
315315 if( !is_array( $cond ) ) {
316316 $cond = array( $cond );
317317 }
318318 $name = array_shift( $cond );
319319
320 -
 320+
321321 $argSummary = implode( ', ', $cond );
322 -
 322+
323323 $val[] = "$group: ".wfMsg( "configure-condition-description-$name", $argSummary );
324324 }
325325 }
@@ -391,30 +391,30 @@
392392
393393 protected function getOldVersion() {
394394 global $wgConf;
395 -
 395+
396396 $settings = $wgConf->getOldSettings( $this->diff );
397 -
 397+
398398 if ($this->diff == 'default') { ## Special case: Replicate settings across all wikis for a fair comparison.
399399 $new = $this->getNewVersion();
400 -
 400+
401401 $defaultSettings = array();
402 -
 402+
403403 ## This is kinda annoying. We can't copy ALL settings over, because not all settings are stored.
404404 foreach( $new as $wiki => $newSettings ) {
405405 if ($wiki == '__metadata') ## Ignore metadata.
406406 continue;
407 -
 407+
408408 $defaultSettings[$wiki] = array();
409 -
 409+
410410 foreach( $newSettings as $key => $value ) {
411411 if (isset($settings['default'][$key]))
412412 $defaultSettings[$wiki][$key] = $settings['default'][$key];
413413 }
414414 }
415 -
 415+
416416 $settings = $defaultSettings;
417417 }
418 -
 418+
419419 return $settings;
420420 }
421421
Index: trunk/extensions/Configure/Configure.func.php
@@ -71,8 +71,7 @@
7272 $wgConf->wikis = $oldConf->wikis;
7373 $wgConf->settings = $oldConf->settings;
7474 $wgConf->localVHosts = $oldConf->localVHosts;
75 - if ( isset( $oldConf->siteParamsCallback ) ) # 1.14+
76 - $wgConf->siteParamsCallback = $oldConf->siteParamsCallback;
 75+ $wgConf->siteParamsCallback = $oldConf->siteParamsCallback;
7776
7877 $wgConf->snapshotDefaults();
7978

Status & tagging log