58 parent::__construct( $imagePage->getContext() );
59 $this->mImagePage = $imagePage;
60 $this->mTitle = $imagePage->getTitle()->createFragmentTarget(
'filehistory' );
63 $this->mRange = [ 0, 0 ];
66 $this->mLimitsShown = array_merge( [ 10 ], $this->mLimitsShown );
67 $this->mDefaultLimit = 10;
68 list( $this->mLimit, ) =
69 $this->mRequest->getLimitOffsetForUser(
108 if ( count( $this->mHist ) ) {
109 if ( $this->mImg->isLocal() ) {
112 for ( $i = $this->mRange[0]; $i <= $this->mRange[1]; $i++ ) {
113 $file = $this->mHist[$i];
114 $user =
$file->getUser(
'text' );
115 $linkBatch->add(
NS_USER, $user );
118 $linkBatch->execute();
122 # Generate prev/next links
124 $s = $list->beginImageHistoryList( $navLink );
126 for ( $i = $this->mRange[0]; $i <= $this->mRange[1]; $i++ ) {
127 $file = $this->mHist[$i];
128 $s .= $list->imageHistoryLine( !
$file->isOld(),
$file );
130 $s .= $list->endImageHistoryList( $navLink );
132 if ( $list->getPreventClickjacking() ) {
140 if ( $this->mQueryDone ) {
143 $this->mImg = $this->mImagePage->getPage()->getFile();
144 if ( !$this->mImg->exists() ) {
148 if ( $this->mOffset !==
null ) {
150 $sadlyWeCannotPassThisTimestampDownTheStack = $this->mDb->timestamp( $this->mOffset );
151 }
catch ( TimestampException $e ) {
152 $this->mOffset =
null;
155 $queryLimit = $this->mLimit + 1;
156 if ( $this->mIsBackwards ) {
158 $this->mHist = $this->mImg->getHistory( $queryLimit,
null, $this->mOffset,
false );
160 $numRows = count( $this->mHist );
161 if ( $numRows <= $this->mLimit && $this->mImg->getTimestamp() > $this->mOffset ) {
162 $this->mHist = array_merge( [ $this->mImg ], $this->mHist );
166 if ( !$this->mOffset || $this->mImg->getTimestamp() < $this->mOffset ) {
170 $oiLimit = count( $this->mHist ) ? $this->mLimit : $this->mLimit + 1;
172 $this->mHist = array_merge( $this->mHist,
173 $this->mImg->getHistory( $oiLimit, $this->mOffset,
null,
false ) );
175 $numRows = count( $this->mHist );
177 # Index value of top item in the list
178 $firstIndex = $this->mIsBackwards ?
179 [ $this->mHist[$numRows - 1]->getTimestamp() ] : [ $this->mHist[0]->getTimestamp() ];
180 # Discard the extra result row if there is one
181 if ( $numRows > $this->mLimit && $numRows > 1 ) {
182 if ( $this->mIsBackwards ) {
183 # Index value of item past the index
184 $this->mPastTheEndIndex = [ $this->mHist[0]->getTimestamp() ];
185 # Index value of bottom item in the list
186 $lastIndex = [ $this->mHist[1]->getTimestamp() ];
188 $this->mRange = [ 1, $numRows - 1 ];
190 # Index value of item past the index
191 $this->mPastTheEndIndex = [ $this->mHist[$numRows - 1]->getTimestamp() ];
192 # Index value of bottom item in the list
193 $lastIndex = [ $this->mHist[$numRows - 2]->getTimestamp() ];
195 $this->mRange = [ 0, $numRows - 2 ];
198 # Setting indexes to an empty array means that they will be
199 # omitted if they would otherwise appear in URLs. It just so
200 # happens that this is the right thing to do in the standard
201 # UI, in all the relevant cases.
202 $this->mPastTheEndIndex = [];
203 # Index value of bottom item in the list
204 $lastIndex = $this->mIsBackwards ?
205 [ $this->mHist[0]->getTimestamp() ] : [ $this->mHist[$numRows - 1]->getTimestamp() ];
207 $this->mRange = [ 0, $numRows - 1 ];
212 $this->mPastTheEndIndex = [];
214 if ( $this->mIsBackwards ) {
215 $this->mIsFirst = ( $numRows < $queryLimit );
216 $this->mIsLast = ( $this->mOffset ==
'' );
217 $this->mLastShown = $firstIndex;
218 $this->mFirstShown = $lastIndex;
220 $this->mIsFirst = ( $this->mOffset ==
'' );
221 $this->mIsLast = ( $numRows < $queryLimit );
222 $this->mLastShown = $lastIndex;
223 $this->mFirstShown = $firstIndex;
225 $this->mQueryDone =
true;