MediaWiki  master
ImageListPager.php
Go to the documentation of this file.
1 <?php
28 
29 class ImageListPager extends TablePager {
30 
31  protected $mFieldNames = null;
32 
33  // Subclasses should override buildQueryConds instead of using $mQueryConds variable.
34  protected $mQueryConds = [];
35 
36  protected $mUserName = null;
37 
43  protected $mUser = null;
44 
45  protected $mSearch = '';
46 
47  protected $mIncluding = false;
48 
49  protected $mShowAll = false;
50 
51  protected $mTableName = 'image';
52 
53  public function __construct( IContextSource $context, $userName = null, $search = '',
54  $including = false, $showAll = false
55  ) {
56  $this->setContext( $context );
57  $this->mIncluding = $including;
58  $this->mShowAll = $showAll;
59 
60  if ( $userName !== null && $userName !== '' ) {
61  $nt = Title::makeTitleSafe( NS_USER, $userName );
62  if ( is_null( $nt ) ) {
63  $this->outputUserDoesNotExist( $userName );
64  } else {
65  $this->mUserName = $nt->getText();
66  $user = User::newFromName( $this->mUserName, false );
67  if ( $user ) {
68  $this->mUser = $user;
69  }
70  if ( !$user || ( $user->isAnon() && !User::isIP( $user->getName() ) ) ) {
71  $this->outputUserDoesNotExist( $userName );
72  }
73  }
74  }
75 
76  if ( $search !== '' && !$this->getConfig()->get( 'MiserMode' ) ) {
77  $this->mSearch = $search;
78  $nt = Title::newFromText( $this->mSearch );
79 
80  if ( $nt ) {
81  $dbr = wfGetDB( DB_REPLICA );
82  $this->mQueryConds[] = 'LOWER(img_name)' .
83  $dbr->buildLike( $dbr->anyString(),
84  strtolower( $nt->getDBkey() ), $dbr->anyString() );
85  }
86  }
87 
88  if ( !$including ) {
89  if ( $this->getRequest()->getText( 'sort', 'img_date' ) == 'img_date' ) {
90  $this->mDefaultDirection = IndexPager::DIR_DESCENDING;
91  } else {
92  $this->mDefaultDirection = IndexPager::DIR_ASCENDING;
93  }
94  } else {
95  $this->mDefaultDirection = IndexPager::DIR_DESCENDING;
96  }
97 
98  parent::__construct( $context );
99  }
100 
106  function getRelevantUser() {
107  return $this->mUser;
108  }
109 
115  protected function outputUserDoesNotExist( $userName ) {
116  $this->getOutput()->wrapWikiMsg(
117  "<div class=\"mw-userpage-userdoesnotexist error\">\n$1\n</div>",
118  [
119  'listfiles-userdoesnotexist',
120  wfEscapeWikiText( $userName ),
121  ]
122  );
123  }
124 
132  protected function buildQueryConds( $table ) {
133  $prefix = $table === 'image' ? 'img' : 'oi';
134  $conds = [];
135 
136  if ( !is_null( $this->mUserName ) ) {
137  // getQueryInfoReal() should have handled the tables and joins.
138  $dbr = wfGetDB( DB_REPLICA );
139  $actorWhere = ActorMigration::newMigration()->getWhere(
140  $dbr,
141  $prefix . '_user',
142  User::newFromName( $this->mUserName, false ),
143  // oldimage doesn't have an index on oi_user, while image does. Set $useId accordingly.
144  $prefix === 'img'
145  );
146  $conds[] = $actorWhere['conds'];
147  }
148 
149  if ( $this->mSearch !== '' ) {
150  $nt = Title::newFromText( $this->mSearch );
151  if ( $nt ) {
152  $dbr = wfGetDB( DB_REPLICA );
153  $conds[] = 'LOWER(' . $prefix . '_name)' .
154  $dbr->buildLike( $dbr->anyString(),
155  strtolower( $nt->getDBkey() ), $dbr->anyString() );
156  }
157  }
158 
159  if ( $table === 'oldimage' ) {
160  // Don't want to deal with revdel.
161  // Future fixme: Show partial information as appropriate.
162  // Would have to be careful about filtering by username when username is deleted.
163  $conds['oi_deleted'] = 0;
164  }
165 
166  // Add mQueryConds in case anyone was subclassing and using the old variable.
167  return $conds + $this->mQueryConds;
168  }
169 
176  function getFieldNames() {
177  if ( !$this->mFieldNames ) {
178  $this->mFieldNames = [
179  'img_timestamp' => $this->msg( 'listfiles_date' )->text(),
180  'img_name' => $this->msg( 'listfiles_name' )->text(),
181  'thumb' => $this->msg( 'listfiles_thumb' )->text(),
182  'img_size' => $this->msg( 'listfiles_size' )->text(),
183  ];
184  if ( is_null( $this->mUserName ) ) {
185  // Do not show username if filtering by username
186  $this->mFieldNames['img_user_text'] = $this->msg( 'listfiles_user' )->text();
187  }
188  // img_description down here, in order so that its still after the username field.
189  $this->mFieldNames['img_description'] = $this->msg( 'listfiles_description' )->text();
190 
191  if ( !$this->getConfig()->get( 'MiserMode' ) && !$this->mShowAll ) {
192  $this->mFieldNames['count'] = $this->msg( 'listfiles_count' )->text();
193  }
194  if ( $this->mShowAll ) {
195  $this->mFieldNames['top'] = $this->msg( 'listfiles-latestversion' )->text();
196  }
197  }
198 
199  return $this->mFieldNames;
200  }
201 
202  function isFieldSortable( $field ) {
203  if ( $this->mIncluding ) {
204  return false;
205  }
206  $sortable = [ 'img_timestamp', 'img_name', 'img_size' ];
207  /* For reference, the indicies we can use for sorting are:
208  * On the image table: img_user_timestamp/img_usertext_timestamp/img_actor_timestamp,
209  * img_size, img_timestamp
210  * On oldimage: oi_usertext_timestamp/oi_actor_timestamp, oi_name_timestamp
211  *
212  * In particular that means we cannot sort by timestamp when not filtering
213  * by user and including old images in the results. Which is sad.
214  */
215  if ( $this->getConfig()->get( 'MiserMode' ) && !is_null( $this->mUserName ) ) {
216  // If we're sorting by user, the index only supports sorting by time.
217  if ( $field === 'img_timestamp' ) {
218  return true;
219  } else {
220  return false;
221  }
222  } elseif ( $this->getConfig()->get( 'MiserMode' )
223  && $this->mShowAll /* && mUserName === null */
224  ) {
225  // no oi_timestamp index, so only alphabetical sorting in this case.
226  if ( $field === 'img_name' ) {
227  return true;
228  } else {
229  return false;
230  }
231  }
232 
233  return in_array( $field, $sortable );
234  }
235 
236  function getQueryInfo() {
237  // Hacky Hacky Hacky - I want to get query info
238  // for two different tables, without reimplementing
239  // the pager class.
240  $qi = $this->getQueryInfoReal( $this->mTableName );
241 
242  return $qi;
243  }
244 
255  protected function getQueryInfoReal( $table ) {
256  $dbr = wfGetDB( DB_REPLICA );
257  $prefix = $table === 'oldimage' ? 'oi' : 'img';
258 
259  $tables = [ $table ];
260  $fields = array_keys( $this->getFieldNames() );
261  $fields = array_combine( $fields, $fields );
262  unset( $fields['img_description'] );
263  unset( $fields['img_user_text'] );
264 
265  if ( $table === 'oldimage' ) {
266  foreach ( $fields as $id => $field ) {
267  if ( substr( $id, 0, 4 ) === 'img_' ) {
268  $fields[$id] = $prefix . substr( $field, 3 );
269  }
270  }
271  $fields['top'] = $dbr->addQuotes( 'no' );
272  } elseif ( $this->mShowAll ) {
273  $fields['top'] = $dbr->addQuotes( 'yes' );
274  }
275  $fields['thumb'] = $prefix . '_name';
276 
277  $options = $join_conds = [];
278 
279  # Description field
280  $commentQuery = CommentStore::getStore()->getJoin( $prefix . '_description' );
281  $tables += $commentQuery['tables'];
282  $fields += $commentQuery['fields'];
283  $join_conds += $commentQuery['joins'];
284  $fields['description_field'] = $dbr->addQuotes( "{$prefix}_description" );
285 
286  # User fields
287  $actorQuery = ActorMigration::newMigration()->getJoin( $prefix . '_user' );
288  $tables += $actorQuery['tables'];
289  $join_conds += $actorQuery['joins'];
290  $fields['img_user'] = $actorQuery['fields'][$prefix . '_user'];
291  $fields['img_user_text'] = $actorQuery['fields'][$prefix . '_user_text'];
292  $fields['img_actor'] = $actorQuery['fields'][$prefix . '_actor'];
293 
294  # Depends on $wgMiserMode
295  # Will also not happen if mShowAll is true.
296  if ( isset( $fields['count'] ) ) {
297  $fields['count'] = $dbr->buildSelectSubquery(
298  'oldimage',
299  'COUNT(oi_archive_name)',
300  'oi_name = img_name',
301  __METHOD__
302  );
303  }
304 
305  return [
306  'tables' => $tables,
307  'fields' => $fields,
308  'conds' => $this->buildQueryConds( $table ),
309  'options' => $options,
310  'join_conds' => $join_conds
311  ];
312  }
313 
326  function reallyDoQuery( $offset, $limit, $order ) {
327  $prevTableName = $this->mTableName;
328  $this->mTableName = 'image';
329  list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
330  $this->buildQueryInfo( $offset, $limit, $order );
331  $imageRes = $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds );
332  $this->mTableName = $prevTableName;
333 
334  if ( !$this->mShowAll ) {
335  return $imageRes;
336  }
337 
338  $this->mTableName = 'oldimage';
339 
340  # Hacky...
341  $oldIndex = $this->mIndexField;
342  if ( substr( $this->mIndexField, 0, 4 ) !== 'img_' ) {
343  throw new MWException( "Expected to be sorting on an image table field" );
344  }
345  $this->mIndexField = 'oi_' . substr( $this->mIndexField, 4 );
346 
347  list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
348  $this->buildQueryInfo( $offset, $limit, $order );
349  $oldimageRes = $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds );
350 
351  $this->mTableName = $prevTableName;
352  $this->mIndexField = $oldIndex;
353 
354  return $this->combineResult( $imageRes, $oldimageRes, $limit, $order );
355  }
356 
368  protected function combineResult( $res1, $res2, $limit, $ascending ) {
369  $res1->rewind();
370  $res2->rewind();
371  $topRes1 = $res1->next();
372  $topRes2 = $res2->next();
373  $resultArray = [];
374  for ( $i = 0; $i < $limit && $topRes1 && $topRes2; $i++ ) {
375  if ( strcmp( $topRes1->{$this->mIndexField}, $topRes2->{$this->mIndexField} ) > 0 ) {
376  if ( !$ascending ) {
377  $resultArray[] = $topRes1;
378  $topRes1 = $res1->next();
379  } else {
380  $resultArray[] = $topRes2;
381  $topRes2 = $res2->next();
382  }
383  } elseif ( !$ascending ) {
384  $resultArray[] = $topRes2;
385  $topRes2 = $res2->next();
386  } else {
387  $resultArray[] = $topRes1;
388  $topRes1 = $res1->next();
389  }
390  }
391 
392  for ( ; $i < $limit && $topRes1; $i++ ) {
393  $resultArray[] = $topRes1;
394  $topRes1 = $res1->next();
395  }
396 
397  for ( ; $i < $limit && $topRes2; $i++ ) {
398  $resultArray[] = $topRes2;
399  $topRes2 = $res2->next();
400  }
401 
402  return new FakeResultWrapper( $resultArray );
403  }
404 
405  function getDefaultSort() {
406  if ( $this->mShowAll && $this->getConfig()->get( 'MiserMode' ) && is_null( $this->mUserName ) ) {
407  // Unfortunately no index on oi_timestamp.
408  return 'img_name';
409  } else {
410  return 'img_timestamp';
411  }
412  }
413 
414  protected function doBatchLookups() {
415  $userIds = [];
416  $this->mResult->seek( 0 );
417  foreach ( $this->mResult as $row ) {
418  $userIds[] = $row->img_user;
419  }
420  # Do a link batch query for names and userpages
421  UserCache::singleton()->doQuery( $userIds, [ 'userpage' ], __METHOD__ );
422  }
423 
438  function formatValue( $field, $value ) {
439  $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
440  switch ( $field ) {
441  case 'thumb':
442  $opt = [ 'time' => wfTimestamp( TS_MW, $this->mCurrentRow->img_timestamp ) ];
443  $file = RepoGroup::singleton()->getLocalRepo()->findFile( $value, $opt );
444  // If statement for paranoia
445  if ( $file ) {
446  $thumb = $file->transform( [ 'width' => 180, 'height' => 360 ] );
447  if ( $thumb ) {
448  return $thumb->toHtml( [ 'desc-link' => true ] );
449  } else {
450  return $this->msg( 'thumbnail_error', '' )->escaped();
451  }
452  } else {
453  return htmlspecialchars( $value );
454  }
455  case 'img_timestamp':
456  // We may want to make this a link to the "old" version when displaying old files
457  return htmlspecialchars( $this->getLanguage()->userTimeAndDate( $value, $this->getUser() ) );
458  case 'img_name':
459  static $imgfile = null;
460  if ( $imgfile === null ) {
461  $imgfile = $this->msg( 'imgfile' )->text();
462  }
463 
464  // Weird files can maybe exist? T24227
465  $filePage = Title::makeTitleSafe( NS_FILE, $value );
466  if ( $filePage ) {
467  $link = $linkRenderer->makeKnownLink(
468  $filePage,
469  $filePage->getText()
470  );
471  $download = Xml::element( 'a',
472  [ 'href' => wfLocalFile( $filePage )->getUrl() ],
473  $imgfile
474  );
475  $download = $this->msg( 'parentheses' )->rawParams( $download )->escaped();
476 
477  // Add delete links if allowed
478  // From https://github.com/Wikia/app/pull/3859
479  if ( $filePage->userCan( 'delete', $this->getUser() ) ) {
480  $deleteMsg = $this->msg( 'listfiles-delete' )->text();
481 
482  $delete = $linkRenderer->makeKnownLink(
483  $filePage, $deleteMsg, [], [ 'action' => 'delete' ]
484  );
485  $delete = $this->msg( 'parentheses' )->rawParams( $delete )->escaped();
486 
487  return "$link $download $delete";
488  }
489 
490  return "$link $download";
491  } else {
492  return htmlspecialchars( $value );
493  }
494  case 'img_user_text':
495  if ( $this->mCurrentRow->img_user ) {
496  $name = User::whoIs( $this->mCurrentRow->img_user );
497  $link = $linkRenderer->makeLink(
499  $name
500  );
501  } else {
502  $link = htmlspecialchars( $value );
503  }
504 
505  return $link;
506  case 'img_size':
507  return htmlspecialchars( $this->getLanguage()->formatSize( $value ) );
508  case 'img_description':
509  $field = $this->mCurrentRow->description_field;
510  $value = CommentStore::getStore()->getComment( $field, $this->mCurrentRow )->text;
511  return Linker::formatComment( $value );
512  case 'count':
513  return $this->getLanguage()->formatNum( intval( $value ) + 1 );
514  case 'top':
515  // Messages: listfiles-latestversion-yes, listfiles-latestversion-no
516  return $this->msg( 'listfiles-latestversion-' . $value );
517  default:
518  throw new MWException( "Unknown field '$field'" );
519  }
520  }
521 
522  function getForm() {
523  $formDescriptor = [];
524  $formDescriptor['limit'] = [
525  'type' => 'select',
526  'name' => 'limit',
527  'label-message' => 'table_pager_limit_label',
528  'options' => $this->getLimitSelectList(),
529  'default' => $this->mLimit,
530  ];
531 
532  if ( !$this->getConfig()->get( 'MiserMode' ) ) {
533  $formDescriptor['ilsearch'] = [
534  'type' => 'text',
535  'name' => 'ilsearch',
536  'id' => 'mw-ilsearch',
537  'label-message' => 'listfiles_search_for',
538  'default' => $this->mSearch,
539  'size' => '40',
540  'maxlength' => '255',
541  ];
542  }
543 
544  $formDescriptor['user'] = [
545  'type' => 'user',
546  'name' => 'user',
547  'id' => 'mw-listfiles-user',
548  'label-message' => 'username',
549  'default' => $this->mUserName,
550  'size' => '40',
551  'maxlength' => '255',
552  ];
553 
554  $formDescriptor['ilshowall'] = [
555  'type' => 'check',
556  'name' => 'ilshowall',
557  'id' => 'mw-listfiles-show-all',
558  'label-message' => 'listfiles-show-all',
559  'default' => $this->mShowAll,
560  ];
561 
562  $query = $this->getRequest()->getQueryValues();
563  unset( $query['title'] );
564  unset( $query['limit'] );
565  unset( $query['ilsearch'] );
566  unset( $query['ilshowall'] );
567  unset( $query['user'] );
568 
569  $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
570  $htmlForm
571  ->setMethod( 'get' )
572  ->setId( 'mw-listfiles-form' )
573  ->setTitle( $this->getTitle() )
574  ->setSubmitTextMsg( 'table_pager_limit_submit' )
575  ->setWrapperLegendMsg( 'listfiles' )
576  ->addHiddenFields( $query )
577  ->prepareForm()
578  ->displayForm( '' );
579  }
580 
581  protected function getTableClass() {
582  return parent::getTableClass() . ' listfiles';
583  }
584 
585  protected function getNavClass() {
586  return parent::getNavClass() . ' listfiles_nav';
587  }
588 
589  protected function getSortHeaderClass() {
590  return parent::getSortHeaderClass() . ' listfiles_sort';
591  }
592 
593  function getPagingQueries() {
594  $queries = parent::getPagingQueries();
595  if ( !is_null( $this->mUserName ) ) {
596  # Append the username to the query string
597  foreach ( $queries as &$query ) {
598  if ( $query !== false ) {
599  $query['user'] = $this->mUserName;
600  }
601  }
602  }
603 
604  return $queries;
605  }
606 
607  function getDefaultQuery() {
608  $queries = parent::getDefaultQuery();
609  if ( !isset( $queries['user'] ) && !is_null( $this->mUserName ) ) {
610  $queries['user'] = $this->mUserName;
611  }
612 
613  return $queries;
614  }
615 
616  function getTitle() {
617  return SpecialPage::getTitleFor( 'Listfiles' );
618  }
619 }
const DIR_DESCENDING
Backwards-compatible constant for $mDefaultDirection field (do not change)
Definition: IndexPager.php:73
setContext(IContextSource $context)
Table-based display with a user-selectable sort order.
Definition: TablePager.php:28
__construct(IContextSource $context, $userName=null, $search='', $including=false, $showAll=false)
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
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
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:1585
static whoIs( $id)
Get the username corresponding to a given user ID.
Definition: User.php:887
outputUserDoesNotExist( $userName)
Add a message to the output stating that the user doesn&#39;t exist.
static isIP( $name)
Does the string match an anonymous IP address?
Definition: User.php:969
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
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 noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form before processing starts Return false to skip default processing and return $ret $linkRenderer
Definition: hooks.txt:1982
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Definition: router.php:42
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 & $formDescriptor
Definition: hooks.txt:2061
buildQueryInfo( $offset, $limit, $order)
Build variables to use by the database wrapper.
Definition: IndexPager.php:424
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
$value
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 MediaWikiServices
Definition: injection.txt:23
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
string $mIndexField
The index to actually be used for ordering.
Definition: IndexPager.php:102
static factory( $displayFormat)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:301
wfLocalFile( $title)
Get an object referring to a locally registered file.
IContextSource $context
getRelevantUser()
Get the user relevant to the ImageList.
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:979
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:3050
getLimitSelectList()
Get a list of items to show in a "<select>" element of limits.
Definition: TablePager.php:364
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
static newMigration()
Static constructor.
static formatComment( $comment, $title=null, $local=false, $wikiId=null)
This function is called by all recent changes variants, by the page history, and by the user contribu...
Definition: Linker.php:1126
isFieldSortable( $field)
static singleton()
Get a RepoGroup instance.
Definition: RepoGroup.php:61
getContext()
Get the base IContextSource 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:1982
getQueryInfoReal( $table)
Actually get the query info.
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:780
reallyDoQuery( $offset, $limit, $order)
Override reallyDoQuery to mix together two queries.
const NS_FILE
Definition: Defines.php:70
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don&#39;t need a full Title object...
Definition: SpecialPage.php:82
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:123
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:617
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:589
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
static getStore()
combineResult( $res1, $res2, $limit, $ascending)
Combine results from 2 tables.
Overloads the relevant methods of the real ResultsWrapper so it doesn&#39;t go anywhere near an actual da...
getFieldNames()
The array keys (but not the array values) are used in sql.
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:41
formatValue( $field, $value)
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271
const DB_REPLICA
Definition: defines.php:25
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:587
$queries
User null $mUser
The relevant user.
buildQueryConds( $table)
Build the where clause of the query.
const DIR_ASCENDING
Backwards-compatible constant for $mDefaultDirection field (do not change)
Definition: IndexPager.php:71
static singleton()
Definition: UserCache.php:34
return true to allow those checks to and false if checking is done & $user
Definition: hooks.txt:1473
int $mLimit
The maximum number of entries to show.
Definition: IndexPager.php:89
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:319