38 parent::__construct( $imagePage->getContext() );
39 $this->mImagePage = $imagePage;
40 $this->mTitle = clone $imagePage->getTitle();
41 $this->mTitle->setFragment(
'#filehistory' );
44 $this->mRange = [ 0, 0 ];
79 if ( count( $this->mHist ) ) {
80 if ( $this->mImg->isLocal() ) {
83 for ( $i = $this->mRange[0]; $i <= $this->mRange[1]; $i++ ) {
84 $file = $this->mHist[$i];
85 $user = $file->getUser(
'text' );
89 $linkBatch->execute();
93 # Generate prev/next links
95 $s = $list->beginImageHistoryList( $navLink );
97 for ( $i = $this->mRange[0]; $i <= $this->mRange[1]; $i++ ) {
98 $file = $this->mHist[$i];
99 $s .= $list->imageHistoryLine( !$file->isOld(), $file );
101 $s .= $list->endImageHistoryList( $navLink );
103 if ( $list->getPreventClickjacking() ) {
111 if ( $this->mQueryDone ) {
114 $this->mImg = $this->mImagePage->getPage()->getFile();
115 if ( !$this->mImg->exists() ) {
118 $queryLimit = $this->mLimit + 1;
119 if ( $this->mIsBackwards ) {
121 $this->mHist = $this->mImg->getHistory( $queryLimit,
null, $this->mOffset,
false );
123 $numRows = count( $this->mHist );
124 if ( $numRows <= $this->mLimit && $this->mImg->getTimestamp() > $this->mOffset ) {
125 $this->mHist = array_merge( [ $this->mImg ], $this->mHist );
129 if ( !$this->mOffset || $this->mImg->getTimestamp() < $this->mOffset ) {
133 $oiLimit = count( $this->mHist ) ? $this->mLimit : $this->mLimit + 1;
135 $this->mHist = array_merge( $this->mHist,
136 $this->mImg->getHistory( $oiLimit, $this->mOffset,
null,
false ) );
138 $numRows = count( $this->mHist );
140 # Index value of top item in the list
141 $firstIndex = $this->mIsBackwards ?
142 $this->mHist[$numRows - 1]->getTimestamp() : $this->mHist[0]->getTimestamp();
143 # Discard the extra result row if there is one
144 if ( $numRows > $this->mLimit && $numRows > 1 ) {
145 if ( $this->mIsBackwards ) {
146 # Index value of item past the index
147 $this->mPastTheEndIndex = $this->mHist[0]->getTimestamp();
148 # Index value of bottom item in the list
149 $lastIndex = $this->mHist[1]->getTimestamp();
151 $this->mRange = [ 1, $numRows - 1 ];
153 # Index value of item past the index
154 $this->mPastTheEndIndex = $this->mHist[$numRows - 1]->getTimestamp();
155 # Index value of bottom item in the list
156 $lastIndex = $this->mHist[$numRows - 2]->getTimestamp();
158 $this->mRange = [ 0, $numRows - 2 ];
161 # Setting indexes to an empty string means that they will be
162 # omitted if they would otherwise appear in URLs. It just so
163 # happens that this is the right thing to do in the standard
164 # UI, in all the relevant cases.
165 $this->mPastTheEndIndex =
'';
166 # Index value of bottom item in the list
167 $lastIndex = $this->mIsBackwards ?
168 $this->mHist[0]->getTimestamp() : $this->mHist[$numRows - 1]->getTimestamp();
170 $this->mRange = [ 0, $numRows - 1 ];
175 $this->mPastTheEndIndex =
'';
177 if ( $this->mIsBackwards ) {
178 $this->mIsFirst = ( $numRows < $queryLimit );
179 $this->mIsLast = ( $this->mOffset ==
'' );
180 $this->mLastShown = $firstIndex;
181 $this->mFirstShown = $lastIndex;
183 $this->mIsFirst = ( $this->mOffset ==
'' );
184 $this->mIsLast = ( $numRows < $queryLimit );
185 $this->mLastShown = $lastIndex;
186 $this->mFirstShown = $firstIndex;
188 $this->mQueryDone =
true;