Correct the address of the FSF in some of the GPL headers
[lhc/web/wiklou.git] / includes / specials / SpecialFilepath.php
1 <?php
2 /**
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 * http://www.gnu.org/copyleft/gpl.html
18 */
19
20 /**
21 * @file
22 * @ingroup SpecialPage
23 */
24
25 function wfSpecialFilepath( $par ) {
26 global $wgRequest, $wgOut;
27
28 $file = isset( $par ) ? $par : $wgRequest->getText( 'file' );
29
30 $title = Title::makeTitleSafe( NS_FILE, $file );
31
32 if ( ! $title instanceof Title || $title->getNamespace() != NS_FILE ) {
33 $cform = new FilepathForm( $title );
34 $cform->execute();
35 } else {
36 $file = wfFindFile( $title );
37 if ( $file && $file->exists() ) {
38 $wgOut->redirect( $file->getURL() );
39 } else {
40 $wgOut->setStatusCode( 404 );
41 $cform = new FilepathForm( $title );
42 $cform->execute();
43 }
44 }
45 }
46
47 /**
48 * @ingroup SpecialPage
49 */
50 class FilepathForm {
51 var $mTitle;
52
53 function FilepathForm( &$title ) {
54 $this->mTitle =& $title;
55 }
56
57 function execute() {
58 global $wgOut, $wgScript;
59
60 $wgOut->addHTML(
61 Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'specialfilepath' ) ) .
62 Xml::openElement( 'fieldset' ) .
63 Xml::element( 'legend', null, wfMsg( 'filepath' ) ) .
64 Xml::hidden( 'title', SpecialPage::getTitleFor( 'Filepath' )->getPrefixedText() ) .
65 Xml::inputLabel( wfMsg( 'filepath-page' ), 'file', 'file', 25, is_object( $this->mTitle ) ? $this->mTitle->getText() : '' ) . ' ' .
66 Xml::submitButton( wfMsg( 'filepath-submit' ) ) . "\n" .
67 Xml::closeElement( 'fieldset' ) .
68 Xml::closeElement( 'form' )
69 );
70 }
71 }