Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -2321,6 +2321,13 @@ |
2322 | 2322 | ); |
2323 | 2323 | |
2324 | 2324 | /** |
| 2325 | + * Login / create account link behavior when it's possible for anonymous users to create an account |
| 2326 | + * true = use a combined login / create account link |
| 2327 | + * false = split login and create account into two separate links |
| 2328 | + */ |
| 2329 | +$wgUseCombinedLoginLink = true; |
| 2330 | + |
| 2331 | +/** |
2325 | 2332 | * Search form behavior for Vector skin only |
2326 | 2333 | * true = use an icon search button |
2327 | 2334 | * false = use Go & Search buttons |
Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -541,6 +541,19 @@ |
542 | 542 | } |
543 | 543 | |
544 | 544 | /** |
| 545 | + * Output a boolean indiciating if buildPersonalUrls should output separate |
| 546 | + * login and create account links or output a combined link |
| 547 | + * By default we simply return a global config setting that affects most skins |
| 548 | + * This is setup as a method so that like with $wgLogo and getLogo() a skin |
| 549 | + * can override this setting and always output one or the other if it has |
| 550 | + * a reason it can't output one of the two modes. |
| 551 | + */ |
| 552 | + function useCombinedLoginLink() { |
| 553 | + global $wgUseCombinedLoginLink; |
| 554 | + return $wgUseCombinedLoginLink; |
| 555 | + } |
| 556 | + |
| 557 | + /** |
545 | 558 | * build array of urls for personal toolbar |
546 | 559 | * @return array |
547 | 560 | * @private |
— | — | @@ -618,23 +631,38 @@ |
619 | 632 | ); |
620 | 633 | } else { |
621 | 634 | global $wgUser; |
622 | | - $loginlink = $wgUser->isAllowed( 'createaccount' ) |
| 635 | + $useCombinedLoginLink = $this->useCombinedLoginLink(); |
| 636 | + $loginlink = $wgUser->isAllowed( 'createaccount' ) && $useCombinedLoginLink |
623 | 637 | ? 'nav-login-createaccount' |
624 | 638 | : 'login'; |
| 639 | + $is_signup = $wgRequest->getText('type') == "signup"; |
625 | 640 | |
626 | 641 | # anonlogin & login are the same |
627 | 642 | $login_url = array( |
628 | 643 | 'text' => wfMsg( $loginlink ), |
629 | 644 | 'href' => self::makeSpecialUrl( 'Userlogin', $returnto ), |
630 | | - 'active' => $title->isSpecial( 'Userlogin' ) |
| 645 | + 'active' => $title->isSpecial( 'Userlogin' ) && ( $loginlink == "nav-login-createaccount" || !$is_signup ) |
631 | 646 | ); |
| 647 | + if ( $wgUser->isAllowed( 'createaccount' ) && !$useCombinedLoginLink ) { |
| 648 | + $createaccount_url = array( |
| 649 | + 'text' => wfMsg( 'createaccount' ), |
| 650 | + 'href' => self::makeSpecialUrl( 'Userlogin', "$returnto&type=signup" ), |
| 651 | + 'active' => $title->isSpecial( 'Userlogin' ) && $is_signup |
| 652 | + ); |
| 653 | + } |
632 | 654 | global $wgProto, $wgSecureLogin; |
633 | 655 | if( $wgProto === 'http' && $wgSecureLogin ) { |
634 | 656 | $title = SpecialPage::getTitleFor( 'Userlogin' ); |
635 | 657 | $https_url = preg_replace( '/^http:/', 'https:', $title->getFullURL() ); |
636 | 658 | $login_url['href'] = $https_url; |
637 | 659 | $login_url['class'] = 'link-https'; # FIXME class depends on skin |
| 660 | + if ( isset($createaccount_url) ) { |
| 661 | + $https_url = preg_replace( '/^http:/', 'https:', $title->getFullURL("type=signup") ); |
| 662 | + $createaccount_url['href'] = $https_url; |
| 663 | + $createaccount_url['class'] = 'link-https'; # FIXME class depends on skin |
| 664 | + } |
638 | 665 | } |
| 666 | + |
639 | 667 | |
640 | 668 | if( $this->showIPinHeader() ) { |
641 | 669 | $href = &$this->userpageUrlDetails['href']; |
— | — | @@ -653,6 +681,9 @@ |
654 | 682 | 'active' => ( $pageurl == $href ) |
655 | 683 | ); |
656 | 684 | $personal_urls['anonlogin'] = $login_url; |
| 685 | + if ( isset($createaccount_url) ) { |
| 686 | + $personal_urls['createaccount'] = $createaccount_url; |
| 687 | + } |
657 | 688 | } else { |
658 | 689 | $personal_urls['login'] = $login_url; |
659 | 690 | } |
— | — | @@ -1259,6 +1290,32 @@ |
1260 | 1291 | } |
1261 | 1292 | |
1262 | 1293 | /** |
| 1294 | + * Create an array of personal tools items from the data in the quicktemplate |
| 1295 | + * stored by SkinTemplate. |
| 1296 | + * The resulting array is built acording to a format intended to be passed |
| 1297 | + * through makeListItem to generate the html. |
| 1298 | + * This is in reality the same list as already stored in personal_urls |
| 1299 | + * however it is reformatted so that you can just pass the individual items |
| 1300 | + * to makeListItem instead of hardcoding the element creation boilerplate. |
| 1301 | + */ |
| 1302 | + function getPersonalTools() { |
| 1303 | + $personal_tools = array(); |
| 1304 | + foreach( $this->data['personal_urls'] as $key => $ptool ) { |
| 1305 | + # The class on a personal_urls item is meant to go on the <a> instead |
| 1306 | + # of the <li> so we have to use a single item "links" array instead |
| 1307 | + # of using most of the personal_url's keys directly |
| 1308 | + $personal_tools[$key] = array(); |
| 1309 | + $personal_tools[$key]["links"][] = array(); |
| 1310 | + $personal_tools[$key]["links"][0]["single-id"] = $personal_tools[$key]["id"] = "pt-$key"; |
| 1311 | + $personal_tools[$key]["active"] = $ptool["active"]; |
| 1312 | + foreach ( array("href", "class", "text") as $k ) { |
| 1313 | + $personal_tools[$key]["links"][0][$k] = $ptool[$k]; |
| 1314 | + } |
| 1315 | + } |
| 1316 | + return $personal_tools; |
| 1317 | + } |
| 1318 | + |
| 1319 | + /** |
1263 | 1320 | * Makes a link, usually used by makeListItem to generate a link for an item |
1264 | 1321 | * in a list used in navigation lists, portlets, portals, sidebars, etc... |
1265 | 1322 | * |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -21,6 +21,8 @@ |
22 | 22 | === Configuration changes in 1.18 === |
23 | 23 | * The WantedPages::getSQL hook has been removed and replaced with |
24 | 24 | WantedPages::getQueryInfo . This may break older extensions. |
| 25 | +* $wgUseCombinedLoginLink controls whether to output a combined login / create account |
| 26 | + link in the personal bar, or to output separate login and create account links |
25 | 27 | |
26 | 28 | === New features in 1.18 === |
27 | 29 | * Added a special page, disabled by default, that allows users with the |