Modified Special:Filepath to subclass SpecialPage; also changed some calls from Xml...
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 3 Jul 2010 18:39:20 +0000 (18:39 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 3 Jul 2010 18:39:20 +0000 (18:39 +0000)
includes/AutoLoader.php
includes/SpecialPage.php
includes/specials/SpecialFilepath.php

index b4ae511..edb3b97 100644 (file)
@@ -582,6 +582,7 @@ $wgAutoloadLocalClasses = array(
        'SpecialBookSources' => 'includes/specials/SpecialBooksources.php',
        'SpecialComparePages' => 'includes/specials/SpecialComparePages.php',
        'SpecialExport' => 'includes/specials/SpecialExport.php',
+       'SpecialFilepath' => 'includes/specials/SpecialFilepath.php',
        'SpecialImport' => 'includes/specials/SpecialImport.php',
        'SpecialListGroupRights' => 'includes/specials/SpecialListgrouprights.php',
        'SpecialLockdb' => 'includes/specials/SpecialLockdb.php',
index f76966a..182c149 100644 (file)
@@ -143,7 +143,7 @@ class SpecialPage {
 
                # Media reports and uploads
                'Listfiles'                 => array( 'SpecialPage', 'Listfiles' ),
-               'Filepath'                  => array( 'SpecialPage', 'Filepath' ),
+               'Filepath'                  => 'SpecialFilepath',
                'MIMEsearch'                => array( 'SpecialPage', 'MIMEsearch' ),
                'FileDuplicateSearch'       => array( 'SpecialPage', 'FileDuplicateSearch' ),
                'Upload'                    => 'SpecialUpload',
index d9a4c67..364ab03 100644 (file)
  */
 
 /**
- * @file
  * @ingroup SpecialPage
  */
+class SpecialFilepath extends SpecialPage {
 
-function wfSpecialFilepath( $par ) {
-       global $wgRequest, $wgOut;
+       function __construct() {
+               parent::__construct( 'Filepath' );
+       }
 
-       $file = isset( $par ) ? $par : $wgRequest->getText( 'file' );
+       function execute( $par ) {
+               global $wgRequest, $wgOut;
 
-       $title = Title::makeTitleSafe( NS_FILE, $file );
+               $this->setHeaders();
+               $this->outputHeader();
 
-       if ( ! $title instanceof Title || $title->getNamespace() != NS_FILE ) {
-               $cform = new FilepathForm( $title );
-               $cform->execute();
-       } else {
-               $file = wfFindFile( $title );
-               if ( $file && $file->exists() ) {
-                       $wgOut->redirect( $file->getURL() );
-               } else {
-                       $wgOut->setStatusCode( 404 );
-                       $cform = new FilepathForm( $title );
-                       $cform->execute();
-               }
-       }
-}
+               $file = !is_null( $par ) ? $par : $wgRequest->getText( 'file' );
 
-/**
- * @ingroup SpecialPage
- */
-class FilepathForm {
-       var $mTitle;
+               $title = Title::makeTitleSafe( NS_FILE, $file );
 
-       function FilepathForm( &$title ) {
-               $this->mTitle =& $title;
+               if ( ! $title instanceof Title || $title->getNamespace() != NS_FILE ) {
+                       $this->showForm( $title );
+               } else {
+                       $file = wfFindFile( $title );
+                       if ( $file && $file->exists() ) {
+                               $wgOut->redirect( $file->getURL() );
+                       } else {
+                               $wgOut->setStatusCode( 404 );
+                               $this->showForm( $title );
+                       }
+               }
        }
 
-       function execute() {
+       function showForm( $title ) {
                global $wgOut, $wgScript;
 
                $wgOut->addHTML(
-                       Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'specialfilepath' ) ) .
-                       Xml::openElement( 'fieldset' ) .
-                       Xml::element( 'legend', null, wfMsg( 'filepath' ) ) .
-                       Xml::hidden( 'title', SpecialPage::getTitleFor( 'Filepath' )->getPrefixedText() ) .
-                       Xml::inputLabel( wfMsg( 'filepath-page' ), 'file', 'file', 25, is_object( $this->mTitle ) ? $this->mTitle->getText() : '' ) . ' ' .
+                       Html::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'specialfilepath' ) ) .
+                       Html::openElement( 'fieldset' ) .
+                       Html::element( 'legend', null, wfMsg( 'filepath' ) ) .
+                       Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
+                       Xml::inputLabel( wfMsg( 'filepath-page' ), 'file', 'file', 25, is_object( $title ) ? $title->getText() : '' ) . ' ' .
                        Xml::submitButton( wfMsg( 'filepath-submit' ) ) . "\n" .
-                       Xml::closeElement( 'fieldset' ) .
-                       Xml::closeElement( 'form' )
+                       Html::closeElement( 'fieldset' ) .
+                       Html::closeElement( 'form' )
                );
        }
 }