MediaWiki REL1_34
UserNotLoggedIn.php
Go to the documentation of this file.
1<?php
54
66 public function __construct(
67 $reasonMsg = 'exception-nologin-text',
68 $titleMsg = 'exception-nologin',
69 $params = []
70 ) {
71 parent::__construct( $titleMsg, $reasonMsg, $params );
72 }
73
78 public function report( $action = self::SEND_OUTPUT ) {
79 // If an unsupported message is used, don't try redirecting to Special:Userlogin,
80 // since the message may not be compatible.
81 if ( !in_array( $this->msg, LoginHelper::getValidErrorMessages() ) ) {
82 parent::report( $action );
83 return;
84 }
85
86 // Message is valid. Redirect to Special:Userlogin
87
88 $context = RequestContext::getMain();
89
90 $output = $context->getOutput();
91 $query = $context->getRequest()->getValues();
92 // Title will be overridden by returnto
93 unset( $query['title'] );
94 // Redirect to Special:Userlogin
95 $output->redirect( SpecialPage::getTitleFor( 'Userlogin' )->getFullURL( [
96 // Return to this page when the user logs in
97 'returnto' => $context->getTitle()->getFullText(),
98 'returntoquery' => wfArrayToCgi( $query ),
99 'warning' => $this->msg,
100 ] ) );
101
102 if ( $action === self::SEND_OUTPUT ) {
103 $output->output();
104 }
105 }
106}
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
An error page which can definitely be safely rendered using the OutputPage.
static getValidErrorMessages()
Returns an array of all valid error messages.
msg( $key, $fallback,... $params)
Get a message from i18n.
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=[])
$context
Definition load.php:45