r79014 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79013‎ | r79014 | r79015 >
Date:13:41, 26 December 2010
Author:dantman
Status:ok (Comments)
Tags:
Comment:
Add a config option to allow the login / create account link to be split into separate login and create account links. (Besides Google and Bing, Wikipedia/MediaWiki is the only big site I see that actually doesn't provide separate login and create account links).
This is partially made because there are skins where separate login and createaccount links are made, not giving them proper login and createaccount links in the personal_urls means partial reimplementation of personal_urls code in the skin (or worse, no support for features like $wgSecureLogin in these skins when they don't keep up with core).
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/DefaultSettings.php
@@ -2321,6 +2321,13 @@
23222322 );
23232323
23242324 /**
 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+/**
23252332 * Search form behavior for Vector skin only
23262333 * true = use an icon search button
23272334 * false = use Go & Search buttons
Index: trunk/phase3/includes/SkinTemplate.php
@@ -541,6 +541,19 @@
542542 }
543543
544544 /**
 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+ /**
545558 * build array of urls for personal toolbar
546559 * @return array
547560 * @private
@@ -618,23 +631,38 @@
619632 );
620633 } else {
621634 global $wgUser;
622 - $loginlink = $wgUser->isAllowed( 'createaccount' )
 635+ $useCombinedLoginLink = $this->useCombinedLoginLink();
 636+ $loginlink = $wgUser->isAllowed( 'createaccount' ) && $useCombinedLoginLink
623637 ? 'nav-login-createaccount'
624638 : 'login';
 639+ $is_signup = $wgRequest->getText('type') == "signup";
625640
626641 # anonlogin & login are the same
627642 $login_url = array(
628643 'text' => wfMsg( $loginlink ),
629644 'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
630 - 'active' => $title->isSpecial( 'Userlogin' )
 645+ 'active' => $title->isSpecial( 'Userlogin' ) && ( $loginlink == "nav-login-createaccount" || !$is_signup )
631646 );
 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+ }
632654 global $wgProto, $wgSecureLogin;
633655 if( $wgProto === 'http' && $wgSecureLogin ) {
634656 $title = SpecialPage::getTitleFor( 'Userlogin' );
635657 $https_url = preg_replace( '/^http:/', 'https:', $title->getFullURL() );
636658 $login_url['href'] = $https_url;
637659 $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+ }
638665 }
 666+
639667
640668 if( $this->showIPinHeader() ) {
641669 $href = &$this->userpageUrlDetails['href'];
@@ -653,6 +681,9 @@
654682 'active' => ( $pageurl == $href )
655683 );
656684 $personal_urls['anonlogin'] = $login_url;
 685+ if ( isset($createaccount_url) ) {
 686+ $personal_urls['createaccount'] = $createaccount_url;
 687+ }
657688 } else {
658689 $personal_urls['login'] = $login_url;
659690 }
@@ -1259,6 +1290,32 @@
12601291 }
12611292
12621293 /**
 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+ /**
12631320 * Makes a link, usually used by makeListItem to generate a link for an item
12641321 * in a list used in navigation lists, portlets, portals, sidebars, etc...
12651322 *
Index: trunk/phase3/RELEASE-NOTES
@@ -21,6 +21,8 @@
2222 === Configuration changes in 1.18 ===
2323 * The WantedPages::getSQL hook has been removed and replaced with
2424 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
2527
2628 === New features in 1.18 ===
2729 * Added a special page, disabled by default, that allows users with the

Follow-up revisions

RevisionCommit summaryAuthorDate
r79015Back out getPersonalTools from r79014 which did not belong in that commit.dantman13:45, 26 December 2010

Comments

#Comment by Dantman (talk | contribs)   13:48, 26 December 2010

:/ I hate svn... that dirty commit would have never happened in my other projects... (getPersonalTools is not part of this commit)

For the record I checked out a number of other sites to see who used combined/separate links:

only a login link
bing, google, craigslist ("my account")
combined
no-one
separate
yahoo, youtube, facebook (in-page), twitter (in-page), flickr, imdb, gmail, mint, amazon, meebo (in-page), howcast, iFixIt, metacritic, ted, nytimes
#Comment by Aaron Schulz (talk | contribs)   21:07, 14 June 2011

Nice. Is wgUseCombinedLoginLink intended to be permanent?

Status & tagging log