Merge "Fix "UTPage" creation in tests"
[lhc/web/wiklou.git] / includes / specials / SpecialListfiles.php
index 7484995..f9caff6 100644 (file)
@@ -33,6 +33,7 @@ class SpecialListFiles extends IncludableSpecialPage {
                if ( $this->including() ) {
                        $userName = $par;
                        $search = '';
+                       $showAll = false;
                } else {
                        $userName = $this->getRequest()->getText( 'user', $par );
                        $search = $this->getRequest()->getText( 'ilsearch', '' );
@@ -120,7 +121,7 @@ class ImageListPager extends TablePager {
         * Build the where clause of the query.
         *
         * Replaces the older mQueryConds member variable.
-        * @param $table String Either "image" or "oldimage"
+        * @param string $table Either "image" or "oldimage"
         * @return array The query conditions.
         */
        protected function buildQueryConds( $table ) {
@@ -128,7 +129,7 @@ class ImageListPager extends TablePager {
                $conds = array();
 
                if ( !is_null( $this->mUserName ) ) {
-                       $conds[ $prefix . '_user_text' ] = $this->mUserName;
+                       $conds[$prefix . '_user_text'] = $this->mUserName;
                }
 
                if ( $this->mSearch !== '' ) {
@@ -153,7 +154,7 @@ class ImageListPager extends TablePager {
        }
 
        /**
-        * @return Array
+        * @return array
         */
        function getFieldNames() {
                if ( !$this->mFieldNames ) {
@@ -214,6 +215,7 @@ class ImageListPager extends TablePager {
                // for two different tables, without reimplementing
                // the pager class.
                $qi = $this->getQueryInfoReal( $this->mTableName );
+
                return $qi;
        }
 
@@ -224,7 +226,7 @@ class ImageListPager extends TablePager {
         *
         * This is a bit hacky.
         *
-        * @param $table String Either 'image' or 'oldimage'
+        * @param string $table Either 'image' or 'oldimage'
         * @return array Query info
         */
        protected function getQueryInfoReal( $table ) {
@@ -289,6 +291,9 @@ class ImageListPager extends TablePager {
         * @note $asc is named $descending in IndexPager base class. However
         *   it is true when the order is ascending, and false when the order
         *   is descending, so I renamed it to $asc here.
+        * @param int $offset
+        * @param int $limit
+        * @param bool $asc
         */
        function reallyDoQuery( $offset, $limit, $asc ) {
                $prevTableName = $this->mTableName;
@@ -324,10 +329,10 @@ class ImageListPager extends TablePager {
         *
         * Note: This will throw away some results
         *
-        * @param $res1 ResultWrapper
-        * @param $res2 ResultWrapper
-        * @param $limit int
-        * @param $ascending boolean See note about $asc in $this->reallyDoQuery
+        * @param ResultWrapper $res1
+        * @param ResultWrapper $res2
+        * @param int $limit
+        * @param bool $ascending See note about $asc in $this->reallyDoQuery
         * @return FakeResultWrapper $res1 and $res2 combined
         */
        protected function combineResult( $res1, $res2, $limit, $ascending ) {
@@ -337,7 +342,7 @@ class ImageListPager extends TablePager {
                $topRes2 = $res2->next();
                $resultArray = array();
                for ( $i = 0; $i < $limit && $topRes1 && $topRes2; $i++ ) {
-                       if ( strcmp( $topRes1->{ $this->mIndexField }, $topRes2->{ $this->mIndexField } ) > 0 ) {
+                       if ( strcmp( $topRes1->{$this->mIndexField}, $topRes2->{$this->mIndexField} ) > 0 ) {
                                if ( !$ascending ) {
                                        $resultArray[] = $topRes1;
                                        $topRes1 = $res1->next();
@@ -363,6 +368,7 @@ class ImageListPager extends TablePager {
                        $resultArray[] = $topRes2;
                        $topRes2 = $res2->next();
                }
+
                return new FakeResultWrapper( $resultArray );
        }
 
@@ -386,6 +392,20 @@ class ImageListPager extends TablePager {
                UserCache::singleton()->doQuery( $userIds, array( 'userpage' ), __METHOD__ );
        }
 
+       /**
+        * @param string $field
+        * @param string $value
+        * @return Message|string|int The return type depends on the value of $field:
+        *   - thumb: string
+        *   - img_timestamp: string
+        *   - img_name: string
+        *   - img_user_text: string
+        *   - img_size: string
+        *   - img_description: string
+        *   - count: int
+        *   - top: Message
+        * @throws MWException
+        */
        function formatValue( $field, $value ) {
                switch ( $field ) {
                        case 'thumb':
@@ -394,6 +414,7 @@ class ImageListPager extends TablePager {
                                // If statement for paranoia
                                if ( $file ) {
                                        $thumb = $file->transform( array( 'width' => 180, 'height' => 360 ) );
+
                                        return $thumb->toHtml( array( 'desc-link' => true ) );
                                } else {
                                        return htmlspecialchars( $value );
@@ -445,6 +466,8 @@ class ImageListPager extends TablePager {
                        case 'top':
                                // Messages: listfiles-latestversion-yes, listfiles-latestversion-no
                                return $this->msg( 'listfiles-latestversion-' . $value );
+                       default:
+                               throw new MWException( "Unknown field '$field'" );
                }
        }
 
@@ -476,6 +499,7 @@ class ImageListPager extends TablePager {
                        'checked' => $this->mShowAll,
                        'tabindex' => 4,
                ) );
+
                return Html::openElement( 'form',
                        array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-listfiles-form' )
                ) .