68 parent::__construct(
'Redirect' );
72 $this->repoGroup = $repoGroup;
73 $this->userFactory = $userFactory;
82 $parts = $subpage !==
null ? explode(
'/', $subpage, 2 ) : [];
83 $this->mType = $parts[0] ??
null;
84 $this->mValue = $parts[1] ??
null;
93 if ( !ctype_digit( $this->mValue ) ) {
97 $user = $this->userFactory->newFromId( (
int)$this->mValue );
99 if ( $user->isAnon() ) {
103 if ( $user->isHidden() && !$this->getAuthority()->isAllowed(
'hideuser' ) ) {
108 $user->getUserPage()->getFullURL(
'',
false,
PROTO_CURRENT ), 302
122 $title = Title::newFromTextThrow( Title::makeName(
NS_FILE, $this->mValue ) );
135 $url =
$file->getUrl();
137 $width = $request->getInt(
'width', -1 );
138 $height = $request->getInt(
'height', -1 );
141 if ( $width != -1 ) {
142 $mto =
$file->transform( [
'width' => $width,
'height' => $height ] );
144 if ( $mto && !$mto->isError() ) {
148 $url = [ $mto->getUrl(), $height === -1 ? 301 : 302 ];
163 if ( !ctype_digit( $oldid ) ) {
167 $oldid = (int)$oldid;
168 if ( $oldid === 0 ) {
185 if ( !ctype_digit( $curid ) ) {
189 $curid = (int)$curid;
190 if ( $curid === 0 ) {
209 if ( !ctype_digit( $logid ) ) {
213 $logid = (int)$logid;
214 if ( $logid === 0 ) {
218 $query = [
'title' =>
'Special:Log',
'logid' => $logid ];
230 private function dispatch() {
232 switch ( $this->mType ) {
252 if ( $status && $status->isGood() ) {
255 $value = $status->getValue();
256 if ( is_array( $value ) ) {
257 [ $url, $code ] = $value;
262 if ( $code === 301 ) {
263 $this->
getOutput()->setCdnMaxage( 60 * 60 );
267 $this->
getOutput()->redirect( $url, $code );
271 if ( $this->mValue !==
null ) {
272 $this->
getOutput()->setStatusCode( 404 );
287 'user' => $mp .
'-user',
288 'page' => $mp .
'-page',
289 'revision' => $mp .
'-revision',
290 'file' => $mp .
'-file',
291 'logid' => $mp .
'-logid',
296 'label-message' => $mp .
'-lookup',
298 'default' => current( array_keys( $ns ) ),
300 foreach ( $ns as $n => $m ) {
301 $m = $this->
msg( $m )->text();
302 $a[
'type'][
'options'][$m] = $n;
306 'label-message' => $mp .
'-value'
309 if ( !empty( $this->mType ) ) {
312 if ( !empty( $this->mValue ) ) {
320 if ( !empty( $data[
'type'] ) && !empty( $data[
'value'] ) ) {
321 $this->
setParameter( $data[
'type'] .
'/' . $data[
'value'] );
325 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.
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 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)
static newFatal( $message,... $parameters)
Factory function for fatal errors.
static newGood( $value=null)
Factory function for good results.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.