67 parent::__construct(
'Redirect' );
71 $this->repoGroup = $repoGroup;
72 $this->userFactory = $userFactory;
81 $parts = $subpage !==
null ? explode(
'/', $subpage, 2 ) : [];
82 $this->mType = $parts[0] ??
null;
83 $this->mValue = $parts[1] ??
null;
92 if ( !ctype_digit( $this->mValue ) ) {
96 $user = $this->userFactory->newFromId( (
int)$this->mValue );
98 if ( $user->isAnon() ) {
102 if ( $user->isHidden() && !$this->getAuthority()->isAllowed(
'hideuser' ) ) {
106 return Status::newGood( [
107 $user->getUserPage()->getFullURL(
'',
false,
PROTO_CURRENT ), 302
121 $title = Title::newFromTextThrow( Title::makeName(
NS_FILE, $this->mValue ) );
134 $url =
$file->getUrl();
136 $width = $request->getInt(
'width', -1 );
137 $height = $request->getInt(
'height', -1 );
140 if ( $width != -1 ) {
141 $mto =
$file->transform( [
'width' => $width,
'height' => $height ] );
143 if ( $mto && !$mto->isError() ) {
147 $url = [ $mto->getUrl(), $height === -1 ? 301 : 302 ];
151 return Status::newGood( $url );
162 if ( !ctype_digit( $oldid ) ) {
166 $oldid = (int)$oldid;
167 if ( $oldid === 0 ) {
184 if ( !ctype_digit( $curid ) ) {
188 $curid = (int)$curid;
189 if ( $curid === 0 ) {
208 if ( !ctype_digit( $logid ) ) {
212 $logid = (int)$logid;
213 if ( $logid === 0 ) {
217 $query = [
'title' =>
'Special:Log',
'logid' => $logid ];
229 private function dispatch() {
231 switch ( $this->mType ) {
251 if ( $status && $status->isGood() ) {
254 $value = $status->getValue();
255 if ( is_array( $value ) ) {
256 list( $url, $code ) = $value;
261 if ( $code === 301 ) {
262 $this->
getOutput()->setCdnMaxage( 60 * 60 );
266 $this->
getOutput()->redirect( $url, $code );
270 if ( $this->mValue !==
null ) {
271 $this->
getOutput()->setStatusCode( 404 );
286 'user' => $mp .
'-user',
287 'page' => $mp .
'-page',
288 'revision' => $mp .
'-revision',
289 'file' => $mp .
'-file',
290 'logid' => $mp .
'-logid',
295 'label-message' => $mp .
'-lookup',
297 'default' => current( array_keys( $ns ) ),
299 foreach ( $ns as $n => $m ) {
300 $m = $this->
msg( $m )->text();
301 $a[
'type'][
'options'][$m] = $n;
305 'label-message' => $mp .
'-value'
308 if ( !empty( $this->mType ) ) {
311 if ( !empty( $this->mValue ) ) {
319 if ( !empty( $data[
'type'] ) && !empty( $data[
'value'] ) ) {
320 $this->
setParameter( $data[
'type'] .
'/' . $data[
'value'] );
324 return $this->dispatch();
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
Special page which uses an HTMLForm to handle processing.
getMessagePrefix()
Get message prefix for HTMLForm.
Show an error when a user tries to do something they do not have the necessary permissions for.
Prioritized list of file repositories.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
getOutput()
Get the OutputPage being used for this instance.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getRequest()
Get the WebRequest being used for this instance.
A special page that redirects to: the user for a numeric user id, the file for a given filename,...
getSubpagesForPrefixSearch()
Return an array of subpages that this special page will accept.
setParameter( $subpage)
Set $mType and $mValue based on parsed value of $subpage.
onSubmit(array $data)
Process the form on POST submission.
getDisplayFormat()
Get display format for the form.
dispatchLog()
Handle Special:Redirect/logid/xxx (by redirecting to index.php?title=Special:Log&logid=xxx)
getFormFields()
Get an HTMLForm descriptor array.
onSuccess()
Do something exciting on successful processing of the form, most likely to show a confirmation messag...
dispatchUser()
Handle Special:Redirect/user/xxxx (by redirecting to User:YYYY)
string null $mValue
The identifier/value for the redirect (which id, which file)
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
alterForm(HTMLForm $form)
Play with the HTMLForm if you need to more substantially.
dispatchRevision()
Handle Special:Redirect/revision/xxx (by redirecting to index.php?oldid=xxx)
dispatchPage()
Handle Special:Redirect/page/xxx (by redirecting to index.php?curid=xxx)
dispatchFile()
Handle Special:Redirect/file/xxxx.
__construct(RepoGroup $repoGroup, UserFactory $userFactory)
string null $mType
The type of the redirect (user/file/revision)
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.