MediaWiki  REL1_31
IndexPager.php
Go to the documentation of this file.
1 <?php
26 
69 abstract class IndexPager extends ContextSource implements Pager {
75  const DIR_ASCENDING = false;
76  const DIR_DESCENDING = true;
77 
78  public $mRequest;
79  public $mLimitsShown = [ 20, 50, 100, 250, 500 ];
80  public $mDefaultLimit = 50;
81  public $mOffset, $mLimit;
82  public $mQueryDone = false;
83  public $mDb;
85 
90  protected $mIndexField;
95  protected $mExtraSortFields;
98  protected $mOrderType;
112 
114  public $mIsFirst;
115  public $mIsLast;
116 
118 
122  protected $mIncludeOffset = false;
123 
129  public $mResult;
130 
131  public function __construct( IContextSource $context = null ) {
132  if ( $context ) {
133  $this->setContext( $context );
134  }
135 
136  $this->mRequest = $this->getRequest();
137 
138  # NB: the offset is quoted, not validated. It is treated as an
139  # arbitrary string to support the widest variety of index types. Be
140  # careful outputting it into HTML!
141  $this->mOffset = $this->mRequest->getText( 'offset' );
142 
143  # Use consistent behavior for the limit options
144  $this->mDefaultLimit = $this->getUser()->getIntOption( 'rclimit' );
145  if ( !$this->mLimit ) {
146  // Don't override if a subclass calls $this->setLimit() in its constructor.
147  list( $this->mLimit, /* $offset */ ) = $this->mRequest->getLimitOffset();
148  }
149 
150  $this->mIsBackwards = ( $this->mRequest->getVal( 'dir' ) == 'prev' );
151  # Let the subclass set the DB here; otherwise use a replica DB for the current wiki
152  $this->mDb = $this->mDb ?: wfGetDB( DB_REPLICA );
153 
154  $index = $this->getIndexField(); // column to sort on
155  $extraSort = $this->getExtraSortFields(); // extra columns to sort on for query planning
156  $order = $this->mRequest->getVal( 'order' );
157  if ( is_array( $index ) && isset( $index[$order] ) ) {
158  $this->mOrderType = $order;
159  $this->mIndexField = $index[$order];
160  $this->mExtraSortFields = isset( $extraSort[$order] )
161  ? (array)$extraSort[$order]
162  : [];
163  } elseif ( is_array( $index ) ) {
164  # First element is the default
165  $this->mIndexField = reset( $index );
166  $this->mOrderType = key( $index );
167  $this->mExtraSortFields = isset( $extraSort[$this->mOrderType] )
168  ? (array)$extraSort[$this->mOrderType]
169  : [];
170  } else {
171  # $index is not an array
172  $this->mOrderType = null;
173  $this->mIndexField = $index;
174  $this->mExtraSortFields = (array)$extraSort;
175  }
176 
177  if ( !isset( $this->mDefaultDirection ) ) {
178  $dir = $this->getDefaultDirections();
179  $this->mDefaultDirection = is_array( $dir )
180  ? $dir[$this->mOrderType]
181  : $dir;
182  }
183  }
184 
190  public function getDatabase() {
191  return $this->mDb;
192  }
193 
199  public function doQuery() {
200  # Use the child class name for profiling
201  $fname = __METHOD__ . ' (' . static::class . ')';
202  $section = Profiler::instance()->scopedProfileIn( $fname );
203 
204  // @todo This should probably compare to DIR_DESCENDING and DIR_ASCENDING constants
205  $descending = ( $this->mIsBackwards == $this->mDefaultDirection );
206  # Plus an extra row so that we can tell the "next" link should be shown
207  $queryLimit = $this->mLimit + 1;
208 
209  if ( $this->mOffset == '' ) {
210  $isFirst = true;
211  } else {
212  // If there's an offset, we may or may not be at the first entry.
213  // The only way to tell is to run the query in the opposite
214  // direction see if we get a row.
215  $oldIncludeOffset = $this->mIncludeOffset;
216  $this->mIncludeOffset = !$this->mIncludeOffset;
217  $isFirst = !$this->reallyDoQuery( $this->mOffset, 1, !$descending )->numRows();
218  $this->mIncludeOffset = $oldIncludeOffset;
219  }
220 
221  $this->mResult = $this->reallyDoQuery(
222  $this->mOffset,
223  $queryLimit,
224  $descending
225  );
226 
227  $this->extractResultInfo( $isFirst, $queryLimit, $this->mResult );
228  $this->mQueryDone = true;
229 
230  $this->preprocessResults( $this->mResult );
231  $this->mResult->rewind(); // Paranoia
232  }
233 
237  function getResult() {
238  return $this->mResult;
239  }
240 
246  function setOffset( $offset ) {
247  $this->mOffset = $offset;
248  }
249 
257  function setLimit( $limit ) {
258  $limit = (int)$limit;
259  // WebRequest::getLimitOffset() puts a cap of 5000, so do same here.
260  if ( $limit > 5000 ) {
261  $limit = 5000;
262  }
263  if ( $limit > 0 ) {
264  $this->mLimit = $limit;
265  }
266  }
267 
273  function getLimit() {
274  return $this->mLimit;
275  }
276 
284  public function setIncludeOffset( $include ) {
285  $this->mIncludeOffset = $include;
286  }
287 
297  function extractResultInfo( $isFirst, $limit, IResultWrapper $res ) {
298  $numRows = $res->numRows();
299  if ( $numRows ) {
300  # Remove any table prefix from index field
301  $parts = explode( '.', $this->mIndexField );
302  $indexColumn = end( $parts );
303 
304  $row = $res->fetchRow();
305  $firstIndex = $row[$indexColumn];
306 
307  # Discard the extra result row if there is one
308  if ( $numRows > $this->mLimit && $numRows > 1 ) {
309  $res->seek( $numRows - 1 );
310  $this->mPastTheEndRow = $res->fetchObject();
311  $this->mPastTheEndIndex = $this->mPastTheEndRow->$indexColumn;
312  $res->seek( $numRows - 2 );
313  $row = $res->fetchRow();
314  $lastIndex = $row[$indexColumn];
315  } else {
316  $this->mPastTheEndRow = null;
317  # Setting indexes to an empty string means that they will be
318  # omitted if they would otherwise appear in URLs. It just so
319  # happens that this is the right thing to do in the standard
320  # UI, in all the relevant cases.
321  $this->mPastTheEndIndex = '';
322  $res->seek( $numRows - 1 );
323  $row = $res->fetchRow();
324  $lastIndex = $row[$indexColumn];
325  }
326  } else {
327  $firstIndex = '';
328  $lastIndex = '';
329  $this->mPastTheEndRow = null;
330  $this->mPastTheEndIndex = '';
331  }
332 
333  if ( $this->mIsBackwards ) {
334  $this->mIsFirst = ( $numRows < $limit );
335  $this->mIsLast = $isFirst;
336  $this->mLastShown = $firstIndex;
337  $this->mFirstShown = $lastIndex;
338  } else {
339  $this->mIsFirst = $isFirst;
340  $this->mIsLast = ( $numRows < $limit );
341  $this->mLastShown = $lastIndex;
342  $this->mFirstShown = $firstIndex;
343  }
344  }
345 
351  function getSqlComment() {
352  return static::class;
353  }
354 
364  public function reallyDoQuery( $offset, $limit, $descending ) {
365  list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
366  $this->buildQueryInfo( $offset, $limit, $descending );
367 
368  return $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds );
369  }
370 
379  protected function buildQueryInfo( $offset, $limit, $descending ) {
380  $fname = __METHOD__ . ' (' . $this->getSqlComment() . ')';
381  $info = $this->getQueryInfo();
382  $tables = $info['tables'];
383  $fields = $info['fields'];
384  $conds = isset( $info['conds'] ) ? $info['conds'] : [];
385  $options = isset( $info['options'] ) ? $info['options'] : [];
386  $join_conds = isset( $info['join_conds'] ) ? $info['join_conds'] : [];
387  $sortColumns = array_merge( [ $this->mIndexField ], $this->mExtraSortFields );
388  if ( $descending ) {
389  $options['ORDER BY'] = $sortColumns;
390  $operator = $this->mIncludeOffset ? '>=' : '>';
391  } else {
392  $orderBy = [];
393  foreach ( $sortColumns as $col ) {
394  $orderBy[] = $col . ' DESC';
395  }
396  $options['ORDER BY'] = $orderBy;
397  $operator = $this->mIncludeOffset ? '<=' : '<';
398  }
399  if ( $offset != '' ) {
400  $conds[] = $this->mIndexField . $operator . $this->mDb->addQuotes( $offset );
401  }
402  $options['LIMIT'] = intval( $limit );
403  return [ $tables, $fields, $conds, $fname, $options, $join_conds ];
404  }
405 
411  protected function preprocessResults( $result ) {
412  }
413 
420  public function getBody() {
421  if ( !$this->mQueryDone ) {
422  $this->doQuery();
423  }
424 
425  if ( $this->mResult->numRows() ) {
426  # Do any special query batches before display
427  $this->doBatchLookups();
428  }
429 
430  # Don't use any extra rows returned by the query
431  $numRows = min( $this->mResult->numRows(), $this->mLimit );
432 
433  $s = $this->getStartBody();
434  if ( $numRows ) {
435  if ( $this->mIsBackwards ) {
436  for ( $i = $numRows - 1; $i >= 0; $i-- ) {
437  $this->mResult->seek( $i );
438  $row = $this->mResult->fetchObject();
439  $s .= $this->formatRow( $row );
440  }
441  } else {
442  $this->mResult->seek( 0 );
443  for ( $i = 0; $i < $numRows; $i++ ) {
444  $row = $this->mResult->fetchObject();
445  $s .= $this->formatRow( $row );
446  }
447  }
448  } else {
449  $s .= $this->getEmptyBody();
450  }
451  $s .= $this->getEndBody();
452  return $s;
453  }
454 
464  function makeLink( $text, array $query = null, $type = null ) {
465  if ( $query === null ) {
466  return $text;
467  }
468 
469  $attrs = [];
470  if ( in_array( $type, [ 'prev', 'next' ] ) ) {
471  $attrs['rel'] = $type;
472  }
473 
474  if ( in_array( $type, [ 'asc', 'desc' ] ) ) {
475  $attrs['title'] = wfMessage( $type == 'asc' ? 'sort-ascending' : 'sort-descending' )->text();
476  }
477 
478  if ( $type ) {
479  $attrs['class'] = "mw-{$type}link";
480  }
481 
482  return Linker::linkKnown(
483  $this->getTitle(),
484  $text,
485  $attrs,
486  $query + $this->getDefaultQuery()
487  );
488  }
489 
497  protected function doBatchLookups() {
498  }
499 
506  protected function getStartBody() {
507  return '';
508  }
509 
515  protected function getEndBody() {
516  return '';
517  }
518 
525  protected function getEmptyBody() {
526  return '';
527  }
528 
536  function getDefaultQuery() {
537  if ( !isset( $this->mDefaultQuery ) ) {
538  $this->mDefaultQuery = $this->getRequest()->getQueryValues();
539  unset( $this->mDefaultQuery['title'] );
540  unset( $this->mDefaultQuery['dir'] );
541  unset( $this->mDefaultQuery['offset'] );
542  unset( $this->mDefaultQuery['limit'] );
543  unset( $this->mDefaultQuery['order'] );
544  unset( $this->mDefaultQuery['month'] );
545  unset( $this->mDefaultQuery['year'] );
546  }
547  return $this->mDefaultQuery;
548  }
549 
555  function getNumRows() {
556  if ( !$this->mQueryDone ) {
557  $this->doQuery();
558  }
559  return $this->mResult->numRows();
560  }
561 
567  function getPagingQueries() {
568  if ( !$this->mQueryDone ) {
569  $this->doQuery();
570  }
571 
572  # Don't announce the limit everywhere if it's the default
573  $urlLimit = $this->mLimit == $this->mDefaultLimit ? null : $this->mLimit;
574 
575  if ( $this->mIsFirst ) {
576  $prev = false;
577  $first = false;
578  } else {
579  $prev = [
580  'dir' => 'prev',
581  'offset' => $this->mFirstShown,
582  'limit' => $urlLimit
583  ];
584  $first = [ 'limit' => $urlLimit ];
585  }
586  if ( $this->mIsLast ) {
587  $next = false;
588  $last = false;
589  } else {
590  $next = [ 'offset' => $this->mLastShown, 'limit' => $urlLimit ];
591  $last = [ 'dir' => 'prev', 'limit' => $urlLimit ];
592  }
593  return [
594  'prev' => $prev,
595  'next' => $next,
596  'first' => $first,
597  'last' => $last
598  ];
599  }
600 
606  function isNavigationBarShown() {
607  if ( !$this->mQueryDone ) {
608  $this->doQuery();
609  }
610  // Hide navigation by default if there is nothing to page
611  return !( $this->mIsFirst && $this->mIsLast );
612  }
613 
624  function getPagingLinks( $linkTexts, $disabledTexts = [] ) {
625  $queries = $this->getPagingQueries();
626  $links = [];
627 
628  foreach ( $queries as $type => $query ) {
629  if ( $query !== false ) {
630  $links[$type] = $this->makeLink(
631  $linkTexts[$type],
632  $queries[$type],
633  $type
634  );
635  } elseif ( isset( $disabledTexts[$type] ) ) {
636  $links[$type] = $disabledTexts[$type];
637  } else {
638  $links[$type] = $linkTexts[$type];
639  }
640  }
641 
642  return $links;
643  }
644 
645  function getLimitLinks() {
646  $links = [];
647  if ( $this->mIsBackwards ) {
648  $offset = $this->mPastTheEndIndex;
649  } else {
650  $offset = $this->mOffset;
651  }
652  foreach ( $this->mLimitsShown as $limit ) {
653  $links[] = $this->makeLink(
654  $this->getLanguage()->formatNum( $limit ),
655  [ 'offset' => $offset, 'limit' => $limit ],
656  'num'
657  );
658  }
659  return $links;
660  }
661 
670  abstract function formatRow( $row );
671 
684  abstract function getQueryInfo();
685 
698  abstract function getIndexField();
699 
716  protected function getExtraSortFields() {
717  return [];
718  }
719 
739  protected function getDefaultDirections() {
740  return self::DIR_ASCENDING;
741  }
742 }
IndexPager\__construct
__construct(IContextSource $context=null)
Definition: IndexPager.php:131
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:33
IndexPager\formatRow
formatRow( $row)
Abstract formatting function.
IndexPager\buildQueryInfo
buildQueryInfo( $offset, $limit, $descending)
Build variables to use by the database wrapper.
Definition: IndexPager.php:379
IndexPager\getStartBody
getStartBody()
Hook into getBody(), allows text to be inserted at the start.
Definition: IndexPager.php:506
use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Definition: APACHE-LICENSE-2.0.txt:10
IndexPager\preprocessResults
preprocessResults( $result)
Pre-process results; useful for performing batch existence checks, etc.
Definition: IndexPager.php:411
IndexPager\$mIsFirst
$mIsFirst
True if the current result set is the first one.
Definition: IndexPager.php:114
IndexPager\getDefaultQuery
getDefaultQuery()
Get an array of query parameters that should be put into self-links.
Definition: IndexPager.php:536
wfMessage
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 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 additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
Profiler\instance
static instance()
Singleton.
Definition: Profiler.php:62
array
the array() calling protocol came about after MediaWiki 1.4rc1.
IndexPager\getResult
getResult()
Definition: IndexPager.php:237
$last
$last
Definition: profileinfo.php:408
IndexPager\getExtraSortFields
getExtraSortFields()
This function should be overridden to return the names of secondary columns to order by in addition t...
Definition: IndexPager.php:716
IndexPager\$mDefaultDirection
$mDefaultDirection
$mDefaultDirection gives the direction to use when sorting results: DIR_ASCENDING or DIR_DESCENDING.
Definition: IndexPager.php:110
IndexPager\$mLastShown
$mLastShown
Definition: IndexPager.php:117
IndexPager\getDatabase
getDatabase()
Get the Database object in use.
Definition: IndexPager.php:190
IndexPager\$mLimitsShown
$mLimitsShown
Definition: IndexPager.php:79
IndexPager\getPagingQueries
getPagingQueries()
Get a URL query array for the prev, next, first and last links.
Definition: IndexPager.php:567
Linker\linkKnown
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
Definition: Linker.php:164
$s
$s
Definition: mergeMessageFileList.php:187
IndexPager\makeLink
makeLink( $text, array $query=null, $type=null)
Make a self-link.
Definition: IndexPager.php:464
$res
$res
Definition: database.txt:21
ContextSource\getRequest
getRequest()
Definition: ContextSource.php:71
IndexPager\$mDefaultLimit
$mDefaultLimit
Definition: IndexPager.php:80
$result
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=(\d*-\d*)") 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. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) '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 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) '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! 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:1993
IndexPager\$mQueryDone
$mQueryDone
Definition: IndexPager.php:82
ContextSource\getUser
getUser()
Definition: ContextSource.php:120
ContextSource\getTitle
getTitle()
Definition: ContextSource.php:79
IndexPager\DIR_ASCENDING
const DIR_ASCENDING
Constants for the $mDefaultDirection field.
Definition: IndexPager.php:75
IndexPager\getLimitLinks
getLimitLinks()
Definition: IndexPager.php:645
php
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:37
IndexPager\$mExtraSortFields
$mExtraSortFields
An array of secondary columns to order by.
Definition: IndexPager.php:95
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:497
IndexPager\getIndexField
getIndexField()
This function should be overridden to return the name of the index fi- eld.
IndexPager\$mDb
$mDb
Definition: IndexPager.php:83
ContextSource\getLanguage
getLanguage()
Definition: ContextSource.php:128
key
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an and does all the work of translating among various forms such as plain database key
Definition: design.txt:26
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:525
IndexPager\$mFirstShown
$mFirstShown
Definition: IndexPager.php:117
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
IndexPager\setLimit
setLimit( $limit)
Set the limit from an other source than the request.
Definition: IndexPager.php:257
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2812
ContextSource
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
Definition: ContextSource.php:29
IndexPager\$mLimit
$mLimit
Definition: IndexPager.php:81
IndexPager\$mPastTheEndRow
$mPastTheEndRow
Definition: IndexPager.php:84
IndexPager\$mIsBackwards
$mIsBackwards
Definition: IndexPager.php:111
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
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:297
ContextSource\setContext
setContext(IContextSource $context)
Definition: ContextSource.php:55
list
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
IndexPager\setIncludeOffset
setIncludeOffset( $include)
Set whether a row matching exactly the offset should be also included in the result or not.
Definition: IndexPager.php:284
$fname
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Definition: Setup.php:112
$options
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:2001
IndexPager\getDefaultDirections
getDefaultDirections()
Return the default sorting direction: DIR_ASCENDING or DIR_DESCENDING.
Definition: IndexPager.php:739
IndexPager\reallyDoQuery
reallyDoQuery( $offset, $limit, $descending)
Do a query with specified parameters, rather than using the object context.
Definition: IndexPager.php:364
IndexPager\$mOffset
$mOffset
Definition: IndexPager.php:81
IndexPager\setOffset
setOffset( $offset)
Set the offset from an other source than the request.
Definition: IndexPager.php:246
IndexPager\$mResult
IResultWrapper $mResult
Result object for the query.
Definition: IndexPager.php:129
IndexPager\$mIncludeOffset
$mIncludeOffset
Whether to include the offset in the query.
Definition: IndexPager.php:122
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:53
IndexPager\DIR_DESCENDING
const DIR_DESCENDING
Definition: IndexPager.php:76
IndexPager\getEndBody
getEndBody()
Hook into getBody() for the end of the list.
Definition: IndexPager.php:515
IndexPager\$mOrderType
$mOrderType
For pages that support multiple types of ordering, which one to use.
Definition: IndexPager.php:98
IndexPager\$mDefaultQuery
$mDefaultQuery
Definition: IndexPager.php:117
IndexPager\getSqlComment
getSqlComment()
Get some text to go in brackets in the "function name" part of the SQL comment.
Definition: IndexPager.php:351
IndexPager\isNavigationBarShown
isNavigationBarShown()
Returns whether to show the "navigation bar".
Definition: IndexPager.php:606
$section
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:3022
$tables
this hook is for auditing only RecentChangesLinked and Watchlist 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:1015
IndexPager\$mIndexField
$mIndexField
The index to actually be used for ordering.
Definition: IndexPager.php:90
as
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:22
IndexPager\$mPastTheEndIndex
$mPastTheEndIndex
Definition: IndexPager.php:117
IndexPager
IndexPager is an efficient pager which uses a (roughly unique) index in the data set to implement pag...
Definition: IndexPager.php:69
IndexPager\$mRequest
$mRequest
Definition: IndexPager.php:78
IndexPager\$mIsLast
$mIsLast
Definition: IndexPager.php:115
IndexPager\$mNavigationBar
$mNavigationBar
Definition: IndexPager.php:117
IndexPager\getLimit
getLimit()
Get the current limit.
Definition: IndexPager.php:273
class
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:56
IndexPager\getBody
getBody()
Get the formatted result list.
Definition: IndexPager.php:420
$query
null for the 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:1620
IndexPager\getQueryInfo
getQueryInfo()
This function should be overridden to provide all parameters needed for the main paged query.
$queries
$queries
Definition: profileinfo.php:405
IndexPager\getNumRows
getNumRows()
Get the number of rows in the result set.
Definition: IndexPager.php:555
IndexPager\getPagingLinks
getPagingLinks( $linkTexts, $disabledTexts=[])
Get paging links.
Definition: IndexPager.php:624
IndexPager\doQuery
doQuery()
Do the query, using information from the object context.
Definition: IndexPager.php:199
$type
$type
Definition: testCompression.php:48