[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/pager/ -> IndexPager.php (summary)

Efficient paging for SQL queries. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

File Size: 742 lines (23 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 0 files

Defines 27 functions

  __construct()
  getDatabase()
  doQuery()
  getResult()
  setOffset()
  setLimit()
  getLimit()
  setIncludeOffset()
  extractResultInfo()
  getSqlComment()
  reallyDoQuery()
  buildQueryInfo()
  preprocessResults()
  getBody()
  makeLink()
  doBatchLookups()
  getStartBody()
  getEndBody()
  getEmptyBody()
  getDefaultQuery()
  getNumRows()
  getPagingQueries()
  isNavigationBarShown()
  getPagingLinks()
  getLimitLinks()
  getExtraSortFields()
  getDefaultDirections()

Functions
Functions that are not part of a class:

__construct( IContextSource $context = null )   X-Ref
Result object for the query. Warning: seek before use.


getDatabase()   X-Ref
Get the Database object in use

return: DatabaseBase

doQuery()   X-Ref
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.


getResult()   X-Ref

return: ResultWrapper The result wrapper.

setOffset( $offset )   X-Ref
Set the offset from an other source than the request

param: int|string $offset

setLimit( $limit )   X-Ref
Set the limit from an other source than the request

Verifies limit is between 1 and 5000

param: int|string $limit

getLimit()   X-Ref
Get the current limit

return: int

setIncludeOffset( $include )   X-Ref
Set whether a row matching exactly the offset should be also included
in the result or not. By default this is not the case, but when the
offset is user-supplied this might be wanted.

param: bool $include

extractResultInfo( $isFirst, $limit, ResultWrapper $res )   X-Ref
Extract some useful data from the result object for use by
the navigation bar, put it into $this

param: bool $isFirst False if there are rows before those fetched (i.e.
param: int $limit Exact query limit
param: ResultWrapper $res

getSqlComment()   X-Ref
Get some text to go in brackets in the "function name" part of the SQL comment

return: string

reallyDoQuery( $offset, $limit, $descending )   X-Ref
Do a query with specified parameters, rather than using the object
context

param: string $offset Index offset, inclusive
param: int $limit Exact query limit
param: bool $descending Query direction, false for ascending, true for descending
return: ResultWrapper

buildQueryInfo( $offset, $limit, $descending )   X-Ref
Build variables to use by the database wrapper.

param: string $offset Index offset, inclusive
param: int $limit Exact query limit
param: bool $descending Query direction, false for ascending, true for descending
return: array

preprocessResults( $result )   X-Ref
Pre-process results; useful for performing batch existence checks, etc.

param: ResultWrapper $result

getBody()   X-Ref
Get the formatted result list. Calls getStartBody(), formatRow() and
getEndBody(), concatenates the results and returns them.

return: string

makeLink( $text, array $query = null, $type = null )   X-Ref
Make a self-link

param: string $text Text displayed on the link
param: array $query Associative array of parameter to be in the query string
param: string $type Link type used to create additional attributes, like "rel", "class" or
return: string HTML fragment

doBatchLookups()   X-Ref
Called from getBody(), before getStartBody() is called and
after doQuery() was called. This will be called only if there
are rows in the result set.

return: void

getStartBody()   X-Ref
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.

return: string

getEndBody()   X-Ref
Hook into getBody() for the end of the list

return: string

getEmptyBody()   X-Ref
Hook into getBody(), for the bit between the start and the
end when there are no rows

return: string

getDefaultQuery()   X-Ref
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.

return: array Associative array

getNumRows()   X-Ref
Get the number of rows in the result set

return: int

getPagingQueries()   X-Ref
Get a URL query array for the prev, next, first and last links.

return: array

isNavigationBarShown()   X-Ref
Returns whether to show the "navigation bar"

return: bool

getPagingLinks( $linkTexts, $disabledTexts = array()   X-Ref
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.

param: array $linkTexts
param: array $disabledTexts
return: array

getLimitLinks()   X-Ref
No description

getExtraSortFields()   X-Ref
This function should be overridden to return the names of secondary columns
to order by in addition to the column in getIndexField(). These fields will
not be used in the pager offset or in any links for users.

If getIndexField() returns an array of 'querykey' => 'indexfield' pairs then
this must return a corresponding array of 'querykey' => array( fields...) pairs
in order for a request with &count=querykey to use array( fields...) to sort.

This is useful for pagers that GROUP BY a unique column (say page_id)
and ORDER BY another (say page_len). Using GROUP BY and ORDER BY both on
page_len,page_id avoids temp tables (given a page_len index). This would
also work if page_id was non-unique but we had a page_len,page_id index.

return: array

getDefaultDirections()   X-Ref
Return the default sorting direction: DIR_ASCENDING or DIR_DESCENDING.
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.

return: bool



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1