http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88344

Revision: 88344
Author:   robin
Date:     2011-05-17 20:04:35 +0000 (Tue, 17 May 2011)
Log Message:
-----------
Improve code (e.g. use Html::*() and Xml::*() functions and use buildLike() for 
DB queries)

Modified Paths:
--------------
    trunk/extensions/WikimediaIncubator/CreateAccountTestWiki.php
    trunk/extensions/WikimediaIncubator/SpecialRandomByTest.php
    trunk/extensions/WikimediaIncubator/SpecialViewUserLang.php

Modified: trunk/extensions/WikimediaIncubator/CreateAccountTestWiki.php
===================================================================
--- trunk/extensions/WikimediaIncubator/CreateAccountTestWiki.php       
2011-05-17 19:58:13 UTC (rev 88343)
+++ trunk/extensions/WikimediaIncubator/CreateAccountTestWiki.php       
2011-05-17 20:04:35 UTC (rev 88344)
@@ -12,9 +12,10 @@
                $projectvalue = strtolower( $wgRequest->getVal( 
'testwikiproject', '' ) );
                $codevalue = strtolower( $wgRequest->getVal( 'testwikicode', '' 
) );
                if ( preg_match( '/[a-z][a-z][a-z]?/', $codevalue ) && 
in_array( $projectvalue, (array)$wmincProjects ) ) {
-                       $template->set( 'header', '<input type="hidden" 
name="testwiki-project" value="' . $projectvalue . '" />
-       <input type="hidden" name="testwiki-code" value="' . $codevalue . '" />
-       ' );
+                       $template->set( 'header',
+                               Html::hidden('testwiki-project', $projectvalue).
+                               Html::hidden('testwiki-code', $codevalue)
+                       );
                }
                return true;
        }

Modified: trunk/extensions/WikimediaIncubator/SpecialRandomByTest.php
===================================================================
--- trunk/extensions/WikimediaIncubator/SpecialRandomByTest.php 2011-05-17 
19:58:13 UTC (rev 88343)
+++ trunk/extensions/WikimediaIncubator/SpecialRandomByTest.php 2011-05-17 
20:04:35 UTC (rev 88344)
@@ -9,8 +9,9 @@
        public function __construct() {
                global $wgUser, $wmincPref, $wmincProjectSite;
                if(IncubatorTest::isNormalPrefix()) {
-                       $this->extra[] = 'page_title like "W' . 
$wgUser->getOption($wmincPref . '-project') .
-                       '/' . $wgUser->getOption($wmincPref . '-code') . '/%%"';
+                       $dbr = wfGetDB( DB_SLAVE );
+                       $this->extra[] = 'page_title' .
+                               $dbr->buildLike( IncubatorTest::displayPrefix() 
. '/', $dbr->anyString() );
                } elseif($wgUser->getOption($wmincPref . '-project') == 
$wmincProjectSite['short'] ) {
                        // project or help namespace
                        $this->extra['page_namespace'] = array( 4, 12 );

Modified: trunk/extensions/WikimediaIncubator/SpecialViewUserLang.php
===================================================================
--- trunk/extensions/WikimediaIncubator/SpecialViewUserLang.php 2011-05-17 
19:58:13 UTC (rev 88343)
+++ trunk/extensions/WikimediaIncubator/SpecialViewUserLang.php 2011-05-17 
20:04:35 UTC (rev 88344)
@@ -71,31 +71,32 @@
         * @param $target Mixed: user whose language and test wiki we're 
looking up
         */
        function showInfo( $target ) {
-               global $wgOut, $wgLang, $wmincPref;
+               global $wgOut, $wgLang, $wmincPref, $wmincProjectSite;
+               $sk = $this->getSkin();
                $user = User::newFromName( $target );
                $langNames = Language::getLanguageNames();
                if ( $user == null || $user->getId() == 0 ) {
-                       $wgOut->addWikiText( '<span class="error">' . 
wfMsgNoTrans( 'wminc-userdoesnotexist', $target ) . '</span>' );
+                       // show error if a user with that name does not exist
+                       $wgOut->addHTML( Xml::span( wfMsg( 
'wminc-userdoesnotexist', $target ), 'error' ) );
                } else {
-                       $name = $user->getName();
-                       $wgOut->addWikiText( '*' . wfMsg( 'username' ) . ' 
[[User:' . $name . '|' . $name . ']] (' .
-                               $wgLang->pipeList( array(
-                                       '[[User talk:' . $name . '|' . wfMsg( 
'talkpagelinktext' ) . ']]',
-                                       '[[Special:Contributions/' . $name . 
'|' . wfMsg( 'contribslink' ) . ']])'
-                               ) ) );
-                       $wgOut->addWikiText(
-                               '*' . wfMsg( 'loginlanguagelabel',
-                               $langNames[$user->mOptions['language']] . ' (' 
. $user->mOptions['language'] . ')'
-                               )
-                       );
                        if ( IncubatorTest::isNormalPrefix() == true ) {
-                               $testwiki = '[[W' . $user->mOptions[$wmincPref 
. '-project'] . '/' . $user->mOptions[$wmincPref . '-code'] . ']]';
-                       } elseif ( IncubatorTest::displayPrefix() == 'inc' ) {
-                               $testwiki = 'Incubator';
+                               $testwiki = Linker::link( 'W' . 
$user->getOption($wmincPref . '-project') .
+                                       '/' . $user->getOption($wmincPref . 
'-code') );
+                       } elseif ( IncubatorTest::displayPrefix() == 
$wmincProjectSite['short'] ) {
+                               $testwiki = $wmincProjectSite['name'];
                        } else {
                                $testwiki = wfMsg( 'wminc-testwiki-none' );
                        }
-                               $wgOut->addWikiText( '*' . wfMsg( 
'wminc-testwiki' ) . ' ' . $testwiki );
+                       $name = $user->getName();
+                       $wgOut->addHtml(
+                               Xml::openElement( 'ul' ) .
+                               '<li>' . wfMsg( 'username' ) . ' ' .
+                                       $sk->userLink( $name, $name ) . 
$sk->userToolLinks( $name, $name ) . '</li>' .
+                               '<li>' . wfMsg( 'loginlanguagelabel', 
$langNames[$user->getOption( 'language' )] .
+                                       ' (' . $user->getOption( 'language' ) . 
')' ) . '</li>' .
+                               '<li>' . wfMsg( 'wminc-testwiki' ) . ' ' . 
$testwiki . '</li>' .
+                               Xml::closeElement( 'ul' )
+                       );
                }
        }
 }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to