]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - includes/specials/SpecialMIMEsearch.php
MediaWiki 1.17.0
[autoinstallsdev/mediawiki.git] / includes / specials / SpecialMIMEsearch.php
index cdfde24ea58ccb7fc86f487974ce0c48e8867b9b..79683a35d8e8cd226759bb63a1f6867ac63f160b 100644 (file)
@@ -1,13 +1,25 @@
 <?php
 /**
- * A special page to search for files by MIME type as defined in the
- * img_major_mime and img_minor_mime fields in the image table
+ * Implements Special:MIMESearch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
  *
  * @file
  * @ingroup SpecialPage
- *
  * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
  */
 
 /**
@@ -18,7 +30,7 @@
 class MIMEsearchPage extends QueryPage {
        var $major, $minor;
 
-       function MIMEsearchPage( $major, $minor ) {
+       function __construct( $major, $minor ) {
                $this->major = $major;
                $this->minor = $minor;
        }
@@ -65,15 +77,20 @@ class MIMEsearchPage extends QueryPage {
 
                $nt = Title::makeTitle( $result->namespace, $result->title );
                $text = $wgContLang->convert( $nt->getText() );
-               $plink = $skin->makeLink( $nt->getPrefixedText(), $text );
+               $plink = $skin->link(
+                       Title::newFromText( $nt->getPrefixedText() ),
+                       htmlspecialchars( $text )
+               );
 
                $download = $skin->makeMediaLinkObj( $nt, wfMsgHtml( 'download' ) );
                $bytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape'),
                        $wgLang->formatNum( $result->img_size ) );
-               $dimensions = wfMsgHtml( 'widthheight', $wgLang->formatNum( $result->img_width ),
-                       $wgLang->formatNum( $result->img_height ) );
-               $user = $skin->makeLinkObj( Title::makeTitle( NS_USER, $result->img_user_text ), $result->img_user_text );
-               $time = $wgLang->timeanddate( $result->img_timestamp );
+               $dimensions = htmlspecialchars( wfMsg( 'widthheight',
+                       $wgLang->formatNum( $result->img_width ),
+                       $wgLang->formatNum( $result->img_height )
+               ) );
+               $user = $skin->link( Title::makeTitle( NS_USER, $result->img_user_text ), htmlspecialchars( $result->img_user_text ) );
+               $time = htmlspecialchars( $wgLang->timeanddate( $result->img_timestamp ) );
 
                return "($download) $plink . . $dimensions . . $bytes . . $user . . $time";
        }
@@ -83,13 +100,14 @@ class MIMEsearchPage extends QueryPage {
  * Output the HTML search form, and constructs the MIMEsearchPage object.
  */
 function wfSpecialMIMEsearch( $par = null ) {
-       global $wgRequest, $wgTitle, $wgOut;
+       global $wgRequest, $wgOut;
 
        $mime = isset( $par ) ? $par : $wgRequest->getText( 'mime' );
 
        $wgOut->addHTML(
-               Xml::openElement( 'form', array( 'id' => 'specialmimesearch', 'method' => 'get', 'action' => $wgTitle->getLocalUrl() ) ) .
+               Xml::openElement( 'form', array( 'id' => 'specialmimesearch', 'method' => 'get', 'action' => SpecialPage::getTitleFor( 'MIMEsearch' )->getLocalUrl() ) ) .
                Xml::openElement( 'fieldset' ) .
+               Html::hidden( 'title', SpecialPage::getTitleFor( 'MIMEsearch' )->getPrefixedText() ) .
                Xml::element( 'legend', null, wfMsg( 'mimesearch' ) ) .
                Xml::inputLabel( wfMsg( 'mimetype' ), 'mime', 'mime', 20, $mime ) . ' ' .
                Xml::submitButton( wfMsg( 'ilsubmit' ) ) .