b4ce739776d306a07b96ae4162aed173b8bad8ee
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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 * http://www.gnu.org/copyleft/gpl.html
22 * @ingroup SpecialPage
25 function wfSpecialFilepath( $par ) {
26 global $wgRequest, $wgOut;
28 $file = isset( $par ) ?
$par : $wgRequest->getText( 'file' );
30 $title = Title
::makeTitleSafe( NS_FILE
, $file );
32 if ( ! $title instanceof Title ||
$title->getNamespace() != NS_FILE
) {
33 $cform = new FilepathForm( $title );
36 $file = wfFindFile( $title );
37 if ( $file && $file->exists() ) {
38 $wgOut->redirect( $file->getURL() );
40 $wgOut->setStatusCode( 404 );
41 $cform = new FilepathForm( $title );
48 * @ingroup SpecialPage
53 function FilepathForm( &$title ) {
54 $this->mTitle
=& $title;
58 global $wgOut, $wgScript;
61 Xml
::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'specialfilepath' ) ) .
62 Xml
::openElement( 'fieldset' ) .
63 Xml
::element( 'legend', null, wfMsg( 'filepath' ) ) .
64 Xml
::hidden( 'title', SpecialPage
::getTitleFor( 'Filepath' )->getPrefixedText() ) .
65 Xml
::inputLabel( wfMsg( 'filepath-page' ), 'file', 'file', 25, is_object( $this->mTitle
) ?
$this->mTitle
->getText() : '' ) . ' ' .
66 Xml
::submitButton( wfMsg( 'filepath-submit' ) ) . "\n" .
67 Xml
::closeElement( 'fieldset' ) .
68 Xml
::closeElement( 'form' )