Merge "SkinTemplate: extract formatLanguageName() from outputPage()"
[lhc/web/wiklou.git] / includes / specials / SpecialFilepath.php
index 744940f..e086650 100644 (file)
@@ -33,14 +33,13 @@ class SpecialFilepath extends SpecialPage {
        }
 
        function execute( $par ) {
-               global $wgRequest, $wgOut;
-
                $this->setHeaders();
                $this->outputHeader();
 
-               $file = !is_null( $par ) ? $par : $wgRequest->getText( 'file' );
+               $request = $this->getRequest();
+               $file = !is_null( $par ) ? $par : $request->getText( 'file' );
 
-               $title = Title::makeTitleSafe( NS_FILE, $file );
+               $title = Title::newFromText( $file, NS_FILE );
 
                if ( ! $title instanceof Title || $title->getNamespace() != NS_FILE ) {
                        $this->showForm( $title );
@@ -50,8 +49,8 @@ class SpecialFilepath extends SpecialPage {
                        if ( $file && $file->exists() ) {
                                // Default behaviour: Use the direct link to the file.
                                $url = $file->getURL();
-                               $width = $wgRequest->getInt( 'width', -1 );
-                               $height = $wgRequest->getInt( 'height', -1 );
+                               $width = $request->getInt( 'width', -1 );
+                               $height = $request->getInt( 'height', -1 );
 
                                // If a width is requested...
                                if ( $width != -1 ) {
@@ -62,24 +61,27 @@ class SpecialFilepath extends SpecialPage {
                                                $url = $mto->getURL();
                                        }
                                }
-                               $wgOut->redirect( $url );
+                               $this->getOutput()->redirect( $url );
                        } else {
-                               $wgOut->setStatusCode( 404 );
+                               $this->getOutput()->setStatusCode( 404 );
                                $this->showForm( $title );
                        }
                }
        }
 
+       /**
+        * @param $title Title
+        */
        function showForm( $title ) {
-               global $wgOut, $wgScript;
+               global $wgScript;
 
-               $wgOut->addHTML(
+               $this->getOutput()->addHTML(
                        Html::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'specialfilepath' ) ) .
                        Html::openElement( 'fieldset' ) .
-                       Html::element( 'legend', null, wfMsg( 'filepath' ) ) .
+                       Html::element( 'legend', null, $this->msg( 'filepath' )->text() ) .
                        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::inputLabel( $this->msg( 'filepath-page' )->text(), 'file', 'file', 25, is_object( $title ) ? $title->getText() : '' ) . ' ' .
+                       Xml::submitButton( $this->msg( 'filepath-submit' )->text() ) . "\n" .
                        Html::closeElement( 'fieldset' ) .
                        Html::closeElement( 'form' )
                );