summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialFilepath.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-12-08 09:55:49 +0100
committerPierre Schmitz <pierre@archlinux.de>2013-12-08 09:55:49 +0100
commit4ac9fa081a7c045f6a9f1cfc529d82423f485b2e (patch)
treeaf68743f2f4a47d13f2b0eb05f5c4aaf86d8ea37 /includes/specials/SpecialFilepath.php
parentaf4da56f1ad4d3ef7b06557bae365da2ea27a897 (diff)
Update to MediaWiki 1.22.0
Diffstat (limited to 'includes/specials/SpecialFilepath.php')
-rw-r--r--includes/specials/SpecialFilepath.php62
1 files changed, 7 insertions, 55 deletions
diff --git a/includes/specials/SpecialFilepath.php b/includes/specials/SpecialFilepath.php
index bbcced26..e7ced52a 100644
--- a/includes/specials/SpecialFilepath.php
+++ b/includes/specials/SpecialFilepath.php
@@ -2,6 +2,7 @@
/**
* Implements Special:Filepath
*
+ * @section LICENSE
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -26,65 +27,16 @@
*
* @ingroup SpecialPage
*/
-class SpecialFilepath extends SpecialPage {
-
+class SpecialFilepath extends RedirectSpecialPage {
function __construct() {
parent::__construct( 'Filepath' );
+ $this->mAllowedRedirectParams = array( 'width', 'height' );
}
- function execute( $par ) {
- $this->setHeaders();
- $this->outputHeader();
-
- $request = $this->getRequest();
- $file = !is_null( $par ) ? $par : $request->getText( 'file' );
-
- $title = Title::newFromText( $file, NS_FILE );
-
- if ( ! $title instanceof Title || $title->getNamespace() != NS_FILE ) {
- $this->showForm( $title );
- } else {
- $file = wfFindFile( $title );
-
- if ( $file && $file->exists() ) {
- // Default behavior: Use the direct link to the file.
- $url = $file->getURL();
- $width = $request->getInt( 'width', -1 );
- $height = $request->getInt( 'height', -1 );
-
- // If a width is requested...
- if ( $width != -1 ) {
- $mto = $file->transform( array( 'width' => $width, 'height' => $height ) );
- // ... and we can
- if ( $mto && !$mto->isError() ) {
- // ... change the URL to point to a thumbnail.
- $url = $mto->getURL();
- }
- }
- $this->getOutput()->redirect( $url );
- } else {
- $this->getOutput()->setStatusCode( 404 );
- $this->showForm( $title );
- }
- }
- }
-
- /**
- * @param $title Title
- */
- function showForm( $title ) {
- global $wgScript;
-
- $this->getOutput()->addHTML(
- Html::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'specialfilepath' ) ) .
- Html::openElement( 'fieldset' ) .
- Html::element( 'legend', null, $this->msg( 'filepath' )->text() ) .
- Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
- Xml::inputLabel( $this->msg( 'filepath-page' )->text(), 'file', 'file', 25, is_object( $title ) ? $title->getText() : '' ) . ' ' .
- Xml::submitButton( $this->msg( 'filepath-submit' )->text() ) . "\n" .
- Html::closeElement( 'fieldset' ) .
- Html::closeElement( 'form' )
- );
+ // implement by redirecting through Special:Redirect/file
+ function getRedirect( $par ) {
+ $file = $par ?: $this->getRequest()->getText( 'file' );
+ return SpecialPage::getSafeTitleFor( 'Redirect', 'file/' . $file );
}
protected function getGroupName() {