r68961 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68960‎ | r68961 | r68962 >
Date:18:39, 3 July 2010
Author:ialex
Status:ok (Comments)
Tags:
Comment:
Modified Special:Filepath to subclass SpecialPage; also changed some calls from Xml:: to Html::
Modified paths:
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialFilepath.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/AutoLoader.php
@@ -582,6 +582,7 @@
583583 'SpecialBookSources' => 'includes/specials/SpecialBooksources.php',
584584 'SpecialComparePages' => 'includes/specials/SpecialComparePages.php',
585585 'SpecialExport' => 'includes/specials/SpecialExport.php',
 586+ 'SpecialFilepath' => 'includes/specials/SpecialFilepath.php',
586587 'SpecialImport' => 'includes/specials/SpecialImport.php',
587588 'SpecialListGroupRights' => 'includes/specials/SpecialListgrouprights.php',
588589 'SpecialLockdb' => 'includes/specials/SpecialLockdb.php',
Index: trunk/phase3/includes/specials/SpecialFilepath.php
@@ -18,54 +18,49 @@
1919 */
2020
2121 /**
22 - * @file
2322 * @ingroup SpecialPage
2423 */
 24+class SpecialFilepath extends SpecialPage {
2525
26 -function wfSpecialFilepath( $par ) {
27 - global $wgRequest, $wgOut;
 26+ function __construct() {
 27+ parent::__construct( 'Filepath' );
 28+ }
2829
29 - $file = isset( $par ) ? $par : $wgRequest->getText( 'file' );
 30+ function execute( $par ) {
 31+ global $wgRequest, $wgOut;
3032
31 - $title = Title::makeTitleSafe( NS_FILE, $file );
 33+ $this->setHeaders();
 34+ $this->outputHeader();
3235
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 );
4042 } 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+ }
4450 }
4551 }
46 -}
4752
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 ) {
5954 global $wgOut, $wgScript;
6055
6156 $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() : '' ) . ' ' .
6762 Xml::submitButton( wfMsg( 'filepath-submit' ) ) . "\n" .
68 - Xml::closeElement( 'fieldset' ) .
69 - Xml::closeElement( 'form' )
 63+ Html::closeElement( 'fieldset' ) .
 64+ Html::closeElement( 'form' )
7065 );
7166 }
7267 }
Index: trunk/phase3/includes/SpecialPage.php
@@ -143,7 +143,7 @@
144144
145145 # Media reports and uploads
146146 'Listfiles' => array( 'SpecialPage', 'Listfiles' ),
147 - 'Filepath' => array( 'SpecialPage', 'Filepath' ),
 147+ 'Filepath' => 'SpecialFilepath',
148148 'MIMEsearch' => array( 'SpecialPage', 'MIMEsearch' ),
149149 'FileDuplicateSearch' => array( 'SpecialPage', 'FileDuplicateSearch' ),
150150 'Upload' => 'SpecialUpload',

Comments

#Comment by Reedy (talk | contribs)   00:43, 23 December 2010

Seems to work fine

Status & tagging log