r99405 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99404‎ | r99405 | r99406 >
Date:15:21, 10 October 2011
Author:ialex
Status:ok (Comments)
Tags:
Comment:
Fixes for SkinLegacy::specialPagesList():
* Use XmlSelect, Html::rawElement() and Xml::submitButton() to make sure things are correctly escaped
* Get a Title object instead of using $wgContLang->specialPage()
* Redirect to index.php and changed the name of the <select> to title to use the common way instead of linking to redirect.php?wpDropDown=...
Modified paths:
  • /trunk/phase3/includes/SkinLegacy.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SkinLegacy.php
@@ -430,34 +430,18 @@
431431 * Show a drop-down box of special pages
432432 */
433433 function specialPagesList() {
434 - global $wgContLang, $wgServer, $wgRedirectScript;
 434+ global $wgScript;
435435
 436+ $select = new XmlSelect( 'title' );
436437 $pages = SpecialPageFactory::getUsablePages();
437 -
438 - foreach ( $pages as $name => $page ) {
439 - $pages[$name] = $page->getDescription();
 438+ array_unshift( $pages, SpecialPageFactory::getPage( 'SpecialPages' ) );
 439+ foreach ( $pages as $obj ) {
 440+ $select->addOption( $obj->getDescription(),
 441+ $obj->getTitle()->getPrefixedDBkey() );
440442 }
441443
442 - $go = wfMsg( 'go' );
443 - $sp = wfMsg( 'specialpages' );
444 - $spp = $wgContLang->specialPage( 'Specialpages' );
445 -
446 - $s = '<form id="specialpages" method="get" ' .
447 - 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
448 - $s .= "<select name=\"wpDropdown\">\n";
449 - $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
450 -
451 -
452 - foreach ( $pages as $name => $desc ) {
453 - $p = $wgContLang->specialPage( $name );
454 - $s .= "<option value=\"{$p}\">{$desc}</option>\n";
455 - }
456 -
457 - $s .= "</select>\n";
458 - $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
459 - $s .= "</form>\n";
460 -
461 - return $s;
 444+ return Html::rawElement( 'form', array( 'id' => 'specialpages', 'method' => 'get',
 445+ 'action' => $wgScript ), $select->getHTML() . Xml::submitButton( wfMsg( 'go' ) ) );
462446 }
463447
464448 function pageTitleLinks() {

Comments

#Comment by Nikerabbit (talk | contribs)   15:50, 11 October 2011

Where did {$wgServer}{$wgRedirectScript} go? Or does it go directly to the correct page now?

#Comment by IAlex (talk | contribs)   15:57, 11 October 2011

As stated in the last line of the commit summary, it goes to index.php?title=... instead of redirect.php?wpDropDown=...

Status & tagging log