MediaWiki  master
IndexPager.php
Go to the documentation of this file.
1 <?php
28 
71 abstract class IndexPager extends ContextSource implements Pager {
73  const DIR_ASCENDING = false;
75  const DIR_DESCENDING = true;
76 
78  const QUERY_ASCENDING = true;
80  const QUERY_DESCENDING = false;
81 
83  public $mRequest;
85  public $mLimitsShown = [ 20, 50, 100, 250, 500 ];
87  public $mDefaultLimit = 50;
89  public $mOffset;
91  public $mLimit;
93  public $mQueryDone = false;
95  public $mDb;
98 
104  protected $mIndexField;
110  protected $mExtraSortFields;
114  protected $mOrderType;
130 
132  public $mIsFirst;
134  public $mIsLast;
135 
137  protected $mLastShown;
139  protected $mFirstShown;
141  protected $mPastTheEndIndex;
143  protected $mDefaultQuery;
145  protected $mNavigationBar;
146 
151  protected $mIncludeOffset = false;
152 
158  public $mResult;
159 
160  public function __construct( IContextSource $context = null ) {
161  if ( $context ) {
162  $this->setContext( $context );
163  }
164 
165  $this->mRequest = $this->getRequest();
166 
167  # NB: the offset is quoted, not validated. It is treated as an
168  # arbitrary string to support the widest variety of index types. Be
169  # careful outputting it into HTML!
170  $this->mOffset = $this->mRequest->getText( 'offset' );
171 
172  # Use consistent behavior for the limit options
173  $this->mDefaultLimit = $this->getUser()->getIntOption( 'rclimit' );
174  if ( !$this->mLimit ) {
175  // Don't override if a subclass calls $this->setLimit() in its constructor.
176  list( $this->mLimit, /* $offset */ ) = $this->mRequest->getLimitOffset();
177  }
178 
179  $this->mIsBackwards = ( $this->mRequest->getVal( 'dir' ) == 'prev' );
180  # Let the subclass set the DB here; otherwise use a replica DB for the current wiki
181  $this->mDb = $this->mDb ?: wfGetDB( DB_REPLICA );
182 
183  $index = $this->getIndexField(); // column to sort on
184  $extraSort = $this->getExtraSortFields(); // extra columns to sort on for query planning
185  $order = $this->mRequest->getVal( 'order' );
186  if ( is_array( $index ) && isset( $index[$order] ) ) {
187  $this->mOrderType = $order;
188  $this->mIndexField = $index[$order];
189  $this->mExtraSortFields = isset( $extraSort[$order] )
190  ? (array)$extraSort[$order]
191  : [];
192  } elseif ( is_array( $index ) ) {
193  # First element is the default
194  $this->mIndexField = reset( $index );
195  $this->mOrderType = key( $index );
196  $this->mExtraSortFields = isset( $extraSort[$this->mOrderType] )
197  ? (array)$extraSort[$this->mOrderType]
198  : [];
199  } else {
200  # $index is not an array
201  $this->mOrderType = null;
202  $this->mIndexField = $index;
203  $this->mExtraSortFields = (array)$extraSort;
204  }
205 
206  if ( !isset( $this->mDefaultDirection ) ) {
207  $dir = $this->getDefaultDirections();
208  $this->mDefaultDirection = is_array( $dir )
209  ? $dir[$this->mOrderType]
210  : $dir;
211  }
212  }
213 
219  public function getDatabase() {
220  return $this->mDb;
221  }
222 
228  public function doQuery() {
229  # Use the child class name for profiling
230  $fname = __METHOD__ . ' (' . static::class . ')';
232  $section = Profiler::instance()->scopedProfileIn( $fname );
233 
234  $defaultOrder = ( $this->mDefaultDirection === self::DIR_ASCENDING )
235  ? self::QUERY_ASCENDING
236  : self::QUERY_DESCENDING;
237  $order = $this->mIsBackwards ? self::oppositeOrder( $defaultOrder ) : $defaultOrder;
238 
239  # Plus an extra row so that we can tell the "next" link should be shown
240  $queryLimit = $this->mLimit + 1;
241 
242  if ( $this->mOffset == '' ) {
243  $isFirst = true;
244  } else {
245  // If there's an offset, we may or may not be at the first entry.
246  // The only way to tell is to run the query in the opposite
247  // direction see if we get a row.
248  $oldIncludeOffset = $this->mIncludeOffset;
249  $this->mIncludeOffset = !$this->mIncludeOffset;
250  $oppositeOrder = self::oppositeOrder( $order );
251  $isFirst = !$this->reallyDoQuery( $this->mOffset, 1, $oppositeOrder )->numRows();
252  $this->mIncludeOffset = $oldIncludeOffset;
253  }
254 
255  $this->mResult = $this->reallyDoQuery(
256  $this->mOffset,
257  $queryLimit,
258  $order
259  );
260 
261  $this->extractResultInfo( $isFirst, $queryLimit, $this->mResult );
262  $this->mQueryDone = true;
263 
264  $this->preprocessResults( $this->mResult );
265  $this->mResult->rewind(); // Paranoia
266  }
267 
272  final protected static function oppositeOrder( $order ) {
273  return ( $order === self::QUERY_ASCENDING )
274  ? self::QUERY_DESCENDING
275  : self::QUERY_ASCENDING;
276  }
277 
281  function getResult() {
282  return $this->mResult;
283  }
284 
290  function setOffset( $offset ) {
291  $this->mOffset = $offset;
292  }
293 
301  function setLimit( $limit ) {
302  $limit = (int)$limit;
303  // WebRequest::getLimitOffset() puts a cap of 5000, so do same here.
304  if ( $limit > 5000 ) {
305  $limit = 5000;
306  }
307  if ( $limit > 0 ) {
308  $this->mLimit = $limit;
309  }
310  }
311 
317  function getLimit() {
318  return $this->mLimit;
319  }
320 
328  public function setIncludeOffset( $include ) {
329  $this->mIncludeOffset = $include;
330  }
331 
341  function extractResultInfo( $isFirst, $limit, IResultWrapper $res ) {
342  $numRows = $res->numRows();
343  if ( $numRows ) {
344  # Remove any table prefix from index field
345  $parts = explode( '.', $this->mIndexField );
346  $indexColumn = end( $parts );
347 
348  $row = $res->fetchRow();
349  $firstIndex = $row[$indexColumn];
350 
351  # Discard the extra result row if there is one
352  if ( $numRows > $this->mLimit && $numRows > 1 ) {
353  $res->seek( $numRows - 1 );
354  $this->mPastTheEndRow = $res->fetchObject();
355  $this->mPastTheEndIndex = $this->mPastTheEndRow->$indexColumn;
356  $res->seek( $numRows - 2 );
357  $row = $res->fetchRow();
358  $lastIndex = $row[$indexColumn];
359  } else {
360  $this->mPastTheEndRow = null;
361  # Setting indexes to an empty string means that they will be
362  # omitted if they would otherwise appear in URLs. It just so
363  # happens that this is the right thing to do in the standard
364  # UI, in all the relevant cases.
365  $this->mPastTheEndIndex = '';
366  $res->seek( $numRows - 1 );
367  $row = $res->fetchRow();
368  $lastIndex = $row[$indexColumn];
369  }
370  } else {
371  $firstIndex = '';
372  $lastIndex = '';
373  $this->mPastTheEndRow = null;
374  $this->mPastTheEndIndex = '';
375  }
376 
377  if ( $this->mIsBackwards ) {
378  $this->mIsFirst = ( $numRows < $limit );
379  $this->mIsLast = $isFirst;
380  $this->mLastShown = $firstIndex;
381  $this->mFirstShown = $lastIndex;
382  } else {
383  $this->mIsFirst = $isFirst;
384  $this->mIsLast = ( $numRows < $limit );
385  $this->mLastShown = $lastIndex;
386  $this->mFirstShown = $firstIndex;
387  }
388  }
389 
395  function getSqlComment() {
396  return static::class;
397  }
398 
409  public function reallyDoQuery( $offset, $limit, $order ) {
410  list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
411  $this->buildQueryInfo( $offset, $limit, $order );
412 
413  return $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds );
414  }
415 
426  protected function buildQueryInfo( $offset, $limit, $order ) {
427  $fname = __METHOD__ . ' (' . $this->getSqlComment() . ')';
428  $info = $this->getQueryInfo();
429  $tables = $info['tables'];
430  $fields = $info['fields'];
431  $conds = $info['conds'] ?? [];
432  $options = $info['options'] ?? [];
433  $join_conds = $info['join_conds'] ?? [];
434  $sortColumns = array_merge( [ $this->mIndexField ], $this->mExtraSortFields );
435  if ( $order === self::QUERY_ASCENDING ) {
436  $options['ORDER BY'] = $sortColumns;
437  $operator = $this->mIncludeOffset ? '>=' : '>';
438  } else {
439  $orderBy = [];
440  foreach ( $sortColumns as $col ) {
441  $orderBy[] = $col . ' DESC';
442  }
443  $options['ORDER BY'] = $orderBy;
444  $operator = $this->mIncludeOffset ? '<=' : '<';
445  }
446  if ( $offset != '' ) {
447  $conds[] = $this->mIndexField . $operator . $this->mDb->addQuotes( $offset );
448  }
449  $options['LIMIT'] = intval( $limit );
450  return [ $tables, $fields, $conds, $fname, $options, $join_conds ];
451  }
452 
458  protected function preprocessResults( $result ) {
459  }
460 
467  public function getBody() {
468  if ( !$this->mQueryDone ) {
469  $this->doQuery();
470  }
471 
472  if ( $this->mResult->numRows() ) {
473  # Do any special query batches before display
474  $this->doBatchLookups();
475  }
476 
477  # Don't use any extra rows returned by the query
478  $numRows = min( $this->mResult->numRows(), $this->mLimit );
479 
480  $s = $this->getStartBody();
481  if ( $numRows ) {
482  if ( $this->mIsBackwards ) {
483  for ( $i = $numRows - 1; $i >= 0; $i-- ) {
484  $this->mResult->seek( $i );
485  $row = $this->mResult->fetchObject();
486  $s .= $this->formatRow( $row );
487  }
488  } else {
489  $this->mResult->seek( 0 );
490  for ( $i = 0; $i < $numRows; $i++ ) {
491  $row = $this->mResult->fetchObject();
492  $s .= $this->formatRow( $row );
493  }
494  }
495  } else {
496  $s .= $this->getEmptyBody();
497  }
498  $s .= $this->getEndBody();
499  return $s;
500  }
501 
511  function makeLink( $text, array $query = null, $type = null ) {
512  if ( $query === null ) {
513  return $text;
514  }
515 
516  $attrs = [];
517  if ( in_array( $type, [ 'prev', 'next' ] ) ) {
518  $attrs['rel'] = $type;
519  }
520 
521  if ( in_array( $type, [ 'asc', 'desc' ] ) ) {
522  $attrs['title'] = $this->msg( $type == 'asc' ? 'sort-ascending' : 'sort-descending' )->text();
523  }
524 
525  if ( $type ) {
526  $attrs['class'] = "mw-{$type}link";
527  }
528 
529  return Linker::linkKnown(
530  $this->getTitle(),
531  $text,
532  $attrs,
533  $query + $this->getDefaultQuery()
534  );
535  }
536 
544  protected function doBatchLookups() {
545  }
546 
553  protected function getStartBody() {
554  return '';
555  }
556 
562  protected function getEndBody() {
563  return '';
564  }
565 
572  protected function getEmptyBody() {
573  return '';
574  }
575 
583  function getDefaultQuery() {
584  if ( !isset( $this->mDefaultQuery ) ) {
585  $this->mDefaultQuery = $this->getRequest()->getQueryValues();
586  unset( $this->mDefaultQuery['title'] );
587  unset( $this->mDefaultQuery['dir'] );
588  unset( $this->mDefaultQuery['offset'] );
589  unset( $this->mDefaultQuery['limit'] );
590  unset( $this->mDefaultQuery['order'] );
591  unset( $this->mDefaultQuery['month'] );
592  unset( $this->mDefaultQuery['year'] );
593  }
594  return $this->mDefaultQuery;
595  }
596 
602  function getNumRows() {
603  if ( !$this->mQueryDone ) {
604  $this->doQuery();
605  }
606  return $this->mResult->numRows();
607  }
608 
614  function getPagingQueries() {
615  if ( !$this->mQueryDone ) {
616  $this->doQuery();
617  }
618 
619  # Don't announce the limit everywhere if it's the default
620  $urlLimit = $this->mLimit == $this->mDefaultLimit ? null : $this->mLimit;
621 
622  if ( $this->mIsFirst ) {
623  $prev = false;
624  $first = false;
625  } else {
626  $prev = [
627  'dir' => 'prev',
628  'offset' => $this->mFirstShown,
629  'limit' => $urlLimit
630  ];
631  $first = [ 'limit' => $urlLimit ];
632  }
633  if ( $this->mIsLast ) {
634  $next = false;
635  $last = false;
636  } else {
637  $next = [ 'offset' => $this->mLastShown, 'limit' => $urlLimit ];
638  $last = [ 'dir' => 'prev', 'limit' => $urlLimit ];
639  }
640  return [
641  'prev' => $prev,
642  'next' => $next,
643  'first' => $first,
644  'last' => $last
645  ];
646  }
647 
653  function isNavigationBarShown() {
654  if ( !$this->mQueryDone ) {
655  $this->doQuery();
656  }
657  // Hide navigation by default if there is nothing to page
658  return !( $this->mIsFirst && $this->mIsLast );
659  }
660 
671  function getPagingLinks( $linkTexts, $disabledTexts = [] ) {
672  $queries = $this->getPagingQueries();
673  $links = [];
674 
675  foreach ( $queries as $type => $query ) {
676  if ( $query !== false ) {
677  $links[$type] = $this->makeLink(
678  $linkTexts[$type],
679  $queries[$type],
680  $type
681  );
682  } elseif ( isset( $disabledTexts[$type] ) ) {
683  $links[$type] = $disabledTexts[$type];
684  } else {
685  $links[$type] = $linkTexts[$type];
686  }
687  }
688 
689  return $links;
690  }
691 
692  function getLimitLinks() {
693  $links = [];
694  if ( $this->mIsBackwards ) {
695  $offset = $this->mPastTheEndIndex;
696  } else {
697  $offset = $this->mOffset;
698  }
699  foreach ( $this->mLimitsShown as $limit ) {
700  $links[] = $this->makeLink(
701  $this->getLanguage()->formatNum( $limit ),
702  [ 'offset' => $offset, 'limit' => $limit ],
703  'num'
704  );
705  }
706  return $links;
707  }
708 
717  abstract function formatRow( $row );
718 
731  abstract function getQueryInfo();
732 
745  abstract function getIndexField();
746 
763  protected function getExtraSortFields() {
764  return [];
765  }
766 
786  protected function getDefaultDirections() {
787  return self::DIR_ASCENDING;
788  }
789 
800  protected function buildPrevNextNavigation( LinkTarget $title, $offset, $limit,
801  array $query = [], $atend = false
802  ) {
803  $prevNext = new PrevNextNavigationRenderer( $this );
804 
805  return $prevNext->buildPrevNextNavigation( $title, $offset, $limit, $query, $atend );
806  }
807 }
const DIR_DESCENDING
Backwards-compatible constant for $mDefaultDirection field (do not change)
Definition: IndexPager.php:75
setContext(IContextSource $context)
setOffset( $offset)
Set the offset from an other source than the request.
Definition: IndexPager.php:290
mixed $mOffset
The starting point to enumerate entries.
Definition: IndexPager.php:89
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
fetchObject()
Fetch the next row from the given result object, in object form.
preprocessResults( $result)
Pre-process results; useful for performing batch existence checks, etc.
Definition: IndexPager.php:458
Helper class for generating prev/next links for paging.
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges use this to change the tables headers change it to an object instance and return false override the list derivative used $groups Array of ChangesListFilterGroup objects(added in 1.34) 'FileDeleteComplete' null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1535
formatRow( $row)
Abstract formatting function.
getIndexField()
This function should be overridden to return the name of the index fi- eld.
bool $mDefaultDirection
$mDefaultDirection gives the direction to use when sorting results: DIR_ASCENDING or DIR_DESCENDING...
Definition: IndexPager.php:127
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
int [] $mLimitsShown
List of default entry limit options to be presented to clients.
Definition: IndexPager.php:85
static instance()
Singleton.
Definition: Profiler.php:62
buildQueryInfo( $offset, $limit, $order)
Build variables to use by the database wrapper.
Definition: IndexPager.php:426
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
bool $mIsLast
Definition: IndexPager.php:134
buildPrevNextNavigation(LinkTarget $title, $offset, $limit, array $query=[], $atend=false)
Generate (prev x| next x) (20|50|100...) type links for paging.
Definition: IndexPager.php:800
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message key
Definition: hooks.txt:2145
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
static oppositeOrder( $order)
Definition: IndexPager.php:272
getPagingLinks( $linkTexts, $disabledTexts=[])
Get paging links.
Definition: IndexPager.php:671
doQuery()
Do the query, using information from the object context.
Definition: IndexPager.php:228
__construct(IContextSource $context=null)
Definition: IndexPager.php:160
string $mIndexField
The index to actually be used for ordering.
Definition: IndexPager.php:104
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:341
IContextSource $context
this hook is for auditing only RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
Definition: hooks.txt:966
getDatabase()
Get the Database object in use.
Definition: IndexPager.php:219
bool $mQueryDone
Whether the listing query completed.
Definition: IndexPager.php:93
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImgAuthModifyHeaders':Executed just before a file is streamed to a user via img_auth.php, allowing headers to be modified beforehand. $title:LinkTarget object & $headers:HTTP headers(name=> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\*-\*)") will be honored when streaming the file. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED since 1.28! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1976
$last
doBatchLookups()
Called from getBody(), before getStartBody() is called and after doQuery() was called.
Definition: IndexPager.php:544
IndexPager is an efficient pager which uses a (roughly unique) index in the data set to implement pag...
Definition: IndexPager.php:71
bool $mIncludeOffset
Whether to include the offset in the query.
Definition: IndexPager.php:151
mixed $mLastShown
Definition: IndexPager.php:137
makeLink( $text, array $query=null, $type=null)
Make a self-link.
Definition: IndexPager.php:511
mixed $mPastTheEndIndex
Definition: IndexPager.php:141
getEmptyBody()
Hook into getBody(), for the bit between the start and the end when there are no rows.
Definition: IndexPager.php:572
getSqlComment()
Get some text to go in brackets in the "function name" part of the SQL comment.
Definition: IndexPager.php:395
Basic pager interface.
Definition: Pager.php:32
WebRequest $mRequest
Definition: IndexPager.php:83
getExtraSortFields()
This function should be overridden to return the names of secondary columns to order by in addition t...
Definition: IndexPager.php:763
getStartBody()
Hook into getBody(), allows text to be inserted at the start.
Definition: IndexPager.php:553
IDatabase $mDb
Definition: IndexPager.php:95
bool $mIsBackwards
Definition: IndexPager.php:129
const QUERY_ASCENDING
Backwards-compatible constant for reallyDoQuery() (do not change)
Definition: IndexPager.php:78
$res
Definition: database.txt:21
reallyDoQuery( $offset, $limit, $order)
Do a query with specified parameters, rather than using the object context.
Definition: IndexPager.php:409
isNavigationBarShown()
Returns whether to show the "navigation bar".
Definition: IndexPager.php:653
getLimit()
Get the current limit.
Definition: IndexPager.php:317
string $mNavigationBar
Definition: IndexPager.php:145
Result wrapper for grabbing data queried from an IDatabase object.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition: hooks.txt:1978
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition: hooks.txt:773
IResultWrapper $mResult
Result object for the query.
Definition: IndexPager.php:158
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:918
getQueryInfo()
This function should be overridden to provide all parameters needed for the main paged query...
mixed $mFirstShown
Definition: IndexPager.php:139
numRows()
Get the number of rows in a result object.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings, LocalSettings).
Definition: Setup.php:131
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
Definition: hooks.txt:3045
const QUERY_DESCENDING
Backwards-compatible constant for reallyDoQuery() (do not change)
Definition: IndexPager.php:80
seek( $pos)
Change the position of the cursor in a result object.
stdClass bool null $mPastTheEndRow
Extra row fetched at the end to see if the end was reached.
Definition: IndexPager.php:97
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to &#39;known&#39;.
Definition: Linker.php:141
getDefaultQuery()
Get an array of query parameters that should be put into self-links.
Definition: IndexPager.php:583
fetchRow()
Fetch the next row from the given result object, in associative array form.
setLimit( $limit)
Set the limit from an other source than the request.
Definition: IndexPager.php:301
setIncludeOffset( $include)
Set whether a row matching exactly the offset should be also included in the result or not...
Definition: IndexPager.php:328
bool $mIsFirst
True if the current result set is the first one.
Definition: IndexPager.php:132
const DB_REPLICA
Definition: defines.php:25
int $mDefaultLimit
The default entry limit choosen for clients.
Definition: IndexPager.php:87
getBody()
Get the formatted result list.
Definition: IndexPager.php:467
getDefaultDirections()
Return the default sorting direction: DIR_ASCENDING or DIR_DESCENDING.
Definition: IndexPager.php:786
getPagingQueries()
Get a URL query array for the prev, next, first and last links.
Definition: IndexPager.php:614
$queries
string [] $mExtraSortFields
An array of secondary columns to order by.
Definition: IndexPager.php:110
string null $mOrderType
For pages that support multiple types of ordering, which one to use.
Definition: IndexPager.php:114
const DIR_ASCENDING
Backwards-compatible constant for $mDefaultDirection field (do not change)
Definition: IndexPager.php:73
array $mDefaultQuery
Definition: IndexPager.php:143
getNumRows()
Get the number of rows in the result set.
Definition: IndexPager.php:602
getEndBody()
Hook into getBody() for the end of the list.
Definition: IndexPager.php:562
int $mLimit
The maximum number of entries to show.
Definition: IndexPager.php:91