MediaWiki REL1_28
LogEventsList.php
Go to the documentation of this file.
1<?php
27 const NO_ACTION_LINK = 1;
29 const USE_CHECKBOXES = 4;
30
31 public $flags;
32
36 protected $mDefaultQuery;
37
41 protected $showTagEditUI;
42
46 protected $allowedActions = null;
47
59 public function __construct( $context, $unused = null, $flags = 0 ) {
60 if ( $context instanceof IContextSource ) {
61 $this->setContext( $context );
62 } else {
63 // Old parameters, $context should be a Skin object
64 $this->setContext( $context->getContext() );
65 }
66
67 $this->flags = $flags;
68 $this->showTagEditUI = ChangeTags::showTagEditingUI( $this->getUser() );
69 }
70
84 public function showOptions( $types = [], $user = '', $page = '', $pattern = '', $year = 0,
85 $month = 0, $filter = null, $tagFilter = '', $action = null
86 ) {
88
90
91 // For B/C, we take strings, but make sure they are converted...
92 $types = ( $types === '' ) ? [] : (array)$types;
93
94 $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter );
95
96 $html = Html::hidden( 'title', $title->getPrefixedDBkey() );
97
98 // Basic selectors
99 $html .= $this->getTypeMenu( $types ) . "\n";
100 $html .= $this->getUserInput( $user ) . "\n";
101 $html .= $this->getTitleInput( $page ) . "\n";
102 $html .= $this->getExtraInputs( $types ) . "\n";
103
104 // Title pattern, if allowed
105 if ( !$wgMiserMode ) {
106 $html .= $this->getTitlePattern( $pattern ) . "\n";
107 }
108
109 // date menu
110 $html .= Xml::tags( 'p', null, Xml::dateMenu( (int)$year, (int)$month ) );
111
112 // Tag filter
113 if ( $tagSelector ) {
114 $html .= Xml::tags( 'p', null, implode( '&#160;', $tagSelector ) );
115 }
116
117 // Filter links
118 if ( $filter ) {
119 $html .= Xml::tags( 'p', null, $this->getFilterLinks( $filter ) );
120 }
121
122 // Action filter
123 if ( $action !== null ) {
124 $html .= Xml::tags( 'p', null, $this->getActionSelector( $types, $action ) );
125 }
126
127 // Submit button
128 $html .= Xml::submitButton( $this->msg( 'logeventslist-submit' )->text() );
129
130 // Fieldset
131 $html = Xml::fieldset( $this->msg( 'log' )->text(), $html );
132
133 // Form wrapping
134 $html = Xml::tags( 'form', [ 'action' => $wgScript, 'method' => 'get' ], $html );
135
136 $this->getOutput()->addHTML( $html );
137 }
138
143 private function getFilterLinks( $filter ) {
144 // show/hide links
145 $messages = [ $this->msg( 'show' )->escaped(), $this->msg( 'hide' )->escaped() ];
146 // Option value -> message mapping
147 $links = [];
148 $hiddens = ''; // keep track for "go" button
149 foreach ( $filter as $type => $val ) {
150 // Should the below assignment be outside the foreach?
151 // Then it would have to be copied. Not certain what is more expensive.
152 $query = $this->getDefaultQuery();
153 $queryKey = "hide_{$type}_log";
154
155 $hideVal = 1 - intval( $val );
156 $query[$queryKey] = $hideVal;
157
159 $this->getTitle(),
160 $messages[$hideVal],
161 [],
162 $query
163 );
164
165 // Message: log-show-hide-patrol
166 $links[$type] = $this->msg( "log-show-hide-{$type}" )->rawParams( $link )->escaped();
167 $hiddens .= Html::hidden( "hide_{$type}_log", $val ) . "\n";
168 }
169
170 // Build links
171 return '<small>' . $this->getLanguage()->pipeList( $links ) . '</small>' . $hiddens;
172 }
173
174 private function getDefaultQuery() {
175 if ( !isset( $this->mDefaultQuery ) ) {
176 $this->mDefaultQuery = $this->getRequest()->getQueryValues();
177 unset( $this->mDefaultQuery['title'] );
178 unset( $this->mDefaultQuery['dir'] );
179 unset( $this->mDefaultQuery['offset'] );
180 unset( $this->mDefaultQuery['limit'] );
181 unset( $this->mDefaultQuery['order'] );
182 unset( $this->mDefaultQuery['month'] );
183 unset( $this->mDefaultQuery['year'] );
184 }
185
187 }
188
193 private function getTypeMenu( $queryTypes ) {
194 $queryType = count( $queryTypes ) == 1 ? $queryTypes[0] : '';
195 $selector = $this->getTypeSelector();
196 $selector->setDefault( $queryType );
197
198 return $selector->getHTML();
199 }
200
206 public function getTypeSelector() {
207 $typesByName = []; // Temporary array
208 // First pass to load the log names
209 foreach ( LogPage::validTypes() as $type ) {
210 $page = new LogPage( $type );
211 $restriction = $page->getRestriction();
212 if ( $this->getUser()->isAllowed( $restriction ) ) {
213 $typesByName[$type] = $page->getName()->text();
214 }
215 }
216
217 // Second pass to sort by name
218 asort( $typesByName );
219
220 // Always put "All public logs" on top
221 $public = $typesByName[''];
222 unset( $typesByName[''] );
223 $typesByName = [ '' => $public ] + $typesByName;
224
225 $select = new XmlSelect( 'type' );
226 foreach ( $typesByName as $type => $name ) {
227 $select->addOption( $name, $type );
228 }
229
230 return $select;
231 }
232
237 private function getUserInput( $user ) {
238 $label = Xml::inputLabel(
239 $this->msg( 'specialloguserlabel' )->text(),
240 'user',
241 'mw-log-user',
242 15,
243 $user,
244 [ 'class' => 'mw-autocomplete-user' ]
245 );
246
247 return '<span class="mw-input-with-label">' . $label . '</span>';
248 }
249
254 private function getTitleInput( $title ) {
255 $label = Xml::inputLabel(
256 $this->msg( 'speciallogtitlelabel' )->text(),
257 'page',
258 'mw-log-page',
259 20,
260 $title
261 );
262
263 return '<span class="mw-input-with-label">' . $label . '</span>';
264 }
265
270 private function getTitlePattern( $pattern ) {
271 return '<span class="mw-input-with-label">' .
272 Xml::checkLabel( $this->msg( 'log-title-wildcard' )->text(), 'pattern', 'pattern', $pattern ) .
273 '</span>';
274 }
275
280 private function getExtraInputs( $types ) {
281 if ( count( $types ) == 1 ) {
282 if ( $types[0] == 'suppress' ) {
283 $offender = $this->getRequest()->getVal( 'offender' );
284 $user = User::newFromName( $offender, false );
285 if ( !$user || ( $user->getId() == 0 && !IP::isIPAddress( $offender ) ) ) {
286 $offender = ''; // Blank field if invalid
287 }
288 return Xml::inputLabel( $this->msg( 'revdelete-offender' )->text(), 'offender',
289 'mw-log-offender', 20, $offender );
290 } else {
291 // Allow extensions to add their own extra inputs
292 $input = '';
293 Hooks::run( 'LogEventsListGetExtraInputs', [ $types[0], $this, &$input ] );
294 return $input;
295 }
296 }
297
298 return '';
299 }
300
308 private function getActionSelector( $types, $action ) {
309 if ( $this->allowedActions === null || !count( $this->allowedActions ) ) {
310 return '';
311 }
312 $html = '';
313 $html .= Xml::label( wfMessage( 'log-action-filter-' . $types[0] )->text(),
314 'action-filter-' .$types[0] ) . "\n";
315 $select = new XmlSelect( 'subtype' );
316 $select->addOption( wfMessage( 'log-action-filter-all' )->text(), '' );
317 foreach ( $this->allowedActions as $value ) {
318 $msgKey = 'log-action-filter-' . $types[0] . '-' . $value;
319 $select->addOption( wfMessage( $msgKey )->text(), $value );
320 }
321 $select->setDefault( $action );
322 $html .= $select->getHTML();
323 return $html;
324 }
325
332 public function setAllowedActions( $actions ) {
333 $this->allowedActions = $actions;
334 }
335
339 public function beginLogEventsList() {
340 return "<ul>\n";
341 }
342
346 public function endLogEventsList() {
347 return "</ul>\n";
348 }
349
354 public function logLine( $row ) {
355 $entry = DatabaseLogEntry::newFromRow( $row );
356 $formatter = LogFormatter::newFromEntry( $entry );
357 $formatter->setContext( $this->getContext() );
358 $formatter->setShowUserToolLinks( !( $this->flags & self::NO_EXTRA_USER_LINKS ) );
359
360 $time = htmlspecialchars( $this->getLanguage()->userTimeAndDate(
361 $entry->getTimestamp(), $this->getUser() ) );
362
363 $action = $formatter->getActionText();
364
365 if ( $this->flags & self::NO_ACTION_LINK ) {
366 $revert = '';
367 } else {
368 $revert = $formatter->getActionLinks();
369 if ( $revert != '' ) {
370 $revert = '<span class="mw-logevent-actionlink">' . $revert . '</span>';
371 }
372 }
373
374 $comment = $formatter->getComment();
375
376 // Some user can hide log items and have review links
377 $del = $this->getShowHideLinks( $row );
378
379 // Any tags...
380 list( $tagDisplay, $newClasses ) = ChangeTags::formatSummaryRow(
381 $row->ts_tags,
382 'logevent',
383 $this->getContext()
384 );
385 $classes = array_merge(
386 [ 'mw-logline-' . $entry->getType() ],
387 $newClasses
388 );
389
390 return Html::rawElement( 'li', [ 'class' => $classes ],
391 "$del $time $action $comment $revert $tagDisplay" ) . "\n";
392 }
393
398 private function getShowHideLinks( $row ) {
399 // We don't want to see the links and
400 if ( $this->flags == self::NO_ACTION_LINK ) {
401 return '';
402 }
403
404 $user = $this->getUser();
405
406 // If change tag editing is available to this user, return the checkbox
407 if ( $this->flags & self::USE_CHECKBOXES && $this->showTagEditUI ) {
408 return Xml::check(
409 'showhiderevisions',
410 false,
411 [ 'name' => 'ids[' . $row->log_id . ']' ]
412 );
413 }
414
415 // no one can hide items from the suppress log.
416 if ( $row->log_type == 'suppress' ) {
417 return '';
418 }
419
420 $del = '';
421 // Don't show useless checkbox to people who cannot hide log entries
422 if ( $user->isAllowed( 'deletedhistory' ) ) {
423 $canHide = $user->isAllowed( 'deletelogentry' );
424 $canViewSuppressedOnly = $user->isAllowed( 'viewsuppressed' ) &&
425 !$user->isAllowed( 'suppressrevision' );
426 $entryIsSuppressed = self::isDeleted( $row, LogPage::DELETED_RESTRICTED );
427 $canViewThisSuppressedEntry = $canViewSuppressedOnly && $entryIsSuppressed;
428 if ( $row->log_deleted || $canHide ) {
429 // Show checkboxes instead of links.
430 if ( $canHide && $this->flags & self::USE_CHECKBOXES && !$canViewThisSuppressedEntry ) {
431 // If event was hidden from sysops
432 if ( !self::userCan( $row, LogPage::DELETED_RESTRICTED, $user ) ) {
433 $del = Xml::check( 'deleterevisions', false, [ 'disabled' => 'disabled' ] );
434 } else {
435 $del = Xml::check(
436 'showhiderevisions',
437 false,
438 [ 'name' => 'ids[' . $row->log_id . ']' ]
439 );
440 }
441 } else {
442 // If event was hidden from sysops
443 if ( !self::userCan( $row, LogPage::DELETED_RESTRICTED, $user ) ) {
444 $del = Linker::revDeleteLinkDisabled( $canHide );
445 } else {
446 $query = [
447 'target' => SpecialPage::getTitleFor( 'Log', $row->log_type )->getPrefixedDBkey(),
448 'type' => 'logging',
449 'ids' => $row->log_id,
450 ];
452 $query,
453 $entryIsSuppressed,
454 $canHide && !$canViewThisSuppressedEntry
455 );
456 }
457 }
458 }
459 }
460
461 return $del;
462 }
463
471 public static function typeAction( $row, $type, $action, $right = '' ) {
472 $match = is_array( $type ) ?
473 in_array( $row->log_type, $type ) : $row->log_type == $type;
474 if ( $match ) {
475 $match = is_array( $action ) ?
476 in_array( $row->log_action, $action ) : $row->log_action == $action;
477 if ( $match && $right ) {
479 $match = $wgUser->isAllowed( $right );
480 }
481 }
482
483 return $match;
484 }
485
495 public static function userCan( $row, $field, User $user = null ) {
496 return self::userCanBitfield( $row->log_deleted, $field, $user );
497 }
498
508 public static function userCanBitfield( $bitfield, $field, User $user = null ) {
509 if ( $bitfield & $field ) {
510 if ( $user === null ) {
512 $user = $wgUser;
513 }
514 if ( $bitfield & LogPage::DELETED_RESTRICTED ) {
515 $permissions = [ 'suppressrevision', 'viewsuppressed' ];
516 } else {
517 $permissions = [ 'deletedhistory' ];
518 }
519 $permissionlist = implode( ', ', $permissions );
520 wfDebug( "Checking for $permissionlist due to $field match on $bitfield\n" );
521 return call_user_func_array( [ $user, 'isAllowedAny' ], $permissions );
522 }
523 return true;
524 }
525
531 public static function isDeleted( $row, $field ) {
532 return ( $row->log_deleted & $field ) == $field;
533 }
534
559 public static function showLogExtract(
560 &$out, $types = [], $page = '', $user = '', $param = []
561 ) {
562 $defaultParameters = [
563 'lim' => 25,
564 'conds' => [],
565 'showIfEmpty' => true,
566 'msgKey' => [ '' ],
567 'wrap' => "$1",
568 'flags' => 0,
569 'useRequestParams' => false,
570 'useMaster' => false,
571 'extraUrlParams' => false,
572 ];
573 # The + operator appends elements of remaining keys from the right
574 # handed array to the left handed, whereas duplicated keys are NOT overwritten.
575 $param += $defaultParameters;
576 # Convert $param array to individual variables
577 $lim = $param['lim'];
578 $conds = $param['conds'];
579 $showIfEmpty = $param['showIfEmpty'];
580 $msgKey = $param['msgKey'];
581 $wrap = $param['wrap'];
582 $flags = $param['flags'];
583 $extraUrlParams = $param['extraUrlParams'];
584
585 $useRequestParams = $param['useRequestParams'];
586 if ( !is_array( $msgKey ) ) {
587 $msgKey = [ $msgKey ];
588 }
589
590 if ( $out instanceof OutputPage ) {
591 $context = $out->getContext();
592 } else {
594 }
595
596 # Insert list of top 50 (or top $lim) items
597 $loglist = new LogEventsList( $context, null, $flags );
598 $pager = new LogPager( $loglist, $types, $user, $page, '', $conds );
599 if ( !$useRequestParams ) {
600 # Reset vars that may have been taken from the request
601 $pager->mLimit = 50;
602 $pager->mDefaultLimit = 50;
603 $pager->mOffset = "";
604 $pager->mIsBackwards = false;
605 }
606
607 if ( $param['useMaster'] ) {
608 $pager->mDb = wfGetDB( DB_MASTER );
609 }
610 if ( isset( $param['offset'] ) ) { # Tell pager to ignore WebRequest offset
611 $pager->setOffset( $param['offset'] );
612 }
613
614 if ( $lim > 0 ) {
615 $pager->mLimit = $lim;
616 }
617 // Fetch the log rows and build the HTML if needed
618 $logBody = $pager->getBody();
619 $numRows = $pager->getNumRows();
620
621 $s = '';
622
623 if ( $logBody ) {
624 if ( $msgKey[0] ) {
625 $dir = $context->getLanguage()->getDir();
626 $lang = $context->getLanguage()->getHtmlCode();
627
628 $s = Xml::openElement( 'div', [
629 'class' => "mw-warning-with-logexcerpt mw-content-$dir",
630 'dir' => $dir,
631 'lang' => $lang,
632 ] );
633
634 if ( count( $msgKey ) == 1 ) {
635 $s .= $context->msg( $msgKey[0] )->parseAsBlock();
636 } else { // Process additional arguments
637 $args = $msgKey;
638 array_shift( $args );
639 $s .= $context->msg( $msgKey[0], $args )->parseAsBlock();
640 }
641 }
642 $s .= $loglist->beginLogEventsList() .
643 $logBody .
644 $loglist->endLogEventsList();
645 } elseif ( $showIfEmpty ) {
646 $s = Html::rawElement( 'div', [ 'class' => 'mw-warning-logempty' ],
647 $context->msg( 'logempty' )->parse() );
648 }
649
650 if ( $numRows > $pager->mLimit ) { # Show "Full log" link
651 $urlParam = [];
652 if ( $page instanceof Title ) {
653 $urlParam['page'] = $page->getPrefixedDBkey();
654 } elseif ( $page != '' ) {
655 $urlParam['page'] = $page;
656 }
657
658 if ( $user != '' ) {
659 $urlParam['user'] = $user;
660 }
661
662 if ( !is_array( $types ) ) { # Make it an array, if it isn't
663 $types = [ $types ];
664 }
665
666 # If there is exactly one log type, we can link to Special:Log?type=foo
667 if ( count( $types ) == 1 ) {
668 $urlParam['type'] = $types[0];
669 }
670
671 if ( $extraUrlParams !== false ) {
672 $urlParam = array_merge( $urlParam, $extraUrlParams );
673 }
674
675 $s .= Linker::linkKnown(
676 SpecialPage::getTitleFor( 'Log' ),
677 $context->msg( 'log-fulllog' )->escaped(),
678 [],
679 $urlParam
680 );
681 }
682
683 if ( $logBody && $msgKey[0] ) {
684 $s .= '</div>';
685 }
686
687 if ( $wrap != '' ) { // Wrap message in html
688 $s = str_replace( '$1', $s, $wrap );
689 }
690
691 /* hook can return false, if we don't want the message to be emitted (Wikia BugId:7093) */
692 if ( Hooks::run( 'LogEventsListShowLogExtract', [ &$s, $types, $page, $user, $param ] ) ) {
693 // $out can be either an OutputPage object or a String-by-reference
694 if ( $out instanceof OutputPage ) {
695 $out->addHTML( $s );
696 } else {
697 $out = $s;
698 }
699 }
700
701 return $numRows;
702 }
703
712 public static function getExcludeClause( $db, $audience = 'public', User $user = null ) {
714
715 if ( $audience != 'public' && $user === null ) {
717 $user = $wgUser;
718 }
719
720 // Reset the array, clears extra "where" clauses when $par is used
721 $hiddenLogs = [];
722
723 // Don't show private logs to unprivileged users
724 foreach ( $wgLogRestrictions as $logType => $right ) {
725 if ( $audience == 'public' || !$user->isAllowed( $right ) ) {
726 $hiddenLogs[] = $logType;
727 }
728 }
729 if ( count( $hiddenLogs ) == 1 ) {
730 return 'log_type != ' . $db->addQuotes( $hiddenLogs[0] );
731 } elseif ( $hiddenLogs ) {
732 return 'log_type NOT IN (' . $db->makeList( $hiddenLogs ) . ')';
733 }
734
735 return false;
736 }
737}
$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.
$messages
$wgUser
Definition Setup.php:806
if( $line===false) $args
Definition cdb.php:64
static formatSummaryRow( $tags, $page, IContextSource $context=null)
Creates HTML for the given tags.
static buildTagFilterSelector( $selected='', $ooui=false)
Build a text box to select a change tag.
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 ...
getUser()
Get the User object.
getRequest()
Get the WebRequest object.
msg()
Get a Message object with context set Parameters are the same as wfMessage()
getTitle()
Get the Title object.
getOutput()
Get the OutputPage object.
IContextSource $context
getLanguage()
Get the Language object.
getContext()
Get the base IContextSource object.
setContext(IContextSource $context)
Set the IContextSource object.
static newFromRow( $row)
Constructs new LogEntry from database result row.
Definition LogEntry.php:201
static isIPAddress( $ip)
Determine if a string is as valid IP address or network (CIDR prefix).
Definition IP.php:79
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
Definition Linker.php:255
static revDeleteLinkDisabled( $delete=true)
Creates a dead (show/hide) link for deleting revisions/log entries.
Definition Linker.php:2166
static revDeleteLink( $query=[], $restricted=false, $delete=true)
Creates a (show/hide) link for deleting revisions/log entries.
Definition Linker.php:2144
getTitleInput( $title)
getActionSelector( $types, $action)
Drop down menu for selection of actions that can be used to filter the log.
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,...
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)
__construct( $context, $unused=null, $flags=0)
Constructor.
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:32
const DELETED_RESTRICTED
Definition LogPage.php:36
static validTypes()
Get the list of valid log types.
Definition LogPage.php:198
This class should be covered by a general architecture document which does not exist as of January 20...
static getMain()
Static methods.
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,...
Represents a title within MediaWiki.
Definition Title.php:36
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:48
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
static check( $name, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox.
Definition Xml.php:324
static dateMenu( $year, $month)
Definition Xml.php:167
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
Definition Xml.php:359
static openElement( $element, $attribs=null)
This opens an XML element.
Definition Xml.php:109
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
Definition Xml.php:460
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
Definition Xml.php:420
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:381
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition Xml.php:131
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
Definition Xml.php:578
=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.
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:249
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition hooks.txt:2568
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition hooks.txt:1752
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:986
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:2097
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:2902
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
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:886
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:1957
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:2900
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:2140
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:304
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Definition hooks.txt:2534
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:1595
$comment
if(count( $args)==0) $dir
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.
getLanguage()
Get the Language object.
msg()
Get a Message object with context set.
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:36
const DB_MASTER
Definition defines.php:23
$selector
if(!isset( $args[0])) $lang