summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialFilepath.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2008-08-15 01:29:47 +0200
committerPierre Schmitz <pierre@archlinux.de>2008-08-15 01:29:47 +0200
commit370e83bb0dfd0c70de268c93bf07ad5ee0897192 (patch)
tree491674f4c242e4d6ba0d04eafa305174c35a3391 /includes/specials/SpecialFilepath.php
parentf4debf0f12d0524d2b2427c55ea3f16b680fad97 (diff)
Update auf 1.13.0
Diffstat (limited to 'includes/specials/SpecialFilepath.php')
-rw-r--r--includes/specials/SpecialFilepath.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/includes/specials/SpecialFilepath.php b/includes/specials/SpecialFilepath.php
new file mode 100644
index 00000000..a2ba3e57
--- /dev/null
+++ b/includes/specials/SpecialFilepath.php
@@ -0,0 +1,53 @@
+<?php
+/**
+ * @file
+ * @ingroup SpecialPage
+ */
+
+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();
+ }
+ }
+}
+
+/**
+ * @ingroup SpecialPage
+ */
+class FilepathForm {
+ var $mTitle;
+
+ function FilepathForm( &$title ) {
+ $this->mTitle =& $title;
+ }
+
+ function execute() {
+ global $wgOut, $wgTitle, $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', $wgTitle->getPrefixedText() ) .
+ Xml::inputLabel( wfMsg( 'filepath-page' ), 'file', 'file', 25, is_object( $this->mTitle ) ? $this->mTitle->getText() : '' ) . ' ' .
+ Xml::submitButton( wfMsg( 'filepath-submit' ) ) . "\n" .
+ Xml::closeElement( 'fieldset' ) .
+ Xml::closeElement( 'form' )
+ );
+ }
+}