MediaWiki master
UserNotLoggedIn.php
Go to the documentation of this file.
1<?php
23
58
72 public function __construct(
73 $reasonMsg = 'exception-nologin-text',
74 $titleMsg = 'exception-nologin',
75 $params = []
76 ) {
77 parent::__construct( $titleMsg, $reasonMsg, $params );
78 }
79
85 public function report( $action = self::SEND_OUTPUT ) {
86 // If an unsupported message is used, don't try redirecting to Special:Userlogin,
87 // since the message may not be compatible.
88 if ( !in_array( $this->msg, LoginHelper::getValidErrorMessages() ) ) {
89 parent::report( $action );
90 return;
91 }
92
93 // Message is valid. Redirect to Special:Userlogin
94
95 $context = RequestContext::getMain();
96
97 $output = $context->getOutput();
98 $query = $context->getRequest()->getValues();
99 // Title will be overridden by returnto
100 unset( $query['title'] );
101 // Redirect to Special:Userlogin
102 $output->redirect( SpecialPage::getTitleFor( 'Userlogin' )->getFullURL( [
103 // Return to this page when the user logs in
104 'returnto' => $context->getTitle()->getFullText(),
105 'returntoquery' => wfArrayToCgi( $query ),
106 'warning' => $this->msg,
107 ] ) );
108
109 if ( $action === self::SEND_OUTPUT ) {
110 $output->output();
111 }
112 }
113}
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
array $params
The job parameters.
An error page which can definitely be safely rendered using the OutputPage.
msg( $key, $fallback,... $params)
Get a message from i18n.
Group all the pieces relevant to the context of a request into one instance.
Parent class for all special pages.
Redirect a user to the login page.
report( $action=self::SEND_OUTPUT)
Redirect to Special:Userlogin if the specified message is compatible.
__construct( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin', $params=[])