rdbms: remove leading table name space hack in Database
[lhc/web/wiklou.git] / includes / page / ImageHistoryPseudoPager.php
index f541387..20bc614 100644 (file)
@@ -31,34 +31,57 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager {
         */
        protected $mTitle;
 
+       /**
+        * @since 1.14
+        * @var ImagePage
+        */
+       public $mImagePage;
+
+       /**
+        * @since 1.14
+        * @var File[]
+        */
+       public $mHist;
+
+       /**
+        * @since 1.14
+        * @var int[]
+        */
+       public $mRange;
+
        /**
         * @param ImagePage $imagePage
         */
-       function __construct( $imagePage ) {
+       public function __construct( $imagePage ) {
                parent::__construct( $imagePage->getContext() );
                $this->mImagePage = $imagePage;
-               $this->mTitle = clone $imagePage->getTitle();
-               $this->mTitle->setFragment( '#filehistory' );
+               $this->mTitle = $imagePage->getTitle()->createFragmentTarget( 'filehistory' );
                $this->mImg = null;
-               $this->mHist = array();
-               $this->mRange = array( 0, 0 ); // display range
+               $this->mHist = [];
+               $this->mRange = [ 0, 0 ]; // display range
+
+               // Only display 10 revisions at once by default, otherwise the list is overwhelming
+               $this->mLimitsShown = array_merge( [ 10 ], $this->mLimitsShown );
+               $this->mDefaultLimit = 10;
+               list( $this->mLimit, /* $offset */ ) =
+                       $this->mRequest->getLimitOffset( $this->mDefaultLimit, '' );
        }
 
        /**
         * @return Title
         */
-       function getTitle() {
+       public function getTitle() {
                return $this->mTitle;
        }
 
-       function getQueryInfo() {
+       public function getQueryInfo() {
                return false;
        }
 
        /**
         * @return string
         */
-       function getIndexField() {
+       public function getIndexField() {
                return '';
        }
 
@@ -66,14 +89,14 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager {
         * @param object $row
         * @return string
         */
-       function formatRow( $row ) {
+       public function formatRow( $row ) {
                return '';
        }
 
        /**
         * @return string
         */
-       function getBody() {
+       public function getBody() {
                $s = '';
                $this->doQuery();
                if ( count( $this->mHist ) ) {
@@ -107,7 +130,7 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager {
                return $s;
        }
 
-       function doQuery() {
+       public function doQuery() {
                if ( $this->mQueryDone ) {
                        return;
                }
@@ -122,7 +145,7 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager {
                        // The current rev may not meet the offset/limit
                        $numRows = count( $this->mHist );
                        if ( $numRows <= $this->mLimit && $this->mImg->getTimestamp() > $this->mOffset ) {
-                               $this->mHist = array_merge( array( $this->mImg ), $this->mHist );
+                               $this->mHist = array_merge( [ $this->mImg ], $this->mHist );
                        }
                } else {
                        // The current rev may not meet the offset
@@ -148,14 +171,14 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager {
                                        # Index value of bottom item in the list
                                        $lastIndex = $this->mHist[1]->getTimestamp();
                                        # Display range
-                                       $this->mRange = array( 1, $numRows - 1 );
+                                       $this->mRange = [ 1, $numRows - 1 ];
                                } else {
                                        # Index value of item past the index
                                        $this->mPastTheEndIndex = $this->mHist[$numRows - 1]->getTimestamp();
                                        # Index value of bottom item in the list
                                        $lastIndex = $this->mHist[$numRows - 2]->getTimestamp();
                                        # Display range
-                                       $this->mRange = array( 0, $numRows - 2 );
+                                       $this->mRange = [ 0, $numRows - 2 ];
                                }
                        } else {
                                # Setting indexes to an empty string means that they will be
@@ -167,7 +190,7 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager {
                                $lastIndex = $this->mIsBackwards ?
                                        $this->mHist[0]->getTimestamp() : $this->mHist[$numRows - 1]->getTimestamp();
                                # Display range
-                               $this->mRange = array( 0, $numRows - 1 );
+                               $this->mRange = [ 0, $numRows - 1 ];
                        }
                } else {
                        $firstIndex = '';