Replace some uses of deprecated wfFindFile() and wfLocalFile()
[lhc/web/wiklou.git] / includes / specials / pagers / ImageListPager.php
index 1794362..1d29efb 100644 (file)
@@ -269,10 +269,8 @@ class ImageListPager extends TablePager {
                                }
                        }
                        $fields['top'] = $dbr->addQuotes( 'no' );
-               } else {
-                       if ( $this->mShowAll ) {
-                               $fields['top'] = $dbr->addQuotes( 'yes' );
-                       }
+               } elseif ( $this->mShowAll ) {
+                       $fields['top'] = $dbr->addQuotes( 'yes' );
                }
                $fields['thumb'] = $prefix . '_name';
 
@@ -321,15 +319,15 @@ class ImageListPager extends TablePager {
         *   is descending, so I renamed it to $asc here.
         * @param int $offset
         * @param int $limit
-        * @param bool $asc
-        * @return array
+        * @param bool $order IndexPager::QUERY_ASCENDING or IndexPager::QUERY_DESCENDING
+        * @return FakeResultWrapper
         * @throws MWException
         */
-       function reallyDoQuery( $offset, $limit, $asc ) {
+       function reallyDoQuery( $offset, $limit, $order ) {
                $prevTableName = $this->mTableName;
                $this->mTableName = 'image';
                list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
-                       $this->buildQueryInfo( $offset, $limit, $asc );
+                       $this->buildQueryInfo( $offset, $limit, $order );
                $imageRes = $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds );
                $this->mTableName = $prevTableName;
 
@@ -347,13 +345,13 @@ class ImageListPager extends TablePager {
                $this->mIndexField = 'oi_' . substr( $this->mIndexField, 4 );
 
                list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
-                       $this->buildQueryInfo( $offset, $limit, $asc );
+                       $this->buildQueryInfo( $offset, $limit, $order );
                $oldimageRes = $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds );
 
                $this->mTableName = $prevTableName;
                $this->mIndexField = $oldIndex;
 
-               return $this->combineResult( $imageRes, $oldimageRes, $limit, $asc );
+               return $this->combineResult( $imageRes, $oldimageRes, $limit, $order );
        }
 
        /**
@@ -382,14 +380,12 @@ class ImageListPager extends TablePager {
                                        $resultArray[] = $topRes2;
                                        $topRes2 = $res2->next();
                                }
+                       } elseif ( !$ascending ) {
+                               $resultArray[] = $topRes2;
+                               $topRes2 = $res2->next();
                        } else {
-                               if ( !$ascending ) {
-                                       $resultArray[] = $topRes2;
-                                       $topRes2 = $res2->next();
-                               } else {
-                                       $resultArray[] = $topRes1;
-                                       $topRes1 = $res1->next();
-                               }
+                               $resultArray[] = $topRes1;
+                               $topRes1 = $res1->next();
                        }
                }
 
@@ -440,7 +436,8 @@ class ImageListPager extends TablePager {
         * @throws MWException
         */
        function formatValue( $field, $value ) {
-               $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
+               $services = MediaWikiServices::getInstance();
+               $linkRenderer = $services->getLinkRenderer();
                switch ( $field ) {
                        case 'thumb':
                                $opt = [ 'time' => wfTimestamp( TS_MW, $this->mCurrentRow->img_timestamp ) ];
@@ -472,8 +469,9 @@ class ImageListPager extends TablePager {
                                                $filePage,
                                                $filePage->getText()
                                        );
-                                       $download = Xml::element( 'a',
-                                               [ 'href' => wfLocalFile( $filePage )->getUrl() ],
+                                       $download = Xml::element(
+                                               'a',
+                                               [ 'href' => $services->getRepoGroup()->findFile( $filePage )->getUrl() ],
                                                $imgfile
                                        );
                                        $download = $this->msg( 'parentheses' )->rawParams( $download )->escaped();
@@ -517,7 +515,7 @@ class ImageListPager extends TablePager {
                                return $this->getLanguage()->formatNum( intval( $value ) + 1 );
                        case 'top':
                                // Messages: listfiles-latestversion-yes, listfiles-latestversion-no
-                               return $this->msg( 'listfiles-latestversion-' . $value );
+                               return $this->msg( 'listfiles-latestversion-' . $value )->escaped();
                        default:
                                throw new MWException( "Unknown field '$field'" );
                }