summaryrefslogtreecommitdiff
path: root/includes/SpecialFilepath.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2008-03-21 11:49:34 +0100
committerPierre Schmitz <pierre@archlinux.de>2008-03-21 11:49:34 +0100
commit086ae52d12011746a75f5588e877347bc0457352 (patch)
treee73263c7a29d0f94fafb874562610e16eb292ba8 /includes/SpecialFilepath.php
parent749e7fb2bae7bbda855de3c9e319435b9f698ff7 (diff)
Update auf MediaWiki 1.12.0
Diffstat (limited to 'includes/SpecialFilepath.php')
-rw-r--r--includes/SpecialFilepath.php69
1 files changed, 69 insertions, 0 deletions
diff --git a/includes/SpecialFilepath.php b/includes/SpecialFilepath.php
new file mode 100644
index 00000000..4ba8fdb0
--- /dev/null
+++ b/includes/SpecialFilepath.php
@@ -0,0 +1,69 @@
+<?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' )
+ );
+ }
+}