Fix disabling of APC cache when loading message files: apc.enabled has been PHP_INI_S...
[lhc/web/wiklou.git] / includes / specials / SpecialNewimages.php
index 4892af6..96fea66 100644 (file)
@@ -40,7 +40,8 @@ function wfSpecialNewimages( $par, $specialPage ) {
        if ($hidebotsql) {
                $sql .= "$hidebotsql WHERE ug_group IS NULL";
        }
-       $sql .= ' ORDER BY img_timestamp DESC LIMIT 1';
+       $sql .= ' ORDER BY img_timestamp DESC';
+       $sql = $dbr->limitResult($sql, 1, false);
        $res = $dbr->query( $sql, __FUNCTION__ );
        $row = $dbr->fetchRow( $res );
        if( $row !== false ) {
@@ -64,13 +65,13 @@ function wfSpecialNewimages( $par, $specialPage ) {
        }
 
        $where = array();
-       $searchpar = '';
+       $searchpar = array();
        if ( $wpIlMatch != '' && !$wgMiserMode) {
                $nt = Title::newFromUrl( $wpIlMatch );
                if( $nt ) {
                        $m = $dbr->escapeLike( strtolower( $nt->getDBkey() ) );
                        $where[] = "LOWER(img_name) LIKE '%{$m}%'";
-                       $searchpar = '&wpIlMatch=' . urlencode( $wpIlMatch );
+                       $searchpar['wpIlMatch'] = $wpIlMatch;
                }
        }
 
@@ -93,7 +94,7 @@ function wfSpecialNewimages( $par, $specialPage ) {
                $sql .= ' WHERE ' . $dbr->makeList( $where, LIST_AND );
        }
        $sql.=' ORDER BY img_timestamp '. ( $invertSort ? '' : ' DESC' );
-       $sql.=' LIMIT ' . ( $limit + 1 );
+       $sql = $dbr->limitResult($sql, ( $limit + 1 ), false);
        $res = $dbr->query( $sql, __FUNCTION__ );
 
        /**
@@ -124,10 +125,10 @@ function wfSpecialNewimages( $par, $specialPage ) {
                $name = $s->img_name;
                $ut = $s->img_user_text;
 
-               $nt = Title::newFromText( $name, NS_IMAGE );
-               $ul = $sk->makeLinkObj( Title::makeTitle( NS_USER, $ut ), $ut );
+               $nt = Title::newFromText( $name, NS_FILE );
+               $ul = $sk->link( Title::makeTitle( NS_USER, $ut ), $ut );
 
-               $gallery->add( $nt, "$ul<br />\n<i>".$wgLang->timeanddate( $s->img_timestamp, true )."</i><br />\n" );
+               $gallery->add( $nt, "$ul<br />\n<i>".htmlspecialchars($wgLang->timeanddate( $s->img_timestamp, true ))."</i><br />\n" );
 
                $timestamp = wfTimestamp( TS_MW, $s->img_timestamp );
                if( empty( $firstTimestamp ) ) {
@@ -136,6 +137,19 @@ function wfSpecialNewimages( $par, $specialPage ) {
                $lastTimestamp = $timestamp;
        }
 
+       $titleObj = SpecialPage::getTitleFor( 'Newimages' );
+       $action = $titleObj->getLocalURL( $hidebots ? '' : 'hidebots=0' );
+       if ( $shownav && !$wgMiserMode ) {
+               $wgOut->addHTML(
+                       Xml::openElement( 'form', array( 'action' => $action, 'method' => 'post', 'id' => 'imagesearch' ) ) .
+                       Xml::fieldset( wfMsg( 'newimages-legend' ) ) .
+                       Xml::inputLabel( wfMsg( 'newimages-label' ), 'wpIlMatch', 'wpIlMatch', 20, $wpIlMatch ) . ' ' .
+                       Xml::submitButton( wfMsg( 'ilsubmit' ), array( 'name' => 'wpIlSubmit' ) ) .
+                       Xml::closeElement( 'fieldset' ) .
+                       Xml::closeElement( 'form' )
+                );
+       }
+
        $bydate = wfMsg( 'bydate' );
        $lt = $wgLang->formatNum( min( $shownImages, $limit ) );
        if ( $shownav ) {
@@ -143,46 +157,78 @@ function wfSpecialNewimages( $par, $specialPage ) {
                $wgOut->addHTML( $text . "\n" );
        }
 
-       $sub = wfMsg( 'ilsubmit' );
-       $titleObj = SpecialPage::getTitleFor( 'Newimages' );
-       $action = $titleObj->escapeLocalURL( $hidebots ? '' : 'hidebots=0' );
-       if ($shownav && !$wgMiserMode) {
-               $wgOut->addHTML( "<form id=\"imagesearch\" method=\"post\" action=\"" .
-                 "{$action}\">" .
-                       Xml::input( 'wpIlMatch', 20, $wpIlMatch ) . ' ' .
-                 Xml::submitButton( $sub, array( 'name' => 'wpIlSubmit' ) ) .
-                 "</form>" );
-       }
-
        /**
         * Paging controls...
         */
 
        # If we change bot visibility, this needs to be carried along.
        if( !$hidebots ) {
-               $botpar = '&hidebots=0';
+               $botpar = array( 'hidebots' => 0 );
        } else {
-               $botpar = '';
+               $botpar = array();
        }
        $now = wfTimestampNow();
        $d = $wgLang->date( $now, true );
        $t = $wgLang->time( $now, true );
-       $dateLink = $sk->makeKnownLinkObj( $titleObj, wfMsgHtml( 'sp-newimages-showfrom', $d, $t ), 
-               'from='.$now.$botpar.$searchpar );
-
-       $botLink = $sk->makeKnownLinkObj($titleObj, wfMsgHtml( 'showhidebots', 
-               ($hidebots ? wfMsgHtml('show') : wfMsgHtml('hide'))),'hidebots='.($hidebots ? '0' : '1').$searchpar);
-
+       $query = array_merge(
+               array( 'from' => $now ),
+               $botpar,
+               $searchpar
+       );
+
+       $dateLink = $sk->linkKnown(
+               $titleObj,
+               htmlspecialchars( wfMsg( 'sp-newimages-showfrom', $d, $t ) ),
+               array(),
+               $query
+       );
+
+       $query = array_merge(
+               array( 'hidebots' => ( $hidebots ? 0 : 1 ) ),
+               $searchpar
+       );
+
+       $showhide = $hidebots ? wfMsg( 'show' ) : wfMsg( 'hide' );
+
+       $botLink = $sk->linkKnown(
+               $titleObj,
+               htmlspecialchars( wfMsg( 'showhidebots', $showhide ) ),
+               array(),
+               $query
+       );
 
        $opts = array( 'parsemag', 'escapenoentities' );
-       $prevLink = wfMsgExt( 'prevn', $opts, $wgLang->formatNum( $limit ) );
+       $prevLink = wfMsgExt( 'pager-newer-n', $opts, $wgLang->formatNum( $limit ) );
        if( $firstTimestamp && $firstTimestamp != $latestTimestamp ) {
-               $prevLink = $sk->makeKnownLinkObj( $titleObj, $prevLink, 'from=' . $firstTimestamp . $botpar . $searchpar );
+               $query = array_merge(
+                       array( 'from' => $firstTimestamp ),
+                       $botpar,
+                       $searchpar
+               );
+
+               $prevLink = $sk->linkKnown(
+                       $titleObj,
+                       $prevLink,
+                       array(),
+                       $query
+               );
        }
 
-       $nextLink = wfMsgExt( 'nextn', $opts, $wgLang->formatNum( $limit ) );
+       $nextLink = wfMsgExt( 'pager-older-n', $opts, $wgLang->formatNum( $limit ) );
        if( $shownImages > $limit && $lastTimestamp ) {
-               $nextLink = $sk->makeKnownLinkObj( $titleObj, $nextLink, 'until=' . $lastTimestamp.$botpar.$searchpar );
+               $query = array_merge(
+                       array( 'until' => $lastTimestamp ),
+                       $botpar,
+                       $searchpar
+               );
+
+               $nextLink = $sk->linkKnown(
+                       $titleObj,
+                       $nextLink,
+                       array(),
+                       $query
+               );
+
        }
 
        $prevnext = '<p>' . $botLink . ' '. wfMsgHtml( 'viewprevnext', $prevLink, $nextLink, $dateLink ) .'</p>';