Index: branches/wmf/1.18wmf1/extensions/WikimediaIncubator/InfoPage.css |
— | — | @@ -50,6 +50,6 @@ |
51 | 51 | #ca-nstab-main a { |
52 | 52 | color: black; |
53 | 53 | } |
54 | | -.subpages { |
55 | | - display: none; |
| 54 | +span.subpages { |
| 55 | + display: none !important; |
56 | 56 | } |
\ No newline at end of file |
Index: branches/wmf/1.18wmf1/extensions/WikimediaIncubator/WikimediaIncubator.php |
— | — | @@ -5,6 +5,8 @@ |
6 | 6 | * for a test wiki system (i.e. incubated wikis inside one actual wiki) |
7 | 7 | * mainly intended for the Wikimedia Incubator |
8 | 8 | * |
| 9 | + * MediaWiki 1.18 or higher required |
| 10 | + * |
9 | 11 | * @file |
10 | 12 | * @ingroup Extensions |
11 | 13 | * @author Robin Pepermans (SPQRobin) |
— | — | @@ -14,8 +16,8 @@ |
15 | 17 | 'path' => __FILE__, |
16 | 18 | 'name' => 'Wikimedia Incubator', |
17 | 19 | 'author' => 'SPQRobin', |
18 | | - 'version' => '4.3.2', |
19 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:WikimediaIncubator', |
| 20 | + 'version' => '4.5', |
| 21 | + 'url' => '//www.mediawiki.org/wiki/Extension:WikimediaIncubator', |
20 | 22 | 'descriptionmsg' => 'wminc-desc', |
21 | 23 | ); |
22 | 24 | |
— | — | @@ -64,6 +66,7 @@ |
65 | 67 | $wgGroupPermissions['test-sysop']['block'] = true; |
66 | 68 | $wgGroupPermissions['test-sysop']['blockemail'] = true; |
67 | 69 | $wgGroupPermissions['test-sysop']['rollback'] = true; |
| 70 | +$wgGroupPermissions['test-sysop']['suppressredirect'] = true; |
68 | 71 | $wgAddGroups['bureaucrat'][] = 'test-sysop'; |
69 | 72 | $wgRemoveGroups['bureaucrat'][] = 'test-sysop'; |
70 | 73 | |
— | — | @@ -141,3 +144,14 @@ |
142 | 145 | |
143 | 146 | /* Set page content language depending on the prefix */ |
144 | 147 | $wgHooks['PageContentLanguage'][] = 'IncubatorTest::onPageContentLanguage'; |
| 148 | + |
| 149 | +/* List of users */ |
| 150 | +$wgAutoloadClasses['ListUsersTestWiki'] = $dir . 'ListUsersTestWiki.php'; |
| 151 | +$wgHooks['SpecialListusersHeaderForm'][] = 'ListUsersTestWiki::onSpecialListusersHeaderForm'; |
| 152 | +$wgHooks['SpecialListusersQueryInfo'][] = 'ListUsersTestWiki::onSpecialListusersQueryInfo'; |
| 153 | +$wgHooks['SpecialListusersHeader'][] = 'ListUsersTestWiki::onSpecialListusersHeader'; |
| 154 | + |
| 155 | +/* Search in test wiki */ |
| 156 | +$wgHooks['SpecialSearchCreateLink'][] = 'IncubatorTest::onSpecialSearchCreateLink'; |
| 157 | +$wgHooks['SpecialSearchPowerBox'][] = 'IncubatorTest::onSpecialSearchPowerBox'; |
| 158 | +$wgHooks['SpecialSearchSetupEngine'][] = 'IncubatorTest::onSpecialSearchSetupEngine'; |
Index: branches/wmf/1.18wmf1/extensions/WikimediaIncubator/SpecialRandomByTest.php |
— | — | @@ -20,12 +20,8 @@ |
21 | 21 | $this->extra[] = 'page_title' . |
22 | 22 | $dbr->buildLike( IncubatorTest::displayPrefix( $project, $lang ) . '/', $dbr->anyString() ); |
23 | 23 | } elseif( $wgUser->getOption($wmincPref . '-project') == $wmincProjectSite['short'] ) { |
24 | | - global $wgVersion; |
25 | | - # only works above MW 1.17 |
26 | | - if( version_compare($wgVersion, '1.17', '>') ) { |
27 | | - # project or help namespace |
28 | | - $this->extra['page_namespace'] = array( 4, 12 ); |
29 | | - } |
| 24 | + # project or help namespace |
| 25 | + $this->extra['page_namespace'] = array( 4, 12 ); |
30 | 26 | } |
31 | 27 | parent::__construct( 'RandomByTest' ); |
32 | 28 | } |
Index: branches/wmf/1.18wmf1/extensions/WikimediaIncubator/SpecialViewUserLang.php |
— | — | @@ -16,6 +16,9 @@ |
17 | 17 | parent::__construct( 'ViewUserLang', 'viewuserlang' ); |
18 | 18 | } |
19 | 19 | |
| 20 | + /** |
| 21 | + * @return String |
| 22 | + */ |
20 | 23 | function getDescription() { return wfMsg( 'wminc-viewuserlang' ); } |
21 | 24 | |
22 | 25 | /** |
— | — | @@ -70,7 +73,8 @@ |
71 | 74 | global $wgOut, $wmincPref, $wmincProjectSite; |
72 | 75 | if( User::isIP( $target ) ) { |
73 | 76 | # show error if it is an IP address |
74 | | - return $wgOut->addHTML( Xml::span( wfMsg( 'wminc-ip', $target ), 'error' ) ); |
| 77 | + $wgOut->addHTML( Xml::span( wfMsg( 'wminc-ip', $target ), 'error' ) ); |
| 78 | + return; |
75 | 79 | } |
76 | 80 | $user = User::newFromName( $target ); |
77 | 81 | $name = $user->getName(); |
— | — | @@ -79,7 +83,8 @@ |
80 | 84 | $linker = class_exists( 'DummyLinker' ) ? new DummyLinker : new Linker; |
81 | 85 | if ( $user == null || $id == 0 ) { |
82 | 86 | # show error if a user with that name does not exist |
83 | | - return $wgOut->addHTML( Xml::span( wfMsg( 'wminc-userdoesnotexist', $target ), 'error' ) ); |
| 87 | + $wgOut->addHTML( Xml::span( wfMsg( 'wminc-userdoesnotexist', $target ), 'error' ) ); |
| 88 | + return; |
84 | 89 | } |
85 | 90 | $userproject = $user->getOption( $wmincPref . '-project' ); |
86 | 91 | $userproject = ( $userproject ? $userproject : 'none' ); |
Index: branches/wmf/1.18wmf1/extensions/WikimediaIncubator/ListUsersTestWiki.php |
— | — | @@ -0,0 +1,77 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Ability to filter list of users based on their test wiki preference |
| 6 | + */ |
| 7 | +class ListUsersTestWiki { |
| 8 | + /** |
| 9 | + * If the &testwiki= parameter matches the project site (Incubator), return that |
| 10 | + * @return Array or null |
| 11 | + */ |
| 12 | + static function getProjectInput() { |
| 13 | + global $wmincProjectSite, $wgRequest; |
| 14 | + $input = strtolower( $wgRequest->getVal( 'testwiki' ) ); |
| 15 | + if( $input == strtolower( $wmincProjectSite['name'] ) || $input == strtolower( $wmincProjectSite['short'] ) ) { |
| 16 | + return $wmincProjectSite; |
| 17 | + } |
| 18 | + return null; |
| 19 | + } |
| 20 | + |
| 21 | + /** |
| 22 | + * Input form |
| 23 | + */ |
| 24 | + static function onSpecialListusersHeaderForm( $pager, &$out ) { |
| 25 | + $testwiki = IncubatorTest::getUrlParam(); |
| 26 | + $project = self::getProjectInput(); |
| 27 | + $input = $project ? $project['name'] : ( $testwiki ? $testwiki['prefix'] : null ); |
| 28 | + $out .= Xml::label( wfMsg( 'wminc-testwiki' ), 'testwiki' ) . ' ' . |
| 29 | + Xml::input( 'testwiki', 20, $input, array( 'id' => 'testwiki' ) ) . '<br />'; |
| 30 | + return true; |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * Show a message that you are viewing a list of users of a certain test wiki |
| 35 | + * @param $pager |
| 36 | + * @param $out |
| 37 | + * @return bool |
| 38 | + */ |
| 39 | + static function onSpecialListusersHeader( $pager, &$out ) { |
| 40 | + $project = self::getProjectInput(); |
| 41 | + if( $project ) { |
| 42 | + $out .= wfMsgWikiHtml( 'wminc-listusers-testwiki', '"' . $project['name'] . '"' ); |
| 43 | + } else { |
| 44 | + $testwiki = IncubatorTest::getUrlParam(); |
| 45 | + if ( $testwiki ) { |
| 46 | + $link = Linker::linkKnown( Title::newFromText( $testwiki['prefix'] ) ); |
| 47 | + $out .= wfMsgWikiHtml( 'wminc-listusers-testwiki', $link ); |
| 48 | + } |
| 49 | + } |
| 50 | + return true; |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * Query |
| 55 | + */ |
| 56 | + static function onSpecialListusersQueryInfo( $pager, &$query ) { |
| 57 | + $testwiki = IncubatorTest::getUrlParam(); |
| 58 | + $project = self::getProjectInput(); |
| 59 | + if( !$project && !$testwiki ) { |
| 60 | + return true; # no input or invalid input |
| 61 | + } |
| 62 | + global $wmincPref; |
| 63 | + $query['tables']['p1'] = 'user_properties'; |
| 64 | + $query['join_conds']['p1'] = array( 'JOIN', array( 'user_id=p1.up_user', |
| 65 | + 'p1.up_property' => "$wmincPref-project", |
| 66 | + 'p1.up_value' => $project ? $project['short'] : $testwiki['project'] |
| 67 | + ) ); |
| 68 | + if( $project ) { |
| 69 | + return true; # project site doesn't need language code = returning |
| 70 | + } |
| 71 | + $query['tables']['p2'] = 'user_properties'; |
| 72 | + $query['join_conds']['p2'] = array( 'JOIN', array( 'user_id=p2.up_user', |
| 73 | + 'p2.up_property' => "$wmincPref-code", |
| 74 | + 'p2.up_value' => $testwiki['lang'] |
| 75 | + ) ); |
| 76 | + return true; |
| 77 | + } |
| 78 | +} |
Property changes on: branches/wmf/1.18wmf1/extensions/WikimediaIncubator/ListUsersTestWiki.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 79 | + native |
Added: svn:keywords |
2 | 80 | + Id |
Index: branches/wmf/1.18wmf1/extensions/WikimediaIncubator/CreateAccountTestWiki.php |
— | — | @@ -12,6 +12,11 @@ |
13 | 13 | */ |
14 | 14 | |
15 | 15 | class AutoTestWiki { |
| 16 | + |
| 17 | + /** |
| 18 | + * @param $template UsercreateTemplate|UserloginTemplate |
| 19 | + * @return bool |
| 20 | + */ |
16 | 21 | public static function onUserCreateForm( $template ) { |
17 | 22 | global $wgRequest, $wmincProjects; |
18 | 23 | $projectvalue = strtolower( $wgRequest->getVal( 'testwikiproject', '' ) ); |
— | — | @@ -25,6 +30,10 @@ |
26 | 31 | return true; |
27 | 32 | } |
28 | 33 | |
| 34 | + /** |
| 35 | + * @param $user User |
| 36 | + * @return bool |
| 37 | + */ |
29 | 38 | public static function onAddNewAccount( $user ) { |
30 | 39 | global $wgRequest, $wmincProjects, $wmincPref; |
31 | 40 | $projectvalue = $wgRequest->getVal( 'testwiki-project' ); |
Index: branches/wmf/1.18wmf1/extensions/WikimediaIncubator/IncubatorTest.php |
— | — | @@ -13,7 +13,9 @@ |
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Add preferences |
17 | | - * @return True |
| 17 | + * @param $user User |
| 18 | + * @param $preferences array |
| 19 | + * @return true |
18 | 20 | */ |
19 | 21 | static function onGetPreferences( $user, &$preferences ) { |
20 | 22 | global $wmincPref, $wmincProjects, $wmincProjectSite, |
— | — | @@ -35,7 +37,7 @@ |
36 | 38 | $prefinsert[$wmincPref . '-code'] = array( |
37 | 39 | 'type' => 'text', |
38 | 40 | 'section' => 'personal/i18n', |
39 | | - 'label-message' => 'wminc-testwiki', |
| 41 | + 'label-message' => 'wminc-testwiki-code', |
40 | 42 | 'id' => $wmincPref . '-code', |
41 | 43 | 'maxlength' => (int)$wmincLangCodeLength, |
42 | 44 | 'size' => (int)$wmincLangCodeLength, |
— | — | @@ -52,6 +54,8 @@ |
53 | 55 | |
54 | 56 | /** |
55 | 57 | * For the preferences above |
| 58 | + * @param $input |
| 59 | + * @param $alldata |
56 | 60 | * @return String or true |
57 | 61 | */ |
58 | 62 | static function validateCodePreference( $input, $alldata ) { |
— | — | @@ -135,15 +139,15 @@ |
136 | 140 | |
137 | 141 | /** |
138 | 142 | * This returns simply true or false based on analyzePrefix(). |
| 143 | + * @param $title Title |
| 144 | + * @param $onlyprefix bool |
139 | 145 | * @return Boolean |
140 | 146 | */ |
141 | 147 | static function validatePrefix( $title, $onlyprefix = false ) { |
142 | 148 | $data = self::analyzePrefix( $title, $onlyprefix ); |
143 | | - if( !$data['error'] ) { return true; } |
144 | | - return false; |
| 149 | + return !$data['error']; |
145 | 150 | } |
146 | 151 | |
147 | | - |
148 | 152 | /** |
149 | 153 | * Get &testwiki=wx/xx and validate that prefix. |
150 | 154 | * Returns the array of analyzePrefix() on success. |
— | — | @@ -197,6 +201,10 @@ |
198 | 202 | |
199 | 203 | /** |
200 | 204 | * Returns a simple boolean based on getProject() |
| 205 | + * @param $project string |
| 206 | + * @param $returnName bool |
| 207 | + * @param $returnName bool |
| 208 | + * @param $includeSister bool |
201 | 209 | * @return Bool |
202 | 210 | */ |
203 | 211 | static function isContentProject( $project = '', $returnName = false, $includeSister = false ) { |
— | — | @@ -322,8 +330,10 @@ |
323 | 331 | $link = self::getSubdomain( $prefixdata['lang'], |
324 | 332 | $prefixdata['project'], ( $title->getNsText() ? $title->getNsText() . ':' : '' ) . |
325 | 333 | str_replace( ' ', '_', $prefixdata['realtitle'] ) ); |
| 334 | + # faking external link to support prot-rel URLs |
| 335 | + $link = "[$link ". self::makeExternalLinkText( $link ) . "]"; |
326 | 336 | $result[] = array( 'wminc-error-wiki-exists', $link ); |
327 | | - return false; |
| 337 | + return $action != 'edit'; |
328 | 338 | } |
329 | 339 | |
330 | 340 | if( !self::shouldWeShowUnprefixedError( $title ) || $action != 'create' ) { |
— | — | @@ -342,7 +352,7 @@ |
343 | 353 | $error = 'wminc-error-unprefixed'; |
344 | 354 | } |
345 | 355 | $result = $error; |
346 | | - return false; |
| 356 | + return $action != 'edit'; |
347 | 357 | } |
348 | 358 | |
349 | 359 | /** |
— | — | @@ -379,18 +389,12 @@ |
380 | 390 | |
381 | 391 | /** |
382 | 392 | * This loads language names. Also from CLDR if that extension is found. |
383 | | - * @return Array with language names or empty array |
| 393 | + * @return Array with language names |
384 | 394 | */ |
385 | | - static public function getLanguageNames( $code = '' ) { |
386 | | - if ( is_callable( array( 'LanguageNames', 'getNames' ) ) ) { |
387 | | - global $wgLang; |
388 | | - $langcode = ( $code ? $code : $wgLang->getCode() ); |
389 | | - return LanguageNames::getNames( $langcode, |
390 | | - LanguageNames::FALLBACK_NORMAL, |
391 | | - LanguageNames::LIST_MW_AND_CLDR |
392 | | - ); |
393 | | - } |
394 | | - return Language::getLanguageNames( false ); |
| 395 | + static public function getLanguageNames( $code = null ) { |
| 396 | + global $wgLang; |
| 397 | + $langcode = ( $code ? $code : $wgLang->getCode() ); |
| 398 | + return Language::getTranslatedLanguageNames( $langcode ); |
395 | 399 | } |
396 | 400 | |
397 | 401 | /** |
— | — | @@ -404,7 +408,7 @@ |
405 | 409 | } |
406 | 410 | return true; # Should work now |
407 | 411 | } |
408 | | - |
| 412 | + |
409 | 413 | /** |
410 | 414 | * Given an incubator testwiki prefix, get the database name of the |
411 | 415 | * corresponding wiki, whether it exists or not |
— | — | @@ -417,7 +421,11 @@ |
418 | 422 | } elseif( !$prefix || $prefix['error'] ) { |
419 | 423 | return false; # shouldn't be, but you never know |
420 | 424 | } |
421 | | - global $wmincProjectDatabases; |
| 425 | + global $wmincProjectDatabases, $wgDummyLanguageCodes; |
| 426 | + $redirectcode = array_search( $prefix['lang'], $wgDummyLanguageCodes ); |
| 427 | + if( $redirectcode ) { |
| 428 | + $prefix['lang'] = $redirectcode; |
| 429 | + } |
422 | 430 | return str_replace('-', '_', $prefix['lang'] ) . |
423 | 431 | $wmincProjectDatabases[$prefix['project']]; |
424 | 432 | } |
— | — | @@ -473,7 +481,6 @@ |
474 | 482 | if( $prefix['error'] ) { # We are not on info pages |
475 | 483 | global $wmincSisterProjects; |
476 | 484 | $prefix2 = self::analyzePrefix( $title->getText(), false, true ); |
477 | | - $linker = class_exists( 'DummyLinker' ) ? new DummyLinker : new Linker; |
478 | 485 | $p = isset( $prefix2['project' ] ) ? $prefix2['project'] : ''; |
479 | 486 | if( self::getDBState( $prefix2 ) == 'existing' ) { |
480 | 487 | $link = self::getSubdomain( $prefix2['lang'], $p, |
— | — | @@ -484,7 +491,7 @@ |
485 | 492 | return true; |
486 | 493 | } else { |
487 | 494 | # Show a link to the existing wiki |
488 | | - $showLink = $linker->makeExternalLink( $link, $link ); |
| 495 | + $showLink = self::makeExternalLinkText( $link, true ); |
489 | 496 | $wgOut->addHtml( '<div class="wminc-wiki-exists">' . |
490 | 497 | wfMsgHtml( 'wminc-error-wiki-exists', $showLink ) . |
491 | 498 | '</div>' ); |
— | — | @@ -493,7 +500,7 @@ |
494 | 501 | # A sister project is not hosted here, so direct the user to the relevant wiki |
495 | 502 | $link = self::getSubdomain( $prefix2['lang'], $p, |
496 | 503 | ( $title->getNsText() ? $title->getNsText() . ':' : '' ) . $prefix2['realtitle'] ); |
497 | | - $showLink = $linker->makeExternalLink( $link, $link ); |
| 504 | + $showLink = self::makeExternalLinkText( $link, true ); |
498 | 505 | $wgOut->addHtml( '<div class="wminc-wiki-sister">' . |
499 | 506 | wfMsgHtml( 'wminc-error-wiki-sister', $showLink ) . |
500 | 507 | '</div>' ); |
— | — | @@ -528,7 +535,7 @@ |
529 | 536 | $wgOut->addHtml( $infopage->showExistingWiki() ); |
530 | 537 | } elseif( $dbstate == 'closed' ) { |
531 | 538 | $infopage->mSubStatus = 'imported'; |
532 | | - $wgOut->addHtml( $infopage->showIncubatingWiki() ); |
| 539 | + $wgOut->addHtml( $infopage->showIncubatingWiki() ); |
533 | 540 | } else { |
534 | 541 | $wgOut->addHtml( $infopage->showMissingWiki() ); |
535 | 542 | } |
— | — | @@ -579,12 +586,15 @@ |
580 | 587 | |
581 | 588 | /** |
582 | 589 | * make "Wx/xxx/Main Page" |
583 | | - * @return String |
| 590 | + * @param $langCode String: The language code |
| 591 | + * @param $prefix Null|String: the "Wx/xxx" prefix to add |
| 592 | + * @return Title |
584 | 593 | */ |
585 | 594 | public static function getMainPage( $langCode, $prefix = null ) { |
586 | 595 | # Take the "mainpage" msg in the given language |
587 | 596 | $msg = wfMsgExt( 'mainpage', array( 'language' => $langCode ) ); |
588 | | - return $prefix !== null ? $prefix . '/' . $msg : $msg; |
| 597 | + $mainpage = $prefix !== null ? $prefix . '/' . $msg : $msg; |
| 598 | + return Title::newFromText( $mainpage ); |
589 | 599 | } |
590 | 600 | |
591 | 601 | /** |
— | — | @@ -612,9 +622,7 @@ |
613 | 623 | # pass through the &uselang parameter |
614 | 624 | $params['uselang'] = $uselang; |
615 | 625 | } |
616 | | - $mainpage = Title::newFromText( |
617 | | - self::getMainPage( $prefix['lang'], $prefix['prefix'] ) |
618 | | - ); |
| 626 | + $mainpage = self::getMainPage( $prefix['lang'], $prefix['prefix'] ); |
619 | 627 | if( $mainpage->exists() ) { |
620 | 628 | # Only redirect to the main page if that page exists |
621 | 629 | $wgOut->redirect( $mainpage->getFullURL( $params ) ); |
— | — | @@ -701,7 +709,74 @@ |
702 | 710 | return true; |
703 | 711 | } |
704 | 712 | |
| 713 | + /** |
| 714 | + * Search: Adapt the default message to show a more descriptive one, |
| 715 | + * along with an adapted link. |
| 716 | + * @return true |
| 717 | + */ |
| 718 | + public static function onSpecialSearchCreateLink( $title, &$params ) { |
| 719 | + if( $title->isKnown() ) { |
| 720 | + return true; |
| 721 | + } |
| 722 | + global $wmincProjectSite, $wmincTestWikiNamespaces; |
| 723 | + $prefix = self::displayPrefix(); |
| 724 | + |
| 725 | + $newNs = $title->getNamespace(); |
| 726 | + $newTitle = $title->getText(); |
| 727 | + if( $prefix == $wmincProjectSite['short'] ) { |
| 728 | + $newNs = NS_PROJECT; |
| 729 | + } else { |
| 730 | + if( !in_array( $title->getNamespace(), $wmincTestWikiNamespaces ) ) { |
| 731 | + $newNs = $wmincTestWikiNamespaces[0]; # no "valid" NS, should be main NS |
| 732 | + } |
| 733 | + $newTitle = $prefix . '/' . $newTitle; |
| 734 | + } |
| 735 | + |
| 736 | + $t = Title::newFromText( $newTitle, $newNs ); |
| 737 | + if( $t->isKnown() ) { |
| 738 | + # use the default message if the suggested title exists |
| 739 | + $params[0] = 'searchmenu-exists'; |
| 740 | + $params[1] = wfEscapeWikiText( $t->getPrefixedText() ); |
| 741 | + return true; |
| 742 | + } |
| 743 | + $params[] = wfEscapeWikiText( $t->getPrefixedText() ); |
| 744 | + $params[0] = $prefix ? 'wminc-search-nocreate-suggest' :'wminc-search-nocreate-nopref'; |
| 745 | + return true; |
| 746 | + } |
| 747 | + |
| 748 | + /** |
| 749 | + * Search: Add an input form to enter a test wiki prefix. |
| 750 | + * @return true |
| 751 | + */ |
| 752 | + public static function onSpecialSearchPowerBox( &$showSections, $term, $opts ) { |
| 753 | + $showSections['testwiki'] = Xml::label( wfMsg( 'wminc-testwiki' ), 'testwiki' ) . ' ' . |
| 754 | + Xml::input( 'testwiki', 20, self::displayPrefix(), array( 'id' => 'testwiki' ) ); |
| 755 | + return true; |
| 756 | + } |
| 757 | + |
| 758 | + /** |
| 759 | + * Search: Search by default in the test wiki of the user's preference (or url &testwiki). |
| 760 | + * @return true |
| 761 | + */ |
| 762 | + public static function onSpecialSearchSetupEngine( $search, $profile, $engine ) { |
| 763 | + if( !isset( $search->prefix ) || !$search->prefix ) { |
| 764 | + $search->prefix = self::displayPrefix(); |
| 765 | + } |
| 766 | + return true; |
| 767 | + } |
| 768 | + |
705 | 769 | private static function preg_quote_slash( $str ) { |
706 | 770 | return preg_quote( $str, '/' ); |
707 | 771 | } |
| 772 | + |
| 773 | + /** |
| 774 | + * @param $url String |
| 775 | + * @param $callLinker Boolean Whether to call makeExternalLink() |
| 776 | + */ |
| 777 | + public static function makeExternalLinkText( $url, $callLinker = false ) { |
| 778 | + # when displaying a URL, if it contains 'http://' or 'https://' it's ok to leave it, |
| 779 | + # but for protocol-relative URLs, it's nicer to remove the '//' |
| 780 | + $linktext = ltrim( $url, '/' ); |
| 781 | + return $callLinker ? Linker::makeExternalLink( $url, $linktext ) : $linktext; |
| 782 | + } |
708 | 783 | } |
Index: branches/wmf/1.18wmf1/extensions/WikimediaIncubator/InfoPage.i18n.php |
— | — | @@ -25,7 +25,13 @@ |
26 | 26 | 'wminc-logo-wikispecies' => 'WikiSpecies.svg', # only translate if necessary |
27 | 27 | 'wminc-logo-mediawiki' => 'MediaWiki.svg', # only translate if necessary |
28 | 28 | 'wminc-manual-url' => 'Help:Manual', # only translate if necessary |
29 | | - 'wminc-infopage-title' => '$1 $2', # only translate if necessary |
| 29 | + 'wminc-infopage-title-p' => 'Wikipedia $1', |
| 30 | + 'wminc-infopage-title-b' => 'Wikibooks $1', |
| 31 | + 'wminc-infopage-title-t' => 'Wiktionary $1', |
| 32 | + 'wminc-infopage-title-q' => 'Wikiquote $1', |
| 33 | + 'wminc-infopage-title-n' => 'Wikinews $1', |
| 34 | + 'wminc-infopage-title-s' => 'Wikisource $1', |
| 35 | + 'wminc-infopage-title-v' => 'Wikiversity $1', |
30 | 36 | 'wminc-infopage-welcome' => 'Welcome to the Wikimedia Incubator, a project of the Wikimedia Foundation ([[{{MediaWiki:Aboutpage}}|About]])', |
31 | 37 | |
32 | 38 | 'wminc-infopage-missingwiki-text' => 'A $1 in this language does not yet exist.', |
Index: branches/wmf/1.18wmf1/extensions/WikimediaIncubator/InfoPage.php |
— | — | @@ -19,6 +19,11 @@ |
20 | 20 | */ |
21 | 21 | |
22 | 22 | class InfoPage { |
| 23 | + |
| 24 | + /** |
| 25 | + * @param $title Title |
| 26 | + * @param $prefixdata |
| 27 | + */ |
23 | 28 | public function __construct( $title, $prefixdata ) { |
24 | 29 | global $wmincProjects, $wmincSisterProjects; |
25 | 30 | $this->mTitle = $title; |
— | — | @@ -39,7 +44,7 @@ |
40 | 45 | $this->mLangNames = IncubatorTest::getLanguageNames(); |
41 | 46 | $this->mLangName = ( isset( $this->mLangNames[$this->mLangCode] ) ? |
42 | 47 | $this->mLangNames[$this->mLangCode] : wfMsg( 'wminc-unknownlang', $this->mLangCode ) ); |
43 | | - $this->mFormatTitle = wfMsgHtml( 'wminc-infopage-title', $this->mProjectName, $this->mLangName ); |
| 48 | + $this->mFormatTitle = wfMsgHtml( 'wminc-infopage-title-' . $this->mProjectCode, $this->mLangName ); |
44 | 49 | return; |
45 | 50 | } |
46 | 51 | |
— | — | @@ -49,15 +54,14 @@ |
50 | 55 | * @return String |
51 | 56 | */ |
52 | 57 | public function makeLogo( $project, $clickable = true, $width = 25, $height = '', $url = '', $args = array() ) { |
53 | | - global $wgUser; |
54 | 58 | $projectForFile = preg_replace('/ /', '-', strtolower( $project ) ); |
55 | 59 | $imageobj = wfFindFile( wfMsg( 'wminc-logo-' . $projectForFile ) ); |
56 | 60 | $useUrl = $url ? $url : IncubatorTest::getSubdomain( 'www', IncubatorTest::getProject( $project, false, true ) ); |
57 | 61 | if ( !$imageobj ) { # image not found |
58 | 62 | if( !$clickable ) { |
59 | | - return $logo; |
| 63 | + return $logo; // FIXME: $logo is undefined |
60 | 64 | } |
61 | | - return $wgUser->getSkin()->makeExternalLink( $useUrl, $project, false ); |
| 65 | + return Linker::makeExternalLink( $useUrl, $project, false ); |
62 | 66 | } |
63 | 67 | if( $clickable ) { |
64 | 68 | $args['link-url'] = $useUrl; |
— | — | @@ -68,7 +72,7 @@ |
69 | 73 | if( $height ) { |
70 | 74 | $handlerParams['height'] = $height; |
71 | 75 | } |
72 | | - return $wgUser->getSkin()->makeImageLink2( $this->mTitle, $imageobj, |
| 76 | + return Linker::makeImageLink2( $this->mTitle, $imageobj, |
73 | 77 | array( 'alt' => $project, 'caption' => $project ) + $args, $handlerParams |
74 | 78 | ); |
75 | 79 | } |
— | — | @@ -80,6 +84,7 @@ |
81 | 85 | public function listOtherProjects() { |
82 | 86 | global $wmincProjects, $wmincSisterProjects; |
83 | 87 | $otherProjects = $wmincProjects + $wmincSisterProjects; |
| 88 | + $listOtherProjects = array(); |
84 | 89 | foreach( $otherProjects as $code => $name ) { |
85 | 90 | $listOtherProjects[$code] = '<li>' . $this->makeLogo( $name, true, |
86 | 91 | 75, null, IncubatorTest::getSubdomain( $this->mLangCode, $code ) ) . '</li>'; |
— | — | @@ -95,10 +100,11 @@ |
96 | 101 | */ |
97 | 102 | public function listMultilingualProjects() { |
98 | 103 | global $wmincMultilingualProjects; |
99 | | - if( !is_array( $wmincMultilingualProjects ) ) { return; } |
| 104 | + if( !is_array( $wmincMultilingualProjects ) ) { return ''; } |
| 105 | + $list = array(); |
100 | 106 | foreach( $wmincMultilingualProjects as $url => $name ) { |
101 | 107 | $list[$url] = '<li>' . $this->makeLogo( $name, true, |
102 | | - 75, null, 'http://'.$url.'/') . '</li>'; |
| 108 | + 75, null, '//'.$url.'/') . '</li>'; |
103 | 109 | } |
104 | 110 | return '<ul class="wminc-infopage-multilingualprojects">' . |
105 | 111 | implode( '', $list ) . '</ul>'; |
— | — | @@ -137,7 +143,7 @@ |
138 | 144 | array( 'class' => 'wminc-infopage-status' ), |
139 | 145 | wfMsgWikiHtml( 'wminc-infopage-missingwiki-text', |
140 | 146 | $this->mProjectName, $this->mLangName ) |
141 | | - ) . |
| 147 | + ) . |
142 | 148 | Html::rawElement( 'ul', array( 'class' => 'wminc-infopage-options' ), |
143 | 149 | Html::rawElement( 'li', null, |
144 | 150 | wfMsgExt( $this->mIsSister ? 'wminc-infopage-option-startsister' : 'wminc-infopage-option-startwiki', |
— | — | @@ -159,22 +165,22 @@ |
160 | 166 | * @return String |
161 | 167 | */ |
162 | 168 | public function showIncubatingWiki() { |
163 | | - global $wgUser, $wgLang; |
| 169 | + global $wgLang; |
164 | 170 | $substatus = $this->mSubStatus; |
165 | 171 | if( $substatus == 'imported' && $this->mIsSister ) { |
166 | 172 | $substatus = 'closedsister'; |
167 | 173 | } |
168 | | - $portalLink = $wgUser->getSkin()->makeExternalLink( $this->mPortal, $this->mProjectName ); |
| 174 | + $portalLink = Linker::makeExternalLink( $this->mPortal, $this->mProjectName ); |
169 | 175 | if( $this->mThisLangData['type'] != 'invalid' ) { |
170 | | - $gotoLink = $wgUser->getSkin()->link( |
171 | | - Title::newFromText( IncubatorTest::getMainPage( $this->mLangCode, $this->mPrefix ) ), |
| 176 | + $gotoLink = Linker::link( |
| 177 | + IncubatorTest::getMainPage( $this->mLangCode, $this->mPrefix ), |
172 | 178 | wfMsgNoTrans( 'wminc-infopage-enter' ) ); |
173 | 179 | $gotoMainPage = Html::rawElement( 'span', |
174 | 180 | array( 'class' => 'wminc-infopage-entertest' ), |
175 | 181 | $wgLang->getArrow() . ' ' . ( $this->mIsSister ? $portalLink : $gotoLink ) ); |
176 | 182 | } |
177 | 183 | $subdomain = IncubatorTest::getSubdomain( $this->mLangCode, $this->mProjectCode ); |
178 | | - $subdomainLink = $wgUser->getSkin()->makeExternalLink( $subdomain, $subdomain ); |
| 184 | + $subdomainLink = IncubatorTest::makeExternalLinkText( $subdomain, true ); |
179 | 185 | $content = Html::rawElement( 'div', array( 'class' => 'wminc-infopage-status' ), |
180 | 186 | wfMsgWikiHtml( 'wminc-infopage-status-' . $substatus, $subdomainLink, $portalLink ) ); |
181 | 187 | if( $this->mSubStatus != 'approved' && $this->mThisLangData['type'] != 'invalid' ) { |
— | — | @@ -189,11 +195,11 @@ |
190 | 196 | * @return String |
191 | 197 | */ |
192 | 198 | public function showExistingWiki() { |
193 | | - global $wgLang, $wgUser; |
| 199 | + global $wgLang; |
194 | 200 | $created = isset( $this->mCreated ) ? $this->mCreated : ''; # for future use |
195 | 201 | $bug = isset( $this->mBug ) ? $this->mBug : ''; # for future use |
196 | 202 | $subdomain = IncubatorTest::getSubdomain( $this->mLangCode, $this->mProjectCode ); |
197 | | - $subdomainLink = $wgUser->getSkin()->makeExternalLink( $subdomain, $subdomain ); |
| 203 | + $subdomainLink = IncubatorTest::makeExternalLinkText( $subdomain, true ); |
198 | 204 | if( $this->mThisLangData['type'] != 'invalid' ) { |
199 | 205 | $gotoSubdomain = Html::rawElement( 'span', |
200 | 206 | array( 'class' => 'wminc-infopage-entertest' ), |
— | — | @@ -210,4 +216,4 @@ |
211 | 217 | ); |
212 | 218 | return $this->StandardInfoPage( $this->showWelcome(), $gotoSubdomain, $content ); |
213 | 219 | } |
214 | | -} |
\ No newline at end of file |
| 220 | +} |
Index: branches/wmf/1.18wmf1/extensions/WikimediaIncubator/WikimediaIncubator.i18n.php |
— | — | @@ -16,6 +16,7 @@ |
17 | 17 | 'wminc-manual' => 'Manual', |
18 | 18 | 'wminc-listwikis' => 'List of wikis', |
19 | 19 | 'wminc-testwiki' => 'Test wiki:', |
| 20 | + 'wminc-testwiki-code' => 'Test wiki language:', |
20 | 21 | 'wminc-testwiki-none' => 'None/All', |
21 | 22 | 'wminc-recentchanges-all' => 'All recent changes', |
22 | 23 | |
— | — | @@ -45,15 +46,22 @@ |
46 | 47 | 'wminc-ip' => '"$1" is an IP address.', |
47 | 48 | |
48 | 49 | # User groups |
49 | | - 'right-viewuserlang' => 'View [[Special:ViewUserLang|user language and test wiki]]', |
| 50 | + 'right-viewuserlang' => 'View user language and test wiki', |
50 | 51 | 'group-test-sysop' => 'Test wiki administrators', |
51 | | - 'group-test-sysop-member' => 'test wiki administrator', |
| 52 | + 'group-test-sysop-member' => '{{GENDER:$1|test wiki administrator}}', |
52 | 53 | 'grouppage-test-sysop' => 'Project:Test wiki administrators', |
53 | 54 | |
54 | 55 | # Language codes |
55 | 56 | 'wminc-code-macrolanguage' => 'The [[wikipedia:$2 language|"$3" language]] is a [[wikipedia:ISO 639 macrolanguage|macrolanguage]], consisting of the following member languages:', |
56 | 57 | 'wminc-code-collective' => 'The code "$1" does not refer to a specific language, but to a collection of languages, namely the [[wikipedia:$2 language|"$3" languages]].', |
57 | 58 | 'wminc-code-retired' => 'This language code has been changed and no longer refers to the original language.', |
| 59 | + |
| 60 | + # Special:ListUsers |
| 61 | + 'wminc-listusers-testwiki' => 'You are viewing users who have set their test wiki preference to $1.', |
| 62 | + |
| 63 | + # Search |
| 64 | + 'wminc-search-nocreate-nopref' => 'You searched for "$1". Please set your [[Special:Preferences|test wiki preference]] so we can tell you which page you can create!', |
| 65 | + 'wminc-search-nocreate-suggest' => 'You searched for "$1". You can create a page in your wiki at <b>[[$2]]</b>!', |
58 | 66 | ); |
59 | 67 | |
60 | 68 | /** Message documentation (Message documentation) |