Login-related messages should get the URL as a parameter
authorGergő Tisza <gtisza@wikimedia.org>
Fri, 7 Dec 2018 00:18:47 +0000 (16:18 -0800)
committerGergő Tisza <gtisza@wikimedia.org>
Fri, 7 Dec 2018 02:38:16 +0000 (02:38 +0000)
System messages along the lines of "you can't view this page,
please log in" get the login link (with returnto parameters) as a
HTML string, but sometimes one might want to customize the link
on one page without affecting all the other pages so it's nice
to have the raw link available as well.

Change-Id: Ib71791ea28718455d2925e4424147e87ef901f33

includes/OutputPage.php
languages/i18n/qqq.json

index 2423315..02e13e7 100644 (file)
@@ -2847,16 +2847,18 @@ class OutputPage extends ContextSource {
                                        $query['returntoquery'] = wfArrayToCgi( $returntoquery );
                                }
                        }
+                       $title = SpecialPage::getTitleFor( 'Userlogin' );
                        $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
+                       $loginUrl = $title->getLinkURL( $query, false, PROTO_RELATIVE );
                        $loginLink = $linkRenderer->makeKnownLink(
-                               SpecialPage::getTitleFor( 'Userlogin' ),
+                               $title,
                                $this->msg( 'loginreqlink' )->text(),
                                [],
                                $query
                        );
 
                        $this->prepareErrorPage( $this->msg( 'loginreqtitle' ) );
-                       $this->addHTML( $this->msg( $msg )->rawParams( $loginLink )->parse() );
+                       $this->addHTML( $this->msg( $msg )->rawParams( $loginLink )->params( $loginUrl )->parse() );
 
                        # Don't return to a page the user can't read otherwise
                        # we'll end up in a pointless loop
index 142cb9b..b98725d 100644 (file)
        "autoblockedtext": "Text displayed to automatically blocked users.\n\n\"email this user\" should be consistent with {{msg-mw|Emailuser}}.\n\nParameters:\n* $1 - the blocking sysop (with a link to his/her userpage)\n* $2 - the reason for the block (in case of autoblocks: {{msg-mw|autoblocker}})\n* $3 - the current IP address of the blocked user\n* $4 - (Unused) the blocking sysop's username (plain text, without the link). Use it for GENDER.\n* $5 - the unique numeric identifier of the applied autoblock\n* $6 - the expiry of the block\n* $7 - the intended target of the block (what the blocking user specified in the blocking form)\n* $8 - the timestamp when the block started\nSee also:\n* {{msg-mw|Grouppage-sysop}}\n* {{msg-mw|Blockedtext|notext=1}}\n* {{msg-mw|Systemblockedtext|notext=1}}",
        "systemblockedtext": "Text displayed to requests blocked by MediaWiki configuration.\n\n\"email this user\" should be consistent with {{msg-mw|Emailuser}}.\n\nParameters:\n* $1 - (Unused) A dummy user attributed as the blocker, possibly as a link to a user page.\n* $2 - the reason for the block\n* $3 - the current IP address of the blocked user\n* $4 - (Unused) the dummy blocking user's username (plain text, without the link).\n* $5 - A short string indicating the type of system block.\n* $6 - the expiry of the block\n* $7 - the intended target of the block\n* $8 - the timestamp when the block started\nSee also:\n* {{msg-mw|Grouppage-sysop}}\n* {{msg-mw|Blockedtext|notext=1}}\n* {{msg-mw|Autoblockedtext|notext=1}}",
        "blockednoreason": "Substituted with <code>$2</code> in the following message if the reason is not given:\n* {{msg-mw|cantcreateaccount-text}}.\n{{Identical|No reason given}}",
-       "whitelistedittext": "Used as error message. Parameters:\n* $1 - a link to [[Special:UserLogin]] with {{msg-mw|loginreqlink}} as link description\nSee also:\n* {{msg-mw|Nocreatetext}}\n* {{msg-mw|Uploadnologintext}}\n* {{msg-mw|Loginreqpagetext}}",
+       "whitelistedittext": "Used as error message. Parameters:\n* $1 - a link to [[Special:UserLogin]] with {{msg-mw|loginreqlink}} as link description\n* $2 - an URL to the same\n\nSee also:\n* {{msg-mw|Nocreatetext}}\n* {{msg-mw|Uploadnologintext}}\n* {{msg-mw|Loginreqpagetext}}",
        "confirmedittext": "Used as error message.",
        "nosuchsectiontitle": "Used as error message when the user has attempted to edit a nonexistent section.",
        "nosuchsectiontext": "This message is displayed when a user tries to edit a section that does not exist.",
        "loginreqtitle": "Used as title of error message.\n\nSee also:\n* {{msg-mw|permissionserrors}}\n{{Identical|Login required}}",
        "loginreqlink": "Take a look on inflection. Used as <code>$1</code> in the following messages:\n* {{msg-mw|loginreqpagetext}}\n* {{msg-mw|exception-nologin-text-manual}}\n* {{msg-mw|whitelistedittext}}\n* {{msg-mw|Uploadnologintext}}\n* {{msg-mw|watchlistanontext}}\n* {{msg-mw|confirmemail_needlogin}}\n* {{msg-mw|changeemail-no-info}}\n* {{msg-mw|resetpass-no-info}}\n* {{msg-mw|prefsnologintext2}}\n{{Identical|Log in}}",
-       "loginreqpagetext": "This message is displayed if an anonymous reader attempts to access a page which is only available to logged-in users.\n\nParameters:\n* $1 - a link to [[Special:UserLogin]] with {{msg-mw|Loginreqlink}} as link description\nSee also:\n* {{msg-mw|Whitelistedittext}}\n* {{msg-mw|Nocreatetext}}\n* {{msg-mw|Uploadnologintext}}",
+       "loginreqpagetext": "This message is displayed if an anonymous reader attempts to access a page which is only available to logged-in users.\n\nParameters:\n* $1 - a link to [[Special:UserLogin]] with {{msg-mw|loginreqlink}} as link description\n* $2 - an URL to the same\n\nSee also:\n* {{msg-mw|Whitelistedittext}}\n* {{msg-mw|Nocreatetext}}\n* {{msg-mw|Uploadnologintext}}",
        "accmailtitle": "Page title when temporary password was sent to a user via email.",
        "accmailtext": "{{doc-important|Do not translate <code><nowiki>[[User talk:$1|$1]]</nowiki></code> and <code>Special:ChangePassword</code>.}}\nThe message shown when a temporary password has been sent to the user's email address.\n\nParameters:\n* $1 - username\n* $2 - email address",
        "newarticle": "{{Identical|New}}",
        "hiddencategories": "This message is shown below the edit form, like you have a section ''\"Templates used on this page\"''.\n\nParameters:\n* $1 - number of categories",
        "edittools": "{{optional}}\nThis text will be shown below edit and upload forms. It can be used to offer special characters not present on most keyboards for copying/pasting, and also often makes them clickable for insertion via a JavaScript. Since these are seen as specific to a wiki, however, this message should not contain anything but an html comment explaining how it should be used once the wiki has been installed.",
        "edittools-upload": "{{optional}}\nThis text will be shown below upload forms. It will default to the contents of edittools.",
-       "nocreatetext": "Used as error message.\n\nSee also:\n* {{msg-mw|Nocreate-loggedin}}\n* {{msg-mw|Whitelistedittext}}\n* {{msg-mw|Uploadnologintext}}\n* {{msg-mw|Loginreqpagetext}}",
+       "nocreatetext": "Used as error message.\n\nParameters:\n* $1 - a link to [[Special:UserLogin]] with {{msg-mw|loginreqlink}} as link description\n* $2 - an URL to the same\n\nSee also:\n* {{msg-mw|Nocreate-loggedin}}\n* {{msg-mw|Whitelistedittext}}\n* {{msg-mw|Uploadnologintext}}\n* {{msg-mw|Loginreqpagetext}}",
        "nocreate-loggedin": "Used as error message.\n\nSee also:\n* {{msg-mw|Nocreatetext}}",
        "sectioneditnotsupported-title": "Page title of special page, which presumably appears when someone tries to edit a section, and section editing is disabled. Explanation of section editing on [[meta:Help:Section_editing#Section_editing|meta]].",
        "sectioneditnotsupported-text": "I think this is the text of an error message, which presumably appears when someone tries to edit a section, and section editing is disabled. Explanation of section editing on [[meta:Help:Section_editing#Section_editing|meta]].",
        "upload-tryagain": "Used as Submit button text in [[Special:Upload]].\n\nSee also:\n* {{msg-mw|Uploaderror|section header}}\n* {{msg-mw|ignorewarning|button text}}\n* {{msg-mw|reuploaddesc|button text}}",
        "upload-tryagain-nostash": "Used as Submit button text in [[Special:Upload]] when the upload could not be stashed & the file needs to be reuploaded.\n\nSee also:\n* {{msg-mw|Uploaderror|section header}}\n* {{msg-mw|ignorewarning|button text}}\n* {{msg-mw|reuploaddesc|button text}}",
        "uploadnologin": "Used as title of the error message {{msg-mw|Uploadnologintext}}.\n{{Identical|Not logged in}}",
-       "uploadnologintext": "Used as error message.\n\nThe title for this message is {{msg-mw|Uploadnologin}}.\n\nParameters:\n* $1 - link text {{msg-mw|Loginreqlink}}. The link points to [[Special:UserLogin]].\nSee also:\n* {{msg-mw|Whitelistedittext}}\n* {{msg-mw|Nocreatetext}}\n* {{msg-mw|Loginreqpagetext}}",
+       "uploadnologintext": "Used as error message.\n\nThe title for this message is {{msg-mw|Uploadnologin}}.\n\nParameters:\n* $1 - a link to [[Special:UserLogin]] with {{msg-mw|loginreqlink}} as link description\n* $2 - an URL to the same\n\nSee also:\n* {{msg-mw|Whitelistedittext}}\n* {{msg-mw|Nocreatetext}}\n* {{msg-mw|Loginreqpagetext}}",
        "upload_directory_missing": "Parameters:\n* $1 - directory name",
        "upload_directory_read_only": "Parameters:\n* $1 - directory name",
        "uploaderror": "Used as section header in [[Special:Upload]].\n\nSee also:\n* {{msg-mw|upload-tryagain|Submit text}}",