MediaWiki  1.29.1
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  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  $conds[$prefix . '_user_text'] = $this->mUserName;
138  }
139 
140  if ( $this->mSearch !== '' ) {
141  $nt = Title::newFromText( $this->mSearch );
142  if ( $nt ) {
143  $dbr = wfGetDB( DB_REPLICA );
144  $conds[] = 'LOWER(' . $prefix . '_name)' .
145  $dbr->buildLike( $dbr->anyString(),
146  strtolower( $nt->getDBkey() ), $dbr->anyString() );
147  }
148  }
149 
150  if ( $table === 'oldimage' ) {
151  // Don't want to deal with revdel.
152  // Future fixme: Show partial information as appropriate.
153  // Would have to be careful about filtering by username when username is deleted.
154  $conds['oi_deleted'] = 0;
155  }
156 
157  // Add mQueryConds in case anyone was subclassing and using the old variable.
158  return $conds + $this->mQueryConds;
159  }
160 
164  function getFieldNames() {
165  if ( !$this->mFieldNames ) {
166  $this->mFieldNames = [
167  'img_timestamp' => $this->msg( 'listfiles_date' )->text(),
168  'img_name' => $this->msg( 'listfiles_name' )->text(),
169  'thumb' => $this->msg( 'listfiles_thumb' )->text(),
170  'img_size' => $this->msg( 'listfiles_size' )->text(),
171  ];
172  if ( is_null( $this->mUserName ) ) {
173  // Do not show username if filtering by username
174  $this->mFieldNames['img_user_text'] = $this->msg( 'listfiles_user' )->text();
175  }
176  // img_description down here, in order so that its still after the username field.
177  $this->mFieldNames['img_description'] = $this->msg( 'listfiles_description' )->text();
178 
179  if ( !$this->getConfig()->get( 'MiserMode' ) && !$this->mShowAll ) {
180  $this->mFieldNames['count'] = $this->msg( 'listfiles_count' )->text();
181  }
182  if ( $this->mShowAll ) {
183  $this->mFieldNames['top'] = $this->msg( 'listfiles-latestversion' )->text();
184  }
185  }
186 
187  return $this->mFieldNames;
188  }
189 
190  function isFieldSortable( $field ) {
191  if ( $this->mIncluding ) {
192  return false;
193  }
194  $sortable = [ 'img_timestamp', 'img_name', 'img_size' ];
195  /* For reference, the indicies we can use for sorting are:
196  * On the image table: img_user_timestamp, img_usertext_timestamp,
197  * img_size, img_timestamp
198  * On oldimage: oi_usertext_timestamp, oi_name_timestamp
199  *
200  * In particular that means we cannot sort by timestamp when not filtering
201  * by user and including old images in the results. Which is sad.
202  */
203  if ( $this->getConfig()->get( 'MiserMode' ) && !is_null( $this->mUserName ) ) {
204  // If we're sorting by user, the index only supports sorting by time.
205  if ( $field === 'img_timestamp' ) {
206  return true;
207  } else {
208  return false;
209  }
210  } elseif ( $this->getConfig()->get( 'MiserMode' )
211  && $this->mShowAll /* && mUserName === null */
212  ) {
213  // no oi_timestamp index, so only alphabetical sorting in this case.
214  if ( $field === 'img_name' ) {
215  return true;
216  } else {
217  return false;
218  }
219  }
220 
221  return in_array( $field, $sortable );
222  }
223 
224  function getQueryInfo() {
225  // Hacky Hacky Hacky - I want to get query info
226  // for two different tables, without reimplementing
227  // the pager class.
228  $qi = $this->getQueryInfoReal( $this->mTableName );
229 
230  return $qi;
231  }
232 
243  protected function getQueryInfoReal( $table ) {
244  $prefix = $table === 'oldimage' ? 'oi' : 'img';
245 
246  $tables = [ $table ];
247  $fields = array_keys( $this->getFieldNames() );
248 
249  if ( $table === 'oldimage' ) {
250  foreach ( $fields as $id => &$field ) {
251  if ( substr( $field, 0, 4 ) !== 'img_' ) {
252  continue;
253  }
254  $field = $prefix . substr( $field, 3 ) . ' AS ' . $field;
255  }
256  $fields[array_search( 'top', $fields )] = "'no' AS top";
257  } else {
258  if ( $this->mShowAll ) {
259  $fields[array_search( 'top', $fields )] = "'yes' AS top";
260  }
261  }
262  $fields[] = $prefix . '_user AS img_user';
263  $fields[array_search( 'thumb', $fields )] = $prefix . '_name AS thumb';
264 
265  $options = $join_conds = [];
266 
267  # Depends on $wgMiserMode
268  # Will also not happen if mShowAll is true.
269  if ( isset( $this->mFieldNames['count'] ) ) {
270  $tables[] = 'oldimage';
271 
272  # Need to rewrite this one
273  foreach ( $fields as &$field ) {
274  if ( $field == 'count' ) {
275  $field = 'COUNT(oi_archive_name) AS count';
276  }
277  }
278  unset( $field );
279 
280  $dbr = wfGetDB( DB_REPLICA );
281  if ( $dbr->implicitGroupby() ) {
282  $options = [ 'GROUP BY' => 'img_name' ];
283  } else {
284  $columnlist = preg_grep( '/^img/', array_keys( $this->getFieldNames() ) );
285  $options = [ 'GROUP BY' => array_merge( [ 'img_user' ], $columnlist ) ];
286  }
287  $join_conds = [ 'oldimage' => [ 'LEFT JOIN', 'oi_name = img_name' ] ];
288  }
289 
290  return [
291  'tables' => $tables,
292  'fields' => $fields,
293  'conds' => $this->buildQueryConds( $table ),
294  'options' => $options,
295  'join_conds' => $join_conds
296  ];
297  }
298 
311  function reallyDoQuery( $offset, $limit, $asc ) {
312  $prevTableName = $this->mTableName;
313  $this->mTableName = 'image';
314  list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
315  $this->buildQueryInfo( $offset, $limit, $asc );
316  $imageRes = $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds );
317  $this->mTableName = $prevTableName;
318 
319  if ( !$this->mShowAll ) {
320  return $imageRes;
321  }
322 
323  $this->mTableName = 'oldimage';
324 
325  # Hacky...
326  $oldIndex = $this->mIndexField;
327  if ( substr( $this->mIndexField, 0, 4 ) !== 'img_' ) {
328  throw new MWException( "Expected to be sorting on an image table field" );
329  }
330  $this->mIndexField = 'oi_' . substr( $this->mIndexField, 4 );
331 
332  list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
333  $this->buildQueryInfo( $offset, $limit, $asc );
334  $oldimageRes = $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds );
335 
336  $this->mTableName = $prevTableName;
337  $this->mIndexField = $oldIndex;
338 
339  return $this->combineResult( $imageRes, $oldimageRes, $limit, $asc );
340  }
341 
353  protected function combineResult( $res1, $res2, $limit, $ascending ) {
354  $res1->rewind();
355  $res2->rewind();
356  $topRes1 = $res1->next();
357  $topRes2 = $res2->next();
358  $resultArray = [];
359  for ( $i = 0; $i < $limit && $topRes1 && $topRes2; $i++ ) {
360  if ( strcmp( $topRes1->{$this->mIndexField}, $topRes2->{$this->mIndexField} ) > 0 ) {
361  if ( !$ascending ) {
362  $resultArray[] = $topRes1;
363  $topRes1 = $res1->next();
364  } else {
365  $resultArray[] = $topRes2;
366  $topRes2 = $res2->next();
367  }
368  } else {
369  if ( !$ascending ) {
370  $resultArray[] = $topRes2;
371  $topRes2 = $res2->next();
372  } else {
373  $resultArray[] = $topRes1;
374  $topRes1 = $res1->next();
375  }
376  }
377  }
378 
379  // @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
380  for ( ; $i < $limit && $topRes1; $i++ ) {
381  // @codingStandardsIgnoreEnd
382  $resultArray[] = $topRes1;
383  $topRes1 = $res1->next();
384  }
385 
386  // @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
387  for ( ; $i < $limit && $topRes2; $i++ ) {
388  // @codingStandardsIgnoreEnd
389  $resultArray[] = $topRes2;
390  $topRes2 = $res2->next();
391  }
392 
393  return new FakeResultWrapper( $resultArray );
394  }
395 
396  function getDefaultSort() {
397  if ( $this->mShowAll && $this->getConfig()->get( 'MiserMode' ) && is_null( $this->mUserName ) ) {
398  // Unfortunately no index on oi_timestamp.
399  return 'img_name';
400  } else {
401  return 'img_timestamp';
402  }
403  }
404 
405  function doBatchLookups() {
406  $userIds = [];
407  $this->mResult->seek( 0 );
408  foreach ( $this->mResult as $row ) {
409  $userIds[] = $row->img_user;
410  }
411  # Do a link batch query for names and userpages
412  UserCache::singleton()->doQuery( $userIds, [ 'userpage' ], __METHOD__ );
413  }
414 
429  function formatValue( $field, $value ) {
430  $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
431  switch ( $field ) {
432  case 'thumb':
433  $opt = [ 'time' => wfTimestamp( TS_MW, $this->mCurrentRow->img_timestamp ) ];
434  $file = RepoGroup::singleton()->getLocalRepo()->findFile( $value, $opt );
435  // If statement for paranoia
436  if ( $file ) {
437  $thumb = $file->transform( [ 'width' => 180, 'height' => 360 ] );
438  if ( $thumb ) {
439  return $thumb->toHtml( [ 'desc-link' => true ] );
440  } else {
441  return wfMessage( 'thumbnail_error', '' )->escaped();
442  }
443  } else {
444  return htmlspecialchars( $value );
445  }
446  case 'img_timestamp':
447  // We may want to make this a link to the "old" version when displaying old files
448  return htmlspecialchars( $this->getLanguage()->userTimeAndDate( $value, $this->getUser() ) );
449  case 'img_name':
450  static $imgfile = null;
451  if ( $imgfile === null ) {
452  $imgfile = $this->msg( 'imgfile' )->text();
453  }
454 
455  // Weird files can maybe exist? T24227
456  $filePage = Title::makeTitleSafe( NS_FILE, $value );
457  if ( $filePage ) {
458  $link = $linkRenderer->makeKnownLink(
459  $filePage,
460  $filePage->getText()
461  );
462  $download = Xml::element( 'a',
463  [ 'href' => wfLocalFile( $filePage )->getUrl() ],
464  $imgfile
465  );
466  $download = $this->msg( 'parentheses' )->rawParams( $download )->escaped();
467 
468  // Add delete links if allowed
469  // From https://github.com/Wikia/app/pull/3859
470  if ( $filePage->userCan( 'delete', $this->getUser() ) ) {
471  $deleteMsg = $this->msg( 'listfiles-delete' )->text();
472 
473  $delete = $linkRenderer->makeKnownLink(
474  $filePage, $deleteMsg, [], [ 'action' => 'delete' ]
475  );
476  $delete = $this->msg( 'parentheses' )->rawParams( $delete )->escaped();
477 
478  return "$link $download $delete";
479  }
480 
481  return "$link $download";
482  } else {
483  return htmlspecialchars( $value );
484  }
485  case 'img_user_text':
486  if ( $this->mCurrentRow->img_user ) {
487  $name = User::whoIs( $this->mCurrentRow->img_user );
488  $link = $linkRenderer->makeLink(
490  $name
491  );
492  } else {
493  $link = htmlspecialchars( $value );
494  }
495 
496  return $link;
497  case 'img_size':
498  return htmlspecialchars( $this->getLanguage()->formatSize( $value ) );
499  case 'img_description':
500  return Linker::formatComment( $value );
501  case 'count':
502  return $this->getLanguage()->formatNum( intval( $value ) + 1 );
503  case 'top':
504  // Messages: listfiles-latestversion-yes, listfiles-latestversion-no
505  return $this->msg( 'listfiles-latestversion-' . $value );
506  default:
507  throw new MWException( "Unknown field '$field'" );
508  }
509  }
510 
511  function getForm() {
512  $fields = [];
513  $fields['limit'] = [
514  'type' => 'select',
515  'name' => 'limit',
516  'label-message' => 'table_pager_limit_label',
517  'options' => $this->getLimitSelectList(),
518  'default' => $this->mLimit,
519  ];
520 
521  if ( !$this->getConfig()->get( 'MiserMode' ) ) {
522  $fields['ilsearch'] = [
523  'type' => 'text',
524  'name' => 'ilsearch',
525  'id' => 'mw-ilsearch',
526  'label-message' => 'listfiles_search_for',
527  'default' => $this->mSearch,
528  'size' => '40',
529  'maxlength' => '255',
530  ];
531  }
532 
533  $this->getOutput()->addModules( 'mediawiki.userSuggest' );
534  $fields['user'] = [
535  'type' => 'text',
536  'name' => 'user',
537  'id' => 'mw-listfiles-user',
538  'label-message' => 'username',
539  'default' => $this->mUserName,
540  'size' => '40',
541  'maxlength' => '255',
542  'cssclass' => 'mw-autocomplete-user', // used by mediawiki.userSuggest
543  ];
544 
545  $fields['ilshowall'] = [
546  'type' => 'check',
547  'name' => 'ilshowall',
548  'id' => 'mw-listfiles-show-all',
549  'label-message' => 'listfiles-show-all',
550  'default' => $this->mShowAll,
551  ];
552 
553  $query = $this->getRequest()->getQueryValues();
554  unset( $query['title'] );
555  unset( $query['limit'] );
556  unset( $query['ilsearch'] );
557  unset( $query['ilshowall'] );
558  unset( $query['user'] );
559 
560  $form = new HTMLForm( $fields, $this->getContext() );
561 
562  $form->setMethod( 'get' );
563  $form->setTitle( $this->getTitle() );
564  $form->setId( 'mw-listfiles-form' );
565  $form->setWrapperLegendMsg( 'listfiles' );
566  $form->setSubmitTextMsg( 'table_pager_limit_submit' );
567  $form->addHiddenFields( $query );
568 
569  $form->prepareForm();
570  $form->displayForm( '' );
571  }
572 
573  protected function getTableClass() {
574  return parent::getTableClass() . ' listfiles';
575  }
576 
577  protected function getNavClass() {
578  return parent::getNavClass() . ' listfiles_nav';
579  }
580 
581  protected function getSortHeaderClass() {
582  return parent::getSortHeaderClass() . ' listfiles_sort';
583  }
584 
585  function getPagingQueries() {
586  $queries = parent::getPagingQueries();
587  if ( !is_null( $this->mUserName ) ) {
588  # Append the username to the query string
589  foreach ( $queries as &$query ) {
590  if ( $query !== false ) {
591  $query['user'] = $this->mUserName;
592  }
593  }
594  }
595 
596  return $queries;
597  }
598 
599  function getDefaultQuery() {
600  $queries = parent::getDefaultQuery();
601  if ( !isset( $queries['user'] ) && !is_null( $this->mUserName ) ) {
602  $queries['user'] = $this->mUserName;
603  }
604 
605  return $queries;
606  }
607 
608  function getTitle() {
609  return SpecialPage::getTitleFor( 'Listfiles' );
610  }
611 }
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:34
ContextSource\getConfig
getConfig()
Get the Config object.
Definition: ContextSource.php:68
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:265
RepoGroup\singleton
static singleton()
Get a RepoGroup instance.
Definition: RepoGroup.php:59
IndexPager\buildQueryInfo
buildQueryInfo( $offset, $limit, $descending)
Build variables to use by the database wrapper.
Definition: IndexPager.php:379
$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:990
ImageListPager\$mSearch
$mSearch
Definition: ImageListPager.php:45
ContextSource\msg
msg()
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:187
ImageListPager\getSortHeaderClass
getSortHeaderClass()
Definition: ImageListPager.php:581
$opt
$opt
Definition: postprocess-phan.php:115
ImageListPager\getPagingQueries
getPagingQueries()
Get a URL query array for the prev, next, first and last links.
Definition: ImageListPager.php:585
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1994
ImageListPager\getNavClass
getNavClass()
Definition: ImageListPager.php:577
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
ImageListPager\$mUser
User null $mUser
The relevant user.
Definition: ImageListPager.php:43
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:246
$fname
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Definition: Setup.php:36
NS_FILE
const NS_FILE
Definition: Defines.php:68
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:556
$linkRenderer
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:1956
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Definition: SpecialPage.php:82
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:304
Wikimedia\Rdbms\ResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: ResultWrapper.php:24
ContextSource\getRequest
getRequest()
Get the WebRequest object.
Definition: ContextSource.php:78
ImageListPager\doBatchLookups
doBatchLookups()
Called from getBody(), before getStartBody() is called and after doQuery() was called.
Definition: ImageListPager.php:405
Wikimedia\Rdbms\FakeResultWrapper
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
Definition: FakeResultWrapper.php:11
getContext
getContext()
IndexPager\DIR_ASCENDING
const DIR_ASCENDING
Constants for the $mDefaultDirection field.
Definition: IndexPager.php:75
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:35
$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:1572
ImageListPager\getFieldNames
getFieldNames()
Definition: ImageListPager.php:164
MWException
MediaWiki exception.
Definition: MWException.php:26
ImageListPager\outputUserDoesNotExist
outputUserDoesNotExist( $userName)
Add a message to the output stating that the user doesn't exist.
Definition: ImageListPager.php:115
ImageListPager\getQueryInfo
getQueryInfo()
This function should be overridden to provide all parameters needed for the main paged query.
Definition: ImageListPager.php:224
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3060
ContextSource\getOutput
getOutput()
Get the OutputPage object.
Definition: ContextSource.php:123
ImageListPager\$mShowAll
$mShowAll
Definition: ImageListPager.php:49
TablePager
Table-based display with a user-selectable sort order.
Definition: TablePager.php:28
ImageListPager\getTitle
getTitle()
Get the Title object.
Definition: ImageListPager.php:608
$limit
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 and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers please use GetContentModels hook to make them known to core if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive $limit
Definition: hooks.txt:1049
Xml\element
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:39
User\isIP
static isIP( $name)
Does the string match an anonymous IP address?
Definition: User.php:819
ImageListPager\__construct
__construct(IContextSource $context, $userName=null, $search='', $including=false, $showAll=false)
Definition: ImageListPager.php:53
ImageListPager\$mTableName
$mTableName
Definition: ImageListPager.php:51
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:514
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
ImageListPager\combineResult
combineResult( $res1, $res2, $limit, $ascending)
Combine results from 2 tables.
Definition: ImageListPager.php:353
ContextSource\setContext
setContext(IContextSource $context)
Set the IContextSource object.
Definition: ContextSource.php:58
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
ImageListPager\getTableClass
getTableClass()
Definition: ImageListPager.php:573
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:538
ImageListPager\getDefaultSort
getDefaultSort()
The database field name used as a default sort order.
Definition: ImageListPager.php:396
User\whoIs
static whoIs( $id)
Get the username corresponding to a given user ID.
Definition: User.php:739
ImageListPager\reallyDoQuery
reallyDoQuery( $offset, $limit, $asc)
Override reallyDoQuery to mix together two queries.
Definition: ImageListPager.php:311
$value
$value
Definition: styleTest.css.php:45
ImageListPager\getQueryInfoReal
getQueryInfoReal( $table)
Actually get the query info.
Definition: ImageListPager.php:243
ImageListPager\$mIncluding
$mIncluding
Definition: ImageListPager.php:47
ImageListPager\$mQueryConds
$mQueryConds
Definition: ImageListPager.php:34
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:1657
ImageListPager\buildQueryConds
buildQueryConds( $table)
Build the where clause of the query.
Definition: ImageListPager.php:132
ImageListPager\isFieldSortable
isFieldSortable( $field)
Return true if the named field should be sortable by the UI, false otherwise.
Definition: ImageListPager.php:190
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:55
Linker\formatComment
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:1094
IndexPager\DIR_DESCENDING
const DIR_DESCENDING
Definition: IndexPager.php:76
$dbr
if(! $regexes) $dbr
Definition: cleanup.php:94
ImageListPager
Definition: ImageListPager.php:29
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:9
UserCache\singleton
static singleton()
Definition: UserCache.php:34
NS_USER
const NS_USER
Definition: Defines.php:64
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:2929
ImageListPager\getRelevantUser
getRelevantUser()
Get the user relevant to the ImageList.
Definition: ImageListPager.php:106
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
ImageListPager\formatValue
formatValue( $field, $value)
Definition: ImageListPager.php:429
MediaWikiServices
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
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:50
wfLocalFile
wfLocalFile( $title)
Get an object referring to a locally registered file.
Definition: GlobalFunctions.php:3112
$queries
$queries
Definition: profileinfo.php:412
$options
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 and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Definition: hooks.txt:1049
ImageListPager\getDefaultQuery
getDefaultQuery()
Get an array of query parameters that should be put into self-links.
Definition: ImageListPager.php:599
ImageListPager\getForm
getForm()
Definition: ImageListPager.php:511
ImageListPager\$mUserName
$mUserName
Definition: ImageListPager.php:36
HTMLForm
Object handling generic submission, CSRF protection, layout and other logic for UI forms.
Definition: HTMLForm.php:128
ImageListPager\$mFieldNames
$mFieldNames
Definition: ImageListPager.php:31