Merge "Notice: Undefined property: stdClass::$hitcount in list=tags"
[lhc/web/wiklou.git] / includes / specials / SpecialNewimages.php
index 99a17f2..350aac6 100644 (file)
@@ -50,9 +50,17 @@ class SpecialNewFiles extends IncludableSpecialPage {
  */
 class NewFilesPager extends ReverseChronologicalPager {
 
+       /**
+        * @var ImageGallery
+        */
+       var $gallery;
+
        function __construct( IContextSource $context, $par = null ) {
                $this->like = $context->getRequest()->getText( 'like' );
                $this->showbots = $context->getRequest()->getBool( 'showbots' , 0 );
+               if ( is_numeric( $par ) ) {
+                       $this->setLimit( $par );
+               }
 
                parent::__construct( $context );
        }
@@ -63,15 +71,18 @@ class NewFilesPager extends ReverseChronologicalPager {
                $tables = array( 'image' );
 
                if( !$this->showbots ) {
-                       $tables[] = 'user_groups';
-                       $conds[] = 'ug_group IS NULL';
-                       $jconds['user_groups'] = array(
-                               'LEFT JOIN',
-                               array(
-                                       'ug_group' => User::getGroupsWithPermission( 'bot' ),
-                                       'ug_user = img_user'
-                               )
-                       );
+                       $groupsWithBotPermission = User::getGroupsWithPermission( 'bot' );
+                       if( count( $groupsWithBotPermission ) ) {
+                               $tables[] = 'user_groups';
+                               $conds[] = 'ug_group IS NULL';
+                               $jconds['user_groups'] = array(
+                                       'LEFT JOIN',
+                                       array(
+                                               'ug_group' => $groupsWithBotPermission,
+                                               'ug_user = img_user'
+                                       )
+                               );
+                       }
                }
 
                if( !$wgMiserMode && $this->like !== null ){
@@ -98,7 +109,10 @@ class NewFilesPager extends ReverseChronologicalPager {
        }
 
        function getStartBody(){
-               $this->gallery = new ImageGallery();
+               if ( !$this->gallery ) {
+                       $this->gallery = new ImageGallery();
+               }
+               return '';
        }
 
        function getEndBody(){
@@ -115,7 +129,7 @@ class NewFilesPager extends ReverseChronologicalPager {
                $this->gallery->add(
                        $title,
                        "$ul<br />\n<i>"
-                               . htmlspecialchars( $this->getLang()->timeanddate( $row->img_timestamp, true ) )
+                               . htmlspecialchars( $this->getLanguage()->userTimeAndDate( $row->img_timestamp, $this->getUser() ) )
                                . "</i><br />\n"
                );
        }
@@ -131,13 +145,13 @@ class NewFilesPager extends ReverseChronologicalPager {
                        ),
                        'showbots' => array(
                                'type' => 'check',
-                               'label' => wfMessage( 'showhidebots', wfMsg( 'show' ) ),
+                               'label' => $this->msg( 'showhidebots', $this->msg( 'show' )->plain() )->escaped(),
                                'name' => 'showbots',
                        #       'default' => $this->getRequest()->getBool( 'showbots', 0 ),
                        ),
                        'limit' => array(
                                'type' => 'hidden',
-                               'default' => $this->getRequest()->getText( 'limit' ),
+                               'default' => $this->mLimit,
                                'name' => 'limit',
                        ),
                        'offset' => array(
@@ -153,9 +167,9 @@ class NewFilesPager extends ReverseChronologicalPager {
 
                $form = new HTMLForm( $fields, $this->getContext() );
                $form->setTitle( $this->getTitle() );
-               $form->setSubmitText( wfMsg( 'ilsubmit' ) );
+               $form->setSubmitTextMsg( 'ilsubmit' );
                $form->setMethod( 'get' );
-               $form->setWrapperLegend( wfMsg( 'newimages-legend' ) );
+               $form->setWrapperLegendMsg( 'newimages-legend' );
 
                return $form;
        }