r21823 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21822‎ | r21823 | r21824 >
Date:14:32, 3 May 2007
Author:nikerabbit
Status:old
Tags:
Comment:
* Fix missing and double escaping
* Don't hardcode colons
* Xml functions, fixed broken labels
Modified paths:
  • /trunk/phase3/includes/SpecialProtectedpages.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesFi.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialProtectedpages.php
@@ -9,6 +9,10 @@
1010 * @addtogroup SpecialPage
1111 */
1212 class ProtectedPagesForm {
 13+
 14+ protected $IdLevel = 'level';
 15+ protected $IdType = 'type';
 16+
1317 function showList( $msg = '' ) {
1418 global $wgOut, $wgRequest;
1519
@@ -22,8 +26,8 @@
2327 Title::purgeExpiredRestrictions();
2428 }
2529
26 - $type = $wgRequest->getVal( 'type' );
27 - $level = $wgRequest->getVal( 'level' );
 30+ $type = $wgRequest->getVal( $this->IdType );
 31+ $level = $wgRequest->getVal( $this->IdLevel );
2832 $sizetype = $wgRequest->getVal( 'sizetype' );
2933 $size = $wgRequest->getIntOrNull( 'size' );
3034 $NS = $wgRequest->getIntOrNull( 'namespace' );
@@ -125,7 +129,7 @@
126130 $out .= "&nbsp".Xml::radio( 'sizetype', 'max', ($sizetype=='max'), array('id' => 'wpmax') );
127131 $out .= Xml::label( wfMsg("maximum-size"), 'wpmax' );
128132 $out .= "&nbsp".Xml::input('size', 9, $size, array( 'id' => 'wpsize' ) );
129 - $out .= ' '.wfMsg('pagesize');
 133+ $out .= ' '.wfMsgHtml('pagesize');
130134 return $out;
131135 }
132136
@@ -134,25 +138,28 @@
135139 * @private
136140 */
137141 function getTypeMenu( $pr_type ) {
138 - global $wgRestrictionTypes, $wgUser;
 142+ global $wgRestrictionTypes;
139143
140 - $out = "<select name='type'>\n";
141144 $m = array(); // Temporary array
 145+ $options = array();
142146
143147 // First pass to load the log names
144148 foreach( $wgRestrictionTypes as $type ) {
145 - $text = wfMsgHtml("restriction-$type");
 149+ $text = wfMsg("restriction-$type");
146150 $m[$text] = $type;
147151 }
148152
149153 // Third pass generates sorted XHTML content
150154 foreach( $m as $text => $type ) {
151155 $selected = ($type == $pr_type );
152 - $out .= Xml::option( $text, $type, $selected ) . "\n";
 156+ $options[] = Xml::option( $text, $type, $selected ) . "\n";
153157 }
154158
155 - $out .= '</select>';
156 - return "<label for='type'>" . wfMsgHtml('restriction-type') . "</label>: " . $out;
 159+ return
 160+ Xml::label( wfMsg('restriction-type') , $this->IdType ) . '&nbsp;' .
 161+ Xml::tags( 'select',
 162+ array( 'id' => $this->IdType, 'name' => $this->IdType ),
 163+ implode( "\n", $options ) );
157164 }
158165
159166 /**
@@ -160,30 +167,30 @@
161168 * @private
162169 */
163170 function getLevelMenu( $pr_level ) {
164 - global $wgRestrictionLevels, $wgUser;
165 -
166 - $out = "<select name='level'>\n";
167 - $m = array( wfMsgHtml('restriction-level-all') => 0 ); // Temporary array
 171+ global $wgRestrictionLevels;
168172
 173+ $m = array( wfMsg('restriction-level-all') => 0 ); // Temporary array
 174+ $options = array();
 175+
169176 // First pass to load the log names
170177 foreach( $wgRestrictionLevels as $type ) {
171178 if ( $type !='' && $type !='*') {
172 - $text = wfMsgHtml("restriction-level-$type");
 179+ $text = wfMsg("restriction-level-$type");
173180 $m[$text] = $type;
174181 }
175182 }
176183
177 - // Second pass to sort by name
178 - ksort($m);
179 -
180184 // Third pass generates sorted XHTML content
181185 foreach( $m as $text => $type ) {
182186 $selected = ($type == $pr_level );
183 - $out .= Xml::option( $text, $type, $selected ) . "\n";
 187+ $options[] = Xml::option( $text, $type, $selected );
184188 }
185189
186 - $out .= '</select>';
187 - return "<label for='level'>" . wfMsgHtml('restriction-level') . "</label>: " . $out;
 190+ return
 191+ Xml::label( wfMsg('restriction-level') , $this->IdLevel ) . '&nbsp;' .
 192+ Xml::tags( 'select',
 193+ array( 'id' => $this->IdLevel, 'name' => $this->IdLevel ),
 194+ implode( "\n", $options ) );
188195 }
189196 }
190197
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1835,8 +1835,8 @@
18361836 'protect-summary-cascade' => 'cascading',
18371837 'protect-expiring' => 'expires $1 (UTC)',
18381838 'protect-cascade' => 'Cascading protection - protect any pages included in this page.',
1839 -'restriction-type' => 'Permission',
1840 -'restriction-level' => 'Restriction level',
 1839+'restriction-type' => 'Permission:',
 1840+'restriction-level' => 'Restriction level:',
18411841 'minimum-size' => 'Min size',
18421842 'maximum-size' => 'Max size',
18431843 'pagesize' => '(bytes)',
Index: trunk/phase3/languages/messages/MessagesFi.php
@@ -1316,7 +1316,7 @@
13171317 'restriction-level' => 'Suojaus',
13181318 'minimum-size' => 'Vähimmäiskoko',
13191319 'maximum-size' => 'Enimmäiskoko',
1320 -'pagesize' => '(tavuina)',
 1320+'pagesize' => 'tavua',
13211321
13221322 # Restrictions (nouns)
13231323 'restriction-edit' => 'muokkaus',
@@ -1357,7 +1357,7 @@
13581358 'undelete-no-results' => 'Poistoarkistosta ei löytynyt haettuja sivuja.',
13591359
13601360 # Namespace form on various pages
1361 -'namespace' => 'Nimiavaruus:',
 1361+'namespace' => 'Nimiavaruus',
13621362 'invert' => 'Käännä nimiavaruusvalinta päinvastaiseksi',
13631363
13641364 # Contributions