Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -582,6 +582,7 @@ |
583 | 583 | 'SpecialBookSources' => 'includes/specials/SpecialBooksources.php', |
584 | 584 | 'SpecialComparePages' => 'includes/specials/SpecialComparePages.php', |
585 | 585 | 'SpecialExport' => 'includes/specials/SpecialExport.php', |
| 586 | + 'SpecialFilepath' => 'includes/specials/SpecialFilepath.php', |
586 | 587 | 'SpecialImport' => 'includes/specials/SpecialImport.php', |
587 | 588 | 'SpecialListGroupRights' => 'includes/specials/SpecialListgrouprights.php', |
588 | 589 | 'SpecialLockdb' => 'includes/specials/SpecialLockdb.php', |
Index: trunk/phase3/includes/specials/SpecialFilepath.php |
— | — | @@ -18,54 +18,49 @@ |
19 | 19 | */ |
20 | 20 | |
21 | 21 | /** |
22 | | - * @file |
23 | 22 | * @ingroup SpecialPage |
24 | 23 | */ |
| 24 | +class SpecialFilepath extends SpecialPage { |
25 | 25 | |
26 | | -function wfSpecialFilepath( $par ) { |
27 | | - global $wgRequest, $wgOut; |
| 26 | + function __construct() { |
| 27 | + parent::__construct( 'Filepath' ); |
| 28 | + } |
28 | 29 | |
29 | | - $file = isset( $par ) ? $par : $wgRequest->getText( 'file' ); |
| 30 | + function execute( $par ) { |
| 31 | + global $wgRequest, $wgOut; |
30 | 32 | |
31 | | - $title = Title::makeTitleSafe( NS_FILE, $file ); |
| 33 | + $this->setHeaders(); |
| 34 | + $this->outputHeader(); |
32 | 35 | |
33 | | - if ( ! $title instanceof Title || $title->getNamespace() != NS_FILE ) { |
34 | | - $cform = new FilepathForm( $title ); |
35 | | - $cform->execute(); |
36 | | - } else { |
37 | | - $file = wfFindFile( $title ); |
38 | | - if ( $file && $file->exists() ) { |
39 | | - $wgOut->redirect( $file->getURL() ); |
| 36 | + $file = !is_null( $par ) ? $par : $wgRequest->getText( 'file' ); |
| 37 | + |
| 38 | + $title = Title::makeTitleSafe( NS_FILE, $file ); |
| 39 | + |
| 40 | + if ( ! $title instanceof Title || $title->getNamespace() != NS_FILE ) { |
| 41 | + $this->showForm( $title ); |
40 | 42 | } else { |
41 | | - $wgOut->setStatusCode( 404 ); |
42 | | - $cform = new FilepathForm( $title ); |
43 | | - $cform->execute(); |
| 43 | + $file = wfFindFile( $title ); |
| 44 | + if ( $file && $file->exists() ) { |
| 45 | + $wgOut->redirect( $file->getURL() ); |
| 46 | + } else { |
| 47 | + $wgOut->setStatusCode( 404 ); |
| 48 | + $this->showForm( $title ); |
| 49 | + } |
44 | 50 | } |
45 | 51 | } |
46 | | -} |
47 | 52 | |
48 | | -/** |
49 | | - * @ingroup SpecialPage |
50 | | - */ |
51 | | -class FilepathForm { |
52 | | - var $mTitle; |
53 | | - |
54 | | - function FilepathForm( &$title ) { |
55 | | - $this->mTitle =& $title; |
56 | | - } |
57 | | - |
58 | | - function execute() { |
| 53 | + function showForm( $title ) { |
59 | 54 | global $wgOut, $wgScript; |
60 | 55 | |
61 | 56 | $wgOut->addHTML( |
62 | | - Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'specialfilepath' ) ) . |
63 | | - Xml::openElement( 'fieldset' ) . |
64 | | - Xml::element( 'legend', null, wfMsg( 'filepath' ) ) . |
65 | | - Xml::hidden( 'title', SpecialPage::getTitleFor( 'Filepath' )->getPrefixedText() ) . |
66 | | - Xml::inputLabel( wfMsg( 'filepath-page' ), 'file', 'file', 25, is_object( $this->mTitle ) ? $this->mTitle->getText() : '' ) . ' ' . |
| 57 | + Html::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'specialfilepath' ) ) . |
| 58 | + Html::openElement( 'fieldset' ) . |
| 59 | + Html::element( 'legend', null, wfMsg( 'filepath' ) ) . |
| 60 | + Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . |
| 61 | + Xml::inputLabel( wfMsg( 'filepath-page' ), 'file', 'file', 25, is_object( $title ) ? $title->getText() : '' ) . ' ' . |
67 | 62 | Xml::submitButton( wfMsg( 'filepath-submit' ) ) . "\n" . |
68 | | - Xml::closeElement( 'fieldset' ) . |
69 | | - Xml::closeElement( 'form' ) |
| 63 | + Html::closeElement( 'fieldset' ) . |
| 64 | + Html::closeElement( 'form' ) |
70 | 65 | ); |
71 | 66 | } |
72 | 67 | } |
Index: trunk/phase3/includes/SpecialPage.php |
— | — | @@ -143,7 +143,7 @@ |
144 | 144 | |
145 | 145 | # Media reports and uploads |
146 | 146 | 'Listfiles' => array( 'SpecialPage', 'Listfiles' ), |
147 | | - 'Filepath' => array( 'SpecialPage', 'Filepath' ), |
| 147 | + 'Filepath' => 'SpecialFilepath', |
148 | 148 | 'MIMEsearch' => array( 'SpecialPage', 'MIMEsearch' ), |
149 | 149 | 'FileDuplicateSearch' => array( 'SpecialPage', 'FileDuplicateSearch' ), |
150 | 150 | 'Upload' => 'SpecialUpload', |