r44235 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44234‎ | r44235 | r44236 >
Date:16:58, 4 December 2008
Author:ialex
Status:ok
Tags:
Comment:
* Support rate-limits in API
* Whitespaces fixes
Modified paths:
  • /trunk/extensions/Configure/Configure.api.php (modified) (history)
  • /trunk/extensions/Configure/Configure.page.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Configure/Configure.api.php
@@ -238,6 +238,19 @@
239239 $result->setIndexedTagName( $arr['values'], 'value' );
240240 $settingRet['values'][] = $arr;
241241 }
 242+ case 'rate-limits':
 243+ $settingRet['values'] = array();
 244+ $result->setIndexedTagName( $settingRet['values'], 'action' );
 245+ foreach ( $settingVal as $action => $limits ) {
 246+ $arr = array( 'name' => $action );
 247+ foreach( $limits as $group => $values ){
 248+ $count = isset( $values[0] ) ? $values[0] : 0;
 249+ $period = isset( $values[1] ) ? $values[1] : 0;
 250+ $arr[] = array( 'name' => $group, 'count' => $values[0], 'period' => $values[1] );
 251+ }
 252+ $result->setIndexedTagName( $arr, 'group' );
 253+ $settingRet['values'][] = $arr;
 254+ }
242255 }
243256 break;
244257 default:
Index: trunk/extensions/Configure/Configure.page.php
@@ -985,18 +985,18 @@
986986 $text .= '</table>';
987987 return $text;
988988 }
989 - if ($type == 'rate-limits') { ## Some of this is stolen from assoc, since it's an assoc with an assoc.
 989+ if ( $type == 'rate-limits' ) { ## Some of this is stolen from assoc, since it's an assoc with an assoc.
990990 $keydesc = wfMsgExt( "configure-setting-$conf-key", 'parseinline' );
991991 $valdesc = wfMsgExt( "configure-setting-$conf-value", 'parseinline' );
992992
993 - if (wfEmptyMsg( "configure-setting-$conf-key", $keydesc ))
 993+ if ( wfEmptyMsg( "configure-setting-$conf-key", $keydesc ) )
994994 $keydesc = wfMsgHtml( 'configure-desc-key' );
995 - if (wfEmptyMsg( "configure-setting-$conf-value", $valdesc ))
 995+ if ( wfEmptyMsg( "configure-setting-$conf-value", $valdesc ) )
996996 $valdesc = wfMsgHtml( 'configure-desc-val' );
997997
998 - $classes = array('configure-array-table', 'configure-rate-limits');
 998+ $classes = array( 'configure-array-table', 'configure-rate-limits' );
999999
1000 - if (!$allowed)
 1000+ if ( !$allowed )
10011001 $classes[] = 'disabled';
10021002
10031003 $rows = Xml::tags( 'tr', null, Xml::tags( 'th', null, $keydesc ) . " " . Xml::tags( 'th', null, $valdesc ) )."\n";
@@ -1007,26 +1007,26 @@
10081008
10091009 foreach( $validActions as $action ) {
10101010 $val = array();
1011 - if (@isset($default[$action]))
 1011+ if ( isset( $default[$action] ) )
10121012 $val = $default[$action];
10131013
10141014 $key = Xml::tags( 'td', null, wfMsgExt( "configure-throttle-action-$action", 'parseinline' ) );
10151015
10161016 ## Build YET ANOTHER ASSOC TABLE ARGH!
1017 - $innerRows = Xml::tags( 'tr', null, Xml::tags( 'th', null, wfMsgExt( 'configure-throttle-group', 'parseinline' ) ) . " " . Xml::tags( 'th', null, wfMsgExt( 'configure-throttle-limit', 'parseinline' ) ) )."\n";
 1017+ $innerRows = Xml::tags( 'tr', null, Xml::tags( 'th', null, wfMsgExt( 'configure-throttle-group', 'parseinline' ) ) . ' ' . Xml::tags( 'th', null, wfMsgExt( 'configure-throttle-limit', 'parseinline' ) ) )."\n";
10181018 foreach( $validGroups as $type ) {
10191019 $limits = null;
1020 - if (@isset($default[$action][$type]))
 1020+ if ( isset( $default[$action][$type] ) )
10211021 $limits = $default[$action][$type];
1022 - if (is_array($limits) && count($limits) == 2)
1023 - list($count, $period) = $limits;
 1022+ if ( is_array( $limits ) && count( $limits ) == 2 )
 1023+ list( $count, $period ) = $limits;
10241024 else
10251025 $count = $period = 0;
10261026
10271027 $id = 'wp'.$conf.'-key-'.$action.'-'.$type;
10281028 $left_col = Xml::tags( 'td', null, wfMsgExt( "configure-throttle-group-$type", 'parseinline' ) );
10291029
1030 - if ($allowed) {
 1030+ if ( $allowed ) {
10311031 $right_col = Xml::inputLabel( wfMsg( 'configure-throttle-count' ), "$id-count", "$id-count", 15, $count ) . ' <br /> ' .
10321032 Xml::inputLabel( wfMsg( 'configure-throttle-period' ), "$id-period", "$id-period", 15, $period );
10331033 } else {
@@ -1036,7 +1036,7 @@
10371037 }
10381038 $right_col = Xml::tags( 'td', null, $right_col );
10391039
1040 - $innerRows .= Xml::tags( 'tr', array( 'id' => $id), $left_col . $right_col ) . "\n";
 1040+ $innerRows .= Xml::tags( 'tr', array( 'id' => $id ), $left_col . $right_col ) . "\n";
10411041 }
10421042
10431043 $value = Xml::tags( 'td', null, Xml::tags( 'table', array( 'class' => 'configure-biglist configure-rate-limits-action' ), Xml::tags( 'tbody', null, $innerRows ) ) );

Status & tagging log