MediaWiki  1.30.0
LogEventsList.php
Go to the documentation of this file.
1 <?php
29 
31  const NO_ACTION_LINK = 1;
33  const USE_CHECKBOXES = 4;
34 
35  public $flags;
36 
40  protected $mDefaultQuery;
41 
45  protected $showTagEditUI;
46 
50  protected $allowedActions = null;
51 
55  private $linkRenderer;
56 
67  public function __construct( $context, $linkRenderer = null, $flags = 0 ) {
68  if ( $context instanceof IContextSource ) {
69  $this->setContext( $context );
70  } else {
71  // Old parameters, $context should be a Skin object
72  $this->setContext( $context->getContext() );
73  }
74 
75  $this->flags = $flags;
76  $this->showTagEditUI = ChangeTags::showTagEditingUI( $this->getUser() );
77  if ( $linkRenderer instanceof LinkRenderer ) {
78  $this->linkRenderer = $linkRenderer;
79  }
80  }
81 
86  protected function getLinkRenderer() {
87  if ( $this->linkRenderer !== null ) {
88  return $this->linkRenderer;
89  } else {
90  return MediaWikiServices::getInstance()->getLinkRenderer();
91  }
92  }
93 
107  public function showOptions( $types = [], $user = '', $page = '', $pattern = '', $year = 0,
108  $month = 0, $filter = null, $tagFilter = '', $action = null
109  ) {
111 
112  $title = SpecialPage::getTitleFor( 'Log' );
113 
114  // For B/C, we take strings, but make sure they are converted...
115  $types = ( $types === '' ) ? [] : (array)$types;
116 
117  $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter, false, $this->getContext() );
118 
119  $html = Html::hidden( 'title', $title->getPrefixedDBkey() );
120 
121  // Basic selectors
122  $html .= $this->getTypeMenu( $types ) . "\n";
123  $html .= $this->getUserInput( $user ) . "\n";
124  $html .= $this->getTitleInput( $page ) . "\n";
125  $html .= $this->getExtraInputs( $types ) . "\n";
126 
127  // Title pattern, if allowed
128  if ( !$wgMiserMode ) {
129  $html .= $this->getTitlePattern( $pattern ) . "\n";
130  }
131 
132  // date menu
133  $html .= Xml::tags( 'p', null, Xml::dateMenu( (int)$year, (int)$month ) );
134 
135  // Tag filter
136  if ( $tagSelector ) {
137  $html .= Xml::tags( 'p', null, implode( '&#160;', $tagSelector ) );
138  }
139 
140  // Filter links
141  if ( $filter ) {
142  $html .= Xml::tags( 'p', null, $this->getFilterLinks( $filter ) );
143  }
144 
145  // Action filter
146  if ( $action !== null ) {
147  $html .= Xml::tags( 'p', null, $this->getActionSelector( $types, $action ) );
148  }
149 
150  // Submit button
151  $html .= Xml::submitButton( $this->msg( 'logeventslist-submit' )->text() );
152 
153  // Fieldset
154  $html = Xml::fieldset( $this->msg( 'log' )->text(), $html );
155 
156  // Form wrapping
157  $html = Xml::tags( 'form', [ 'action' => $wgScript, 'method' => 'get' ], $html );
158 
159  $this->getOutput()->addHTML( $html );
160  }
161 
166  private function getFilterLinks( $filter ) {
167  // show/hide links
168  $messages = [ $this->msg( 'show' )->text(), $this->msg( 'hide' )->text() ];
169  // Option value -> message mapping
170  $links = [];
171  $hiddens = ''; // keep track for "go" button
172  $linkRenderer = $this->getLinkRenderer();
173  foreach ( $filter as $type => $val ) {
174  // Should the below assignment be outside the foreach?
175  // Then it would have to be copied. Not certain what is more expensive.
176  $query = $this->getDefaultQuery();
177  $queryKey = "hide_{$type}_log";
178 
179  $hideVal = 1 - intval( $val );
180  $query[$queryKey] = $hideVal;
181 
183  $this->getTitle(),
184  $messages[$hideVal],
185  [],
186  $query
187  );
188 
189  // Message: log-show-hide-patrol
190  $links[$type] = $this->msg( "log-show-hide-{$type}" )->rawParams( $link )->escaped();
191  $hiddens .= Html::hidden( "hide_{$type}_log", $val ) . "\n";
192  }
193 
194  // Build links
195  return '<small>' . $this->getLanguage()->pipeList( $links ) . '</small>' . $hiddens;
196  }
197 
198  private function getDefaultQuery() {
199  if ( !isset( $this->mDefaultQuery ) ) {
200  $this->mDefaultQuery = $this->getRequest()->getQueryValues();
201  unset( $this->mDefaultQuery['title'] );
202  unset( $this->mDefaultQuery['dir'] );
203  unset( $this->mDefaultQuery['offset'] );
204  unset( $this->mDefaultQuery['limit'] );
205  unset( $this->mDefaultQuery['order'] );
206  unset( $this->mDefaultQuery['month'] );
207  unset( $this->mDefaultQuery['year'] );
208  }
209 
210  return $this->mDefaultQuery;
211  }
212 
217  private function getTypeMenu( $queryTypes ) {
218  $queryType = count( $queryTypes ) == 1 ? $queryTypes[0] : '';
219  $selector = $this->getTypeSelector();
220  $selector->setDefault( $queryType );
221 
222  return $selector->getHTML();
223  }
224 
230  public function getTypeSelector() {
231  $typesByName = []; // Temporary array
232  // First pass to load the log names
233  foreach ( LogPage::validTypes() as $type ) {
234  $page = new LogPage( $type );
235  $restriction = $page->getRestriction();
236  if ( $this->getUser()->isAllowed( $restriction ) ) {
237  $typesByName[$type] = $page->getName()->text();
238  }
239  }
240 
241  // Second pass to sort by name
242  asort( $typesByName );
243 
244  // Always put "All public logs" on top
245  $public = $typesByName[''];
246  unset( $typesByName[''] );
247  $typesByName = [ '' => $public ] + $typesByName;
248 
249  $select = new XmlSelect( 'type' );
250  foreach ( $typesByName as $type => $name ) {
251  $select->addOption( $name, $type );
252  }
253 
254  return $select;
255  }
256 
261  private function getUserInput( $user ) {
262  $label = Xml::inputLabel(
263  $this->msg( 'specialloguserlabel' )->text(),
264  'user',
265  'mw-log-user',
266  15,
267  $user,
268  [ 'class' => 'mw-autocomplete-user' ]
269  );
270 
271  return '<span class="mw-input-with-label">' . $label . '</span>';
272  }
273 
278  private function getTitleInput( $title ) {
279  $label = Xml::inputLabel(
280  $this->msg( 'speciallogtitlelabel' )->text(),
281  'page',
282  'mw-log-page',
283  20,
284  $title
285  );
286 
287  return '<span class="mw-input-with-label">' . $label . '</span>';
288  }
289 
294  private function getTitlePattern( $pattern ) {
295  return '<span class="mw-input-with-label">' .
296  Xml::checkLabel( $this->msg( 'log-title-wildcard' )->text(), 'pattern', 'pattern', $pattern ) .
297  '</span>';
298  }
299 
304  private function getExtraInputs( $types ) {
305  if ( count( $types ) == 1 ) {
306  if ( $types[0] == 'suppress' ) {
307  $offender = $this->getRequest()->getVal( 'offender' );
308  $user = User::newFromName( $offender, false );
309  if ( !$user || ( $user->getId() == 0 && !IP::isIPAddress( $offender ) ) ) {
310  $offender = ''; // Blank field if invalid
311  }
312  return Xml::inputLabel( $this->msg( 'revdelete-offender' )->text(), 'offender',
313  'mw-log-offender', 20, $offender );
314  } else {
315  // Allow extensions to add their own extra inputs
316  $input = '';
317  Hooks::run( 'LogEventsListGetExtraInputs', [ $types[0], $this, &$input ] );
318  return $input;
319  }
320  }
321 
322  return '';
323  }
324 
332  private function getActionSelector( $types, $action ) {
333  if ( $this->allowedActions === null || !count( $this->allowedActions ) ) {
334  return '';
335  }
336  $html = '';
337  $html .= Xml::label( wfMessage( 'log-action-filter-' . $types[0] )->text(),
338  'action-filter-' .$types[0] ) . "\n";
339  $select = new XmlSelect( 'subtype' );
340  $select->addOption( wfMessage( 'log-action-filter-all' )->text(), '' );
341  foreach ( $this->allowedActions as $value ) {
342  $msgKey = 'log-action-filter-' . $types[0] . '-' . $value;
343  $select->addOption( wfMessage( $msgKey )->text(), $value );
344  }
345  $select->setDefault( $action );
346  $html .= $select->getHTML();
347  return $html;
348  }
349 
356  public function setAllowedActions( $actions ) {
357  $this->allowedActions = $actions;
358  }
359 
363  public function beginLogEventsList() {
364  return "<ul>\n";
365  }
366 
370  public function endLogEventsList() {
371  return "</ul>\n";
372  }
373 
378  public function logLine( $row ) {
379  $entry = DatabaseLogEntry::newFromRow( $row );
380  $formatter = LogFormatter::newFromEntry( $entry );
381  $formatter->setContext( $this->getContext() );
382  $formatter->setLinkRenderer( $this->getLinkRenderer() );
383  $formatter->setShowUserToolLinks( !( $this->flags & self::NO_EXTRA_USER_LINKS ) );
384 
385  $time = htmlspecialchars( $this->getLanguage()->userTimeAndDate(
386  $entry->getTimestamp(), $this->getUser() ) );
387 
388  $action = $formatter->getActionText();
389 
390  if ( $this->flags & self::NO_ACTION_LINK ) {
391  $revert = '';
392  } else {
393  $revert = $formatter->getActionLinks();
394  if ( $revert != '' ) {
395  $revert = '<span class="mw-logevent-actionlink">' . $revert . '</span>';
396  }
397  }
398 
399  $comment = $formatter->getComment();
400 
401  // Some user can hide log items and have review links
402  $del = $this->getShowHideLinks( $row );
403 
404  // Any tags...
405  list( $tagDisplay, $newClasses ) = ChangeTags::formatSummaryRow(
406  $row->ts_tags,
407  'logevent',
408  $this->getContext()
409  );
410  $classes = array_merge(
411  [ 'mw-logline-' . $entry->getType() ],
412  $newClasses
413  );
414  $attribs = [
415  'data-mw-logid' => $entry->getId(),
416  'data-mw-logaction' => $entry->getFullType(),
417  ];
418  $ret = "$del $time $action $comment $revert $tagDisplay";
419 
420  // Let extensions add data
421  Hooks::run( 'LogEventsListLineEnding', [ $this, &$ret, $entry, &$classes, &$attribs ] );
422  $attribs = wfArrayFilterByKey( $attribs, [ Sanitizer::class, 'isReservedDataAttribute' ] );
423  $attribs['class'] = implode( ' ', $classes );
424 
425  return Html::rawElement( 'li', $attribs, $ret ) . "\n";
426  }
427 
432  private function getShowHideLinks( $row ) {
433  // We don't want to see the links and
434  if ( $this->flags == self::NO_ACTION_LINK ) {
435  return '';
436  }
437 
438  $user = $this->getUser();
439 
440  // If change tag editing is available to this user, return the checkbox
441  if ( $this->flags & self::USE_CHECKBOXES && $this->showTagEditUI ) {
442  return Xml::check(
443  'showhiderevisions',
444  false,
445  [ 'name' => 'ids[' . $row->log_id . ']' ]
446  );
447  }
448 
449  // no one can hide items from the suppress log.
450  if ( $row->log_type == 'suppress' ) {
451  return '';
452  }
453 
454  $del = '';
455  // Don't show useless checkbox to people who cannot hide log entries
456  if ( $user->isAllowed( 'deletedhistory' ) ) {
457  $canHide = $user->isAllowed( 'deletelogentry' );
458  $canViewSuppressedOnly = $user->isAllowed( 'viewsuppressed' ) &&
459  !$user->isAllowed( 'suppressrevision' );
460  $entryIsSuppressed = self::isDeleted( $row, LogPage::DELETED_RESTRICTED );
461  $canViewThisSuppressedEntry = $canViewSuppressedOnly && $entryIsSuppressed;
462  if ( $row->log_deleted || $canHide ) {
463  // Show checkboxes instead of links.
464  if ( $canHide && $this->flags & self::USE_CHECKBOXES && !$canViewThisSuppressedEntry ) {
465  // If event was hidden from sysops
466  if ( !self::userCan( $row, LogPage::DELETED_RESTRICTED, $user ) ) {
467  $del = Xml::check( 'deleterevisions', false, [ 'disabled' => 'disabled' ] );
468  } else {
469  $del = Xml::check(
470  'showhiderevisions',
471  false,
472  [ 'name' => 'ids[' . $row->log_id . ']' ]
473  );
474  }
475  } else {
476  // If event was hidden from sysops
477  if ( !self::userCan( $row, LogPage::DELETED_RESTRICTED, $user ) ) {
478  $del = Linker::revDeleteLinkDisabled( $canHide );
479  } else {
480  $query = [
481  'target' => SpecialPage::getTitleFor( 'Log', $row->log_type )->getPrefixedDBkey(),
482  'type' => 'logging',
483  'ids' => $row->log_id,
484  ];
485  $del = Linker::revDeleteLink(
486  $query,
487  $entryIsSuppressed,
488  $canHide && !$canViewThisSuppressedEntry
489  );
490  }
491  }
492  }
493  }
494 
495  return $del;
496  }
497 
505  public static function typeAction( $row, $type, $action, $right = '' ) {
506  $match = is_array( $type ) ?
507  in_array( $row->log_type, $type ) : $row->log_type == $type;
508  if ( $match ) {
509  $match = is_array( $action ) ?
510  in_array( $row->log_action, $action ) : $row->log_action == $action;
511  if ( $match && $right ) {
512  global $wgUser;
513  $match = $wgUser->isAllowed( $right );
514  }
515  }
516 
517  return $match;
518  }
519 
529  public static function userCan( $row, $field, User $user = null ) {
530  return self::userCanBitfield( $row->log_deleted, $field, $user );
531  }
532 
542  public static function userCanBitfield( $bitfield, $field, User $user = null ) {
543  if ( $bitfield & $field ) {
544  if ( $user === null ) {
545  global $wgUser;
546  $user = $wgUser;
547  }
548  if ( $bitfield & LogPage::DELETED_RESTRICTED ) {
549  $permissions = [ 'suppressrevision', 'viewsuppressed' ];
550  } else {
551  $permissions = [ 'deletedhistory' ];
552  }
553  $permissionlist = implode( ', ', $permissions );
554  wfDebug( "Checking for $permissionlist due to $field match on $bitfield\n" );
555  return call_user_func_array( [ $user, 'isAllowedAny' ], $permissions );
556  }
557  return true;
558  }
559 
565  public static function isDeleted( $row, $field ) {
566  return ( $row->log_deleted & $field ) == $field;
567  }
568 
594  public static function showLogExtract(
595  &$out, $types = [], $page = '', $user = '', $param = []
596  ) {
597  $defaultParameters = [
598  'lim' => 25,
599  'conds' => [],
600  'showIfEmpty' => true,
601  'msgKey' => [ '' ],
602  'wrap' => "$1",
603  'flags' => 0,
604  'useRequestParams' => false,
605  'useMaster' => false,
606  'extraUrlParams' => false,
607  ];
608  # The + operator appends elements of remaining keys from the right
609  # handed array to the left handed, whereas duplicated keys are NOT overwritten.
610  $param += $defaultParameters;
611  # Convert $param array to individual variables
612  $lim = $param['lim'];
613  $conds = $param['conds'];
614  $showIfEmpty = $param['showIfEmpty'];
615  $msgKey = $param['msgKey'];
616  $wrap = $param['wrap'];
617  $flags = $param['flags'];
618  $extraUrlParams = $param['extraUrlParams'];
619 
620  $useRequestParams = $param['useRequestParams'];
621  if ( !is_array( $msgKey ) ) {
622  $msgKey = [ $msgKey ];
623  }
624 
625  if ( $out instanceof OutputPage ) {
626  $context = $out->getContext();
627  } else {
629  }
630 
631  // FIXME: Figure out how to inject this
632  $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
633 
634  # Insert list of top 50 (or top $lim) items
635  $loglist = new LogEventsList( $context, $linkRenderer, $flags );
636  $pager = new LogPager( $loglist, $types, $user, $page, '', $conds );
637  if ( !$useRequestParams ) {
638  # Reset vars that may have been taken from the request
639  $pager->mLimit = 50;
640  $pager->mDefaultLimit = 50;
641  $pager->mOffset = "";
642  $pager->mIsBackwards = false;
643  }
644 
645  if ( $param['useMaster'] ) {
646  $pager->mDb = wfGetDB( DB_MASTER );
647  }
648  if ( isset( $param['offset'] ) ) { # Tell pager to ignore WebRequest offset
649  $pager->setOffset( $param['offset'] );
650  }
651 
652  if ( $lim > 0 ) {
653  $pager->mLimit = $lim;
654  }
655  // Fetch the log rows and build the HTML if needed
656  $logBody = $pager->getBody();
657  $numRows = $pager->getNumRows();
658 
659  $s = '';
660 
661  if ( $logBody ) {
662  if ( $msgKey[0] ) {
663  $dir = $context->getLanguage()->getDir();
664  $lang = $context->getLanguage()->getHtmlCode();
665 
666  $s = Xml::openElement( 'div', [
667  'class' => "mw-warning-with-logexcerpt mw-content-$dir",
668  'dir' => $dir,
669  'lang' => $lang,
670  ] );
671 
672  if ( count( $msgKey ) == 1 ) {
673  $s .= $context->msg( $msgKey[0] )->parseAsBlock();
674  } else { // Process additional arguments
675  $args = $msgKey;
676  array_shift( $args );
677  $s .= $context->msg( $msgKey[0], $args )->parseAsBlock();
678  }
679  }
680  $s .= $loglist->beginLogEventsList() .
681  $logBody .
682  $loglist->endLogEventsList();
683  } elseif ( $showIfEmpty ) {
684  $s = Html::rawElement( 'div', [ 'class' => 'mw-warning-logempty' ],
685  $context->msg( 'logempty' )->parse() );
686  }
687 
688  if ( $numRows > $pager->mLimit ) { # Show "Full log" link
689  $urlParam = [];
690  if ( $page instanceof Title ) {
691  $urlParam['page'] = $page->getPrefixedDBkey();
692  } elseif ( $page != '' ) {
693  $urlParam['page'] = $page;
694  }
695 
696  if ( $user != '' ) {
697  $urlParam['user'] = $user;
698  }
699 
700  if ( !is_array( $types ) ) { # Make it an array, if it isn't
701  $types = [ $types ];
702  }
703 
704  # If there is exactly one log type, we can link to Special:Log?type=foo
705  if ( count( $types ) == 1 ) {
706  $urlParam['type'] = $types[0];
707  }
708 
709  if ( $extraUrlParams !== false ) {
710  $urlParam = array_merge( $urlParam, $extraUrlParams );
711  }
712 
713  $s .= $linkRenderer->makeKnownLink(
714  SpecialPage::getTitleFor( 'Log' ),
715  $context->msg( 'log-fulllog' )->text(),
716  [],
717  $urlParam
718  );
719  }
720 
721  if ( $logBody && $msgKey[0] ) {
722  $s .= '</div>';
723  }
724 
725  if ( $wrap != '' ) { // Wrap message in html
726  $s = str_replace( '$1', $s, $wrap );
727  }
728 
729  /* hook can return false, if we don't want the message to be emitted (Wikia BugId:7093) */
730  if ( Hooks::run( 'LogEventsListShowLogExtract', [ &$s, $types, $page, $user, $param ] ) ) {
731  // $out can be either an OutputPage object or a String-by-reference
732  if ( $out instanceof OutputPage ) {
733  $out->addHTML( $s );
734  } else {
735  $out = $s;
736  }
737  }
738 
739  return $numRows;
740  }
741 
750  public static function getExcludeClause( $db, $audience = 'public', User $user = null ) {
752 
753  if ( $audience != 'public' && $user === null ) {
754  global $wgUser;
755  $user = $wgUser;
756  }
757 
758  // Reset the array, clears extra "where" clauses when $par is used
759  $hiddenLogs = [];
760 
761  // Don't show private logs to unprivileged users
762  foreach ( $wgLogRestrictions as $logType => $right ) {
763  if ( $audience == 'public' || !$user->isAllowed( $right ) ) {
764  $hiddenLogs[] = $logType;
765  }
766  }
767  if ( count( $hiddenLogs ) == 1 ) {
768  return 'log_type != ' . $db->addQuotes( $hiddenLogs[0] );
769  } elseif ( $hiddenLogs ) {
770  return 'log_type NOT IN (' . $db->makeList( $hiddenLogs ) . ')';
771  }
772 
773  return false;
774  }
775 }
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:34
$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:244
$wgUser
$wgUser
Definition: Setup.php:809
ContextSource\getContext
getContext()
Get the base IContextSource object.
Definition: ContextSource.php:41
LogPage\validTypes
static validTypes()
Get the list of valid log types.
Definition: LogPage.php:193
type
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type
Definition: postgres.txt:22
Xml\tags
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:131
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
Xml\label
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
Definition: Xml.php:358
captcha-old.count
count
Definition: captcha-old.py:249
text
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 text
Definition: design.txt:12
$wgScript
$wgScript
The URL path to index.php.
Definition: DefaultSettings.php:202
ContextSource\msg
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:189
MediaWiki\Linker\LinkRenderer
Class that generates HTML links for pages.
Definition: LinkRenderer.php:42
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
it
=Architecture==Two class hierarchies are used to provide the functionality associated with the different content models:*Content interface(and AbstractContent base class) define functionality that acts on the concrete content of a page, and *ContentHandler base class provides functionality specific to a content model, but not acting on concrete content. The most important function of ContentHandler is to act as a factory for the appropriate implementation of Content. These Content objects are to be used by MediaWiki everywhere, instead of passing page content around as text. All manipulation and analysis of page content must be done via the appropriate methods of the Content object. For each content model, a subclass of ContentHandler has to be registered with $wgContentHandlers. The ContentHandler object for a given content model can be obtained using ContentHandler::getForModelID($id). Also Title, WikiPage and Revision now have getContentHandler() methods for convenience. ContentHandler objects are singletons that provide functionality specific to the content type, but not directly acting on the content of some page. ContentHandler::makeEmptyContent() and ContentHandler::unserializeContent() can be used to create a Content object of the appropriate type. However, it is recommended to instead use WikiPage::getContent() resp. Revision::getContent() to get a page 's content as a Content object. These two methods should be the ONLY way in which page content is accessed. Another important function of ContentHandler objects is to define custom action handlers for a content model, see ContentHandler::getActionOverrides(). This is similar to what WikiPage::getActionOverrides() was already doing.==Serialization==With the ContentHandler facility, page content no longer has to be text based. Objects implementing the Content interface are used to represent and handle the content internally. For storage and data exchange, each content model supports at least one serialization format via ContentHandler::serializeContent($content). The list of supported formats for a given content model can be accessed using ContentHandler::getSupportedFormats(). Content serialization formats are identified using MIME type like strings. The following formats are built in:*text/x-wiki - wikitext *text/javascript - for js pages *text/css - for css pages *text/plain - for future use, e.g. with plain text messages. *text/html - for future use, e.g. with plain html messages. *application/vnd.php.serialized - for future use with the api and for extensions *application/json - for future use with the api, and for use by extensions *application/xml - for future use with the api, and for use by extensions In PHP, use the corresponding CONTENT_FORMAT_XXX constant. Note that when using the API to access page content, especially action=edit, action=parse and action=query &prop=revisions, the model and format of the content should always be handled explicitly. Without that information, interpretation of the provided content is not reliable. The same applies to XML dumps generated via maintenance/dumpBackup.php or Special:Export. Also note that the API will provide encapsulated, serialized content - so if the API was called with format=json, and contentformat is also json(or rather, application/json), the page content is represented as a string containing an escaped json structure. Extensions that use JSON to serialize some types of page content may provide specialized API modules that allow access to that content in a more natural form.==Compatibility==The ContentHandler facility is introduced in a way that should allow all existing code to keep functioning at least for pages that contain wikitext or other text based content. However, a number of functions and hooks have been deprecated in favor of new versions that are aware of the page 's content model, and will now generate warnings when used. Most importantly, the following functions have been deprecated:*Revisions::getText() is deprecated in favor Revisions::getContent() *WikiPage::getText() is deprecated in favor WikiPage::getContent() Also, the old Article::getContent()(which returns text) is superceded by Article::getContentObject(). However, both methods should be avoided since they do not provide clean access to the page 's actual content. For instance, they may return a system message for non-existing pages. Use WikiPage::getContent() instead. Code that relies on a textual representation of the page content should eventually be rewritten. However, ContentHandler::getContentText() provides a stop-gap that can be used to get text for a page. Its behavior is controlled by $wgContentHandlerTextFallback it
Definition: contenthandler.txt:104
LogEventsList\$showTagEditUI
bool $showTagEditUI
Definition: LogEventsList.php:45
LogPager
Definition: LogPager.php:29
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:550
link
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template to be included in the link
Definition: hooks.txt:2981
$s
$s
Definition: mergeMessageFileList.php:188
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
ChangeTags\showTagEditingUI
static showTagEditingUI(User $user)
Indicate whether change tag editing UI is relevant.
Definition: ChangeTags.php:1421
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
LogEventsList\getTitleInput
getTitleInput( $title)
Definition: LogEventsList.php:278
ContextSource\getRequest
getRequest()
Get the WebRequest object.
Definition: ContextSource.php:78
ChangeTags\buildTagFilterSelector
static buildTagFilterSelector( $selected='', $ooui=false, IContextSource $context=null)
Build a text box to select a change tag.
Definition: ChangeTags.php:715
LogEventsList\$mDefaultQuery
array $mDefaultQuery
Definition: LogEventsList.php:40
wfArrayFilterByKey
wfArrayFilterByKey(array $arr, callable $callback)
Like array_filter with ARRAY_FILTER_USE_KEY, but works pre-5.6.
Definition: GlobalFunctions.php:233
ContextSource\getUser
getUser()
Get the User object.
Definition: ContextSource.php:133
ContextSource\getTitle
getTitle()
Get the Title object.
Definition: ContextSource.php:88
$messages
$messages
Definition: LogTests.i18n.php:8
Xml\openElement
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:109
LogEventsList\USE_CHECKBOXES
const USE_CHECKBOXES
Definition: LogEventsList.php:33
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
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:40
XmlSelect
Class for generating HTML <select> or <datalist> elements.
Definition: XmlSelect.php:26
ContextSource\getLanguage
getLanguage()
Get the Language object.
Definition: ContextSource.php:143
Xml\fieldset
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
Definition: Xml.php:609
LogEventsList\__construct
__construct( $context, $linkRenderer=null, $flags=0)
The first two parameters used to be $skin and $out, but now only a context is needed,...
Definition: LogEventsList.php:67
flags
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 etc For and for historical it also represents a few features of articles that don t involve their such as access rights See also title txt Article Encapsulates access to the page table of the database The object represents a an and maintains state such as flags
Definition: design.txt:34
$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:1581
$html
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 & $html
Definition: hooks.txt:1965
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:932
DatabaseLogEntry\newFromRow
static newFromRow( $row)
Constructs new LogEntry from database result row.
Definition: LogEntry.php:205
LogEventsList\setAllowedActions
setAllowedActions( $actions)
Sets the action types allowed for log filtering To one action type may correspond several log_actions...
Definition: LogEventsList.php:356
LogEventsList\getTypeMenu
getTypeMenu( $queryTypes)
Definition: LogEventsList.php:217
LogEventsList\getUserInput
getUserInput( $user)
Definition: LogEventsList.php:261
LogEventsList\getTypeSelector
getTypeSelector()
Returns log page selector.
Definition: LogEventsList.php:230
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2856
$input
if(is_array( $mode)) switch( $mode) $input
Definition: postprocess-phan.php:141
ContextSource\getOutput
getOutput()
Get the OutputPage object.
Definition: ContextSource.php:123
ContextSource
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
Definition: ContextSource.php:30
Xml\check
static check( $name, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox.
Definition: Xml.php:323
$attribs
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 & $attribs
Definition: hooks.txt:1965
LogEventsList\typeAction
static typeAction( $row, $type, $action, $right='')
Definition: LogEventsList.php:505
LogPage
Class to simplify the use of log pages.
Definition: LogPage.php:31
LogEventsList\showOptions
showOptions( $types=[], $user='', $page='', $pattern='', $year=0, $month=0, $filter=null, $tagFilter='', $action=null)
Show options for the log list.
Definition: LogEventsList.php:107
LogEventsList\logLine
logLine( $row)
Definition: LogEventsList.php:378
message
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 message
Definition: hooks.txt:2133
Linker\revDeleteLinkDisabled
static revDeleteLinkDisabled( $delete=true)
Creates a dead (show/hide) link for deleting revisions/log entries.
Definition: Linker.php:2093
MessageLocalizer\msg
msg( $key)
This is the method for getting translated interface messages.
LogEventsList\getFilterLinks
getFilterLinks( $filter)
Definition: LogEventsList.php:166
$time
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition: hooks.txt:1778
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
LogEventsList\showLogExtract
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Definition: LogEventsList.php:594
DB_MASTER
const DB_MASTER
Definition: defines.php:26
LogEventsList\getActionSelector
getActionSelector( $types, $action)
Drop down menu for selection of actions that can be used to filter the log.
Definition: LogEventsList.php:332
wfDebug
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:1047
ContextSource\setContext
setContext(IContextSource $context)
Set the IContextSource object.
Definition: ContextSource.php:58
LogEventsList
Definition: LogEventsList.php:30
OutputPage
This class should be covered by a general architecture document which does not exist as of January 20...
Definition: OutputPage.php:44
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
$dir
$dir
Definition: Autoload.php:8
Html\hidden
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition: Html.php:725
$selector
$selector
Definition: styleTest.css.php:43
$value
$value
Definition: styleTest.css.php:45
$wgLogRestrictions
$wgLogRestrictions
This restricts log access to those who have a certain right Users without this will not see it in the...
Definition: DefaultSettings.php:7592
LogEventsList\getExcludeClause
static getExcludeClause( $db, $audience='public', User $user=null)
SQL clause to skip forbidden log types for this user.
Definition: LogEventsList.php:750
LogEventsList\$linkRenderer
LinkRenderer null $linkRenderer
Definition: LogEventsList.php:55
LogEventsList\getShowHideLinks
getShowHideLinks( $row)
Definition: LogEventsList.php:432
$ret
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 & $ret
Definition: hooks.txt:1965
RequestContext\getMain
static getMain()
Static methods.
Definition: RequestContext.php:470
$revert
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging a wrapping ErrorException instead of letting the login form give the generic error message that the account does not exist For when the account has been renamed or deleted or an array to pass a message key and parameters create2 Corresponds to logging log_action database field and which is displayed in the UI & $revert
Definition: hooks.txt:2141
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:55
WebRequest
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
Definition: WebRequest.php:38
$args
if( $line===false) $args
Definition: cdb.php:63
Title
Represents a title within MediaWiki.
Definition: Title.php:39
$wgMiserMode
$wgMiserMode
Disable database-intensive features.
Definition: DefaultSettings.php:2166
LogEventsList\userCanBitfield
static userCanBitfield( $bitfield, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this log row,...
Definition: LogEventsList.php:542
LogEventsList\$flags
$flags
Definition: LogEventsList.php:35
MediaWiki\Linker\LinkRenderer\makeKnownLink
makeKnownLink(LinkTarget $target, $text=null, array $extraAttribs=[], array $query=[])
Definition: LinkRenderer.php:282
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
Xml\dateMenu
static dateMenu( $year, $month)
Definition: Xml.php:167
LogEventsList\userCan
static userCan( $row, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this log row,...
Definition: LogEventsList.php:529
LogEventsList\isDeleted
static isDeleted( $row, $field)
Definition: LogEventsList.php:565
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
Linker\revDeleteLink
static revDeleteLink( $query=[], $restricted=false, $delete=true)
Creates a (show/hide) link for deleting revisions/log entries.
Definition: Linker.php:2071
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:2981
LogPage\DELETED_RESTRICTED
const DELETED_RESTRICTED
Definition: LogPage.php:35
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
LogEventsList\NO_ACTION_LINK
const NO_ACTION_LINK
Definition: LogEventsList.php:31
LogEventsList\getDefaultQuery
getDefaultQuery()
Definition: LogEventsList.php:198
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:52
LogEventsList\endLogEventsList
endLogEventsList()
Definition: LogEventsList.php:370
LogEventsList\getExtraInputs
getExtraInputs( $types)
Definition: LogEventsList.php:304
LogEventsList\NO_EXTRA_USER_LINKS
const NO_EXTRA_USER_LINKS
Definition: LogEventsList.php:32
LogEventsList\$allowedActions
array $allowedActions
Definition: LogEventsList.php:50
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
LogEventsList\getLinkRenderer
getLinkRenderer()
Definition: LogEventsList.php:86
LogEventsList\beginLogEventsList
beginLogEventsList()
Definition: LogEventsList.php:363
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:51
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:203
Xml\inputLabel
static inputLabel( $label, $name, $id, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field with a label.
Definition: Xml.php:380
LogEventsList\getTitlePattern
getTitlePattern( $pattern)
Definition: LogEventsList.php:294
ChangeTags\formatSummaryRow
static formatSummaryRow( $tags, $page, IContextSource $context=null)
Creates HTML for the given tags.
Definition: ChangeTags.php:53
IP\isIPAddress
static isIPAddress( $ip)
Determine if a string is as valid IP address or network (CIDR prefix).
Definition: IP.php:77
IContextSource\getLanguage
getLanguage()
Get the Language object.
array
the array() calling protocol came about after MediaWiki 1.4rc1.
Xml\submitButton
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
Definition: Xml.php:459
Xml\checkLabel
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
Definition: Xml.php:419
LogFormatter\newFromEntry
static newFromEntry(LogEntry $entry)
Constructs a new formatter suitable for given entry.
Definition: LogFormatter.php:50
$out
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:781
$type
$type
Definition: testCompression.php:48