r11994 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r11993‎ | r11994 | r11995 >
Date:20:56, 6 December 2005
Author:hashar
Status:old
Tags:
Comment:
* code layout
* rewrote list of "$foobar = wfmsg('foobar')" with a array / foreach
Modified paths:
  • /branches/wikidata/phase3/includes/SpecialNamespaces.php (modified) (history)

Diff [purge]

Index: branches/wikidata/phase3/includes/SpecialNamespaces.php
@@ -9,7 +9,7 @@
1010 * Constructor
1111 */
1212 function wfSpecialNamespaces() {
13 - global $wgUser, $wgOut, $wgRequest;
 13+ global $wgUser, $wgRequest;
1414
1515 $action = $wgRequest->getVal( 'action' );
1616 $f = new NamespaceForm();
@@ -36,15 +36,15 @@
3737 class NamespaceForm {
3838
3939 function showForm( $errorHeader='', $errorBody='' ) {
40 - global $wgOut, $wgUser, $wgLang, $wgNamespaces,$wgTitle;
 40+ global $wgOut, $wgUser, $wgNamespaces,$wgTitle;
4141
42 - $wgOut->setPagetitle( wfMsg( "namespaces" ) );
 42+ $wgOut->setPagetitle( wfMsg( 'namespaces' ) );
4343
4444 /* In case of an error, we generally just show what went wrong
4545 and continue displaying the main form */
4646 if ( '' != $errorHeader ) {
47 - $wgOut->setSubtitle( wfMsg( "transactionerror" ) );
48 - $wgOut->addHTML( "<p class='error'>".htmlspecialchars($errorHeader)."</P>");
 47+ $wgOut->setSubtitle( wfMsg( 'transactionerror' ) );
 48+ $wgOut->addHTML( '<p class="error">' . htmlspecialchars($errorHeader) . '</p>');
4949 if($errorBody) {
5050 $wgOut->addWikiText($errorBody);
5151 }
@@ -52,8 +52,8 @@
5353
5454 # Standard token to avoid remote form submission exploits
5555 $token = $wgUser->editToken();
56 - $action = $wgTitle->escapeLocalURL( "action=submit" );
57 - $talksuffix = wfEscapeJsString(wfMsgForContent("talkpagesuffix"));
 56+ $action = $wgTitle->escapeLocalURL( 'action=submit' );
 57+ $talksuffix = wfEscapeJsString(wfMsgForContent('talkpagesuffix'));
5858
5959 # For the namespace selection box
6060 $name_array = Namespace::getFormattedDefaultNamespaces();
@@ -63,7 +63,7 @@
6464 # Sort for foreach loops
6565 ksort($name_array);
6666
67 - $wgOut->addWikiText( wfMsg( "add_namespaces_header" ) );
 67+ $wgOut->addWikiText( wfMsg( 'add_namespaces_header' ) );
6868
6969 # Prefill talk namespace field, but only for languages
7070 # where it's not disabled
@@ -106,40 +106,45 @@
107107
108108 $wgOut->addWikiText( wfMsg( "modify_namespaces_header" ) );
109109
110 - $namespace_child_of = wfMsg('namespace_child_of');
111 - $namespace_support_subpages = wfMsg('namespace_support_subpages');
112 - $namespace_search_by_default = wfMsg('namespace_search_by_default');
113 - $namespace_hide_in_lists = wfMsg('namespace_hide_in_lists');
114 - $namespace_default_link_prefix = wfMsg('namespace_default_link_prefix');
115 - $namespace_system = wfMsg('namespace_system');
116 - $namespace_properties = wfMsg('namespace_properties');
117 - $namespace_slot = wfMsg('namespace_slot');
118 - $namespace_names = wfMsg('namespace_names');
119 - $namespace_existing_names = wfMsg('namespace_existing_names');
120 - $namespace_new_names = wfMsg('namespace_new_names');
121 - $namespace_default_name = wfMsg('namespace_default_name');
122 - $namespace_delete_name = wfMsg('namespace_delete_name');
123 - $namespace_save_changes = wfMsg('namespace_save_changes');
124 -
 110+ // Array of messages to be used
 111+ $nsMessages = array (
 112+ 'child_of', 'default_link_prefix', 'default_name', 'delete_name',
 113+ 'existing_names', 'hide_in_lists', 'names', 'new_names',
 114+ 'properties', 'save_changes', 'search_by_default', 'slot',
 115+ 'support_subpages', 'system',
 116+ );
 117+
 118+ // Build variables using the array. 'child_of' will do:
 119+ // $namespace_child_of = wfMsg('namespace_child_of');
 120+ foreach( $nsMessages as $nsMessage ) {
 121+ $msgName = 'namespace_' . $nsMessage ;
 122+ $$msgName = wfMsg( $msgName );
 123+ }
 124+
 125+ // Initialise the form
125126 $htmlform=<<<END
126127 <form name="changenamespaces" method="post" action="{$action}">
127128 <input type="hidden" name="nsAction" value="changenamespaces" />
128129 <input type="hidden" name="wpEditToken" value="{$token}" />
129130 END;
 131+
 132+ // Now we proceed each namespace
130133 foreach ($wgNamespaces as $ns) {
131134
132135 $index = $ns->getIndex();
 136+
 137+ // Make sure the checkboxes remain checked:
133138 $subpages = $ns->allowsSubpages() ? ' checked' : '';
134139 $searchdefault = $ns->isSearchedByDefault() ? ' checked' :'';
135140 $hidden = $ns->isHidden ? ' checked' : '';
 141+
136142 $linkprefix = $ns->getTarget();
 143+ $parentslot = $ns->getParentIndex();
137144 $namespaceselect = '';
138 - $parentslot = $ns->getParentIndex();
139145
140146 # maybe make HTMLnamespaceselector more flexible and use
141147 # it instead here
142 - if(!$ns->isSpecial()) {
143 -
 148+ if( !$ns->isSpecial() ) {
144149 foreach ( $name_array as $arr_index => $arr_name ) {
145150 if( $arr_index < NS_MAIN && $arr_name!=$noparent )
146151 continue;
@@ -151,6 +156,10 @@
152157 }
153158 $namespaceselect .= "\n<option value='$arr_index'$selected>$list_option</option>";
154159 }
 160+
 161+
 162+ // TODO : fix code below, maybe use HTMLForm ?
 163+
155164 $namespaceselect_html=<<<END
156165 <tr valign="top"><td colspan="2">
157166 {$namespace_child_of}<br />
@@ -199,14 +208,14 @@
200209 $special_html='';
201210
202211 } else {
203 -
204 - $namespaceselect_html='';
205 - $subpages_html='';
206 - $searchdefault_html='';
207 - $hide_html='';
208 - $target_html='';
209 - $special_namespace=wfMsg('special_namespace');
210 - $special_html=<<<END
 212+ // For special namespace
 213+ $namespaceselect_html = '';
 214+ $subpages_html = '';
 215+ $searchdefault_html = '';
 216+ $hide_html = '';
 217+ $target_html = '';
 218+ $special_namespace = wfMsg('special_namespace');
 219+ $special_html = <<<END
211220 <tr valign="top"><td colspan="2">
212221 <em>{$special_namespace}</em>
213222 </td>
@@ -214,82 +223,69 @@
215224 END;
216225 }
217226
218 - $systemtype=$ns->getSystemType();
219 - if($ns->getSystemType()) {
220 - $systemtype_html=<<<END
 227+
 228+ $systemtype = $ns->getSystemType();
 229+
 230+ if( $ns->getSystemType() ) {
 231+ // No delete link ?
 232+ $systemtype_html = <<<END
221233 <tr valign="top"><td>
222 -<B><font color="red">{$namespace_system}</font></B>
 234+<b><font color="red">{$namespace_system}</font></b>
223235 </td>
224236 <td align="right">
225 -<B>{$systemtype}</B>
 237+<b>{$systemtype}</b>
226238 </td>
227239 </tr>
228240 END;
229 - $deletenamespace_html='';
 241+ $deletenamespace_html = '';
230242 } else {
231 - $sk=$wgUser->getSkin();
232 - $delete_link=$sk->makeKnownLinkObj($wgTitle,wfMsg('delete_namespace'),'action=delete&ns='.$index);
233 - $deletenamespace_html=<<<END
 243+ // Give out a link to delete the namespace
 244+ $sk = $wgUser->getSkin();
 245+ $delete_link = $sk->makeKnownLinkObj( $wgTitle, wfMsg('delete_namespace'), 'action=delete&ns=' . $index );
 246+ $deletenamespace_html = <<<END
234247 <tr valign="top"><td colspan="2">
235 -<strong>{$delete_link}</strong>
 248+<b>{$delete_link}</b>
236249 </td>
237250 </tr>
238251 END;
239252 $systemtype_html='';
240253 }
241 -
242254
 255+
 256+ // Yet another table of tables :p
 257+
243258 $htmlform .= <<<END
244259 <table border="0">
245 -<tr valign="top">
246 -<td>
247 -<table border="0" style="margin-right:1em;" width="300">
248 -<tr><th colspan="2">
249 -{$namespace_properties}
250 -</th>
251 -</tr>
252 -<tr><td>
253 -{$namespace_slot}
254 -</td>
255 -<td align="right">{$index}
256 -</td>
257 -</tr>
258 -{$systemtype_html}
259 -{$special_html}
260 -{$subpages_html}
261 -{$searchdefault_html}
262 -{$hide_html}
263 -{$target_html}
264 -{$namespaceselect_html}
265 -{$deletenamespace_html}
266 -</table>
267 -</td>
268 -<td>
269 -<table border="0">
270 -<tr>
271 -<th colspan="3">
272 -{$namespace_names}
273 -</th>
274 -</tr>
275 -<tr>
276 -<th align="left">
277 -{$namespace_existing_names}
278 -</th>
279 -<th>
280 -{$namespace_default_name}
281 -</th>
282 -<th>
283 -{$namespace_delete_name}
284 -</th>
285 -</tr>
 260+<tr valign="top"><td>
 261+ <table border="0" style="margin-right:1em;" width="300">
 262+ <tr><th colspan="2">{$namespace_properties}</th></tr>
 263+ <tr><td>{$namespace_slot}</td><td align="right">{$index}</td></tr>
 264+ {$systemtype_html}
 265+ {$special_html}
 266+ {$subpages_html}
 267+ {$searchdefault_html}
 268+ {$hide_html}
 269+ {$target_html}
 270+ {$namespaceselect_html}
 271+ {$deletenamespace_html}
 272+ </table>
 273+</td><td>
 274+ <table border="0">
 275+ <tr><th colspan="3">{$namespace_names}</th></tr>
 276+ <tr>
 277+ <th align="left">{$namespace_existing_names}</th>
 278+ <th>{$namespace_default_name}</th>
 279+ <th>{$namespace_delete_name}</th>
 280+ </tr>
286281 END;
287282
288 - foreach ( $ns->names as $nsi=>$nsname ) {
 283+ foreach ( $ns->names as $nsi => $nsname ) {
289284 if ( !is_null($ns->getDefaultNameIndex()) && $ns->getDefaultNameIndex() == $nsi ) {
290285 $dc=' checked';
291286 } else {
292287 $dc='';
293288 }
 289+
294290 $default = "<input type=\"radio\" name=\"ns{$index}Default\" value=\"{$nsi}\"{$dc} />";
295291 if (!is_null($ns->getCanonicalNameIndex()) &&$ns->getCanonicalNameIndex()== $nsi) {
296292 $nameinput = $nsname . '<br/><small>'.wfMsg('canonicalname').'</small>';
@@ -298,45 +294,35 @@
299295 $nameinput = "<input name=\"ns{$index}Name{$nsi}\" size=\"20\" value=\"{$nsname}\" />";
300296 $delete = "<input name=\"ns{$index}Delete{$nsi}\" type=\"checkbox\" value=\"1\" />";
301297 }
302 - $htmlform.=
 298+ $htmlform .=
303299 <<<END
304 -<tr valign="top">
305 -<td width="300">
306 -{$nameinput}
307 -</td>
308 -<td align="center">
309 -{$default}
310 -</td>
311 -<td align="center">
312 -{$delete}
313 -</td>
314 -</tr>
 300+ <tr valign="top">
 301+ <td width="300">{$nameinput}</td>
 302+ <td align="center">{$default}</td>
 303+ <td align="center">{$delete}</td>
 304+ </tr>
315305 END;
316 -
317306 }
318 - $htmlform.="<tr><th align=\"left\">{$namespace_new_names}</th></tr>";
319307
 308+ $htmlform .= '<tr><th align="left">' . $namespace_new_names . '</th></tr>' ;
 309+
320310 # 3 blank namespace fields
321 - if(!is_null($ns->names)) {
322 - end($ns->names);
323 - $highestName=key($ns->names)+1;
 311+ // FIXME cant we just count elements ?
 312+ if( !is_null( $ns->names ) ) {
 313+ end( $ns->names );
 314+ $highestName = key( $ns->names ) + 1;
324315 } else {
325 - $highestName=0;
 316+ $highestName = 0;
326317 }
327 - for($i=$highestName;$i<$highestName+3;$i++) {
328 - $htmlform.=
 318+
 319+ for( $i=$highestName; $i<$highestName+3; $i++) {
 320+ $htmlform .=
329321 <<<END
330 -<tr valign="top">
331 -<td width="300">
332 -<input name="ns{$index}NewName{$i}" size="20" value="" />
333 -</td>
334 -<td align="center">
335 -<input type="radio" name="ns{$index}Default" value="{$i}" />
336 -</td>
337 -<td align="center">
338 -&nbsp;
339 -</td>
340 -</tr>
 322+ <tr valign="top">
 323+ <td width="300"><input name="ns{$index}NewName{$i}" size="20" value="" /></td>
 324+ <td align="center"><input type="radio" name="ns{$index}Default" value="{$i}" /></td>
 325+ <td align="center">&nbsp;</td>
 326+ </tr>
341327 END;
342328 }
343329 $htmlform .= '</table></td></tr>';
@@ -344,144 +330,174 @@
345331 }
346332 $htmlform.=
347333 <<<END
348 -<tr><td>
349 -<input type="submit" value="{$namespace_save_changes}" />
350 -</td></tr>
 334+<tr><td><input type="submit" value="{$namespace_save_changes}" /></td></tr>
351335 </table>
352336 </form>
353337 END;
354338
355 - $wgOut->addHTML($htmlform);
 339+ // Ouput the form
 340+ $wgOut->addHTML( $htmlform );
 341+
356342 }
357343
 344+ /**
 345+ * @todo Document
 346+ */
358347 function addNamespaces() {
359348
360 - global $wgOut, $wgUser, $wgLang, $wgRequest;
 349+ global $wgOut, $wgUser, $wgRequest;
361350
362351 $nsname = $wgRequest->getText('nsName');
363352 $nstalkname = $wgRequest->getText('nsTalkName');
364353 $nscreatetalk = $wgRequest->getBool('nsCreateTalk');
365354
366355 if(empty($nsname)) {
367 - $this->showForm(wfMsg('namespace_name_missing'));
 356+ $this->showForm( wfMsg('namespace_name_missing') );
368357 }
369 - $dbr=&wfGetDB(DB_SLAVE);
370 - $ns=new Namespace();
371 - $newnameindex=$ns->addName($nsname);
372 - if(is_null($newnameindex)) {
373 - $this->showForm(wfMsg('namespace_error',$nsname),
374 - wfMsg('namespace_name_illegal_characters', NS_CHAR));
 358+
 359+ $ns = new Namespace();
 360+ $newnameindex = $ns->addName($nsname);
 361+
 362+ if( is_null($newnameindex) ) {
 363+ $this->showForm(
 364+ wfMsg('namespace_error',$nsname),
 365+ wfMsg('namespace_name_illegal_characters', NS_CHAR)
 366+ );
375367 return false;
376368 }
 369+
377370 $ns->setDefaultNameIndex($newnameindex);
378371 $nrv=$ns->testSave();
379372 /*
380373 The only errors which can occur here should be
381374 name-related.
382375 */
383 - if($nrv[NS_RESULT]==NS_NAME_ISSUES) {
384 - $this->showForm(wfMsg("namespace_error",$nsname),$this->nameIssues($nrv));
 376+ if( $nrv[NS_RESULT] == NS_NAME_ISSUES ) {
 377+ $this->showForm(
 378+ wfMsg('namespace_error',$nsname),
 379+ $this->nameIssues($nrv)
 380+ );
385381 return false;
386382 }
387 - $newnamespaceindex=$nrv[NS_SAVE_ID];
388 - if($nscreatetalk && !empty($nstalkname)) {
389 - $talkns=new Namespace();
390 - $talkns->setParentIndex($newnamespaceindex);
 383+
 384+ $newnamespaceindex = $nrv[NS_SAVE_ID];
 385+
 386+ if( $nscreatetalk && !empty($nstalkname) ) {
 387+
 388+ // Initialize a talk namespace
 389+ $talkns = new Namespace();
 390+ $talkns->setParentIndex( $newnamespaceindex );
391391 $talkns->setSubpages();
392 - $newtalknameindex=$talkns->addName($nstalkname);
393 - $talkns->setDefaultNameIndex($newtalknameindex);
394 - $trv=$talkns->testSave();
395 - if($trv[NS_RESULT]!=NS_CREATED) {
396 - $this->showForm(wfMsg("talk_namespace_error",$nstalkname),$this->nameIssues($trv));
 392+ $newtalknameindex=$talkns->addName( $nstalkname );
 393+ $talkns->setDefaultNameIndex( $newtalknameindex );
 394+
 395+ // attempt to create it
 396+ $trv = $talkns->testSave();
 397+ // Did it success ?
 398+ if( $trv[NS_RESULT] != NS_CREATED ) {
 399+ $this->showForm(
 400+ wfMsg('talk_namespace_error',$nstalkname),
 401+ $this->nameIssues($trv)
 402+ );
397403 return false;
398404 }
399405 }
400406
401 - # Save for real.
 407+ // We now have validated stuff, lets save for real.
 408+
 409+ // TODO error handling ?
402410 $ns->save();
403 - $complete = wfMsg('namespace_created',$nsname);
404 - if($nscreatetalk) {
 411+ $complete = wfMsg( 'namespace_created', $nsname );
 412+
 413+ if( $nscreatetalk ) {
 414+ // TODO error handling ?
405415 $talkns->save();
406416 $complete .= ' '.wfMsg('talk_namespace_created');
407417 }
 418+
 419+ // Report success to user
408420 $wgOut->addWikiText($complete);
409421 $this->showForm();
410422 }
411423
412 -
 424+ /**
 425+ * @todo Document
 426+ */
413427 function changeNamespaces() {
414428
415429 global $wgOut, $wgNamespaces, $wgRequest;
416430
417 - $newns=array();
418 - foreach($wgNamespaces as $ns) {
419 - $nsindex=$ns->getIndex();
420 - $newns[$nsindex]=new Namespace();
 431+ $newns = array();
 432+ foreach( $wgNamespaces as $ns ) {
 433+ $nsindex = $ns->getIndex();
 434+ $newns[$nsindex] = new Namespace();
421435 $newns[$nsindex]->setIndex($nsindex);
422436 $newns[$nsindex]->setSystemType($ns->getSystemType());
423437
424438 if(!$ns->isSpecial()) {
425 - $subvar="ns{$nsindex}Subpages";
426 - $searchvar="ns{$nsindex}Search";
427 - $hiddenvar="ns{$nsindex}Hidden";
428 - $prefixvar="ns{$nsindex}Linkprefix";
429 - $parentvar="ns{$nsindex}Parent";
430 - $subpages=$wgRequest->getBool($subvar);
431 - $searchdefault=$wgRequest->getBool($searchvar);
432 - $hidden=$wgRequest->getBool($hiddenvar);
433 - $prefix=$wgRequest->getText($prefixvar);
434 - $parent=$wgRequest->getIntOrNull($parentvar);
 439+ // Some variables names
 440+ $subvar = "ns{$nsindex}Subpages";
 441+ $searchvar = "ns{$nsindex}Search";
 442+ $hiddenvar = "ns{$nsindex}Hidden";
 443+ $prefixvar = "ns{$nsindex}Linkprefix";
 444+ $parentvar = "ns{$nsindex}Parent";
 445+
 446+ // Get data submitted by user
 447+ $subpages = $wgRequest->getBool($subvar);
 448+ $searchdefault = $wgRequest->getBool($searchvar);
 449+ $hidden = $wgRequest->getBool($hiddenvar);
 450+ $prefix = $wgRequest->getText($prefixvar);
 451+ $parent = $wgRequest->getIntOrNull($parentvar);
 452+
 453+ // Initialise our new namespace
435454 $newns[$nsindex]->setSubpages($subpages);
436455 $newns[$nsindex]->setSearchedByDefault($searchdefault);
437456 $newns[$nsindex]->setHidden($hidden);
438457 $newns[$nsindex]->setTarget($prefix);
 458+
439459 if(array_key_exists($parent,$wgNamespaces)) {
440460 $newns[$nsindex]->setParentIndex($parent);
441461 }
442462 }
443463
444 - $newns[$nsindex]->names=$ns->names;
 464+ // Inherit namespace names
 465+ $newns[$nsindex]->names = $ns->names;
445466
446 - # This can never be changed by the user.
 467+ // This can never be changed by the user.
447468 $newns[$nsindex]->setCanonicalNameIndex($ns->getCanonicalNameIndex());
448469
449 - # New names, appended to end
 470+ // New names, appended to end
450471 for($i=1;$i<=3;$i++) {
451 - $nvar="ns{$nsindex}NewName{$i}";
452 - if($nname=$wgRequest->getText($nvar)) {
 472+ $nvar = "ns{$nsindex}NewName{$i}";
 473+ if( $nname = $wgRequest->getText($nvar) ) {
453474 $newns[$nsindex]->addName($nname);
454475 }
455476 }
456477
457478 # Changes and deletions. Do them last since they can
458479 # affect index slots of existing names.
459 - foreach($ns->names as $nameindex=>$name) {
 480+ foreach( $ns->names as $nameindex=>$name ) {
460481 $var="ns{$nsindex}Name{$nameindex}";
461482 if($req=$wgRequest->getText($var)) {
462483 #wfDebug("Name var $var contains $req\n");
463484
464485 # Alter name if necessary.
465 - if($req!=$name) {
466 -
467 - # The last parameter means
468 - # that we do not check if the
469 - # name is valid - this
470 - # is done later for all names.
471 - $newns[$nsindex]->setName(
472 - $name,$req,false
473 - );
 486+ if($req != $name) {
 487+ # The last parameter means that we do not check if the
 488+ # name is valid - this is done later for all names.
 489+ $newns[$nsindex]->setName($name, $req, false);
474490
475491 #wfDebug("Setting name $nameindex of namespace $nsindex to $req. Old name is $name.\n");
476492 }
477493 }
478 - $delvar="ns{$nsindex}Delete{$nameindex}";
479 - if($wgRequest->getInt($delvar)) {
 494+ $delvar = "ns{$nsindex}Delete{$nameindex}";
 495+ if( $wgRequest->getInt($delvar) ) {
480496 #wfDebug("$delvar should be deleted.\n");
481497 $newns[$nsindex]->removeNameByIndex($nameindex);
482498 }
483499 }
484500
485 - $dvar="ns{$nsindex}Default";
 501+ $dvar = "ns{$nsindex}Default";
486502
487503 # Did the user select a default name?
488504 $dindex = $wgRequest->getIntOrNull($dvar);
@@ -492,28 +508,35 @@
493509 }
494510
495511 # Does the name exist and is it non-empty?
496 - if(!is_null($dindex) && array_key_exists($dindex, $newns[$nsindex]->names) && !empty($newns[$nsindex]->names[$dindex]) ) {
 512+ if(
 513+ !is_null($dindex)
 514+ && array_key_exists($dindex, $newns[$nsindex]->names)
 515+ && !empty($newns[$nsindex]->names[$dindex])
 516+ ) {
497517 # Use this default name.
498518 $newns[$nsindex]->setDefaultNameIndex($dindex);
499519 #wfDebug("Setting index for $nsindex to $dindex!\n");
500520 } else {
501 - # We have lost our default name, perhaps
502 - # it was deleted. Get a new one if
503 - # possible.
 521+ # We have lost our default name, perhaps it was deleted.
 522+ # Get a new one if possible.
504523 $newns[$nsindex]->setDefaultNameIndex($newns[$nsindex]->getNewDefaultNameIndex());
505 -
506524 }
507525 }
508526
509527 foreach($newns as $nns) {
510 - $nrv=$nns->testSave();
511 - if($nrv[NS_RESULT]==NS_NAME_ISSUES) {
512 - $this->showForm(wfMsg("namespace_error",$nns->getDefaultName()),$this->nameIssues($nrv));
 528+ $nrv = $nns->testSave();
 529+ if( $nrv[NS_RESULT] == NS_NAME_ISSUES ) {
 530+ $this->showForm(
 531+ wfMsg(
 532+ 'namespace_error',
 533+ $nns->getDefaultName()),
 534+ $this->nameIssues($nrv)
 535+ );
513536 return false;
514537 }
515538 $nns->save();
516539 }
517 -
 540+
518541 # IMPORTANT: The namespace name indexes are unpredictable when
519542 # serialized, so we have to reload the definitions from the
520543 # database at this point; otherwise, there could be index
@@ -521,21 +544,26 @@
522545 Namespace::load();
523546
524547 # Return to the namespace manager with the changes made.
525 - $wgOut->addWikiText(wfMsg("namespace_changes_saved"));
 548+ $wgOut->addWikiText( wfMsg('namespace_changes_saved') );
526549 $this->showForm();
 550+
527551 return true;
528552 }
529 -
530 - function nameIssues($result) {
531 -
532 - $htmltable='
533 - <table border="0" width="100%" cellspacing="5" cellpadding="5" rules="all">
534 - <tr>
535 - <th colspan="2">'.wfMsg('namespace_name_issues').'</th>
536 - </tr><tr>
537 - <th>'.wfMsg('namespace_name_header').'</th>
538 - <th>'.wfMsg('namespace_issue_header').'</th>
539 - </tr>';
 553+
 554+ /**
 555+ * @parameter array $result
 556+ * @return string A HTML table with namespaces issues
 557+ */
 558+ function nameIssues( $result ) {
 559+
 560+ # Initialize table with heading
 561+ $htmltable=
 562+ '<table border="0" width="100%" cellspacing="5" cellpadding="5" rules="all">'
 563+ . '<tr><th colspan="2">' . wfMsg('namespace_name_issues') . '</th></tr>'
 564+ . '<tr><th>' . wfMsg('namespace_name_header') . '</th>'
 565+ . '<th>'.wfMsg('namespace_issue_header').'</th></tr>'
 566+ . "\n";
 567+
540568 foreach($result[NS_ILLEGAL_NAMES] as $illegalName) {
541569 $htmltable.=
542570 '<tr><td>'
@@ -576,11 +604,15 @@
577605 .wfMsg('namespace_name_linked').
578606 '</td></tr>';
579607 }
580 -
581 - $htmltable.='</table>';
 608+
 609+ # Close table
 610+ $htmltable .= '</table>'."\n";
582611 return $htmltable;
583612 }
584 -
 613+
 614+ /**
 615+ * delete the namespace
 616+ */
585617 function deleteNamespace() {
586618
587619 global $wgOut,$wgRequest,$wgNamespaces;
@@ -589,21 +621,21 @@
590622
591623 /* There should be no delete links for namespaces which cannot
592624 be deleted, but let's catch two possible problems just in case. */
593 - if(!array_key_exists($nsid,$wgNamespaces)) {
594 - $this->showForm( wfMsg('namespace_not_deletable'),wfMsg('namespace_not_deletable_missing',$nsid) );
 625+ if(!array_key_exists( $nsid, $wgNamespaces) ) {
 626+ $this->showForm( wfMsg('namespace_not_deletable') , wfMsg('namespace_not_deletable_missing', $nsid) );
595627 return false;
596 - } elseif($wgNamespaces[$nsid]->isSystemNamespace()) {
597 - $this->showForm( wfMsg('namespace_not_deletable'),wfMsg('namespace_not_deletable_system',$nsid) );
 628+ } elseif( $wgNamespaces[$nsid]->isSystemNamespace() ) {
 629+ $this->showForm( wfMsg('namespace_not_deletable') , wfMsg('namespace_not_deletable_system', $nsid) );
598630 return false;
599631 }
600632
601 - $nsdelete = clone($wgNamespaces[$nsid]);
602 - $nsdeletename = $nsdelete->getDefaultName();
 633+ $nsdelete = clone( $wgNamespaces[$nsid] );
 634+ $nsdeletename = $nsdelete->getDefaultName();
603635 $drv = $nsdelete->deleteNamespace();
604636
605637 if( empty($nsdeletename) ) {
606638 # At least show the index
607 - $nsdeletename=$nsid;
 639+ $nsdeletename = $nsid;
608640 }
609641
610642 if( $drv[NS_RESULT] == NS_DELETED ) {

Status & tagging log