Slowly merge in a few rev_deleted checks
[lhc/web/wiklou.git] / includes / SpecialFilepath.php
1 <?php
2
3 function wfSpecialFilepath( $par ) {
4 global $wgRequest, $wgOut;
5
6 $file = isset( $par ) ? $par : $wgRequest->getText( 'file' );
7
8 $title = Title::newFromText( $file, NS_IMAGE );
9
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();
21 }
22 }
23 }
24
25 class FilepathForm {
26 var $mTitle;
27
28 function FilepathForm( &$title ) {
29 $this->mTitle =& $title;
30 }
31
32 function execute() {
33 global $wgOut, $wgTitle, $wgScript;
34
35 $wgOut->addHTML(
36 wfElement( 'form',
37 array(
38 'id' => 'specialfilepath',
39 'method' => 'get',
40 'action' => $wgScript,
41 ),
42 null
43 ) .
44 wfHidden( 'title', $wgTitle->getPrefixedText() ) .
45 wfOpenElement( 'label' ) .
46 wfMsgHtml( 'filepath-page' ) .
47 ' ' .
48 wfElement( 'input',
49 array(
50 'type' => 'text',
51 'size' => 25,
52 'name' => 'file',
53 'value' => is_object( $this->mTitle ) ? $this->mTitle->getText() : ''
54 ),
55 ''
56 ) .
57 ' ' .
58 wfElement( 'input',
59 array(
60 'type' => 'submit',
61 'value' => wfMsgHtml( 'filepath-submit' )
62 ),
63 ''
64 ) .
65 wfCloseElement( 'label' ) .
66 wfCloseElement( 'form' )
67 );
68 }
69 }