MediaWiki  1.32.5
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 
110  public function showOptions( $types = [], $user = '', $page = '', $pattern = false, $year = 0,
111  $month = 0, $day = 0, $filter = null, $tagFilter = '', $action = null
112  ) {
113  // For B/C, we take strings, but make sure they are converted...
114  $types = ( $types === '' ) ? [] : (array)$types;
115 
116  $formDescriptor = [];
117 
118  // Basic selectors
119  $formDescriptor['type'] = $this->getTypeMenuDesc( $types );
120  $formDescriptor['user'] = $this->getUserInputDesc( $user );
121  $formDescriptor['page'] = $this->getTitleInputDesc( $page );
122 
123  // Add extra inputs if any
124  // This could either be a form descriptor array or a string with raw HTML.
125  // We need it to work in both cases and show a deprecation warning if it
126  // is a string. See T199495.
127  $extraInputsDescriptor = $this->getExtraInputsDesc( $types );
128  if (
129  is_array( $extraInputsDescriptor ) &&
130  !empty( $extraInputsDescriptor )
131  ) {
132  $formDescriptor[ 'extra' ] = $extraInputsDescriptor;
133  } elseif (
134  is_string( $extraInputsDescriptor ) &&
135  $extraInputsDescriptor !== ''
136  ) {
137  // We'll add this to the footer of the form later
138  $extraInputsString = $extraInputsDescriptor;
139  wfDeprecated( '$input in LogEventsListGetExtraInputs hook', '1.32' );
140  }
141 
142  // Title pattern, if allowed
143  if ( !$this->getConfig()->get( 'MiserMode' ) ) {
144  $formDescriptor['pattern'] = $this->getTitlePatternDesc( $pattern );
145  }
146 
147  // Date menu
148  $formDescriptor['date'] = [
149  'type' => 'date',
150  'label-message' => 'date',
151  'default' => sprintf( "%04d-%02d-%02d", $year, $month, $day ),
152  ];
153 
154  // Tag filter
155  $formDescriptor['tagfilter'] = [
156  'type' => 'tagfilter',
157  'name' => 'tagfilter',
158  'label-raw' => $this->msg( 'tag-filter' )->parse(),
159  ];
160 
161  // Filter links
162  if ( $filter ) {
163  $formDescriptor['filters'] = $this->getFiltersDesc( $filter );
164  }
165 
166  // Action filter
167  if (
168  $action !== null &&
169  $this->allowedActions !== null &&
170  count( $this->allowedActions ) > 0
171  ) {
172  $formDescriptor['subtype'] = $this->getActionSelectorDesc( $types, $action );
173  }
174 
175  $context = new DerivativeContext( $this->getContext() );
176  $context->setTitle( SpecialPage::getTitleFor( 'Log' ) ); // Remove subpage
177  $htmlForm = new HTMLForm( $formDescriptor, $context );
178  $htmlForm
179  ->setSubmitText( $this->msg( 'logeventslist-submit' )->text() )
180  ->setMethod( 'get' )
181  ->setWrapperLegendMsg( 'log' );
182 
183  // TODO This will should be removed at some point. See T199495.
184  if ( isset( $extraInputsString ) ) {
185  $htmlForm->addFooterText( Html::rawElement(
186  'div',
187  null,
188  $extraInputsString
189  ) );
190  }
191 
192  $htmlForm->prepareForm()->displayForm( false );
193  }
194 
199  private function getFiltersDesc( $filter ) {
200  $options = [];
201  $default = [];
202  foreach ( $filter as $type => $val ) {
203  $message = $this->msg( "logeventslist-{$type}-log" );
204  // FIXME: Remove this check once T199657 is fully resolved.
205  if ( !$message->exists() ) {
206  $message = $this->msg( "log-show-hide-{$type}" )->params( $this->msg( 'show' )->text() );
207  }
208  $options[ $message->text() ] = $type;
209 
210  if ( $val === false ) {
211  $default[] = $type;
212  }
213  }
214  return [
215  'class' => 'HTMLMultiSelectField',
216  'label-message' => 'logeventslist-more-filters',
217  'flatlist' => true,
218  'options' => $options,
219  'default' => $default,
220  ];
221  }
222 
223  private function getDefaultQuery() {
224  if ( !isset( $this->mDefaultQuery ) ) {
225  $this->mDefaultQuery = $this->getRequest()->getQueryValues();
226  unset( $this->mDefaultQuery['title'] );
227  unset( $this->mDefaultQuery['dir'] );
228  unset( $this->mDefaultQuery['offset'] );
229  unset( $this->mDefaultQuery['limit'] );
230  unset( $this->mDefaultQuery['order'] );
231  unset( $this->mDefaultQuery['month'] );
232  unset( $this->mDefaultQuery['year'] );
233  }
234 
235  return $this->mDefaultQuery;
236  }
237 
242  private function getTypeMenuDesc( $queryTypes ) {
243  $queryType = count( $queryTypes ) == 1 ? $queryTypes[0] : '';
244 
245  $typesByName = []; // Temporary array
246  // First pass to load the log names
247  foreach ( LogPage::validTypes() as $type ) {
248  $page = new LogPage( $type );
249  $restriction = $page->getRestriction();
250  if ( $this->getUser()->isAllowed( $restriction ) ) {
251  $typesByName[$type] = $page->getName()->text();
252  }
253  }
254 
255  // Second pass to sort by name
256  asort( $typesByName );
257 
258  // Always put "All public logs" on top
259  $public = $typesByName[''];
260  unset( $typesByName[''] );
261  $typesByName = [ '' => $public ] + $typesByName;
262 
263  return [
264  'class' => 'HTMLSelectField',
265  'name' => 'type',
266  'options' => array_flip( $typesByName ),
267  'default' => $queryType,
268  ];
269  }
270 
275  private function getUserInputDesc( $user ) {
276  return [
277  'class' => 'HTMLUserTextField',
278  'label-message' => 'specialloguserlabel',
279  'name' => 'user',
280  'default' => $user,
281  ];
282  }
283 
288  private function getTitleInputDesc( $title ) {
289  return [
290  'class' => 'HTMLTitleTextField',
291  'label-message' => 'speciallogtitlelabel',
292  'name' => 'page',
293  'required' => false
294  ];
295  }
296 
301  private function getTitlePatternDesc( $pattern ) {
302  return [
303  'type' => 'check',
304  'label-message' => 'log-title-wildcard',
305  'name' => 'pattern',
306  ];
307  }
308 
313  private function getExtraInputsDesc( $types ) {
314  if ( count( $types ) == 1 ) {
315  if ( $types[0] == 'suppress' ) {
316  return [
317  'type' => 'text',
318  'label-message' => 'revdelete-offender',
319  'name' => 'offender',
320  ];
321  } else {
322  // Allow extensions to add their own extra inputs
323  // This could be an array or string. See T199495.
324  $input = ''; // Deprecated
325  $formDescriptor = [];
326  Hooks::run( 'LogEventsListGetExtraInputs', [ $types[0], $this, &$input, &$formDescriptor ] );
327 
328  return empty( $formDescriptor ) ? $input : $formDescriptor;
329  }
330  }
331 
332  return [];
333  }
334 
341  private function getActionSelectorDesc( $types, $action ) {
342  $actionOptions = [];
343  $actionOptions[ 'log-action-filter-all' ] = '';
344 
345  foreach ( $this->allowedActions as $value ) {
346  $msgKey = 'log-action-filter-' . $types[0] . '-' . $value;
347  $actionOptions[ $msgKey ] = $value;
348  }
349 
350  return [
351  'class' => 'HTMLSelectField',
352  'name' => 'subtype',
353  'options-messages' => $actionOptions,
354  'default' => $action,
355  'label' => $this->msg( 'log-action-filter-' . $types[0] )->text(),
356  ];
357  }
358 
365  public function setAllowedActions( $actions ) {
366  $this->allowedActions = $actions;
367  }
368 
372  public function beginLogEventsList() {
373  return "<ul>\n";
374  }
375 
379  public function endLogEventsList() {
380  return "</ul>\n";
381  }
382 
387  public function logLine( $row ) {
388  $entry = DatabaseLogEntry::newFromRow( $row );
389  $formatter = LogFormatter::newFromEntry( $entry );
390  $formatter->setContext( $this->getContext() );
391  $formatter->setLinkRenderer( $this->getLinkRenderer() );
392  $formatter->setShowUserToolLinks( !( $this->flags & self::NO_EXTRA_USER_LINKS ) );
393 
394  $time = htmlspecialchars( $this->getLanguage()->userTimeAndDate(
395  $entry->getTimestamp(), $this->getUser() ) );
396 
397  $action = $formatter->getActionText();
398 
399  if ( $this->flags & self::NO_ACTION_LINK ) {
400  $revert = '';
401  } else {
402  $revert = $formatter->getActionLinks();
403  if ( $revert != '' ) {
404  $revert = '<span class="mw-logevent-actionlink">' . $revert . '</span>';
405  }
406  }
407 
408  $comment = $formatter->getComment();
409 
410  // Some user can hide log items and have review links
411  $del = $this->getShowHideLinks( $row );
412 
413  // Any tags...
414  list( $tagDisplay, $newClasses ) = ChangeTags::formatSummaryRow(
415  $row->ts_tags,
416  'logevent',
417  $this->getContext()
418  );
419  $classes = array_merge(
420  [ 'mw-logline-' . $entry->getType() ],
421  $newClasses
422  );
423  $attribs = [
424  'data-mw-logid' => $entry->getId(),
425  'data-mw-logaction' => $entry->getFullType(),
426  ];
427  $ret = "$del $time $action $comment $revert $tagDisplay";
428 
429  // Let extensions add data
430  Hooks::run( 'LogEventsListLineEnding', [ $this, &$ret, $entry, &$classes, &$attribs ] );
431  $attribs = array_filter( $attribs,
432  [ Sanitizer::class, 'isReservedDataAttribute' ],
433  ARRAY_FILTER_USE_KEY
434  );
435  $attribs['class'] = implode( ' ', $classes );
436 
437  return Html::rawElement( 'li', $attribs, $ret ) . "\n";
438  }
439 
444  private function getShowHideLinks( $row ) {
445  // We don't want to see the links and
446  if ( $this->flags == self::NO_ACTION_LINK ) {
447  return '';
448  }
449 
450  $user = $this->getUser();
451 
452  // If change tag editing is available to this user, return the checkbox
453  if ( $this->flags & self::USE_CHECKBOXES && $this->showTagEditUI ) {
454  return Xml::check(
455  'showhiderevisions',
456  false,
457  [ 'name' => 'ids[' . $row->log_id . ']' ]
458  );
459  }
460 
461  // no one can hide items from the suppress log.
462  if ( $row->log_type == 'suppress' ) {
463  return '';
464  }
465 
466  $del = '';
467  // Don't show useless checkbox to people who cannot hide log entries
468  if ( $user->isAllowed( 'deletedhistory' ) ) {
469  $canHide = $user->isAllowed( 'deletelogentry' );
470  $canViewSuppressedOnly = $user->isAllowed( 'viewsuppressed' ) &&
471  !$user->isAllowed( 'suppressrevision' );
472  $entryIsSuppressed = self::isDeleted( $row, LogPage::DELETED_RESTRICTED );
473  $canViewThisSuppressedEntry = $canViewSuppressedOnly && $entryIsSuppressed;
474  if ( $row->log_deleted || $canHide ) {
475  // Show checkboxes instead of links.
476  if ( $canHide && $this->flags & self::USE_CHECKBOXES && !$canViewThisSuppressedEntry ) {
477  // If event was hidden from sysops
478  if ( !self::userCan( $row, LogPage::DELETED_RESTRICTED, $user ) ) {
479  $del = Xml::check( 'deleterevisions', false, [ 'disabled' => 'disabled' ] );
480  } else {
481  $del = Xml::check(
482  'showhiderevisions',
483  false,
484  [ 'name' => 'ids[' . $row->log_id . ']' ]
485  );
486  }
487  } else {
488  // If event was hidden from sysops
489  if ( !self::userCan( $row, LogPage::DELETED_RESTRICTED, $user ) ) {
490  $del = Linker::revDeleteLinkDisabled( $canHide );
491  } else {
492  $query = [
493  'target' => SpecialPage::getTitleFor( 'Log', $row->log_type )->getPrefixedDBkey(),
494  'type' => 'logging',
495  'ids' => $row->log_id,
496  ];
497  $del = Linker::revDeleteLink(
498  $query,
499  $entryIsSuppressed,
500  $canHide && !$canViewThisSuppressedEntry
501  );
502  }
503  }
504  }
505  }
506 
507  return $del;
508  }
509 
517  public static function typeAction( $row, $type, $action, $right = '' ) {
518  $match = is_array( $type ) ?
519  in_array( $row->log_type, $type ) : $row->log_type == $type;
520  if ( $match ) {
521  $match = is_array( $action ) ?
522  in_array( $row->log_action, $action ) : $row->log_action == $action;
523  if ( $match && $right ) {
524  global $wgUser;
525  $match = $wgUser->isAllowed( $right );
526  }
527  }
528 
529  return $match;
530  }
531 
541  public static function userCan( $row, $field, User $user = null ) {
542  return self::userCanBitfield( $row->log_deleted, $field, $user ) &&
543  self::userCanViewLogType( $row->log_type, $user );
544  }
545 
555  public static function userCanBitfield( $bitfield, $field, User $user = null ) {
556  if ( $bitfield & $field ) {
557  if ( $user === null ) {
558  global $wgUser;
559  $user = $wgUser;
560  }
561  if ( $bitfield & LogPage::DELETED_RESTRICTED ) {
562  $permissions = [ 'suppressrevision', 'viewsuppressed' ];
563  } else {
564  $permissions = [ 'deletedhistory' ];
565  }
566  $permissionlist = implode( ', ', $permissions );
567  wfDebug( "Checking for $permissionlist due to $field match on $bitfield\n" );
568  return $user->isAllowedAny( ...$permissions );
569  }
570  return true;
571  }
572 
581  public static function userCanViewLogType( $type, User $user = null ) {
582  if ( $user === null ) {
583  global $wgUser;
584  $user = $wgUser;
585  }
586  $logRestrictions = MediaWikiServices::getInstance()->getMainConfig()->get( 'LogRestrictions' );
587  if ( isset( $logRestrictions[$type] ) && !$user->isAllowed( $logRestrictions[$type] ) ) {
588  return false;
589  }
590  return true;
591  }
592 
598  public static function isDeleted( $row, $field ) {
599  return ( $row->log_deleted & $field ) == $field;
600  }
601 
627  public static function showLogExtract(
628  &$out, $types = [], $page = '', $user = '', $param = []
629  ) {
630  $defaultParameters = [
631  'lim' => 25,
632  'conds' => [],
633  'showIfEmpty' => true,
634  'msgKey' => [ '' ],
635  'wrap' => "$1",
636  'flags' => 0,
637  'useRequestParams' => false,
638  'useMaster' => false,
639  'extraUrlParams' => false,
640  ];
641  # The + operator appends elements of remaining keys from the right
642  # handed array to the left handed, whereas duplicated keys are NOT overwritten.
643  $param += $defaultParameters;
644  # Convert $param array to individual variables
645  $lim = $param['lim'];
646  $conds = $param['conds'];
647  $showIfEmpty = $param['showIfEmpty'];
648  $msgKey = $param['msgKey'];
649  $wrap = $param['wrap'];
650  $flags = $param['flags'];
651  $extraUrlParams = $param['extraUrlParams'];
652 
653  $useRequestParams = $param['useRequestParams'];
654  if ( !is_array( $msgKey ) ) {
655  $msgKey = [ $msgKey ];
656  }
657 
658  if ( $out instanceof OutputPage ) {
659  $context = $out->getContext();
660  } else {
662  }
663 
664  // FIXME: Figure out how to inject this
665  $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
666 
667  # Insert list of top 50 (or top $lim) items
668  $loglist = new LogEventsList( $context, $linkRenderer, $flags );
669  $pager = new LogPager( $loglist, $types, $user, $page, '', $conds );
670  if ( !$useRequestParams ) {
671  # Reset vars that may have been taken from the request
672  $pager->mLimit = 50;
673  $pager->mDefaultLimit = 50;
674  $pager->mOffset = "";
675  $pager->mIsBackwards = false;
676  }
677 
678  if ( $param['useMaster'] ) {
679  $pager->mDb = wfGetDB( DB_MASTER );
680  }
681  if ( isset( $param['offset'] ) ) { # Tell pager to ignore WebRequest offset
682  $pager->setOffset( $param['offset'] );
683  }
684 
685  if ( $lim > 0 ) {
686  $pager->mLimit = $lim;
687  }
688  // Fetch the log rows and build the HTML if needed
689  $logBody = $pager->getBody();
690  $numRows = $pager->getNumRows();
691 
692  $s = '';
693 
694  if ( $logBody ) {
695  if ( $msgKey[0] ) {
696  $dir = $context->getLanguage()->getDir();
697  $lang = $context->getLanguage()->getHtmlCode();
698 
699  $s = Xml::openElement( 'div', [
700  'class' => "mw-warning-with-logexcerpt mw-content-$dir",
701  'dir' => $dir,
702  'lang' => $lang,
703  ] );
704 
705  if ( count( $msgKey ) == 1 ) {
706  $s .= $context->msg( $msgKey[0] )->parseAsBlock();
707  } else { // Process additional arguments
708  $args = $msgKey;
709  array_shift( $args );
710  $s .= $context->msg( $msgKey[0], $args )->parseAsBlock();
711  }
712  }
713  $s .= $loglist->beginLogEventsList() .
714  $logBody .
715  $loglist->endLogEventsList();
716  } elseif ( $showIfEmpty ) {
717  $s = Html::rawElement( 'div', [ 'class' => 'mw-warning-logempty' ],
718  $context->msg( 'logempty' )->parse() );
719  }
720 
721  if ( $numRows > $pager->mLimit ) { # Show "Full log" link
722  $urlParam = [];
723  if ( $page instanceof Title ) {
724  $urlParam['page'] = $page->getPrefixedDBkey();
725  } elseif ( $page != '' ) {
726  $urlParam['page'] = $page;
727  }
728 
729  if ( $user != '' ) {
730  $urlParam['user'] = $user;
731  }
732 
733  if ( !is_array( $types ) ) { # Make it an array, if it isn't
734  $types = [ $types ];
735  }
736 
737  # If there is exactly one log type, we can link to Special:Log?type=foo
738  if ( count( $types ) == 1 ) {
739  $urlParam['type'] = $types[0];
740  }
741 
742  if ( $extraUrlParams !== false ) {
743  $urlParam = array_merge( $urlParam, $extraUrlParams );
744  }
745 
746  $s .= $linkRenderer->makeKnownLink(
747  SpecialPage::getTitleFor( 'Log' ),
748  $context->msg( 'log-fulllog' )->text(),
749  [],
750  $urlParam
751  );
752  }
753 
754  if ( $logBody && $msgKey[0] ) {
755  $s .= '</div>';
756  }
757 
758  if ( $wrap != '' ) { // Wrap message in html
759  $s = str_replace( '$1', $s, $wrap );
760  }
761 
762  /* hook can return false, if we don't want the message to be emitted (Wikia BugId:7093) */
763  if ( Hooks::run( 'LogEventsListShowLogExtract', [ &$s, $types, $page, $user, $param ] ) ) {
764  // $out can be either an OutputPage object or a String-by-reference
765  if ( $out instanceof OutputPage ) {
766  $out->addHTML( $s );
767  } else {
768  $out = $s;
769  }
770  }
771 
772  return $numRows;
773  }
774 
783  public static function getExcludeClause( $db, $audience = 'public', User $user = null ) {
784  global $wgLogRestrictions;
785 
786  if ( $audience != 'public' && $user === null ) {
787  global $wgUser;
788  $user = $wgUser;
789  }
790 
791  // Reset the array, clears extra "where" clauses when $par is used
792  $hiddenLogs = [];
793 
794  // Don't show private logs to unprivileged users
795  foreach ( $wgLogRestrictions as $logType => $right ) {
796  if ( $audience == 'public' || !$user->isAllowed( $right ) ) {
797  $hiddenLogs[] = $logType;
798  }
799  }
800  if ( count( $hiddenLogs ) == 1 ) {
801  return 'log_type != ' . $db->addQuotes( $hiddenLogs[0] );
802  } elseif ( $hiddenLogs ) {
803  return 'log_type NOT IN (' . $db->makeList( $hiddenLogs ) . ')';
804  }
805 
806  return false;
807  }
808 }
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:33
ContextSource\getConfig
getConfig()
Definition: ContextSource.php:63
$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
ContextSource\getContext
getContext()
Get the base IContextSource object.
Definition: ContextSource.php:40
LogPage\validTypes
static validTypes()
Get the list of valid log types.
Definition: LogPage.php:194
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
captcha-old.count
count
Definition: captcha-old.py:249
ContextSource\msg
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:168
MediaWiki\Linker\LinkRenderer
Class that generates HTML links for pages.
Definition: LinkRenderer.php:41
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
LogEventsList\userCanViewLogType
static userCanViewLogType( $type, User $user=null)
Determine if the current user is allowed to view a particular field of this log row,...
Definition: LogEventsList.php:581
LogEventsList\getTitlePatternDesc
getTitlePatternDesc( $pattern)
Definition: LogEventsList.php:301
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:3098
$s
$s
Definition: mergeMessageFileList.php:187
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
$formDescriptor
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:2123
ChangeTags\showTagEditingUI
static showTagEditingUI(User $user)
Indicate whether change tag editing UI is relevant.
Definition: ChangeTags.php:1665
ContextSource\getRequest
getRequest()
Definition: ContextSource.php:71
LogEventsList\$mDefaultQuery
array $mDefaultQuery
Definition: LogEventsList.php:40
ContextSource\getUser
getUser()
Definition: ContextSource.php:120
Xml\openElement
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:110
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:38
ContextSource\getLanguage
getLanguage()
Definition: ContextSource.php:128
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
$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:1627
DerivativeContext
An IContextSource implementation which will inherit context from another source but allow individual ...
Definition: DerivativeContext.php:30
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:964
DatabaseLogEntry\newFromRow
static newFromRow( $row)
Constructs new LogEntry from database result row.
Definition: LogEntry.php:208
LogEventsList\setAllowedActions
setAllowedActions( $actions)
Sets the action types allowed for log filtering To one action type may correspond several log_actions...
Definition: LogEventsList.php:365
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Definition: GlobalFunctions.php:1118
LogEventsList\getActionSelectorDesc
getActionSelectorDesc( $types, $action)
Drop down menu for selection of actions that can be used to filter the log.
Definition: LogEventsList.php:341
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2693
$input
if(is_array( $mode)) switch( $mode) $input
Definition: postprocess-phan.php:141
ContextSource
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
Definition: ContextSource.php:29
Xml\check
static check( $name, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox.
Definition: Xml.php:325
$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:2044
LogEventsList\typeAction
static typeAction( $row, $type, $action, $right='')
Definition: LogEventsList.php:517
LogPage
Class to simplify the use of log pages.
Definition: LogPage.php:33
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
div
div
Definition: parserTests.txt:6868
LogEventsList\logLine
logLine( $row)
Definition: LogEventsList.php:387
LogEventsList\showOptions
showOptions( $types=[], $user='', $page='', $pattern=false, $year=0, $month=0, $day=0, $filter=null, $tagFilter='', $action=null)
Show options for the log list.
Definition: LogEventsList.php:110
Linker\revDeleteLinkDisabled
static revDeleteLinkDisabled( $delete=true)
Creates a dead (show/hide) link for deleting revisions/log entries.
Definition: Linker.php:2114
MessageLocalizer\msg
msg( $key)
This is the method for getting translated interface messages.
$time
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition: hooks.txt:1841
LogEventsList\showLogExtract
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Definition: LogEventsList.php:627
DB_MASTER
const DB_MASTER
Definition: defines.php:26
array
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
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:988
ContextSource\setContext
setContext(IContextSource $context)
Definition: ContextSource.php:55
LogEventsList
Definition: LogEventsList.php:30
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
$value
$value
Definition: styleTest.css.php:49
$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:7739
LogEventsList\getExcludeClause
static getExcludeClause( $db, $audience='public', User $user=null)
SQL clause to skip forbidden log types for this user.
Definition: LogEventsList.php:783
LogEventsList\getTitleInputDesc
getTitleInputDesc( $title)
Definition: LogEventsList.php:288
LogEventsList\$linkRenderer
LinkRenderer null $linkRenderer
Definition: LogEventsList.php:55
LogEventsList\getShowHideLinks
getShowHideLinks( $row)
Definition: LogEventsList.php:444
$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:2044
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:434
$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:2221
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 use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a message
Definition: hooks.txt:2213
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:53
WebRequest
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
Definition: WebRequest.php:41
text
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
Definition: All_system_messages.txt:1267
$args
if( $line===false) $args
Definition: cdb.php:64
Title
Represents a title within MediaWiki.
Definition: Title.php:39
$options
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition: hooks.txt:2044
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:555
LogEventsList\$flags
$flags
Definition: LogEventsList.php:35
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
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:541
LogEventsList\isDeleted
static isDeleted( $row, $field)
Definition: LogEventsList.php:598
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:210
Linker\revDeleteLink
static revDeleteLink( $query=[], $restricted=false, $delete=true)
Creates a (show/hide) link for deleting revisions/log entries.
Definition: Linker.php:2092
LogEventsList\getTypeMenuDesc
getTypeMenuDesc( $queryTypes)
Definition: LogEventsList.php:242
LogPage\DELETED_RESTRICTED
const DELETED_RESTRICTED
Definition: LogPage.php:37
LogEventsList\NO_ACTION_LINK
const NO_ACTION_LINK
Definition: LogEventsList.php:31
LogEventsList\getDefaultQuery
getDefaultQuery()
Definition: LogEventsList.php:223
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:379
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\getUserInputDesc
getUserInputDesc( $user)
Definition: LogEventsList.php:275
LogEventsList\getLinkRenderer
getLinkRenderer()
Definition: LogEventsList.php:86
LogEventsList\getFiltersDesc
getFiltersDesc( $filter)
Definition: LogEventsList.php:199
LogEventsList\beginLogEventsList
beginLogEventsList()
Definition: LogEventsList.php:372
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:47
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
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
ChangeTags\formatSummaryRow
static formatSummaryRow( $tags, $page, IContextSource $context=null)
Creates HTML for the given tags.
Definition: ChangeTags.php:93
LogEventsList\getExtraInputsDesc
getExtraInputsDesc( $types)
Definition: LogEventsList.php:313
IContextSource\getLanguage
getLanguage()
LogFormatter\newFromEntry
static newFromEntry(LogEntry $entry)
Constructs a new formatter suitable for given entry.
Definition: LogFormatter.php:50
HTMLForm
Object handling generic submission, CSRF protection, layout and other logic for UI forms.
Definition: HTMLForm.php:136
$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:813
$type
$type
Definition: testCompression.php:48