Login & signup form float fixes:
[lhc/web/wiklou.git] / includes / SpecialFilepath.php
1 <?php
2 /**
3 * @file
4 * @ingroup SpecialPage
5 */
6
7 function wfSpecialFilepath( $par ) {
8 global $wgRequest, $wgOut;
9
10 $file = isset( $par ) ? $par : $wgRequest->getText( 'file' );
11
12 $title = Title::newFromText( $file, NS_IMAGE );
13
14 if ( ! $title instanceof Title || $title->getNamespace() != NS_IMAGE ) {
15 $cform = new FilepathForm( $title );
16 $cform->execute();
17 } else {
18 $file = wfFindFile( $title );
19 if ( $file && $file->exists() ) {
20 $wgOut->redirect( $file->getURL() );
21 } else {
22 $wgOut->setStatusCode( 404 );
23 $cform = new FilepathForm( $title );
24 $cform->execute();
25 }
26 }
27 }
28
29 /**
30 * @ingroup SpecialPage
31 */
32 class FilepathForm {
33 var $mTitle;
34
35 function FilepathForm( &$title ) {
36 $this->mTitle =& $title;
37 }
38
39 function execute() {
40 global $wgOut, $wgTitle, $wgScript;
41
42 $wgOut->addHTML(
43 Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'specialfilepath' ) ) .
44 Xml::openElement( 'fieldset' ) .
45 Xml::element( 'legend', null, wfMsg( 'filepath' ) ) .
46 Xml::hidden( 'title', $wgTitle->getPrefixedText() ) .
47 Xml::inputLabel( wfMsg( 'filepath-page' ), 'file', 'file', 25, is_object( $this->mTitle ) ? $this->mTitle->getText() : '' ) . ' ' .
48 Xml::submitButton( wfMsg( 'filepath-submit' ) ) . "\n" .
49 Xml::closeElement( 'fieldset' ) .
50 Xml::closeElement( 'form' )
51 );
52 }
53 }