MediaWiki  1.34.0
SpecialFilepath.php
Go to the documentation of this file.
1 <?php
30  public function __construct() {
31  parent::__construct( 'Filepath' );
32  $this->mAllowedRedirectParams = [ 'width', 'height' ];
33  }
34 
41  public function getRedirect( $par ) {
42  $file = $par ?: $this->getRequest()->getText( 'file' );
43 
44  $redirect = null;
45  if ( $file ) {
46  $redirect = SpecialPage::getSafeTitleFor( 'Redirect', "file/$file" );
47  }
48  if ( $redirect === null ) {
49  // The user input is empty or an invalid title,
50  // redirect to form of Special:Redirect with the invalid value prefilled
51  $this->mAddedRedirectParams['wpvalue'] = $file;
52  $redirect = SpecialPage::getSafeTitleFor( 'Redirect', 'file' );
53  }
54  return $redirect;
55  }
56 
57  protected function getGroupName() {
58  return 'media';
59  }
60 }
SpecialFilepath
A special page that redirects to the URL of a given file.
Definition: SpecialFilepath.php:29
SpecialFilepath\getRedirect
getRedirect( $par)
Implement by redirecting through Special:Redirect/file.
Definition: SpecialFilepath.php:41
$file
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition: router.php:42
RedirectSpecialPage
Shortcut to construct a special page alias.
Definition: RedirectSpecialPage.php:29
SpecialPage\getSafeTitleFor
static getSafeTitleFor( $name, $subpage=false)
Get a localised Title object for a page name with a possibly unvalidated subpage.
Definition: SpecialPage.php:112
SpecialFilepath\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialFilepath.php:57
SpecialFilepath\__construct
__construct()
Definition: SpecialFilepath.php:30
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:709