Reverting r16861; incompatible change to message texts, breaks a lot of toggle displa...
[lhc/web/wiklou.git] / includes / SpecialNewimages.php
index 2d693ed..95c90e4 100644 (file)
@@ -5,9 +5,6 @@
  * @subpackage SpecialPage
  */
 
-/** */
-require_once( 'ImageGallery.php' );
-
 /**
  *
  */
@@ -20,7 +17,8 @@ function wfSpecialNewimages( $par, $specialPage ) {
        $shownav = !$specialPage->including();
        $hidebots = $wgRequest->getBool('hidebots',1);
 
-       if($hidebots) {
+       $hidebotsql = '';
+       if ($hidebots) {
 
                /** Make a list of group names which have the 'bot' flag
                    set.
@@ -31,23 +29,26 @@ function wfSpecialNewimages( $par, $specialPage ) {
                                $botconds[]="ug_group='$groupname'";
                        }
                }
-               $isbotmember=$dbr->makeList($botconds, LIST_OR);
 
-               /** This join, in conjunction with WHERE ug_group
-                   IS NULL, returns only those rows from IMAGE
-                   where the uploading user is not a member of
-                   a group which has the 'bot' permission set.
-               */
-               $ug = $dbr->tableName('user_groups');
-               $joinsql=" LEFT OUTER JOIN $ug ON img_user=ug_user AND ("
-                 . $isbotmember.')';
+               /* If not bot groups, do not set $hidebotsql */
+               if ($botconds) {
+                       $isbotmember=$dbr->makeList($botconds, LIST_OR);
+
+                       /** This join, in conjunction with WHERE ug_group
+                           IS NULL, returns only those rows from IMAGE
+                       where the uploading user is not a member of
+                       a group which has the 'bot' permission set.
+                       */
+                       $ug = $dbr->tableName('user_groups');
+                       $hidebotsql = " LEFT OUTER JOIN $ug ON img_user=ug_user AND ($isbotmember)";
+               }
        }
 
        $image = $dbr->tableName('image');
 
        $sql="SELECT img_timestamp from $image";
-       if($hidebots) {
-               $sql.=$joinsql.' WHERE ug_group IS NULL';
+       if ($hidebotsql) {
+               $sql .= "$hidebotsql WHERE ug_group IS NULL";
        }
        $sql.=' ORDER BY img_timestamp DESC LIMIT 1';
        $res = $dbr->query($sql, 'wfSpecialNewImages');
@@ -94,8 +95,8 @@ function wfSpecialNewimages( $par, $specialPage ) {
        $sql='SELECT img_size, img_name, img_user, img_user_text,'.
             "img_description,img_timestamp FROM $image";
 
-       if($hidebots) {
-               $sql.=$joinsql;
+       if($hidebotsql) {
+               $sql .= $hidebotsql;
                $where[]='ug_group IS NULL';
        }
        if(count($where)) {
@@ -133,7 +134,7 @@ function wfSpecialNewimages( $par, $specialPage ) {
                $ut = $s->img_user_text;
 
                $nt = Title::newFromText( $name, NS_IMAGE );
-               $img = Image::newFromTitle( $nt );
+               $img = new Image( $nt );
                $ul = $sk->makeLinkObj( Title::makeTitle( NS_USER, $ut ), $ut );
 
                $gallery->add( $img, "$ul<br />\n<i>".$wgLang->timeanddate( $s->img_timestamp, true )."</i><br />\n" );
@@ -148,16 +149,13 @@ function wfSpecialNewimages( $par, $specialPage ) {
        $bydate = wfMsg( 'bydate' );
        $lt = $wgLang->formatNum( min( $shownImages, $limit ) );
        if ($shownav) {
-               $text = wfMsg( 'imagelisttext', $lt, $bydate );
-               $wgOut->addHTML( "<p>{$text}\n</p>" );
+               $text = wfMsgExt( 'imagelisttext', array('parse'), $lt, $bydate );
+               $wgOut->addHTML( $text . "\n" );
        }
 
        $sub = wfMsg( 'ilsubmit' );
        $titleObj = Title::makeTitle( NS_SPECIAL, 'Newimages' );
-       $action = $titleObj->escapeLocalURL();
-       if(!$hidebots) {
-               $action.='&hidebots=0';
-       }
+       $action = $titleObj->escapeLocalURL( $hidebots ? '' : 'hidebots=0' );
        if ($shownav) {
                $wgOut->addHTML( "<form id=\"imagesearch\" method=\"post\" action=\"" .
                  "{$action}\">" .
@@ -178,7 +176,7 @@ function wfSpecialNewimages( $par, $specialPage ) {
                $botpar='';
        }
        $now = wfTimestampNow();
-       $date = $wgLang->timeanddate( $now );
+       $date = $wgLang->timeanddate( $now, true );
        $dateLink = $sk->makeKnownLinkObj( $titleObj, wfMsg( 'sp-newimages-showfrom', $date ), 'from='.$now.$botpar.$searchpar );
 
        $botLink = $sk->makeKnownLinkObj($titleObj, wfMsg( 'showhidebots', ($hidebots ? wfMsg('show') : wfMsg('hide'))),'hidebots='.($hidebots ? '0' : '1').$searchpar);