MediaWiki
REL1_37
LoginHelper.php
Go to the documentation of this file.
1
<?php
2
3
use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
4
10
class
LoginHelper
extends
ContextSource
{
11
use ProtectedHookAccessorTrait;
12
25
public
static
$validErrorMessages
= [
26
'exception-nologin-text'
,
27
'watchlistanontext'
,
28
'changeemail-no-info'
,
29
'resetpass-no-info'
,
30
'confirmemail_needlogin'
,
31
'prefsnologintext2'
,
32
'specialmute-login-required'
,
33
];
34
41
public
static
function
getValidErrorMessages
() {
42
static
$messages =
null
;
43
if
( !$messages ) {
44
$messages =
self::$validErrorMessages
;
45
Hooks::runner()->onLoginFormValidErrorMessages( $messages );
46
}
47
48
return
$messages;
49
}
50
51
public
function
__construct
(
IContextSource
$context
) {
52
$this->
setContext
( $context );
53
}
54
69
public
function
showReturnToPage
(
70
$type
, $returnTo =
''
, $returnToQuery =
''
, $stickHTTPS =
false
71
) {
72
$config = $this->
getConfig
();
73
if
(
$type
!==
'error'
&& $config->get(
'RedirectOnLogin'
) !==
null
) {
74
$returnTo = $config->get(
'RedirectOnLogin'
);
75
$returnToQuery = [];
76
} elseif ( is_string( $returnToQuery ) ) {
77
$returnToQuery =
wfCgiToArray
( $returnToQuery );
78
}
79
80
// Allow modification of redirect behavior
81
$this->getHookRunner()->onPostLoginRedirect( $returnTo, $returnToQuery,
$type
);
82
83
$returnToTitle = Title::newFromText( $returnTo ) ?: Title::newMainPage();
84
85
if
( $config->get(
'ForceHTTPS'
)
86
|| ( $config->get(
'SecureLogin'
) && $stickHTTPS )
87
) {
88
$options = [
'https'
];
89
$proto =
PROTO_HTTPS
;
90
} elseif ( $config->get(
'SecureLogin'
) && !$stickHTTPS ) {
91
$options = [
'http'
];
92
$proto =
PROTO_HTTP
;
93
}
else
{
94
$options = [];
95
$proto =
PROTO_RELATIVE
;
96
}
97
98
if
(
$type
===
'successredirect'
) {
99
$redirectUrl = $returnToTitle->getFullUrlForRedirect( $returnToQuery, $proto );
100
$this->
getOutput
()->redirect( $redirectUrl );
101
}
else
{
102
$this->
getOutput
()->addReturnTo( $returnToTitle, $returnToQuery,
null
, $options );
103
}
104
}
105
}
PROTO_HTTPS
const PROTO_HTTPS
Definition
Defines.php:193
PROTO_HTTP
const PROTO_HTTP
Definition
Defines.php:192
PROTO_RELATIVE
const PROTO_RELATIVE
Definition
Defines.php:194
wfCgiToArray
wfCgiToArray( $query)
This is the logical opposite of wfArrayToCgi(): it accepts a query string as its argument and returns...
Definition
GlobalFunctions.php:375
ContextSource
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
Definition
ContextSource.php:33
ContextSource\getConfig
getConfig()
Definition
ContextSource.php:72
ContextSource\getOutput
getOutput()
Definition
ContextSource.php:126
ContextSource\$context
IContextSource $context
Definition
ContextSource.php:39
ContextSource\setContext
setContext(IContextSource $context)
Definition
ContextSource.php:63
LoginHelper
Helper functions for the login form that need to be shared with other special pages (such as CentralA...
Definition
LoginHelper.php:10
LoginHelper\getValidErrorMessages
static getValidErrorMessages()
Returns an array of all valid error messages.
Definition
LoginHelper.php:41
LoginHelper\__construct
__construct(IContextSource $context)
Definition
LoginHelper.php:51
LoginHelper\$validErrorMessages
static string[] $validErrorMessages
Valid error and warning messages.
Definition
LoginHelper.php:25
LoginHelper\showReturnToPage
showReturnToPage( $type, $returnTo='', $returnToQuery='', $stickHTTPS=false)
Show a return link or redirect to it.
Definition
LoginHelper.php:69
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition
IContextSource.php:58
$type
$type
Definition
testCompression.php:52
includes
specials
helpers
LoginHelper.php
Generated on Fri Apr 5 2024 23:40:55 for MediaWiki by
1.9.8