--- /dev/null
+<?php
+
+function wfSpecialFilepath( $par ) {
+ global $wgRequest, $wgOut;
+
+ $file = isset( $par ) ? $par : $wgRequest->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' )
+ );
+ }
+}
'Unusedtemplates' => array( 'SpecialPage', 'Unusedtemplates' ),
'Randomredirect' => 'SpecialRandomredirect',
'Withoutinterwiki' => array( 'SpecialPage', 'Withoutinterwiki' ),
+ 'Filepath' => array( 'SpecialPage', 'Filepath' ),
'Mypage' => array( 'SpecialMypage' ),
'Mytalk' => array( 'SpecialMytalk' ),
'Resetpass' => array( 'Resetpass' ),
'Withoutinterwiki' => array( 'Withoutinterwiki' ),
'MergeHistory' => array( 'MergeHistory' ),
+ 'Filepath' => array( 'Filepath' ),
);
/**
'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.',
);
'version-hook-subscribedby',
'version-version',
),
+ 'filepath' => array(
+ 'filepath',
+ 'filepath-page',
+ 'filepath-submit',
+ 'filepath-summary'
+ ),
);
/** Comments for each block */
$wgBlockComments = array(