MediaWiki REL1_31
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
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 ) {
89 } else {
90 return MediaWikiServices::getInstance()->getLinkRenderer();
91 }
92 }
93
108 public function showOptions( $types = [], $user = '', $page = '', $pattern = '', $year = 0,
109 $month = 0, $filter = null, $tagFilter = '', $action = null
110 ) {
112
113 $title = SpecialPage::getTitleFor( 'Log' );
114
115 // For B/C, we take strings, but make sure they are converted...
116 $types = ( $types === '' ) ? [] : (array)$types;
117
118 $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter, false, $this->getContext() );
119
120 $html = Html::hidden( 'title', $title->getPrefixedDBkey() );
121
122 // Basic selectors
123 $html .= $this->getTypeMenu( $types ) . "\n";
124 $html .= $this->getUserInput( $user ) . "\n";
125 $html .= $this->getTitleInput( $page ) . "\n";
126 $html .= $this->getExtraInputs( $types ) . "\n";
127
128 // Title pattern, if allowed
129 if ( !$wgMiserMode ) {
130 $html .= $this->getTitlePattern( $pattern ) . "\n";
131 }
132
133 // date menu
134 $html .= Xml::tags( 'p', null, Xml::dateMenu( (int)$year, (int)$month ) );
135
136 // Tag filter
137 if ( $tagSelector ) {
138 $html .= Xml::tags( 'p', null, implode( '&#160;', $tagSelector ) );
139 }
140
141 // Filter links
142 if ( $filter ) {
143 $html .= Xml::tags( 'p', null, $this->getFilterLinks( $filter ) );
144 }
145
146 // Action filter
147 if ( $action !== null ) {
148 $html .= Xml::tags( 'p', null, $this->getActionSelector( $types, $action ) );
149 }
150
151 // Submit button
152 $html .= Xml::submitButton( $this->msg( 'logeventslist-submit' )->text() );
153
154 // Fieldset
155 $html = Xml::fieldset( $this->msg( 'log' )->text(), $html );
156
157 // Form wrapping
158 $html = Xml::tags( 'form', [ 'action' => $wgScript, 'method' => 'get' ], $html );
159
160 $this->getOutput()->addHTML( $html );
161 }
162
167 private function getFilterLinks( $filter ) {
168 // show/hide links
169 $messages = [ $this->msg( 'show' )->text(), $this->msg( 'hide' )->text() ];
170 // Option value -> message mapping
171 $links = [];
172 $hiddens = ''; // keep track for "go" button
174 foreach ( $filter as $type => $val ) {
175 // Should the below assignment be outside the foreach?
176 // Then it would have to be copied. Not certain what is more expensive.
177 $query = $this->getDefaultQuery();
178 $queryKey = "hide_{$type}_log";
179
180 $hideVal = 1 - intval( $val );
181 $query[$queryKey] = $hideVal;
182
184 $this->getTitle(),
185 $messages[$hideVal],
186 [],
187 $query
188 );
189
190 // Message: log-show-hide-patrol
191 $links[$type] = $this->msg( "log-show-hide-{$type}" )->rawParams( $link )->escaped();
192 $hiddens .= Html::hidden( "hide_{$type}_log", $val ) . "\n";
193 }
194
195 // Build links
196 return '<small>' . $this->getLanguage()->pipeList( $links ) . '</small>' . $hiddens;
197 }
198
199 private function getDefaultQuery() {
200 if ( !isset( $this->mDefaultQuery ) ) {
201 $this->mDefaultQuery = $this->getRequest()->getQueryValues();
202 unset( $this->mDefaultQuery['title'] );
203 unset( $this->mDefaultQuery['dir'] );
204 unset( $this->mDefaultQuery['offset'] );
205 unset( $this->mDefaultQuery['limit'] );
206 unset( $this->mDefaultQuery['order'] );
207 unset( $this->mDefaultQuery['month'] );
208 unset( $this->mDefaultQuery['year'] );
209 }
210
212 }
213
218 private function getTypeMenu( $queryTypes ) {
219 $queryType = count( $queryTypes ) == 1 ? $queryTypes[0] : '';
220 $selector = $this->getTypeSelector();
221 $selector->setDefault( $queryType );
222
223 return $selector->getHTML();
224 }
225
231 public function getTypeSelector() {
232 $typesByName = []; // Temporary array
233 // First pass to load the log names
234 foreach ( LogPage::validTypes() as $type ) {
235 $page = new LogPage( $type );
236 $restriction = $page->getRestriction();
237 if ( $this->getUser()->isAllowed( $restriction ) ) {
238 $typesByName[$type] = $page->getName()->text();
239 }
240 }
241
242 // Second pass to sort by name
243 asort( $typesByName );
244
245 // Always put "All public logs" on top
246 $public = $typesByName[''];
247 unset( $typesByName[''] );
248 $typesByName = [ '' => $public ] + $typesByName;
249
250 $select = new XmlSelect( 'type' );
251 foreach ( $typesByName as $type => $name ) {
252 $select->addOption( $name, $type );
253 }
254
255 return $select;
256 }
257
262 private function getUserInput( $user ) {
263 $label = Xml::inputLabel(
264 $this->msg( 'specialloguserlabel' )->text(),
265 'user',
266 'mw-log-user',
267 15,
268 $user,
269 [ 'class' => 'mw-autocomplete-user' ]
270 );
271
272 return '<span class="mw-input-with-label">' . $label . '</span>';
273 }
274
279 private function getTitleInput( $title ) {
280 $label = Xml::inputLabel(
281 $this->msg( 'speciallogtitlelabel' )->text(),
282 'page',
283 'mw-log-page',
284 20,
285 $title
286 );
287
288 return '<span class="mw-input-with-label">' . $label . '</span>';
289 }
290
295 private function getTitlePattern( $pattern ) {
296 return '<span class="mw-input-with-label">' .
297 Xml::checkLabel( $this->msg( 'log-title-wildcard' )->text(), 'pattern', 'pattern', $pattern ) .
298 '</span>';
299 }
300
305 private function getExtraInputs( $types ) {
306 if ( count( $types ) == 1 ) {
307 if ( $types[0] == 'suppress' ) {
308 $offender = $this->getRequest()->getVal( 'offender' );
309 $user = User::newFromName( $offender, false );
310 if ( !$user || ( $user->getId() == 0 && !IP::isIPAddress( $offender ) ) ) {
311 $offender = ''; // Blank field if invalid
312 }
313 return Xml::inputLabel( $this->msg( 'revdelete-offender' )->text(), 'offender',
314 'mw-log-offender', 20, $offender );
315 } else {
316 // Allow extensions to add their own extra inputs
317 $input = '';
318 Hooks::run( 'LogEventsListGetExtraInputs', [ $types[0], $this, &$input ] );
319 return $input;
320 }
321 }
322
323 return '';
324 }
325
333 private function getActionSelector( $types, $action ) {
334 if ( $this->allowedActions === null || !count( $this->allowedActions ) ) {
335 return '';
336 }
337 $html = '';
338 $html .= Xml::label( wfMessage( 'log-action-filter-' . $types[0] )->text(),
339 'action-filter-' .$types[0] ) . "\n";
340 $select = new XmlSelect( 'subtype' );
341 $select->addOption( wfMessage( 'log-action-filter-all' )->text(), '' );
342 foreach ( $this->allowedActions as $value ) {
343 $msgKey = 'log-action-filter-' . $types[0] . '-' . $value;
344 $select->addOption( wfMessage( $msgKey )->text(), $value );
345 }
346 $select->setDefault( $action );
347 $html .= $select->getHTML();
348 return $html;
349 }
350
357 public function setAllowedActions( $actions ) {
358 $this->allowedActions = $actions;
359 }
360
364 public function beginLogEventsList() {
365 return "<ul>\n";
366 }
367
371 public function endLogEventsList() {
372 return "</ul>\n";
373 }
374
379 public function logLine( $row ) {
380 $entry = DatabaseLogEntry::newFromRow( $row );
381 $formatter = LogFormatter::newFromEntry( $entry );
382 $formatter->setContext( $this->getContext() );
383 $formatter->setLinkRenderer( $this->getLinkRenderer() );
384 $formatter->setShowUserToolLinks( !( $this->flags & self::NO_EXTRA_USER_LINKS ) );
385
386 $time = htmlspecialchars( $this->getLanguage()->userTimeAndDate(
387 $entry->getTimestamp(), $this->getUser() ) );
388
389 $action = $formatter->getActionText();
390
391 if ( $this->flags & self::NO_ACTION_LINK ) {
392 $revert = '';
393 } else {
394 $revert = $formatter->getActionLinks();
395 if ( $revert != '' ) {
396 $revert = '<span class="mw-logevent-actionlink">' . $revert . '</span>';
397 }
398 }
399
400 $comment = $formatter->getComment();
401
402 // Some user can hide log items and have review links
403 $del = $this->getShowHideLinks( $row );
404
405 // Any tags...
406 list( $tagDisplay, $newClasses ) = ChangeTags::formatSummaryRow(
407 $row->ts_tags,
408 'logevent',
409 $this->getContext()
410 );
411 $classes = array_merge(
412 [ 'mw-logline-' . $entry->getType() ],
413 $newClasses
414 );
415 $attribs = [
416 'data-mw-logid' => $entry->getId(),
417 'data-mw-logaction' => $entry->getFullType(),
418 ];
419 $ret = "$del $time $action $comment $revert $tagDisplay";
420
421 // Let extensions add data
422 Hooks::run( 'LogEventsListLineEnding', [ $this, &$ret, $entry, &$classes, &$attribs ] );
423 $attribs = wfArrayFilterByKey( $attribs, [ Sanitizer::class, 'isReservedDataAttribute' ] );
424 $attribs['class'] = implode( ' ', $classes );
425
426 return Html::rawElement( 'li', $attribs, $ret ) . "\n";
427 }
428
433 private function getShowHideLinks( $row ) {
434 // We don't want to see the links and
435 if ( $this->flags == self::NO_ACTION_LINK ) {
436 return '';
437 }
438
439 $user = $this->getUser();
440
441 // If change tag editing is available to this user, return the checkbox
442 if ( $this->flags & self::USE_CHECKBOXES && $this->showTagEditUI ) {
443 return Xml::check(
444 'showhiderevisions',
445 false,
446 [ 'name' => 'ids[' . $row->log_id . ']' ]
447 );
448 }
449
450 // no one can hide items from the suppress log.
451 if ( $row->log_type == 'suppress' ) {
452 return '';
453 }
454
455 $del = '';
456 // Don't show useless checkbox to people who cannot hide log entries
457 if ( $user->isAllowed( 'deletedhistory' ) ) {
458 $canHide = $user->isAllowed( 'deletelogentry' );
459 $canViewSuppressedOnly = $user->isAllowed( 'viewsuppressed' ) &&
460 !$user->isAllowed( 'suppressrevision' );
461 $entryIsSuppressed = self::isDeleted( $row, LogPage::DELETED_RESTRICTED );
462 $canViewThisSuppressedEntry = $canViewSuppressedOnly && $entryIsSuppressed;
463 if ( $row->log_deleted || $canHide ) {
464 // Show checkboxes instead of links.
465 if ( $canHide && $this->flags & self::USE_CHECKBOXES && !$canViewThisSuppressedEntry ) {
466 // If event was hidden from sysops
467 if ( !self::userCan( $row, LogPage::DELETED_RESTRICTED, $user ) ) {
468 $del = Xml::check( 'deleterevisions', false, [ 'disabled' => 'disabled' ] );
469 } else {
470 $del = Xml::check(
471 'showhiderevisions',
472 false,
473 [ 'name' => 'ids[' . $row->log_id . ']' ]
474 );
475 }
476 } else {
477 // If event was hidden from sysops
478 if ( !self::userCan( $row, LogPage::DELETED_RESTRICTED, $user ) ) {
479 $del = Linker::revDeleteLinkDisabled( $canHide );
480 } else {
481 $query = [
482 'target' => SpecialPage::getTitleFor( 'Log', $row->log_type )->getPrefixedDBkey(),
483 'type' => 'logging',
484 'ids' => $row->log_id,
485 ];
487 $query,
488 $entryIsSuppressed,
489 $canHide && !$canViewThisSuppressedEntry
490 );
491 }
492 }
493 }
494 }
495
496 return $del;
497 }
498
506 public static function typeAction( $row, $type, $action, $right = '' ) {
507 $match = is_array( $type ) ?
508 in_array( $row->log_type, $type ) : $row->log_type == $type;
509 if ( $match ) {
510 $match = is_array( $action ) ?
511 in_array( $row->log_action, $action ) : $row->log_action == $action;
512 if ( $match && $right ) {
514 $match = $wgUser->isAllowed( $right );
515 }
516 }
517
518 return $match;
519 }
520
530 public static function userCan( $row, $field, User $user = null ) {
531 return self::userCanBitfield( $row->log_deleted, $field, $user ) &&
532 self::userCanViewLogType( $row->log_type, $user );
533 }
534
544 public static function userCanBitfield( $bitfield, $field, User $user = null ) {
545 if ( $bitfield & $field ) {
546 if ( $user === null ) {
548 $user = $wgUser;
549 }
550 if ( $bitfield & LogPage::DELETED_RESTRICTED ) {
551 $permissions = [ 'suppressrevision', 'viewsuppressed' ];
552 } else {
553 $permissions = [ 'deletedhistory' ];
554 }
555 $permissionlist = implode( ', ', $permissions );
556 wfDebug( "Checking for $permissionlist due to $field match on $bitfield\n" );
557 return call_user_func_array( [ $user, 'isAllowedAny' ], $permissions );
558 }
559 return true;
560 }
561
570 public static function userCanViewLogType( $type, User $user = null ) {
571 if ( $user === null ) {
573 $user = $wgUser;
574 }
575 $logRestrictions = MediaWikiServices::getInstance()->getMainConfig()->get( 'LogRestrictions' );
576 if ( isset( $logRestrictions[$type] ) && !$user->isAllowed( $logRestrictions[$type] ) ) {
577 return false;
578 }
579 return true;
580 }
581
587 public static function isDeleted( $row, $field ) {
588 return ( $row->log_deleted & $field ) == $field;
589 }
590
616 public static function showLogExtract(
617 &$out, $types = [], $page = '', $user = '', $param = []
618 ) {
619 $defaultParameters = [
620 'lim' => 25,
621 'conds' => [],
622 'showIfEmpty' => true,
623 'msgKey' => [ '' ],
624 'wrap' => "$1",
625 'flags' => 0,
626 'useRequestParams' => false,
627 'useMaster' => false,
628 'extraUrlParams' => false,
629 ];
630 # The + operator appends elements of remaining keys from the right
631 # handed array to the left handed, whereas duplicated keys are NOT overwritten.
632 $param += $defaultParameters;
633 # Convert $param array to individual variables
634 $lim = $param['lim'];
635 $conds = $param['conds'];
636 $showIfEmpty = $param['showIfEmpty'];
637 $msgKey = $param['msgKey'];
638 $wrap = $param['wrap'];
639 $flags = $param['flags'];
640 $extraUrlParams = $param['extraUrlParams'];
641
642 $useRequestParams = $param['useRequestParams'];
643 if ( !is_array( $msgKey ) ) {
644 $msgKey = [ $msgKey ];
645 }
646
647 if ( $out instanceof OutputPage ) {
648 $context = $out->getContext();
649 } else {
651 }
652
653 // FIXME: Figure out how to inject this
654 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
655
656 # Insert list of top 50 (or top $lim) items
657 $loglist = new LogEventsList( $context, $linkRenderer, $flags );
658 $pager = new LogPager( $loglist, $types, $user, $page, '', $conds );
659 if ( !$useRequestParams ) {
660 # Reset vars that may have been taken from the request
661 $pager->mLimit = 50;
662 $pager->mDefaultLimit = 50;
663 $pager->mOffset = "";
664 $pager->mIsBackwards = false;
665 }
666
667 if ( $param['useMaster'] ) {
668 $pager->mDb = wfGetDB( DB_MASTER );
669 }
670 if ( isset( $param['offset'] ) ) { # Tell pager to ignore WebRequest offset
671 $pager->setOffset( $param['offset'] );
672 }
673
674 if ( $lim > 0 ) {
675 $pager->mLimit = $lim;
676 }
677 // Fetch the log rows and build the HTML if needed
678 $logBody = $pager->getBody();
679 $numRows = $pager->getNumRows();
680
681 $s = '';
682
683 if ( $logBody ) {
684 if ( $msgKey[0] ) {
685 $dir = $context->getLanguage()->getDir();
686 $lang = $context->getLanguage()->getHtmlCode();
687
688 $s = Xml::openElement( 'div', [
689 'class' => "mw-warning-with-logexcerpt mw-content-$dir",
690 'dir' => $dir,
691 'lang' => $lang,
692 ] );
693
694 if ( count( $msgKey ) == 1 ) {
695 $s .= $context->msg( $msgKey[0] )->parseAsBlock();
696 } else { // Process additional arguments
697 $args = $msgKey;
698 array_shift( $args );
699 $s .= $context->msg( $msgKey[0], $args )->parseAsBlock();
700 }
701 }
702 $s .= $loglist->beginLogEventsList() .
703 $logBody .
704 $loglist->endLogEventsList();
705 } elseif ( $showIfEmpty ) {
706 $s = Html::rawElement( 'div', [ 'class' => 'mw-warning-logempty' ],
707 $context->msg( 'logempty' )->parse() );
708 }
709
710 if ( $numRows > $pager->mLimit ) { # Show "Full log" link
711 $urlParam = [];
712 if ( $page instanceof Title ) {
713 $urlParam['page'] = $page->getPrefixedDBkey();
714 } elseif ( $page != '' ) {
715 $urlParam['page'] = $page;
716 }
717
718 if ( $user != '' ) {
719 $urlParam['user'] = $user;
720 }
721
722 if ( !is_array( $types ) ) { # Make it an array, if it isn't
723 $types = [ $types ];
724 }
725
726 # If there is exactly one log type, we can link to Special:Log?type=foo
727 if ( count( $types ) == 1 ) {
728 $urlParam['type'] = $types[0];
729 }
730
731 if ( $extraUrlParams !== false ) {
732 $urlParam = array_merge( $urlParam, $extraUrlParams );
733 }
734
735 $s .= $linkRenderer->makeKnownLink(
736 SpecialPage::getTitleFor( 'Log' ),
737 $context->msg( 'log-fulllog' )->text(),
738 [],
739 $urlParam
740 );
741 }
742
743 if ( $logBody && $msgKey[0] ) {
744 $s .= '</div>';
745 }
746
747 if ( $wrap != '' ) { // Wrap message in html
748 $s = str_replace( '$1', $s, $wrap );
749 }
750
751 /* hook can return false, if we don't want the message to be emitted (Wikia BugId:7093) */
752 if ( Hooks::run( 'LogEventsListShowLogExtract', [ &$s, $types, $page, $user, $param ] ) ) {
753 // $out can be either an OutputPage object or a String-by-reference
754 if ( $out instanceof OutputPage ) {
755 $out->addHTML( $s );
756 } else {
757 $out = $s;
758 }
759 }
760
761 return $numRows;
762 }
763
772 public static function getExcludeClause( $db, $audience = 'public', User $user = null ) {
774
775 if ( $audience != 'public' && $user === null ) {
777 $user = $wgUser;
778 }
779
780 // Reset the array, clears extra "where" clauses when $par is used
781 $hiddenLogs = [];
782
783 // Don't show private logs to unprivileged users
784 foreach ( $wgLogRestrictions as $logType => $right ) {
785 if ( $audience == 'public' || !$user->isAllowed( $right ) ) {
786 $hiddenLogs[] = $logType;
787 }
788 }
789 if ( count( $hiddenLogs ) == 1 ) {
790 return 'log_type != ' . $db->addQuotes( $hiddenLogs[0] );
791 } elseif ( $hiddenLogs ) {
792 return 'log_type NOT IN (' . $db->makeList( $hiddenLogs ) . ')';
793 }
794
795 return false;
796 }
797}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$wgScript
The URL path to index.php.
$wgLogRestrictions
This restricts log access to those who have a certain right Users without this will not see it in the...
$wgMiserMode
Disable database-intensive features.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfArrayFilterByKey(array $arr, callable $callback)
Like array_filter with ARRAY_FILTER_USE_KEY, but works pre-5.6.
$messages
$wgUser
Definition Setup.php:902
if( $line===false) $args
Definition cdb.php:64
static buildTagFilterSelector( $selected='', $ooui=false, IContextSource $context=null)
Build a text box to select a change tag.
static formatSummaryRow( $tags, $page, IContextSource $context=null)
Creates HTML for the given tags.
static showTagEditingUI(User $user)
Indicate whether change tag editing UI is relevant.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
IContextSource $context
getContext()
Get the base IContextSource object.
setContext(IContextSource $context)
static newFromRow( $row)
Constructs new LogEntry from database result row.
Definition LogEntry.php:207
static revDeleteLinkDisabled( $delete=true)
Creates a dead (show/hide) link for deleting revisions/log entries.
Definition Linker.php:2116
static revDeleteLink( $query=[], $restricted=false, $delete=true)
Creates a (show/hide) link for deleting revisions/log entries.
Definition Linker.php:2094
getTitleInput( $title)
getActionSelector( $types, $action)
Drop down menu for selection of actions that can be used to filter the log.
LinkRenderer null $linkRenderer
static typeAction( $row, $type, $action, $right='')
const NO_EXTRA_USER_LINKS
showOptions( $types=[], $user='', $page='', $pattern='', $year=0, $month=0, $filter=null, $tagFilter='', $action=null)
Show options for the log list.
static getExcludeClause( $db, $audience='public', User $user=null)
SQL clause to skip forbidden log types for this user.
getTypeMenu( $queryTypes)
getShowHideLinks( $row)
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
getFilterLinks( $filter)
getTitlePattern( $pattern)
static userCan( $row, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this log row,...
__construct( $context, $linkRenderer=null, $flags=0)
The first two parameters used to be $skin and $out, but now only a context is needed,...
setAllowedActions( $actions)
Sets the action types allowed for log filtering To one action type may correspond several log_actions...
getTypeSelector()
Returns log page selector.
getExtraInputs( $types)
static userCanViewLogType( $type, User $user=null)
Determine if the current user is allowed to view a particular field of this log row,...
static userCanBitfield( $bitfield, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this log row,...
static isDeleted( $row, $field)
static newFromEntry(LogEntry $entry)
Constructs a new formatter suitable for given entry.
Class to simplify the use of log pages.
Definition LogPage.php:31
const DELETED_RESTRICTED
Definition LogPage.php:35
static validTypes()
Get the list of valid log types.
Definition LogPage.php:192
Class that generates HTML links for pages.
makeKnownLink(LinkTarget $target, $text=null, array $extraAttribs=[], array $query=[])
MediaWikiServices is the service locator for the application scope of MediaWiki.
This class should be covered by a general architecture document which does not exist as of January 20...
static getMain()
Get the RequestContext object associated with the main request.
Represents a title within MediaWiki.
Definition Title.php:39
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:53
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition User.php:591
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
Class for generating HTML <select> or <datalist> elements.
Definition XmlSelect.php:26
=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
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
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
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
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:18
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
the array() calling protocol came about after MediaWiki 1.4rc1.
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition hooks.txt:1795
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:2163
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:3023
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:964
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;div ...>$1&lt;/div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
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:2005
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:864
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:2013
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:3021
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:2206
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:302
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:2014
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition hooks.txt:1620
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 local account $user
Definition hooks.txt:247
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
Interface for objects which can provide a MediaWiki context on request.
msg( $key)
This is the method for getting translated interface messages.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38
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 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:30
if(is_array($mode)) switch( $mode) $input
const DB_MASTER
Definition defines.php:29
$selector
if(!isset( $args[0])) $lang