seek() does nothing here
[mediawiki.git] / includes / SpecialFilepath.php
blob84412ab616167c30b0a1517c5357bd5fdd4a28bc
1 <?php
3 function wfSpecialFilepath( $par ) {
4 global $wgRequest, $wgOut;
6 $file = isset( $par ) ? $par : $wgRequest->getText( 'file' );
8 $title = Title::newFromText( $file, NS_IMAGE );
10 if ( ! $title instanceof Title || $title->getNamespace() != NS_IMAGE ) {
11 $cform = new FilepathForm( $title );
12 $cform->execute();
13 } else {
14 $file = wfFindFile( $title );
15 if ( $file && $file->exists() ) {
16 $wgOut->redirect( $file->getURL() );
17 } else {
18 $wgOut->setStatusCode( 404 );
19 $cform = new FilepathForm( $title );
20 $cform->execute();
25 class FilepathForm {
26 var $mTitle;
28 function FilepathForm( &$title ) {
29 $this->mTitle =& $title;
32 function execute() {
33 global $wgOut, $wgTitle, $wgScript;
35 $wgOut->addHTML(
36 Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'specialfilepath' ) ) .
37 Xml::openElement( 'fieldset' ) .
38 Xml::element( 'legend', null, wfMsg( 'filepath' ) ) .
39 Xml::hidden( 'title', $wgTitle->getPrefixedText() ) .
40 Xml::inputLabel( wfMsg( 'filepath-page' ), 'file', 'file', 25, is_object( $this->mTitle ) ? $this->mTitle->getText() : '' ) . ' ' .
41 Xml::submitButton( wfMsg( 'filepath-submit' ) ) . "\n" .
42 Xml::closeElement( 'fieldset' ) .
43 Xml::closeElement( 'form' )