Go to the documentation of this file.
88 $month = 0, $filter =
null, $tagFilter =
'', $action =
null
95 $types = ( $types ===
'' ) ? [] : (
array)$types;
116 if ( $tagSelector ) {
117 $html .=
Xml::tags(
'p',
null, implode(
' ', $tagSelector ) );
126 if ( $action !==
null ) {
148 $messages = [ $this->
msg(
'show' )->text(), $this->
msg(
'hide' )->text() ];
152 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
153 foreach ( $filter
as $type => $val ) {
157 $queryKey =
"hide_{$type}_log";
159 $hideVal = 1 - intval( $val );
160 $query[$queryKey] = $hideVal;
170 $links[
$type] = $this->
msg(
"log-show-hide-{$type}" )->rawParams(
$link )->escaped();
171 $hiddens .=
Html::hidden(
"hide_{$type}_log", $val ) .
"\n";
175 return '<small>' . $this->
getLanguage()->pipeList( $links ) .
'</small>' . $hiddens;
179 if ( !isset( $this->mDefaultQuery ) ) {
180 $this->mDefaultQuery = $this->
getRequest()->getQueryValues();
181 unset( $this->mDefaultQuery[
'title'] );
182 unset( $this->mDefaultQuery[
'dir'] );
183 unset( $this->mDefaultQuery[
'offset'] );
184 unset( $this->mDefaultQuery[
'limit'] );
185 unset( $this->mDefaultQuery[
'order'] );
186 unset( $this->mDefaultQuery[
'month'] );
187 unset( $this->mDefaultQuery[
'year'] );
198 $queryType =
count( $queryTypes ) == 1 ? $queryTypes[0] :
'';
215 $restriction =
$page->getRestriction();
216 if ( $this->
getUser()->isAllowed( $restriction ) ) {
217 $typesByName[
$type] =
$page->getName()->text();
222 asort( $typesByName );
225 $public = $typesByName[
''];
226 unset( $typesByName[
''] );
227 $typesByName = [
'' => $public ] + $typesByName;
243 $this->
msg(
'specialloguserlabel' )->
text(),
248 [
'class' =>
'mw-autocomplete-user' ]
251 return '<span class="mw-input-with-label">' . $label .
'</span>';
260 $this->
msg(
'speciallogtitlelabel' )->
text(),
267 return '<span class="mw-input-with-label">' . $label .
'</span>';
275 return '<span class="mw-input-with-label">' .
285 if (
count( $types ) == 1 ) {
286 if ( $types[0] ==
'suppress' ) {
287 $offender = $this->
getRequest()->getVal(
'offender' );
293 'mw-log-offender', 20, $offender );
313 if ( $this->allowedActions ===
null || !
count( $this->allowedActions ) ) {
318 'action-filter-' .$types[0] ) .
"\n";
320 $select->addOption(
wfMessage(
'log-action-filter-all' )->
text(),
'' );
321 foreach ( $this->allowedActions
as $value ) {
322 $msgKey =
'log-action-filter-' . $types[0] .
'-' .
$value;
325 $select->setDefault( $action );
326 $html .= $select->getHTML();
337 $this->allowedActions = $actions;
361 $formatter->setContext( $this->
getContext() );
362 $formatter->setShowUserToolLinks( !( $this->
flags & self::NO_EXTRA_USER_LINKS ) );
365 $entry->getTimestamp(), $this->
getUser() ) );
367 $action = $formatter->getActionText();
369 if ( $this->
flags & self::NO_ACTION_LINK ) {
372 $revert = $formatter->getActionLinks();
374 $revert =
'<span class="mw-logevent-actionlink">' .
$revert .
'</span>';
378 $comment = $formatter->getComment();
389 $classes = array_merge(
390 [
'mw-logline-' . $entry->getType() ],
395 "$del $time $action $comment $revert $tagDisplay" ) .
"\n";
404 if ( $this->
flags == self::NO_ACTION_LINK ) {
411 if ( $this->
flags & self::USE_CHECKBOXES && $this->showTagEditUI ) {
415 [
'name' =>
'ids[' . $row->log_id .
']' ]
420 if ( $row->log_type ==
'suppress' ) {
426 if (
$user->isAllowed(
'deletedhistory' ) ) {
427 $canHide =
$user->isAllowed(
'deletelogentry' );
428 $canViewSuppressedOnly =
$user->isAllowed(
'viewsuppressed' ) &&
429 !
$user->isAllowed(
'suppressrevision' );
431 $canViewThisSuppressedEntry = $canViewSuppressedOnly && $entryIsSuppressed;
432 if ( $row->log_deleted || $canHide ) {
434 if ( $canHide && $this->
flags & self::USE_CHECKBOXES && !$canViewThisSuppressedEntry ) {
437 $del =
Xml::check(
'deleterevisions',
false, [
'disabled' =>
'disabled' ] );
442 [
'name' =>
'ids[' . $row->log_id .
']' ]
453 'ids' => $row->log_id,
458 $canHide && !$canViewThisSuppressedEntry
476 $match = is_array(
$type ) ?
477 in_array( $row->log_type,
$type ) : $row->log_type ==
$type;
479 $match = is_array( $action ) ?
480 in_array( $row->log_action, $action ) : $row->log_action == $action;
481 if ( $match && $right ) {
483 $match =
$wgUser->isAllowed( $right );
513 if ( $bitfield & $field ) {
514 if (
$user ===
null ) {
519 $permissions = [
'suppressrevision',
'viewsuppressed' ];
521 $permissions = [
'deletedhistory' ];
523 $permissionlist = implode(
', ', $permissions );
524 wfDebug(
"Checking for $permissionlist due to $field match on $bitfield\n" );
525 return call_user_func_array( [
$user,
'isAllowedAny' ], $permissions );
536 return ( $row->log_deleted & $field ) == $field;
567 $defaultParameters = [
570 'showIfEmpty' =>
true,
574 'useRequestParams' =>
false,
575 'useMaster' =>
false,
576 'extraUrlParams' =>
false,
578 # The + operator appends elements of remaining keys from the right
579 # handed array to the left handed, whereas duplicated keys are NOT overwritten.
580 $param += $defaultParameters;
581 # Convert $param array to individual variables
582 $lim = $param[
'lim'];
583 $conds = $param[
'conds'];
584 $showIfEmpty = $param[
'showIfEmpty'];
585 $msgKey = $param[
'msgKey'];
586 $wrap = $param[
'wrap'];
588 $extraUrlParams = $param[
'extraUrlParams'];
590 $useRequestParams = $param[
'useRequestParams'];
591 if ( !is_array( $msgKey ) ) {
592 $msgKey = [ $msgKey ];
601 # Insert list of top 50 (or top $lim) items
604 if ( !$useRequestParams ) {
605 # Reset vars that may have been taken from the request
607 $pager->mDefaultLimit = 50;
608 $pager->mOffset =
"";
609 $pager->mIsBackwards =
false;
612 if ( $param[
'useMaster'] ) {
615 if ( isset( $param[
'offset'] ) ) { # Tell pager to ignore
WebRequest offset
616 $pager->setOffset( $param[
'offset'] );
620 $pager->mLimit = $lim;
623 $logBody = $pager->getBody();
624 $numRows = $pager->getNumRows();
634 'class' =>
"mw-warning-with-logexcerpt mw-content-$dir",
639 if (
count( $msgKey ) == 1 ) {
643 array_shift(
$args );
647 $s .= $loglist->beginLogEventsList() .
649 $loglist->endLogEventsList();
650 } elseif ( $showIfEmpty ) {
655 if ( $numRows > $pager->mLimit ) { # Show
"Full log" link
658 $urlParam[
'page'] =
$page->getPrefixedDBkey();
659 } elseif (
$page !=
'' ) {
660 $urlParam[
'page'] =
$page;
664 $urlParam[
'user'] =
$user;
667 if ( !is_array( $types ) ) { # Make
it an
array,
if it isn
't
671 # If there is exactly one log type, we can link to Special:Log?type=foo
672 if ( count( $types ) == 1 ) {
673 $urlParam['type'] = $types[0];
676 if ( $extraUrlParams !== false ) {
677 $urlParam = array_merge( $urlParam, $extraUrlParams );
680 $s .= MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
681 SpecialPage::getTitleFor( 'Log
' ),
682 $context->msg( 'log-fulllog
' )->text(),
688 if ( $logBody && $msgKey[0] ) {
692 if ( $wrap != '' ) { // Wrap message in html
693 $s = str_replace( '$1
', $s, $wrap );
696 /* hook can return false, if we don't want the
message to be emitted (Wikia BugId:7093) */
718 global $wgLogRestrictions;
720 if ( $audience !=
'public' &&
$user ===
null ) {
729 foreach ( $wgLogRestrictions
as $logType => $right ) {
730 if ( $audience ==
'public' || !
$user->isAllowed( $right ) ) {
731 $hiddenLogs[] = $logType;
734 if (
count( $hiddenLogs ) == 1 ) {
735 return 'log_type != ' . $db->addQuotes( $hiddenLogs[0] );
736 } elseif ( $hiddenLogs ) {
737 return 'log_type NOT IN (' . $db->makeList( $hiddenLogs ) .
')';
getContext()
Get the base IContextSource object.
static validTypes()
Get the list of valid log types.
msg()
Get a Message object with context set Parameters are the same as wfMessage()
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
if(!isset( $args[0])) $lang
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
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
$wgScript
The URL path to index.php.
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
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
=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
msg()
Get a Message object with context set.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
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
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form before processing starts Return false to skip default processing and return $ret $linkRenderer
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,...
Allows to change the fields on the form that will be generated $name
getRequest()
Get the WebRequest object.
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 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
getUser()
Get the User object.
getTitle()
Get the Title object.
static openElement( $element, $attribs=null)
This opens an XML element.
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
Class for generating HTML <select> or <datalist> elements.
getLanguage()
Get the Language object.
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
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
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
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
namespace and then decline to actually register it file or subcat img or subcat $title
static newFromRow( $row)
Constructs new LogEntry from database result row.
setAllowedActions( $actions)
Sets the action types allowed for log filtering To one action type may correspond several log_actions...
getTypeMenu( $queryTypes)
getTypeSelector()
Returns log page selector.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
if(is_array( $mode)) switch( $mode) $input
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
getOutput()
Get the OutputPage object.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
static check( $name, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox.
static typeAction( $row, $type, $action, $right='')
Class to simplify the use of log pages.
showOptions( $types=[], $user='', $page='', $pattern='', $year=0, $month=0, $filter=null, $tagFilter='', $action=null)
Show options for the log list.
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
static revDeleteLinkDisabled( $delete=true)
Creates a dead (show/hide) link for deleting revisions/log entries.
see documentation in includes Linker php for Linker::makeImageLink & $time
when a variable name is used in a it is silently declared as a new masking the global
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
getActionSelector( $types, $action)
Drop down menu for selection of actions that can be used to filter the log.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
setContext(IContextSource $context)
Set the IContextSource object.
This class should be covered by a general architecture document which does not exist as of January 20...
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
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
static getExcludeClause( $db, $audience='public', User $user=null)
SQL clause to skip forbidden log types for this user.
__construct( $context, $unused=null, $flags=0)
Constructor.
static getMain()
Static methods.
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
Interface for objects which can provide a MediaWiki context on request.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
Represents a title within MediaWiki.
$wgMiserMode
Disable database-intensive features.
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
static userCanBitfield( $bitfield, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this log row,...
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
static dateMenu( $year, $month)
static userCan( $row, $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 rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
static revDeleteLink( $query=[], $restricted=false, $delete=true)
Creates a (show/hide) link for deleting revisions/log entries.
usually copyright or history_copyright This message must be in HTML not wikitext & $link
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 "<
const NO_EXTRA_USER_LINKS
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
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
static inputLabel( $label, $name, $id, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field with a label.
getTitlePattern( $pattern)
static isIPAddress( $ip)
Determine if a string is as valid IP address or network (CIDR prefix).
getLanguage()
Get the Language object.
the array() calling protocol came about after MediaWiki 1.4rc1.
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
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