From cb41d3b2ef253bf9774eb12057a2f7b0596a218a Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Fri, 1 Feb 2008 20:05:20 +0000 Subject: [PATCH] Merge Special:Filepath to the core --- includes/SpecialFilepath.php | 69 +++++++++++++++++++++++++++++++ includes/SpecialPage.php | 1 + languages/messages/MessagesEn.php | 9 ++++ maintenance/language/messages.inc | 6 +++ 4 files changed, 85 insertions(+) create mode 100644 includes/SpecialFilepath.php diff --git a/includes/SpecialFilepath.php b/includes/SpecialFilepath.php new file mode 100644 index 0000000000..4ba8fdb032 --- /dev/null +++ b/includes/SpecialFilepath.php @@ -0,0 +1,69 @@ +getText( 'file' ); + + $title = Title::newFromText( $file, NS_IMAGE ); + + if ( ! $title instanceof Title || $title->getNamespace() != NS_IMAGE ) { + $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(); + } + } +} + +class FilepathForm { + var $mTitle; + + function FilepathForm( &$title ) { + $this->mTitle =& $title; + } + + function execute() { + global $wgOut, $wgTitle, $wgScript; + + $wgOut->addHTML( + wfElement( 'form', + array( + 'id' => 'specialfilepath', + 'method' => 'get', + 'action' => $wgScript, + ), + null + ) . + wfHidden( 'title', $wgTitle->getPrefixedText() ) . + wfOpenElement( 'label' ) . + wfMsgHtml( 'filepath-page' ) . + ' ' . + wfElement( 'input', + array( + 'type' => 'text', + 'size' => 25, + 'name' => 'file', + 'value' => is_object( $this->mTitle ) ? $this->mTitle->getText() : '' + ), + '' + ) . + ' ' . + wfElement( 'input', + array( + 'type' => 'submit', + 'value' => wfMsgHtml( 'filepath-submit' ) + ), + '' + ) . + wfCloseElement( 'label' ) . + wfCloseElement( 'form' ) + ); + } +} diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index dbc8be735b..3be70ee099 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -144,6 +144,7 @@ class SpecialPage 'Unusedtemplates' => array( 'SpecialPage', 'Unusedtemplates' ), 'Randomredirect' => 'SpecialRandomredirect', 'Withoutinterwiki' => array( 'SpecialPage', 'Withoutinterwiki' ), + 'Filepath' => array( 'SpecialPage', 'Filepath' ), 'Mypage' => array( 'SpecialMypage' ), 'Mytalk' => array( 'SpecialMytalk' ), diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 86b242692d..3d0be171dc 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -425,6 +425,7 @@ $specialPageAliases = array( 'Resetpass' => array( 'Resetpass' ), 'Withoutinterwiki' => array( 'Withoutinterwiki' ), 'MergeHistory' => array( 'MergeHistory' ), + 'Filepath' => array( 'Filepath' ), ); /** @@ -3150,4 +3151,12 @@ $1', 'version-hook-name' => 'Hook name', 'version-hook-subscribedby' => 'Subscribed by', 'version-version' => 'Version', + +# Special:Filepath +'filepath' => 'File path', +'filepath-page' => 'File:', +'filepath-submit' => 'Path', +'filepath-summary' => 'This special page returns the complete path for a file. Images are shown in full resolution, other file types are started with their associated program directly. + +Enter the file name without the "{{ns:image}}:" prefix.', ); diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 1409f16baf..1276b8718d 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -2362,6 +2362,12 @@ $wgMessageStructure = array( 'version-hook-subscribedby', 'version-version', ), + 'filepath' => array( + 'filepath', + 'filepath-page', + 'filepath-submit', + 'filepath-summary' + ), ); /** Comments for each block */ $wgBlockComments = array( -- 2.20.1