MediaWiki  master
IndexPager.php
Go to the documentation of this file.
1 <?php
24 use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
30 
73 abstract class IndexPager extends ContextSource implements Pager {
74  use ProtectedHookAccessorTrait;
75 
77  public const DIR_ASCENDING = false;
79  public const DIR_DESCENDING = true;
80 
82  public const QUERY_ASCENDING = true;
84  public const QUERY_DESCENDING = false;
85 
87  public $mRequest;
89  public $mLimitsShown = [ 20, 50, 100, 250, 500 ];
91  public $mDefaultLimit = 50;
93  public $mOffset;
95  public $mLimit;
97  public $mQueryDone = false;
99  public $mDb;
102 
109  protected $mIndexField;
115  protected $mExtraSortFields;
119  protected $mOrderType;
135 
137  public $mIsFirst;
139  public $mIsLast;
140 
142  protected $mLastShown;
144  protected $mFirstShown;
146  protected $mPastTheEndIndex;
148  protected $mDefaultQuery;
150  protected $mNavigationBar;
151 
156  protected $mIncludeOffset = false;
157 
163  public $mResult;
164 
166  private $linkRenderer;
167 
168  public function __construct( IContextSource $context = null, LinkRenderer $linkRenderer = null ) {
169  if ( $context ) {
170  $this->setContext( $context );
171  }
172 
173  $this->mRequest = $this->getRequest();
174 
175  # NB: the offset is quoted, not validated. It is treated as an
176  # arbitrary string to support the widest variety of index types. Be
177  # careful outputting it into HTML!
178  $this->mOffset = $this->mRequest->getText( 'offset' );
179 
180  # Use consistent behavior for the limit options
181  $this->mDefaultLimit = $this->getUser()->getIntOption( 'rclimit' );
182  if ( !$this->mLimit ) {
183  // Don't override if a subclass calls $this->setLimit() in its constructor.
184  list( $this->mLimit, /* $offset */ ) = $this->mRequest
185  ->getLimitOffsetForUser( $this->getUser() );
186  }
187 
188  $this->mIsBackwards = ( $this->mRequest->getVal( 'dir' ) == 'prev' );
189  # Let the subclass set the DB here; otherwise use a replica DB for the current wiki
190  $this->mDb = $this->mDb ?: wfGetDB( DB_REPLICA );
191 
192  $index = $this->getIndexField(); // column to sort on
193  $extraSort = $this->getExtraSortFields(); // extra columns to sort on for query planning
194  $order = $this->mRequest->getVal( 'order' );
195 
196  if ( is_array( $index ) && isset( $index[$order] ) ) {
197  $this->mOrderType = $order;
198  $this->mIndexField = $index[$order];
199  $this->mExtraSortFields = isset( $extraSort[$order] )
200  ? (array)$extraSort[$order]
201  : [];
202  } elseif ( is_array( $index ) ) {
203  # First element is the default
204  $this->mIndexField = reset( $index );
205  $this->mOrderType = key( $index );
206  $this->mExtraSortFields = isset( $extraSort[$this->mOrderType] )
207  ? (array)$extraSort[$this->mOrderType]
208  : [];
209  } else {
210  # $index is not an array
211  $this->mOrderType = null;
212  $this->mIndexField = $index;
213  $isSortAssociative = array_values( $extraSort ) !== $extraSort;
214  if ( $isSortAssociative ) {
215  $this->mExtraSortFields = isset( $extraSort[$index] )
216  ? (array)$extraSort[$index]
217  : [];
218  } else {
219  $this->mExtraSortFields = (array)$extraSort;
220  }
221  }
222 
223  if ( !isset( $this->mDefaultDirection ) ) {
224  $dir = $this->getDefaultDirections();
225  $this->mDefaultDirection = is_array( $dir )
226  ? $dir[$this->mOrderType]
227  : $dir;
228  }
229  $this->linkRenderer = $linkRenderer;
230  }
231 
237  public function getDatabase() {
238  return $this->mDb;
239  }
240 
246  public function doQuery() {
247  $defaultOrder = ( $this->mDefaultDirection === self::DIR_ASCENDING )
248  ? self::QUERY_ASCENDING
249  : self::QUERY_DESCENDING;
250  $order = $this->mIsBackwards ? self::oppositeOrder( $defaultOrder ) : $defaultOrder;
251 
252  # Plus an extra row so that we can tell the "next" link should be shown
253  $queryLimit = $this->mLimit + 1;
254 
255  if ( $this->mOffset == '' ) {
256  $isFirst = true;
257  } else {
258  // If there's an offset, we may or may not be at the first entry.
259  // The only way to tell is to run the query in the opposite
260  // direction see if we get a row.
261  $oldIncludeOffset = $this->mIncludeOffset;
262  $this->mIncludeOffset = !$this->mIncludeOffset;
263  $oppositeOrder = self::oppositeOrder( $order );
264  $isFirst = !$this->reallyDoQuery( $this->mOffset, 1, $oppositeOrder )->numRows();
265  $this->mIncludeOffset = $oldIncludeOffset;
266  }
267 
268  $this->mResult = $this->reallyDoQuery(
269  $this->mOffset,
270  $queryLimit,
271  $order
272  );
273 
274  $this->extractResultInfo( $isFirst, $queryLimit, $this->mResult );
275  $this->mQueryDone = true;
276 
277  $this->preprocessResults( $this->mResult );
278  $this->mResult->rewind(); // Paranoia
279  }
280 
285  final protected static function oppositeOrder( $order ) {
286  return ( $order === self::QUERY_ASCENDING )
289  }
290 
294  public function getResult() {
295  return $this->mResult;
296  }
297 
303  public function setOffset( $offset ) {
304  $this->mOffset = $offset;
305  }
306 
314  public function setLimit( $limit ) {
315  $limit = (int)$limit;
316  // WebRequest::getLimitOffsetForUser() puts a cap of 5000, so do same here.
317  if ( $limit > 5000 ) {
318  $limit = 5000;
319  }
320  if ( $limit > 0 ) {
321  $this->mLimit = $limit;
322  }
323  }
324 
330  public function getLimit() {
331  return $this->mLimit;
332  }
333 
341  public function setIncludeOffset( $include ) {
342  $this->mIncludeOffset = $include;
343  }
344 
354  protected function extractResultInfo( $isFirst, $limit, IResultWrapper $res ) {
355  $numRows = $res->numRows();
356 
357  $firstIndex = [];
358  $lastIndex = [];
359  $this->mPastTheEndIndex = [];
360  $this->mPastTheEndRow = null;
361 
362  if ( $numRows ) {
363  $indexColumns = array_map( function ( $v ) {
364  // Remove any table prefix from index field
365  $parts = explode( '.', $v );
366  return end( $parts );
367  }, (array)$this->mIndexField );
368 
369  $row = $res->fetchRow();
370  foreach ( $indexColumns as $indexColumn ) {
371  $firstIndex[] = $row[$indexColumn];
372  }
373 
374  # Discard the extra result row if there is one
375  if ( $numRows > $this->mLimit && $numRows > 1 ) {
376  $res->seek( $numRows - 1 );
377  $this->mPastTheEndRow = $res->fetchObject();
378  foreach ( $indexColumns as $indexColumn ) {
379  $this->mPastTheEndIndex[] = $this->mPastTheEndRow->$indexColumn;
380  }
381  $res->seek( $numRows - 2 );
382  $row = $res->fetchRow();
383  foreach ( $indexColumns as $indexColumn ) {
384  $lastIndex[] = $row[$indexColumn];
385  }
386  } else {
387  $this->mPastTheEndRow = null;
388  $res->seek( $numRows - 1 );
389  $row = $res->fetchRow();
390  foreach ( $indexColumns as $indexColumn ) {
391  $lastIndex[] = $row[$indexColumn];
392  }
393  }
394  }
395 
396  if ( $this->mIsBackwards ) {
397  $this->mIsFirst = ( $numRows < $limit );
398  $this->mIsLast = $isFirst;
399  $this->mLastShown = $firstIndex;
400  $this->mFirstShown = $lastIndex;
401  } else {
402  $this->mIsFirst = $isFirst;
403  $this->mIsLast = ( $numRows < $limit );
404  $this->mLastShown = $lastIndex;
405  $this->mFirstShown = $firstIndex;
406  }
407  }
408 
414  protected function getSqlComment() {
415  return static::class;
416  }
417 
428  public function reallyDoQuery( $offset, $limit, $order ) {
429  list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
430  $this->buildQueryInfo( $offset, $limit, $order );
431 
432  return $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds );
433  }
434 
445  protected function buildQueryInfo( $offset, $limit, $order ) {
446  $fname = __METHOD__ . ' (' . $this->getSqlComment() . ')';
447  $info = $this->getQueryInfo();
448  $tables = $info['tables'];
449  $fields = $info['fields'];
450  $conds = $info['conds'] ?? [];
451  $options = $info['options'] ?? [];
452  $join_conds = $info['join_conds'] ?? [];
453  $indexColumns = (array)$this->mIndexField;
454  $sortColumns = array_merge( $indexColumns, $this->mExtraSortFields );
455 
456  if ( $order === self::QUERY_ASCENDING ) {
457  $options['ORDER BY'] = $sortColumns;
458  $operator = $this->mIncludeOffset ? '>=' : '>';
459  } else {
460  $orderBy = [];
461  foreach ( $sortColumns as $col ) {
462  $orderBy[] = $col . ' DESC';
463  }
464  $options['ORDER BY'] = $orderBy;
465  $operator = $this->mIncludeOffset ? '<=' : '<';
466  }
467  if ( $offset != '' ) {
468  $offsets = explode( '|', $offset, /* Limit to max of indices */ count( $indexColumns ) );
469 
470  $conds[] = $this->buildOffsetConds(
471  $offsets,
472  $indexColumns,
473  $operator
474  );
475  }
476  $options['LIMIT'] = intval( $limit );
477  return [ $tables, $fields, $conds, $fname, $options, $join_conds ];
478  }
479 
516  private function buildOffsetConds( $offsets, $columns, $operator ) {
517  $innerConds = [];
518  // $offsets and $columns are the same length
519  for ( $i = 1; $i <= count( $offsets ); $i++ ) {
520  $innerConds[] = $this->buildOffsetInnerConds(
521  array_slice( $offsets, 0, $i ),
522  array_slice( $columns, 0, $i ),
523  $operator
524  );
525  }
526  return $this->mDb->makeList( $innerConds, IDatabase::LIST_OR );
527  }
528 
538  private function buildOffsetInnerConds( $offsets, $columns, $operator ) {
539  $conds = [];
540  while ( count( $offsets ) > 1 ) {
541  $conds[] = $columns[0] . '=' . $this->mDb->addQuotes( $offsets[0] );
542  array_shift( $columns );
543  array_shift( $offsets );
544  }
545  $conds[] = $columns[0] . $operator . $this->mDb->addQuotes( $offsets[0] );
546  return $this->mDb->makeList( $conds, IDatabase::LIST_AND );
547  }
548 
554  protected function preprocessResults( $result ) {
555  }
556 
563  public function getBody() {
564  if ( !$this->mQueryDone ) {
565  $this->doQuery();
566  }
567 
568  if ( $this->mResult->numRows() ) {
569  # Do any special query batches before display
570  $this->doBatchLookups();
571  }
572 
573  # Don't use any extra rows returned by the query
574  $numRows = min( $this->mResult->numRows(), $this->mLimit );
575 
576  $s = $this->getStartBody();
577  if ( $numRows ) {
578  if ( $this->mIsBackwards ) {
579  for ( $i = $numRows - 1; $i >= 0; $i-- ) {
580  $this->mResult->seek( $i );
581  $row = $this->mResult->fetchObject();
582  $s .= $this->formatRow( $row );
583  }
584  } else {
585  $this->mResult->seek( 0 );
586  for ( $i = 0; $i < $numRows; $i++ ) {
587  $row = $this->mResult->fetchObject();
588  $s .= $this->formatRow( $row );
589  }
590  }
591  } else {
592  $s .= $this->getEmptyBody();
593  }
594  $s .= $this->getEndBody();
595  return $s;
596  }
597 
607  protected function makeLink( $text, array $query = null, $type = null ) {
608  if ( $query === null ) {
609  return $text;
610  }
611 
612  $attrs = [];
613  if ( in_array( $type, [ 'prev', 'next' ] ) ) {
614  $attrs['rel'] = $type;
615  }
616 
617  if ( in_array( $type, [ 'asc', 'desc' ] ) ) {
618  $attrs['title'] = $this->msg( $type == 'asc' ? 'sort-ascending' : 'sort-descending' )->text();
619  }
620 
621  if ( $type ) {
622  $attrs['class'] = "mw-{$type}link";
623  }
624 
625  return $this->getLinkRenderer()->makeKnownLink(
626  $this->getTitle(),
627  new HtmlArmor( $text ),
628  $attrs,
629  $query + $this->getDefaultQuery()
630  );
631  }
632 
640  protected function doBatchLookups() {
641  }
642 
649  protected function getStartBody() {
650  return '';
651  }
652 
658  protected function getEndBody() {
659  return '';
660  }
661 
668  protected function getEmptyBody() {
669  return '';
670  }
671 
679  public function getDefaultQuery() {
680  if ( !isset( $this->mDefaultQuery ) ) {
681  $this->mDefaultQuery = $this->getRequest()->getQueryValues();
682  unset( $this->mDefaultQuery['title'] );
683  unset( $this->mDefaultQuery['dir'] );
684  unset( $this->mDefaultQuery['offset'] );
685  unset( $this->mDefaultQuery['limit'] );
686  unset( $this->mDefaultQuery['order'] );
687  unset( $this->mDefaultQuery['month'] );
688  unset( $this->mDefaultQuery['year'] );
689  }
690  return $this->mDefaultQuery;
691  }
692 
698  public function getNumRows() {
699  if ( !$this->mQueryDone ) {
700  $this->doQuery();
701  }
702  return $this->mResult->numRows();
703  }
704 
710  public function getPagingQueries() {
711  if ( !$this->mQueryDone ) {
712  $this->doQuery();
713  }
714 
715  # Don't announce the limit everywhere if it's the default
716  $urlLimit = $this->mLimit == $this->mDefaultLimit ? null : $this->mLimit;
717 
718  if ( $this->mIsFirst ) {
719  $prev = false;
720  $first = false;
721  } else {
722  $prev = [
723  'dir' => 'prev',
724  'offset' => implode( '|', (array)$this->mFirstShown ),
725  'limit' => $urlLimit
726  ];
727  $first = [ 'limit' => $urlLimit ];
728  }
729  if ( $this->mIsLast ) {
730  $next = false;
731  $last = false;
732  } else {
733  $next = [ 'offset' => implode( '|', (array)$this->mLastShown ), 'limit' => $urlLimit ];
734  $last = [ 'dir' => 'prev', 'limit' => $urlLimit ];
735  }
736 
737  return [
738  'prev' => $prev,
739  'next' => $next,
740  'first' => $first,
741  'last' => $last
742  ];
743  }
744 
750  protected function isNavigationBarShown() {
751  if ( !$this->mQueryDone ) {
752  $this->doQuery();
753  }
754  // Hide navigation by default if there is nothing to page
755  return !( $this->mIsFirst && $this->mIsLast );
756  }
757 
768  protected function getPagingLinks( $linkTexts, $disabledTexts = [] ) {
769  $queries = $this->getPagingQueries();
770  $links = [];
771 
772  foreach ( $queries as $type => $query ) {
773  if ( $query !== false ) {
774  $links[$type] = $this->makeLink(
775  $linkTexts[$type],
776  $query,
777  $type
778  );
779  } elseif ( isset( $disabledTexts[$type] ) ) {
780  $links[$type] = $disabledTexts[$type];
781  } else {
782  $links[$type] = $linkTexts[$type];
783  }
784  }
785 
786  return $links;
787  }
788 
789  protected function getLimitLinks() {
790  $links = [];
791  if ( $this->mIsBackwards ) {
792  $offset = implode( '|', (array)$this->mPastTheEndIndex );
793  } else {
794  $offset = $this->mOffset;
795  }
796  foreach ( $this->mLimitsShown as $limit ) {
797  $links[] = $this->makeLink(
798  $this->getLanguage()->formatNum( $limit ),
799  [ 'offset' => $offset, 'limit' => $limit ],
800  'num'
801  );
802  }
803  return $links;
804  }
805 
813  abstract public function formatRow( $row );
814 
826  abstract public function getQueryInfo();
827 
864  abstract public function getIndexField();
865 
887  protected function getExtraSortFields() {
888  return [];
889  }
890 
910  protected function getDefaultDirections() {
911  return self::DIR_ASCENDING;
912  }
913 
924  protected function buildPrevNextNavigation( Title $title, $offset, $limit,
925  array $query = [], $atend = false
926  ) {
927  $prevNext = new PrevNextNavigationRenderer( $this );
928 
929  return $prevNext->buildPrevNextNavigation( $title, $offset, $limit, $query, $atend );
930  }
931 
932  protected function getLinkRenderer() {
933  if ( $this->linkRenderer === null ) {
934  $this->linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
935  }
936  return $this->linkRenderer;
937  }
938 }
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:33
IndexPager\$mLimit
int $mLimit
The maximum number of entries to show.
Definition: IndexPager.php:95
IndexPager\formatRow
formatRow( $row)
Returns an HTML string representing the result row $row.
HtmlArmor
Marks HTML that shouldn't be escaped.
Definition: HtmlArmor.php:28
IndexPager\getStartBody
getStartBody()
Hook into getBody(), allows text to be inserted at the start.
Definition: IndexPager.php:649
IndexPager\$mDefaultDirection
bool $mDefaultDirection
$mDefaultDirection gives the direction to use when sorting results: DIR_ASCENDING or DIR_DESCENDING.
Definition: IndexPager.php:132
IndexPager\$mPastTheEndIndex
array $mPastTheEndIndex
Definition: IndexPager.php:146
IndexPager\preprocessResults
preprocessResults( $result)
Pre-process results; useful for performing batch existence checks, etc.
Definition: IndexPager.php:554
IndexPager\getDefaultQuery
getDefaultQuery()
Get an array of query parameters that should be put into self-links.
Definition: IndexPager.php:679
IndexPager\$mIncludeOffset
bool $mIncludeOffset
Whether to include the offset in the query.
Definition: IndexPager.php:156
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:146
IndexPager\QUERY_ASCENDING
const QUERY_ASCENDING
Backwards-compatible constant for reallyDoQuery() (do not change)
Definition: IndexPager.php:82
IndexPager\getResult
getResult()
Definition: IndexPager.php:294
IndexPager\$mFirstShown
array $mFirstShown
Definition: IndexPager.php:144
MediaWiki\Linker\LinkRenderer
Class that generates HTML links for pages.
Definition: LinkRenderer.php:43
IndexPager\$mLimitsShown
int[] $mLimitsShown
List of default entry limit options to be presented to clients.
Definition: IndexPager.php:89
IndexPager\getExtraSortFields
getExtraSortFields()
Returns the names of secondary columns to order by in addition to the column in getIndexField().
Definition: IndexPager.php:887
IndexPager\getDatabase
getDatabase()
Get the Database object in use.
Definition: IndexPager.php:237
IndexPager\getPagingQueries
getPagingQueries()
Get a URL query array for the prev, next, first and last links.
Definition: IndexPager.php:710
MediaWiki\Navigation\PrevNextNavigationRenderer
Helper class for generating prev/next links for paging.
Definition: PrevNextNavigationRenderer.php:33
$s
$s
Definition: mergeMessageFileList.php:185
IndexPager\$linkRenderer
LinkRenderer $linkRenderer
Definition: IndexPager.php:166
IndexPager\__construct
__construct(IContextSource $context=null, LinkRenderer $linkRenderer=null)
Definition: IndexPager.php:168
IndexPager\$mNavigationBar
string $mNavigationBar
Definition: IndexPager.php:150
IndexPager\makeLink
makeLink( $text, array $query=null, $type=null)
Make a self-link.
Definition: IndexPager.php:607
ContextSource\getRequest
getRequest()
Definition: ContextSource.php:71
IndexPager\buildPrevNextNavigation
buildPrevNextNavigation(Title $title, $offset, $limit, array $query=[], $atend=false)
Generate (prev x| next x) (20|50|100...) type links for paging.
Definition: IndexPager.php:924
$res
$res
Definition: testCompression.php:57
ContextSource\getUser
getUser()
Definition: ContextSource.php:120
ContextSource\getTitle
getTitle()
Definition: ContextSource.php:79
IndexPager\DIR_ASCENDING
const DIR_ASCENDING
Backwards-compatible constant for $mDefaultDirection field (do not change)
Definition: IndexPager.php:77
IndexPager\getLimitLinks
getLimitLinks()
Definition: IndexPager.php:789
LIST_AND
const LIST_AND
Definition: Defines.php:48
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
IndexPager\doBatchLookups
doBatchLookups()
Called from getBody(), before getStartBody() is called and after doQuery() was called.
Definition: IndexPager.php:640
IndexPager\getIndexField
getIndexField()
Returns the name of the index field.
IndexPager\$mPastTheEndRow
stdClass bool null $mPastTheEndRow
Extra row fetched at the end to see if the end was reached.
Definition: IndexPager.php:101
ContextSource\getLanguage
getLanguage()
Definition: ContextSource.php:128
IndexPager\$mIndexField
string string[] $mIndexField
The index to actually be used for ordering.
Definition: IndexPager.php:109
Pager
Basic pager interface.
Definition: Pager.php:32
IndexPager\getEmptyBody
getEmptyBody()
Hook into getBody(), for the bit between the start and the end when there are no rows.
Definition: IndexPager.php:668
IndexPager\reallyDoQuery
reallyDoQuery( $offset, $limit, $order)
Do a query with specified parameters, rather than using the object context.
Definition: IndexPager.php:428
IndexPager\QUERY_DESCENDING
const QUERY_DESCENDING
Backwards-compatible constant for reallyDoQuery() (do not change)
Definition: IndexPager.php:84
IndexPager\$mQueryDone
bool $mQueryDone
Whether the listing query completed.
Definition: IndexPager.php:97
LIST_OR
const LIST_OR
Definition: Defines.php:51
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
IndexPager\buildQueryInfo
buildQueryInfo( $offset, $limit, $order)
Build variables to use by the database wrapper.
Definition: IndexPager.php:445
IndexPager\setLimit
setLimit( $limit)
Set the limit from an other source than the request.
Definition: IndexPager.php:314
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2463
IndexPager\$mIsLast
bool $mIsLast
Definition: IndexPager.php:139
ContextSource
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
Definition: ContextSource.php:29
IndexPager\$mDb
IDatabase $mDb
Definition: IndexPager.php:99
$title
$title
Definition: testCompression.php:38
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
IndexPager\$mRequest
WebRequest $mRequest
Definition: IndexPager.php:87
IndexPager\extractResultInfo
extractResultInfo( $isFirst, $limit, IResultWrapper $res)
Extract some useful data from the result object for use by the navigation bar, put it into $this.
Definition: IndexPager.php:354
ContextSource\setContext
setContext(IContextSource $context)
Definition: ContextSource.php:55
IndexPager\setIncludeOffset
setIncludeOffset( $include)
Set whether a row matching exactly the offset should be also included in the result or not.
Definition: IndexPager.php:341
IndexPager\$mIsBackwards
bool $mIsBackwards
Definition: IndexPager.php:134
ContextSource\msg
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:168
IndexPager\oppositeOrder
static oppositeOrder( $order)
Definition: IndexPager.php:285
IndexPager\getDefaultDirections
getDefaultDirections()
Return the default sorting direction: DIR_ASCENDING or DIR_DESCENDING.
Definition: IndexPager.php:910
IndexPager\setOffset
setOffset( $offset)
Set the offset from an other source than the request.
Definition: IndexPager.php:303
IndexPager\$mResult
IResultWrapper $mResult
Result object for the query.
Definition: IndexPager.php:163
IndexPager\getLinkRenderer
getLinkRenderer()
Definition: IndexPager.php:932
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:53
WebRequest
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
Definition: WebRequest.php:43
IndexPager\buildOffsetInnerConds
buildOffsetInnerConds( $offsets, $columns, $operator)
Build an inner part of an offset condition, consisting of inequalities joined by AND,...
Definition: IndexPager.php:538
IndexPager\DIR_DESCENDING
const DIR_DESCENDING
Backwards-compatible constant for $mDefaultDirection field (do not change)
Definition: IndexPager.php:79
IndexPager\getEndBody
getEndBody()
Hook into getBody() for the end of the list.
Definition: IndexPager.php:658
IndexPager\getSqlComment
getSqlComment()
Get some text to go in brackets in the "function name" part of the SQL comment.
Definition: IndexPager.php:414
IndexPager\isNavigationBarShown
isNavigationBarShown()
Returns whether to show the "navigation bar".
Definition: IndexPager.php:750
Title
Represents a title within MediaWiki.
Definition: Title.php:42
IndexPager\$mExtraSortFields
string[] $mExtraSortFields
An array of secondary columns to order by.
Definition: IndexPager.php:115
IndexPager\$mOrderType
string null $mOrderType
For pages that support multiple types of ordering, which one to use.
Definition: IndexPager.php:119
IndexPager\buildOffsetConds
buildOffsetConds( $offsets, $columns, $operator)
Build the conditions for the offset, given that we may be paginating on a single column or multiple c...
Definition: IndexPager.php:516
IndexPager
IndexPager is an efficient pager which uses a (roughly unique) index in the data set to implement pag...
Definition: IndexPager.php:73
IndexPager\getLimit
getLimit()
Get the current limit.
Definition: IndexPager.php:330
IndexPager\$mLastShown
array $mLastShown
Definition: IndexPager.php:142
IndexPager\getBody
getBody()
Get the formatted result list.
Definition: IndexPager.php:563
IndexPager\$mDefaultLimit
int $mDefaultLimit
The default entry limit choosen for clients.
Definition: IndexPager.php:91
IndexPager\$mOffset
mixed $mOffset
The starting point to enumerate entries.
Definition: IndexPager.php:93
IndexPager\getQueryInfo
getQueryInfo()
Provides all parameters needed for the main paged query.
IndexPager\$mDefaultQuery
array $mDefaultQuery
Definition: IndexPager.php:148
IndexPager\getNumRows
getNumRows()
Get the number of rows in the result set.
Definition: IndexPager.php:698
IndexPager\getPagingLinks
getPagingLinks( $linkTexts, $disabledTexts=[])
Get paging links.
Definition: IndexPager.php:768
IndexPager\$mIsFirst
bool $mIsFirst
True if the current result set is the first one.
Definition: IndexPager.php:137
IndexPager\doQuery
doQuery()
Do the query, using information from the object context.
Definition: IndexPager.php:246
$type
$type
Definition: testCompression.php:52