364ab032acb4316cb1eecacb1a7d52cbcc92913b
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup SpecialPage
23 class SpecialFilepath
extends SpecialPage
{
25 function __construct() {
26 parent
::__construct( 'Filepath' );
29 function execute( $par ) {
30 global $wgRequest, $wgOut;
33 $this->outputHeader();
35 $file = !is_null( $par ) ?
$par : $wgRequest->getText( 'file' );
37 $title = Title
::makeTitleSafe( NS_FILE
, $file );
39 if ( ! $title instanceof Title ||
$title->getNamespace() != NS_FILE
) {
40 $this->showForm( $title );
42 $file = wfFindFile( $title );
43 if ( $file && $file->exists() ) {
44 $wgOut->redirect( $file->getURL() );
46 $wgOut->setStatusCode( 404 );
47 $this->showForm( $title );
52 function showForm( $title ) {
53 global $wgOut, $wgScript;
56 Html
::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'specialfilepath' ) ) .
57 Html
::openElement( 'fieldset' ) .
58 Html
::element( 'legend', null, wfMsg( 'filepath' ) ) .
59 Html
::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
60 Xml
::inputLabel( wfMsg( 'filepath-page' ), 'file', 'file', 25, is_object( $title ) ?
$title->getText() : '' ) . ' ' .
61 Xml
::submitButton( wfMsg( 'filepath-submit' ) ) . "\n" .
62 Html
::closeElement( 'fieldset' ) .
63 Html
::closeElement( 'form' )