Index: trunk/extensions/WikimediaIncubator/WikimediaIncubator.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | 'path' => __FILE__, |
16 | 16 | 'name' => 'Wikimedia Incubator', |
17 | 17 | 'author' => 'SPQRobin', |
18 | | - 'version' => '4.1', |
| 18 | + 'version' => '4.2', |
19 | 19 | 'url' => 'http://www.mediawiki.org/wiki/Extension:WikimediaIncubator', |
20 | 20 | 'descriptionmsg' => 'wminc-desc', |
21 | 21 | ); |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | /* General (globals and/or configuration) */ |
24 | 24 | $wmincPref = 'incubatortestwiki'; // Name of the preference |
25 | 25 | $dir = dirname( __FILE__ ) . '/'; |
26 | | -$wmincScriptDir = $wgScriptPath . '/extensions/WikimediaIncubator/'; |
| 26 | +$wmincScriptDir = $wgExtensionAssetsPath . '/WikimediaIncubator/'; |
27 | 27 | # only one-letter codes can be used for projects |
28 | 28 | $wmincProjects = array( |
29 | 29 | 'p' => 'Wikipedia', |
— | — | @@ -133,7 +133,7 @@ |
134 | 134 | $wgResourceModules['WikimediaIncubator.InfoPage'] = array( |
135 | 135 | 'styles' => 'InfoPage.css', |
136 | 136 | 'localBasePath' => dirname(__FILE__), |
137 | | - 'remoteExtPath' => $wmincScriptDir, |
| 137 | + 'remoteExtPath' => 'WikimediaIncubator', |
138 | 138 | ); |
139 | 139 | |
140 | 140 | /* Possibility to set a logo per test wiki */ |
Index: trunk/extensions/WikimediaIncubator/IncubatorTest.php |
— | — | @@ -114,11 +114,13 @@ |
115 | 115 | } |
116 | 116 | } |
117 | 117 | global $wmincProjects, $wmincSisterProjects; |
118 | | - $listProjects = implode( '', array_keys( $wmincProjects ) ); # project codes like: pbtqn |
| 118 | + $listProjects = array_map( 'preg_quote', array_keys( $wmincProjects ) ); |
119 | 119 | if( $allowSister && is_array( $wmincSisterProjects ) ) { |
120 | | - # join the project codes with those of the sister projects, like: pbtqnsv |
121 | | - $listProjects = $listProjects . implode( '', array_keys( $wmincSisterProjects ) ); |
| 120 | + # join the project codes with those of the sister projects |
| 121 | + $listSister = array_map( 'preg_quote', array_keys( $wmincSisterProjects ) ); |
| 122 | + $listProjects = array_merge( $listProjects, $listSister ); |
122 | 123 | } |
| 124 | + $listProjects = implode( '|', $listProjects ); |
123 | 125 | if( !preg_match( '/^W['.$listProjects.']\/[a-z-]+' . |
124 | 126 | ($onlyInfoPage ? '$/' : '(\/.+)?$/' ), $title ) ) { |
125 | 127 | $data['error'] = 'invalidprefix'; |
— | — | @@ -278,9 +280,10 @@ |
279 | 281 | * @return Boolean |
280 | 282 | */ |
281 | 283 | static function shouldWeShowUnprefixedError( $title ) { |
282 | | - global $wmincTestWikiNamespaces, $wmincProjectSite; |
| 284 | + global $wmincTestWikiNamespaces, $wmincProjectSite, $wmincPseudoCategoryNSes; |
283 | 285 | $prefixdata = self::analyzePrefix( $title->getText() ); |
284 | 286 | $ns = $title->getNamespace(); |
| 287 | + $categories = array_map( 'preg_quote', $wmincPseudoCategoryNSes ); |
285 | 288 | if( !$prefixdata['error'] ) { |
286 | 289 | # no error in prefix -> no error to show |
287 | 290 | return false; |
— | — | @@ -291,7 +294,7 @@ |
292 | 295 | # OK if it's not in one of the content namespaces |
293 | 296 | return false; |
294 | 297 | } elseif( ( $ns == NS_CATEGORY || $ns == NS_CATEGORY_TALK ) && |
295 | | - preg_match( '/^(' . implode( '|', $wmincPseudoCategoryNSes ) .'):.+$/', $title->getText() ) ) { |
| 298 | + preg_match( '/^(' . implode( '|', $categories ) .'):.+$/', $title->getText() ) ) { |
296 | 299 | # whitelisted unprefixed categories |
297 | 300 | return false; |
298 | 301 | } |
— | — | @@ -411,7 +414,7 @@ |
412 | 415 | static function getDB( $prefix ) { |
413 | 416 | if( !self::canWeCheckDB() ) { |
414 | 417 | return false; |
415 | | - } elseif( !isset( $prefix ) || $prefix['error'] ) { |
| 418 | + } elseif( !$prefix || $prefix['error'] ) { |
416 | 419 | return false; # shouldn't be, but you never know |
417 | 420 | } |
418 | 421 | global $wmincProjectDatabases; |
— | — | @@ -471,11 +474,10 @@ |
472 | 475 | global $wmincSisterProjects; |
473 | 476 | $prefix2 = self::analyzePrefix( $title->getText(), false, true ); |
474 | 477 | $linker = class_exists( 'DummyLinker' ) ? new DummyLinker : new Linker; |
475 | | - $p = $prefix2['project']; |
476 | | - $link = self::getSubdomain( $prefix2['lang'], $p, |
477 | | - ( $title->getNsText() ? $title->getNsText() . ':' : '' ) . |
478 | | - $prefix2['realtitle'] ); |
| 478 | + $p = isset( $prefix2['project' ] ) ? $prefix2['project'] : ''; |
479 | 479 | if( self::getDBState( $prefix2 ) == 'existing' ) { |
| 480 | + $link = self::getSubdomain( $prefix2['lang'], $p, |
| 481 | + ( $title->getNsText() ? $title->getNsText() . ':' : '' ) . $prefix2['realtitle'] ); |
480 | 482 | if( self::displayPrefix() == $prefix2['prefix'] ) { |
481 | 483 | # Redirect to the existing wiki if the user has this wiki as preference |
482 | 484 | $wgOut->redirect( $link ); |
— | — | @@ -489,6 +491,8 @@ |
490 | 492 | } |
491 | 493 | } elseif( array_key_exists( $p, $wmincSisterProjects ) ) { |
492 | 494 | # A sister project is not hosted here, so direct the user to the relevant wiki |
| 495 | + $link = self::getSubdomain( $prefix2['lang'], $p, |
| 496 | + ( $title->getNsText() ? $title->getNsText() . ':' : '' ) . $prefix2['realtitle'] ); |
493 | 497 | $showLink = $linker->makeExternalLink( $link, $link ); |
494 | 498 | $wgOut->addHtml( '<div class="wminc-wiki-sister">' . |
495 | 499 | wfMsgHtml( 'wminc-error-wiki-sister', $showLink ) . |
— | — | @@ -529,7 +533,7 @@ |
530 | 534 | $wgOut->addHtml( $infopage->showMissingWiki() ); |
531 | 535 | } |
532 | 536 | # Set the page title from "Wx/xyz - Incubator" to "Wikiproject Language - Incubator" |
533 | | - $wgOut->setHTMLTitle( wfMsg( 'pagetitle', htmlspecialchars( $infopage->mFormatTitle ) ) ); |
| 537 | + $wgOut->setHTMLTitle( wfMsg( 'pagetitle', $infopage->mFormatTitle ) ); |
534 | 538 | return true; |
535 | 539 | } |
536 | 540 | |
— | — | @@ -579,7 +583,7 @@ |
580 | 584 | public static function getMainPage( $langCode, $prefix = null ) { |
581 | 585 | # Take the "mainpage" msg in the given language |
582 | 586 | $msg = wfMsgExt( 'mainpage', array( 'language' => $langCode ) ); |
583 | | - return isset( $prefix ) ? $prefix . '/' . $msg : $msg; |
| 587 | + return $prefix !== null ? $prefix . '/' . $msg : $msg; |
584 | 588 | } |
585 | 589 | |
586 | 590 | /** |
Index: trunk/extensions/WikimediaIncubator/InfoPage.php |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | $this->mLangNames = IncubatorTest::getLanguageNames(); |
41 | 41 | $this->mLangName = ( isset( $this->mLangNames[$this->mLangCode] ) ? |
42 | 42 | $this->mLangNames[$this->mLangCode] : wfMsg( 'wminc-unknownlang', $this->mLangCode ) ); |
43 | | - $this->mFormatTitle = wfMsg( 'wminc-infopage-title', $this->mProjectName, $this->mLangName ); |
| 43 | + $this->mFormatTitle = wfMsgHtml( 'wminc-infopage-title', $this->mProjectName, $this->mLangName ); |
44 | 44 | return; |
45 | 45 | } |
46 | 46 | |
— | — | @@ -117,7 +117,7 @@ |
118 | 118 | */ |
119 | 119 | public function StandardInfoPage( $beforetitle, $aftertitle, $content ) { |
120 | 120 | global $wgLang, $wgOut; |
121 | | - $wgOut->addModules( 'WikimediaIncubator.InfoPage' ); |
| 121 | + $wgOut->addModuleStyles( 'WikimediaIncubator.InfoPage' ); |
122 | 122 | return Html::rawElement( 'div', array( 'class' => 'wminc-infopage plainlinks', |
123 | 123 | 'lang' => $wgLang->getCode(), 'dir' => $wgLang->getDir() ), |
124 | 124 | $beforetitle . |
— | — | @@ -190,8 +190,8 @@ |
191 | 191 | */ |
192 | 192 | public function showExistingWiki() { |
193 | 193 | global $wgLang, $wgUser; |
194 | | - $created = isset( $this->mCreated ) ? $this->mCreated : ''; |
195 | | - $bug = isset( $this->mBug ) ? $this->mBug : ''; |
| 194 | + $created = isset( $this->mCreated ) ? $this->mCreated : ''; # for future use |
| 195 | + $bug = isset( $this->mBug ) ? $this->mBug : ''; # for future use |
196 | 196 | $subdomain = IncubatorTest::getSubdomain( $this->mLangCode, $this->mProjectCode ); |
197 | 197 | $subdomainLink = $wgUser->getSkin()->makeExternalLink( $subdomain, $subdomain ); |
198 | 198 | if( $this->mThisLangData['type'] != 'invalid' ) { |
— | — | @@ -201,7 +201,7 @@ |
202 | 202 | } |
203 | 203 | $content = Html::rawElement( 'div', |
204 | 204 | array( 'class' => 'wminc-infopage-status' ), |
205 | | - wfMsg( 'wminc-infopage-status-' . $this->mSubStatus, $subdomainLink ) |
| 205 | + wfMsgWikiHtml( 'wminc-infopage-status-' . $this->mSubStatus, $subdomainLink ) |
206 | 206 | ) . Html::rawElement( 'ul', array( 'class' => 'wminc-infopage-options' ), |
207 | 207 | Html::rawElement( 'li', null, wfMsgWikiHtml( 'wminc-infopage-option-sisterprojects-other' ) . |
208 | 208 | $this->listOtherProjects() ) . |