r94452 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94451‎ | r94452 | r94453 >
Date:12:31, 14 August 2011
Author:robin
Status:ok
Tags:
Comment:
Followup r94434:
* Make the message names in showMissingWiki() searchable
* Use str_replace() instead of preg_replace()
Plus some more documentation
Modified paths:
  • /trunk/extensions/WikimediaIncubator/IncubatorTest.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/InfoPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikimediaIncubator/IncubatorTest.php
@@ -318,7 +318,7 @@
319319 # no permission if the wiki already exists
320320 $link = self::getSubdomain( $prefixdata['lang'],
321321 $prefixdata['project'], ( $title->getNsText() ? $title->getNsText() . ':' : '' ) .
322 - preg_replace( '/ /', '_', $prefixdata['realtitle'] ) );
 322+ str_replace( ' ', '_', $prefixdata['realtitle'] ) );
323323 $result[] = array( 'wminc-error-wiki-exists', $link );
324324 return false;
325325 }
@@ -415,7 +415,7 @@
416416 return false; # shouldn't be, but you never know
417417 }
418418 global $wmincProjectDatabases;
419 - return preg_replace('/-/', '_', $prefix['lang'] ) .
 419+ return str_replace('-', '_', $prefix['lang'] ) .
420420 $wmincProjectDatabases[$prefix['project']];
421421 }
422422
@@ -565,7 +565,7 @@
566566 return $wgConf->get( 'wgServer',
567567 self::getDB( $prefix ), $projectName,
568568 array( 'lang' => str_replace( '_', '-', $lang ), 'site' => $projectName )
569 - ) . ( $title ? preg_replace( '/\$1/', $title, $wgArticlePath ) : '' );
 569+ ) . ( $title ? str_replace( '$1', $title, $wgArticlePath ) : '' );
570570 }
571571
572572 /**
@@ -652,14 +652,14 @@
653653 return false;
654654 }
655655 global $wgLogo;
656 - $prefixForPageTitle = preg_replace('/\//', '-', strtolower( $setLogo['prefix'] ) );
 656+ $prefixForPageTitle = str_replace( '/', '-', strtolower( $setLogo['prefix'] ) );
657657 $file = wfFindFile( wfMsgForContentNoTrans( 'Incubator-logo-' . $prefixForPageTitle ) );
658658 if( !$file ) {
659659 # if MediaWiki:Incubator-logo-wx-xx(x) doesn't exist,
660660 # try a general, default logo for that project
661661 global $wmincProjects;
662662 $project = $setLogo['project'];
663 - $projectForFile = preg_replace('/ /', '-', strtolower( $wmincProjects[$project] ) );
 663+ $projectForFile = str_replace( ' ', '-', strtolower( $wmincProjects[$project] ) );
664664 $imageobj = wfFindFile( wfMsg( 'wminc-logo-' . $projectForFile ) );
665665 if( $imageobj ) {
666666 $thumb = $imageobj->transform( array( 'width' => 135, 'height' => 135 ) );
Index: trunk/extensions/WikimediaIncubator/InfoPage.php
@@ -46,6 +46,7 @@
4747 /**
4848 * Small convenience function to display a (clickable) logo
4949 * @param $project Project name
 50+ * @return String
5051 */
5152 public function makeLogo( $project, $clickable = true, $width = 25, $height = '', $url = '', $args = array() ) {
5253 global $wgUser;
@@ -72,6 +73,10 @@
7374 );
7475 }
7576
 77+ /**
 78+ * @return String: list of clickable logos of other projects
 79+ * (Wikipedia, Wiktionary, ...)
 80+ */
7681 public function listOtherProjects() {
7782 global $wmincProjects, $wmincSisterProjects;
7883 $otherProjects = $wmincProjects + $wmincSisterProjects;
@@ -84,6 +89,10 @@
8590 implode( '', $listOtherProjects ) . '</ul>';
8691 }
8792
 93+ /**
 94+ * @return String: list of clickable logos of multilingual projects
 95+ * (Meta, Commons, ...)
 96+ */
8897 public function listMultilingualProjects() {
8998 global $wmincMultilingualProjects;
9099 if( !is_array( $wmincMultilingualProjects ) ) { return; }
@@ -95,11 +104,17 @@
96105 implode( '', $list ) . '</ul>';
97106 }
98107
 108+ /**
 109+ * @return String: "Welcome to Incubator" message
 110+ */
99111 public function showWelcome() {
100112 return Html::rawElement( 'div', array( 'class' => 'wminc-infopage-welcome' ),
101113 wfMsgWikiHtml( 'wminc-infopage-welcome' ) );
102114 }
103115
 116+ /**
 117+ * @return String: the core HTML for the info page
 118+ */
104119 public function StandardInfoPage( $beforetitle, $aftertitle, $content ) {
105120 global $wgLang, $wgOut;
106121 $wgOut->addModules( 'WikimediaIncubator.InfoPage' );
@@ -114,6 +129,9 @@
115130 $content );
116131 }
117132
 133+ /**
 134+ * @return String
 135+ */
118136 public function showMissingWiki() {
119137 $content = Html::rawElement( 'div',
120138 array( 'class' => 'wminc-infopage-status' ),
@@ -122,7 +140,7 @@
123141 ) .
124142 Html::rawElement( 'ul', array( 'class' => 'wminc-infopage-options' ),
125143 Html::rawElement( 'li', null,
126 - wfMsgExt( 'wminc-infopage-option-' . ( $this->mIsSister ? 'startsister' : 'startwiki' ),
 144+ wfMsgExt( $this->mIsSister ? 'wminc-infopage-option-startsister' : 'wminc-infopage-option-startwiki',
127145 array( 'parseinline' ), $this->mProjectName, $this->mPortal ) ) .
128146 Html::rawElement( 'li', null,
129147 wfMsgExt( 'wminc-infopage-option-languages-existing',
@@ -137,6 +155,9 @@
138156 return $this->StandardInfoPage( $this->showWelcome(), '', $content );
139157 }
140158
 159+ /**
 160+ * @return String
 161+ */
141162 public function showIncubatingWiki() {
142163 global $wgUser, $wgLang;
143164 $substatus = $this->mSubStatus;
@@ -164,6 +185,9 @@
165186 return $this->StandardInfoPage( '', $gotoMainPage, $content );
166187 }
167188
 189+ /**
 190+ * @return String
 191+ */
168192 public function showExistingWiki() {
169193 global $wgLang, $wgUser;
170194 $created = isset( $this->mCreated ) ? $this->mCreated : '';

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r94434* Better support for sister projects (wikiversity / wikisource): direct users...robin21:41, 13 August 2011

Status & tagging log