r44281 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44280‎ | r44281 | r44282 >
Date:15:30, 7 December 2008
Author:nikerabbit
Status:ok
Tags:
Comment:
* Improvements
Modified paths:
  • /trunk/extensions/Translate/SpecialTranslations.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/SpecialTranslations.php
@@ -68,9 +68,14 @@
6969 * @param string $from dbKey we are starting listing at.
7070 */
7171 function namespaceMessageForm( $namespace = NS_MAIN, $message = '' ) {
72 - global $wgScript;
 72+ global $wgContLang, $wgScript, $wgTranslateMessageNamespaces;
7373 $t = $this->getTitle();
7474
 75+ $namespaces = new XmlSelect( 'namespace' );
 76+ foreach ($wgTranslateMessageNamespaces as $ns ) {
 77+ $namespaces->addOption( $wgContLang->getFormattedNsText( $ns ), $ns );
 78+ }
 79+
7580 $out = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) );
7681 $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
7782 $out .= Xml::hidden( 'title', $t->getPrefixedText() );
@@ -90,7 +95,7 @@
9196 Xml::label( wfMsg( 'namespace' ), 'namespace' ) .
9297 "</td>
9398 <td class='mw-input'>" .
94 - Xml::namespaceSelector( $namespace, null ) . ' ' .
 99+ $namespaces->getHTML() . ' ' .
95100 Xml::submitButton( wfMsg( 'allpagessubmit' ) ) .
96101 "</td>
97102 </tr>";
@@ -141,15 +146,15 @@
142147 )
143148 );
144149
145 - # FIXME: there probably is some smart way to get everything needed
146 - # using TranslateUtils::getContents() only once.
 150+ if( $res->numRows() ) {
 151+ $titles = array();
 152+ foreach ( $res as $s ) { $titles[] = $s->page_title; }
 153+ $pageInfo = TranslateUtils::getContents( $titles, $namespace );
147154
148 - $n = 0;
149 - if( $res->numRows() > 0 ) {
150155 // Adapted version of TranslateUtils:makeListing() by Nikerabbit
151156 $out = TranslateUtils::tableHeader();
152157
153 - while( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
 158+ foreach ( $res as $s ) {
154159 $key = $s->page_title;
155160 $t = Title::makeTitle( $s->page_namespace, $key );
156161
@@ -167,7 +172,6 @@
168173 $extra = '';
169174
170175 $leftColumn = $anchor . $tools['edit'] . $extra;
171 - $pageInfo = TranslateUtils::getContents( array( $key ), $namespace );
172176 $out .= Xml::tags( 'tr', array( 'class' => 'def' ),
173177 Xml::tags( 'td', null, $leftColumn ) .
174178 Xml::tags( 'td', null, TranslateUtils::convertWhiteSpaceToHTML( $pageInfo[$key][0] ) )

Status & tagging log