r23413 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23412‎ | r23413 | r23414 >
Date:07:21, 26 June 2007
Author:raymond
Status:old
Tags:
Comment:
* (bug 10160) Show error message for unknown namespace on Special:Allpages and
Special:Prefixindex
* Making input forms prettier for RTL wikis.
* Use proper XML functions for input forms
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialAllpages.php (modified) (history)
  • /trunk/phase3/includes/SpecialPrefixindex.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesDe.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -1045,6 +1045,7 @@
10461046 'allpagessubmit',
10471047 'allpagesprefix',
10481048 'allpagesbadtitle',
 1049+ 'allpages-bad-ns',
10491050 ),
10501051 'listusers' => array(
10511052 'listusersfrom',
Index: trunk/phase3/includes/SpecialAllpages.php
@@ -19,10 +19,7 @@
2020
2121 $indexPage = new SpecialAllpages();
2222
23 - if( !in_array($namespace, array_keys($namespaces)) )
24 - $namespace = 0;
25 -
26 - $wgOut->setPagetitle( $namespace > 0 ?
 23+ $wgOut->setPagetitle( ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces) ) ) ?
2724 wfMsg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) ) :
2825 wfMsg( 'allarticles' )
2926 );
@@ -53,41 +50,44 @@
5451 * @param string $from Article name we are starting listing at.
5552 */
5653 function namespaceForm ( $namespace = NS_MAIN, $from = '' ) {
57 - global $wgScript;
 54+ global $wgScript, $wgContLang;
5855 $t = SpecialPage::getTitleFor( $this->name );
 56+ $align = $wgContLang->isRtl() ? 'left' : 'right';
5957
60 - $namespaceselect = HTMLnamespaceselector($namespace, null);
61 -
62 - $frombox = "<input type='text' size='20' name='from' id='nsfrom' value=\""
63 - . htmlspecialchars ( $from ) . '"/>';
64 - $submitbutton = '<input type="submit" value="' . wfMsgHtml( 'allpagessubmit' ) . '" />';
65 -
66 - $out = "<div class='namespaceoptions'><form method='get' action='{$wgScript}'>";
67 - $out .= '<input type="hidden" name="title" value="'.$t->getPrefixedText().'" />';
68 - $out .= "
69 -<table id='nsselect' class='allpages'>
70 - <tr>
71 - <td align='right'>" . wfMsgHtml($this->nsfromMsg) . "</td>
72 - <td align='left'><label for='nsfrom'>$frombox</label></td>
73 - </tr>
74 - <tr>
75 - <td align='right'><label for='namespace'>" . wfMsgHtml('namespace') . "</label></td>
76 - <td align='left'>
77 - $namespaceselect $submitbutton
78 - </td>
79 - </tr>
80 -</table>
81 -";
82 - $out .= '</form></div>';
83 - return $out;
 58+ $out = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) );
 59+ $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
 60+ $out .= Xml::hidden( 'title', $t->getPrefixedText() );
 61+ $out .= Xml::openElement( 'table', array( 'id' => 'nsselect', 'class' => 'allpages' ) );
 62+ $out .= "<tr>
 63+ <td align='$align'>" .
 64+ Xml::label( wfMsg( $this->nsfromMsg ), 'nsfrom' ) .
 65+ "</td>
 66+ <td>" .
 67+ Xml::input( 'from', 20, htmlspecialchars ( $from ), array( 'id' => 'nsfrom' ) ) .
 68+ "</td>
 69+ </tr>
 70+ <tr>
 71+ <td align='$align'>" .
 72+ Xml::label( wfMsg( 'namespace' ), 'namespace' ) .
 73+ "</td>
 74+ <td>" .
 75+ Xml::namespaceSelector( $namespace, null ) .
 76+ Xml::submitButton( wfMsg( 'allpagessubmit' ) ) .
 77+ "</td>
 78+ </tr>";
 79+ $out .= Xml::closeElement( 'table' );
 80+ $out .= Xml::closeElement( 'form' );
 81+ $out .= Xml::closeElement( 'div' );
 82+ return $out;
8483 }
8584
8685 /**
8786 * @param integer $namespace (default NS_MAIN)
8887 */
8988 function showToplevel ( $namespace = NS_MAIN, $including = false ) {
90 - global $wgOut;
 89+ global $wgOut, $wgContLang;
9190 $fname = "indexShowToplevel";
 91+ $align = $wgContLang->isRtl() ? 'left' : 'right';
9292
9393 # TODO: Either make this *much* faster or cache the title index points
9494 # in the querycache table.
@@ -170,8 +170,8 @@
171171 $morelinks = '';
172172 if ( $morelinks != '' ) {
173173 $out2 = '<table style="background: inherit;" width="100%" cellpadding="0" cellspacing="0" border="0">';
174 - $out2 .= '<tr valign="top"><td align="left">' . $nsForm;
175 - $out2 .= '</td><td align="right" style="font-size: smaller; margin-bottom: 1em;">';
 174+ $out2 .= '<tr valign="top"><td>' . $nsForm;
 175+ $out2 .= '</td><td align="' . $align . '" style="font-size: smaller; margin-bottom: 1em;">';
176176 $out2 .= $morelinks . '</td></tr></table><hr />';
177177 } else {
178178 $out2 = $nsForm . '<hr />';
@@ -187,6 +187,8 @@
188188 * @param integer $namespace (Default NS_MAIN)
189189 */
190190 function showline( $inpoint, $outpoint, $namespace = NS_MAIN ) {
 191+ global $wgContLang;
 192+ $align = $wgContLang->isRtl() ? 'left' : 'right';
191193 $inpointf = htmlspecialchars( str_replace( '_', ' ', $inpoint ) );
192194 $outpointf = htmlspecialchars( str_replace( '_', ' ', $outpoint ) );
193195 $queryparams = ($namespace ? "namespace=$namespace" : '');
@@ -196,9 +198,9 @@
197199 $out = wfMsgHtml(
198200 'alphaindexline',
199201 "<a href=\"$link\">$inpointf</a></td><td><a href=\"$link\">",
200 - "</a></td><td align=\"left\"><a href=\"$link\">$outpointf</a>"
 202+ "</a></td><td><a href=\"$link\">$outpointf</a>"
201203 );
202 - return '<tr><td align="right">'.$out.'</td></tr>';
 204+ return '<tr><td align="' . $align . '">'.$out.'</td></tr>';
203205 }
204206
205207 /**
@@ -209,14 +211,20 @@
210212 global $wgOut, $wgUser, $wgContLang;
211213
212214 $fname = 'indexShowChunk';
213 -
214215 $sk = $wgUser->getSkin();
215216
216217 $fromList = $this->getNamespaceKeyAndText($namespace, $from);
 218+ $namespaces = $wgContLang->getNamespaces();
 219+ $align = $wgContLang->isRtl() ? 'left' : 'right';
 220+
217221 $n = 0;
218 -
 222+
219223 if ( !$fromList ) {
220224 $out = wfMsgWikiHtml( 'allpagesbadtitle' );
 225+ } elseif ( !in_array( $namespace, array_keys( $namespaces ) ) ) {
 226+ // Show errormessage and reset to NS_MAIN
 227+ $out = wfMsgExt( 'allpages-bad-ns', array( 'parseinline' ), $namespace );
 228+ $namespace = NS_MAIN;
221229 } else {
222230 list( $namespace, $fromKey, $from ) = $fromList;
223231
@@ -298,8 +306,8 @@
299307
300308 $nsForm = $this->namespaceForm ( $namespace, $from );
301309 $out2 = '<table style="background: inherit;" width="100%" cellpadding="0" cellspacing="0" border="0">';
302 - $out2 .= '<tr valign="top"><td align="left">' . $nsForm;
303 - $out2 .= '</td><td align="right" style="font-size: smaller; margin-bottom: 1em;">' .
 310+ $out2 .= '<tr valign="top"><td>' . $nsForm;
 311+ $out2 .= '</td><td align="' . $align . '" style="font-size: smaller; margin-bottom: 1em;">' .
304312 $sk->makeKnownLink( $wgContLang->specialPage( "Allpages" ),
305313 wfMsgHtml ( 'allpages' ) );
306314
@@ -324,11 +332,16 @@
325333
326334 $wgOut->addHtml( $out2 . $out );
327335 if( isset($prevLink) or isset($nextLink) ) {
328 - $wgOut->addHtml( '<hr/><p style="font-size: smaller; float: right;">' );
329 - if( isset( $prevLink ) )
330 - $wgOut->addHTML( $prevLink . ' | ');
331 - if( isset( $nextLink ) )
 336+ $wgOut->addHtml( '<hr /><p style="font-size: smaller; float: ' . $align . '">' );
 337+ if( isset( $prevLink ) ) {
 338+ $wgOut->addHTML( $prevLink );
 339+ }
 340+ if( isset( $prevLink ) && isset( $nextLink ) ) {
 341+ $wgOut->addHTML( ' | ' );
 342+ }
 343+ if( isset( $nextLink ) ) {
332344 $wgOut->addHTML( $nextLink );
 345+ }
333346 $wgOut->addHTML( '</p>' );
334347
335348 }
Index: trunk/phase3/includes/SpecialPrefixindex.php
@@ -15,21 +15,15 @@
1616 $from = $wgRequest->getVal( 'from' );
1717 $prefix = $wgRequest->getVal( 'prefix' );
1818 $namespace = $wgRequest->getInt( 'namespace' );
19 -
2019 $namespaces = $wgContLang->getNamespaces();
2120
2221 $indexPage = new SpecialPrefixIndex();
2322
24 - if( !in_array($namespace, array_keys($namespaces)) )
25 - $namespace = 0;
 23+ $wgOut->setPagetitle( ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces ) ) )
 24+ ? wfMsg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) )
 25+ : wfMsg( 'allarticles' )
 26+ );
2627
27 - $wgOut->setPagetitle( $namespace > 0 ?
28 - wfMsg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) ) :
29 - wfMsg( 'allarticles' )
30 - );
31 -
32 -
33 -
3428 if ( isset($par) ) {
3529 $indexPage->showChunk( $namespace, $par, $specialPage->including(), $from );
3630 } elseif ( isset($prefix) ) {
@@ -67,9 +61,15 @@
6862
6963 $fromList = $this->getNamespaceKeyAndText($namespace, $from);
7064 $prefixList = $this->getNamespaceKeyAndText($namespace, $prefix);
 65+ $namespaces = $wgContLang->getNamespaces();
 66+ $align = $wgContLang->isRtl() ? 'left' : 'right';
7167
7268 if ( !$prefixList || !$fromList ) {
7369 $out = wfMsgWikiHtml( 'allpagesbadtitle' );
 70+ } elseif ( !in_array( $namespace, array_keys( $namespaces ) ) ) {
 71+ // Show errormessage and reset to NS_MAIN
 72+ $out = wfMsgExt( 'allpages-bad-ns', array( 'parseinline' ), $namespace );
 73+ $namespace = NS_MAIN;
7474 } else {
7575 list( $namespace, $prefixKey, $prefix ) = $prefixList;
7676 list( /* $fromNs */, $fromKey, $from ) = $fromList;
@@ -127,8 +127,8 @@
128128 } else {
129129 $nsForm = $this->namespaceForm ( $namespace, $prefix );
130130 $out2 = '<table style="background: inherit;" width="100%" cellpadding="0" cellspacing="0" border="0">';
131 - $out2 .= '<tr valign="top"><td align="left">' . $nsForm;
132 - $out2 .= '</td><td align="right" style="font-size: smaller; margin-bottom: 1em;">' .
 131+ $out2 .= '<tr valign="top"><td>' . $nsForm;
 132+ $out2 .= '</td><td align="' . $align . '" style="font-size: smaller; margin-bottom: 1em;">' .
133133 $sk->makeKnownLink( $wgContLang->specialPage( $this->name ),
134134 wfMsg ( 'allpages' ) );
135135 if ( isset($dbr) && $dbr && ($n == $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) {
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1652,6 +1652,7 @@
16531653 'allpagessubmit' => 'Go',
16541654 'allpagesprefix' => 'Display pages with prefix:',
16551655 'allpagesbadtitle' => 'The given page title was invalid or had an inter-language or inter-wiki prefix. It may contain one or more characters which cannot be used in titles.',
 1656+'allpages-bad-ns' => '{{SITENAME}} does not have namespace "$1".',
16561657
16571658 # Special:Listusers
16581659 'listusersfrom' => 'Display users starting at:',
Index: trunk/phase3/languages/messages/MessagesDe.php
@@ -1273,6 +1273,7 @@
12741274 'allpagessubmit' => 'Anwenden',
12751275 'allpagesprefix' => 'Seiten anzeigen mit Präfix:',
12761276 'allpagesbadtitle' => 'Der eingegebene Seitenname ist ungültig: Er hat entweder ein vorangestelltes Sprach-, ein Interwiki-Kürzel oder enthält ein oder mehrere Zeichen, welche in Seitennamen nicht verwendet werden dürfen.',
 1277+'allpages-bad-ns' => 'Der Namensraum „$1“ ist in {{SITENAME}} nicht vorhanden.',
12771278
12781279 # Special:Listusers
12791280 'listusersfrom' => 'Zeige Benutzer ab:',
Index: trunk/phase3/RELEASE-NOTES
@@ -208,6 +208,8 @@
209209 * Fixed zero-padding issues with MySQL 5 binary schema
210210 * (bug 10344) Don't follow a redirect after changing its protection level
211211 * (bug 10333) Correct date format in Slovenian
 212+* (bug 10160) Show error message for unknown namespace on Special:Allpages and
 213+ Special:Prefixindex; making forms prettier for RTL wikis.
212214
213215 == API changes since 1.10 ==
214216

Follow-up revisions

RevisionCommit summaryAuthorDate
r23581Merged revisions 23406-23580 via svnmerge from...david04:50, 30 June 2007

Status & tagging log