Inherits Pager.
Inherited by AlphabeticPager, DeletedContribsPager, ReverseChronologicalPager, and TablePager.
Public Member Functions | |
__construct () | |
doQuery () | |
Do the query, using information from the object context. | |
getResult () | |
Return the result wrapper. | |
setOffset ($offset) | |
Set the offset from an other source than $wgRequest. | |
setLimit ($limit) | |
Set the limit from an other source than $wgRequest. | |
extractResultInfo ($offset, $limit, ResultWrapper $res) | |
Extract some useful data from the result object for use by the navigation bar, put it into $this. | |
reallyDoQuery ($offset, $limit, $descending) | |
Do a query with specified parameters, rather than using the object context. | |
getBody () | |
Get the formatted result list. | |
makeLink ($text, $query=null, $type=null) | |
Make a self-link. | |
getStartBody () | |
Hook into getBody(), allows text to be inserted at the start. | |
getEndBody () | |
Hook into getBody() for the end of the list. | |
getEmptyBody () | |
Hook into getBody(), for the bit between the start and the end when there are no rows. | |
getTitle () | |
Title used for self-links. | |
getSkin () | |
Get the current skin. | |
getDefaultQuery () | |
Get an array of query parameters that should be put into self-links. | |
getNumRows () | |
Get the number of rows in the result set. | |
getPagingQueries () | |
Get a URL query array for the prev, next, first and last links. | |
getPagingLinks ($linkTexts, $disabledTexts=array()) | |
Get paging links. | |
getLimitLinks () | |
formatRow ($row) | |
Abstract formatting function. | |
getQueryInfo () | |
This function should be overridden to provide all parameters needed for the main paged query. | |
getIndexField () | |
This function should be overridden to return the name of the index fi- eld. | |
Public Attributes | |
$mRequest | |
$mLimitsShown = array( 20, 50, 100, 250, 500 ) | |
$mDefaultLimit = 50 | |
$mOffset | |
$mLimit | |
$mQueryDone = false | |
$mDb | |
$mPastTheEndRow | |
$mDefaultDirection | |
$mDefaultDirection gives the direction to use when sorting results: false for ascending, true for descending. | |
$mIsBackwards | |
$mResult | |
Result object for the query. | |
Protected Member Functions | |
preprocessResults ($result) | |
Pre-process results; useful for performing batch existence checks, etc. | |
getDefaultDirections () | |
Return the default sorting direction: false for ascending, true for de- scending. | |
Protected Attributes | |
$mIndexField | |
The index to actually be used for ordering. | |
$mOrderType | |
For pages that support multiple types of ordering, which one to use. |
In MySQL, such a limit/offset clause requires counting through the specified number of offset rows to find the desired data, which can be expensive for large offsets.
ReverseChronologicalPager is a child class of the abstract IndexPager, and contains some formatting and display code which is specific to the use of timestamps as indexes. Here is a synopsis of its operation:
* The query is specified by the offset, limit and direction (dir) parameters, in addition to any subclass-specific parameters. * The offset is the non-inclusive start of the DB query. A row with an index value equal to the offset will never be shown. * The query may either be done backwards, where the rows are returned by the database in the opposite order to which they are displayed to the user, or forwards. This is specified by the "dir" parameter, dir=prev means backwards, anything else means forwards. The offset value specifies the start of the database result set, which may be either the start or end of the displayed data set. This allows "previous" links to be implemented without knowledge of the index value at the start of the previous page. * An additional row beyond the user-specified limit is always requested. This allows us to tell whether we should display a "next" link in the case of forwards mode, or a "previous" link in the case of backwards mode. Determining whether to display the other link (the one for the page before the start of the database result set) can be done heuristically by examining the offset.
* An empty offset indicates that the offset condition should be omitted from the query. This naturally produces either the first page or the last page depending on the dir parameter.
Subclassing the pager to implement concrete functionality should be fairly simple, please see the examples in PageHistory.php and SpecialIpblocklist.php. You just need to override formatRow(), getQueryInfo() and getIndexField(). Don't forget to call the parent constructor if you override it.
Definition at line 60 of file Pager.php.
IndexPager::__construct | ( | ) |
Reimplemented in ReverseChronologicalPager, TablePager, and ImageListPager.
Definition at line 95 of file Pager.php.
References $wgRequest, $wgUser, getDefaultDirections(), getIndexField(), and wfGetDB().
Referenced by ProtectedtitlesPager::__construct(), ProtectedPagesPager::__construct(), UsersPager::__construct(), DeletedContribsPager::__construct(), and CategoryPager::__construct().
IndexPager::doQuery | ( | ) |
Do the query, using information from the object context.
This function has been kept minimal to make it overridable if necessary, to allow for result sets formed from multiple DB queries.
Reimplemented in ImageHistoryPseudoPager.
Definition at line 139 of file Pager.php.
References $fname, extractResultInfo(), preprocessResults(), reallyDoQuery(), wfProfileIn(), and wfProfileOut().
Referenced by UsersPager::getBody(), CategoryPager::getBody(), getBody(), getNumRows(), and getPagingQueries().
IndexPager::extractResultInfo | ( | $ | offset, | |
$ | limit, | |||
ResultWrapper $ | res | |||
) |
Extract some useful data from the result object for use by the navigation bar, put it into $this.
Definition at line 182 of file Pager.php.
References $numRows, $offset, $row, ResultWrapper::fetchObject(), ResultWrapper::fetchRow(), ResultWrapper::numRows(), and ResultWrapper::seek().
Referenced by doQuery().
IndexPager::formatRow | ( | $ | row | ) | [abstract] |
Abstract formatting function.
This should return an HTML string representing the result row $row. Rows will be concatenated and returned by getBody()
Reimplemented in ImageHistoryPseudoPager, LogPager, PageHistoryPager, TablePager, CategoryPager, ContribsPager, DeletedContribsPager, IPBlocklistPager, UserRestrictionsPager, UsersPager, MergeHistoryPager, NewPagesPager, ProtectedPagesPager, and ProtectedtitlesPager.
Referenced by getBody().
IndexPager::getBody | ( | ) |
Get the formatted result list.
Calls getStartBody(), formatRow() and getEndBody(), concatenates the results and returns them.
Implements Pager.
Reimplemented in ImageHistoryPseudoPager, CategoryPager, and UsersPager.
Definition at line 271 of file Pager.php.
References $i, $numRows, $row, $s, doQuery(), formatRow(), getEmptyBody(), getEndBody(), and getStartBody().
IndexPager::getDefaultDirections | ( | ) | [protected] |
Return the default sorting direction: false for ascending, true for de- scending.
You can also have an associative array of ordertype => dir, if multiple order types are supported. In this case getIndexField() must return an array, and the keys of that must exactly match the keys of this.
For backward compatibility, this method's return value will be ignored if $this->mDefaultDirection is already set when the constructor is called, for instance if it's statically initialized. In that case the value of that variable (which must be a boolean) will be used.
Note that despite its name, this does not return the value of the $this->mDefaultDirection member variable. That's the default for this particular instantiation, which is a single value. This is the set of all defaults for the class.
Reimplemented in CategoryPager.
Definition at line 503 of file Pager.php.
Referenced by __construct().
IndexPager::getDefaultQuery | ( | ) |
Get an array of query parameters that should be put into self-links.
By default, all parameters passed in the URL are used, except for a short blacklist.
Reimplemented in LogPager, CategoryPager, ContribsPager, DeletedContribsPager, and UsersPager.
Definition at line 368 of file Pager.php.
Referenced by makeLink().
IndexPager::getEmptyBody | ( | ) |
Hook into getBody(), for the bit between the start and the end when there are no rows.
Reimplemented in TablePager.
Definition at line 340 of file Pager.php.
Referenced by getBody().
IndexPager::getEndBody | ( | ) |
Hook into getBody() for the end of the list.
Reimplemented in PageHistoryPager, TablePager, ContribsPager, DeletedContribsPager, and NewPagesPager.
Definition at line 332 of file Pager.php.
Referenced by getBody().
IndexPager::getIndexField | ( | ) | [abstract] |
This function should be overridden to return the name of the index fi- eld.
If the pager supports multiple orders, it may return an array of 'querykey' => 'indexfield' pairs, so that a request with &count=querykey will use indexfield to sort. In this case, the first returned key is the default.
Needless to say, it's really not a good idea to use a non-unique index for this! That won't page right.
Reimplemented in ImageHistoryPseudoPager, LogPager, PageHistoryPager, TablePager, CategoryPager, ContribsPager, DeletedContribsPager, IPBlocklistPager, UserRestrictionsPager, UsersPager, MergeHistoryPager, NewPagesPager, ProtectedPagesPager, and ProtectedtitlesPager.
Referenced by __construct(), and AlphabeticPager::getNavigationBar().
IndexPager::getLimitLinks | ( | ) |
Definition at line 441 of file Pager.php.
References $offset, $wgLang, and makeLink().
Referenced by DeletedContribsPager::getNavigationBar(), ReverseChronologicalPager::getNavigationBar(), and AlphabeticPager::getNavigationBar().
IndexPager::getNumRows | ( | ) |
Get the number of rows in the result set.
Definition at line 385 of file Pager.php.
References doQuery().
Referenced by LogPager::getStartBody().
IndexPager::getPagingLinks | ( | $ | linkTexts, | |
$ | disabledTexts = array() | |||
) |
Get paging links.
If a link is disabled, the item from $disabledTexts will be used. If there is no such item, the unlinked text from $linkTexts will be used. Both $linkTexts and $disabledTexts are arrays of HTML.
Definition at line 426 of file Pager.php.
References $type, getPagingQueries(), and makeLink().
Referenced by DeletedContribsPager::getNavigationBar(), TablePager::getNavigationBar(), ReverseChronologicalPager::getNavigationBar(), and AlphabeticPager::getNavigationBar().
IndexPager::getPagingQueries | ( | ) |
Get a URL query array for the prev, next, first and last links.
Definition at line 395 of file Pager.php.
References doQuery().
Referenced by getPagingLinks().
IndexPager::getQueryInfo | ( | ) | [abstract] |
This function should be overridden to provide all parameters needed for the main paged query.
It returns an associative array with the following elements: tables => Table(s) for passing to Database::select() fields => Field(s) for passing to Database::select(), may be * conds => WHERE conditions options => option array
Reimplemented in ImageHistoryPseudoPager, LogPager, PageHistoryPager, CategoryPager, ContribsPager, DeletedContribsPager, IPBlocklistPager, ImageListPager, UserRestrictionsPager, UsersPager, MergeHistoryPager, NewPagesPager, ProtectedPagesPager, and ProtectedtitlesPager.
Referenced by reallyDoQuery().
IndexPager::getSkin | ( | ) |
Get the current skin.
This can be overridden if necessary.
Definition at line 355 of file Pager.php.
References $wgUser.
Referenced by UsersPager::formatRow(), DeletedContribsPager::formatRow(), ContribsPager::formatRow(), CategoryPager::formatRow(), ImageListPager::formatValue(), and makeLink().
IndexPager::getStartBody | ( | ) |
Hook into getBody(), allows text to be inserted at the start.
This will be called even if there are no rows in the result set.
Reimplemented in LogPager, PageHistoryPager, TablePager, ContribsPager, DeletedContribsPager, IPBlocklistPager, ImageListPager, UserRestrictionsPager, MergeHistoryPager, NewPagesPager, ProtectedPagesPager, and ProtectedtitlesPager.
Definition at line 325 of file Pager.php.
Referenced by getBody().
IndexPager::getTitle | ( | ) |
Title used for self-links.
Override this if you want to be able to use a title other than $wgTitle
Reimplemented in ImageHistoryPseudoPager, and NewPagesPager.
Definition at line 348 of file Pager.php.
References $GLOBALS.
Referenced by ImageListPager::getForm(), TablePager::getLimitForm(), UsersPager::getPageHeader(), and makeLink().
IndexPager::makeLink | ( | $ | text, | |
$ | query = null , |
|||
$ | type = null | |||
) |
Make a self-link.
Definition at line 303 of file Pager.php.
References $text, $type, getDefaultQuery(), getSkin(), and getTitle().
Referenced by getLimitLinks(), AlphabeticPager::getNavigationBar(), getPagingLinks(), and TablePager::getStartBody().
IndexPager::preprocessResults | ( | $ | result | ) | [protected] |
Pre-process results; useful for performing batch existence checks, etc.
ResultWrapper | $result Result wrapper |
Definition at line 265 of file Pager.php.
Referenced by doQuery().
IndexPager::reallyDoQuery | ( | $ | offset, | |
$ | limit, | |||
$ | descending | |||
) |
Do a query with specified parameters, rather than using the object context.
string | $offset Index offset, inclusive | |
integer | $limit Exact query limit | |
boolean | $descending Query direction, false for ascending, true for descending |
Definition at line 237 of file Pager.php.
References $conds, $fields, $fname, $offset, $options, $res, and getQueryInfo().
Referenced by doQuery().
IndexPager::setLimit | ( | $ | limit | ) |
IndexPager::setOffset | ( | $ | offset | ) |
IndexPager::$mDb |
IndexPager::$mDefaultDirection |
$mDefaultDirection gives the direction to use when sorting results: false for ascending, true for descending.
If $mIsBackwards is set, we start from the opposite end, but we still sort the page itself according to $mDefaultDirection. E.g., if $mDefaultDirection is false but we're going backwards, we'll display the last page of results, but the last result will be at the bottom, not the top.
Like $mIndexField, $mDefaultDirection will be a single value even if the class supports multiple default directions for different order types.
Reimplemented in ReverseChronologicalPager, ContribsPager, and DeletedContribsPager.
IndexPager::$mIndexField [protected] |
IndexPager::$mOrderType [protected] |
IndexPager::$mResult |