56 parent::__construct( $imagePage->getContext() );
57 $this->mImagePage = $imagePage;
58 $this->mTitle = clone $imagePage->getTitle();
59 $this->mTitle->setFragment(
'#filehistory' );
62 $this->mRange = [ 0, 0 ];
65 $this->mLimitsShown = array_merge( [ 10 ], $this->mLimitsShown );
66 $this->mDefaultLimit = 10;
67 list( $this->mLimit, ) =
68 $this->mRequest->getLimitOffset( $this->mDefaultLimit,
'' );
103 if (
count( $this->mHist ) ) {
104 if ( $this->mImg->isLocal() ) {
107 for ( $i = $this->mRange[0]; $i <= $this->mRange[1]; $i++ ) {
108 $file = $this->mHist[$i];
109 $user = $file->getUser(
'text' );
113 $linkBatch->execute();
117 # Generate prev/next links
119 $s = $list->beginImageHistoryList( $navLink );
121 for ( $i = $this->mRange[0]; $i <= $this->mRange[1]; $i++ ) {
122 $file = $this->mHist[$i];
123 $s .= $list->imageHistoryLine( !$file->isOld(), $file );
125 $s .= $list->endImageHistoryList( $navLink );
127 if ( $list->getPreventClickjacking() ) {
135 if ( $this->mQueryDone ) {
138 $this->mImg = $this->mImagePage->getPage()->getFile();
139 if ( !$this->mImg->exists() ) {
142 $queryLimit = $this->mLimit + 1;
143 if ( $this->mIsBackwards ) {
145 $this->mHist = $this->mImg->getHistory( $queryLimit,
null, $this->mOffset,
false );
147 $numRows =
count( $this->mHist );
148 if ( $numRows <= $this->mLimit && $this->mImg->getTimestamp() >
$this->mOffset ) {
149 $this->mHist = array_merge( [ $this->mImg ], $this->mHist );
153 if ( !$this->mOffset || $this->mImg->getTimestamp() <
$this->mOffset ) {
157 $oiLimit =
count( $this->mHist ) ? $this->mLimit : $this->mLimit + 1;
159 $this->mHist = array_merge( $this->mHist,
160 $this->mImg->getHistory( $oiLimit, $this->mOffset,
null,
false ) );
162 $numRows =
count( $this->mHist );
164 # Index value of top item in the list
165 $firstIndex = $this->mIsBackwards ?
166 $this->mHist[$numRows - 1]->getTimestamp() : $this->mHist[0]->getTimestamp();
167 # Discard the extra result row if there is one
168 if ( $numRows > $this->mLimit && $numRows > 1 ) {
169 if ( $this->mIsBackwards ) {
170 # Index value of item past the index
171 $this->mPastTheEndIndex = $this->mHist[0]->getTimestamp();
172 # Index value of bottom item in the list
173 $lastIndex = $this->mHist[1]->getTimestamp();
175 $this->mRange = [ 1, $numRows - 1 ];
177 # Index value of item past the index
178 $this->mPastTheEndIndex = $this->mHist[$numRows - 1]->getTimestamp();
179 # Index value of bottom item in the list
180 $lastIndex = $this->mHist[$numRows - 2]->getTimestamp();
182 $this->mRange = [ 0, $numRows - 2 ];
185 # Setting indexes to an empty string means that they will be
186 # omitted if they would otherwise appear in URLs. It just so
187 # happens that this is the right thing to do in the standard
188 # UI, in all the relevant cases.
189 $this->mPastTheEndIndex =
'';
190 # Index value of bottom item in the list
191 $lastIndex = $this->mIsBackwards ?
192 $this->mHist[0]->getTimestamp() : $this->mHist[$numRows - 1]->getTimestamp();
194 $this->mRange = [ 0, $numRows - 1 ];
199 $this->mPastTheEndIndex =
'';
201 if ( $this->mIsBackwards ) {
202 $this->mIsFirst = ( $numRows < $queryLimit );
203 $this->mIsLast = ( $this->mOffset ==
'' );
204 $this->mLastShown = $firstIndex;
205 $this->mFirstShown = $lastIndex;
207 $this->mIsFirst = ( $this->mOffset ==
'' );
208 $this->mIsLast = ( $numRows < $queryLimit );
209 $this->mLastShown = $lastIndex;
210 $this->mFirstShown = $firstIndex;
212 $this->mQueryDone =
true;