MediaWiki
1.33.1
|
Implements the default log formatting. More...
Public Member Functions | |
formatParametersForApi () | |
Format parameters for API output. More... | |
getActionLinks () | |
Returns extra links that comes after the action text, like "revert", etc. More... | |
getActionText () | |
Gets the log action, including username. More... | |
getComment () | |
Gets the user provided comment. More... | |
getIRCActionComment () | |
Even uglier hack to maintain backwards compatibility with IRC bots (T36508). More... | |
getIRCActionText () | |
Even uglier hack to maintain backwards compatibility with IRC bots (T36508). More... | |
getLinkRenderer () | |
getMessageParametersForTesting () | |
getPerformerElement () | |
Provides the name of the user who performed the log action. More... | |
getPlainActionText () | |
Ugly hack to produce plaintext version of the message. More... | |
getPreloadTitles () | |
setAudience ( $audience) | |
Set the visibility restrictions for displaying content. More... | |
setContext (IContextSource $context) | |
Replace the default context. More... | |
setLinkRenderer (LinkRenderer $linkRenderer) | |
setShowUserToolLinks ( $value) | |
If set to true, will produce user tool links after the user name. More... | |
Static Public Member Functions | |
static | newFromEntry (LogEntry $entry) |
Constructs a new formatter suitable for given entry. More... | |
static | newFromRow ( $row) |
Handy shortcut for constructing a formatter directly from database row. More... | |
Public Attributes | |
IContextSource | $context |
Context for logging. More... | |
const | FOR_PUBLIC = 1 |
const | FOR_THIS_USER = 2 |
Protected Member Functions | |
__construct (LogEntry $entry) | |
canView ( $field) | |
Check if a log item can be displayed. More... | |
extractParameters () | |
Extracts the optional extra parameters for use in action messages. More... | |
formatParameterValue ( $type, $value) | |
Formats parameters values dependent to their type. More... | |
formatParameterValueForApi ( $name, $type, $value) | |
Format a single parameter value for API output. More... | |
getActionMessage () | |
Returns a sentence describing the log action. More... | |
getMessageKey () | |
Returns a key to be used for formatting the action sentence. More... | |
getMessageParameters () | |
Formats parameters intented for action message from array of all parameters. More... | |
getParametersForApi () | |
Get the array of parameters, converted from legacy format if necessary. More... | |
getRestrictedElement ( $message) | |
Helper method for displaying restricted element. More... | |
makePageLink (Title $title=null, $parameters=[], $html=null) | |
Helper to make a link to the page, taking the plaintext value in consideration. More... | |
makeUserLink (User $user, $toolFlags=0) | |
msg ( $key) | |
Shortcut for wfMessage which honors local context. More... | |
styleRestricedElement ( $content) | |
Helper method for styling restricted element. More... | |
Protected Attributes | |
int | $audience = self::FOR_PUBLIC |
Constant for handling log_deleted. More... | |
LogEntryBase | $entry |
string | $irctext = false |
bool | $linkFlood = false |
Whether to output user tool links. More... | |
array | $parsedParameters |
string | $plaintext = false |
Set to true if we are constructing a message text that is going to be included in page history or send to IRC feed. More... | |
Private Attributes | |
LinkRenderer null | $linkRenderer |
Implements the default log formatting.
Can be overridden by subclassing and setting:
$wgLogActionsHandlers['type/subtype'] = 'class'; or $wgLogActionsHandlers['type/*'] = 'class';
Definition at line 38 of file LogFormatter.php.
|
protected |
Definition at line 111 of file LogFormatter.php.
References $entry, and RequestContext\getMain().
|
protected |
Check if a log item can be displayed.
int | $field | LogPage::DELETED_* constant |
Definition at line 161 of file LogFormatter.php.
References LogEventsList\userCanBitfield().
Referenced by getActionText(), getComment(), getMessageParameters(), and getPerformerElement().
|
protected |
Extracts the optional extra parameters for use in action messages.
The array indexes start from number 3.
Reimplemented in BlockLogFormatter.
Definition at line 498 of file LogFormatter.php.
References $entry, $params, $type, $value, as, captcha-old\count, false, formatParameterValue(), LogEntry\getParameters(), LogEntryBase\isLegacy(), and list.
Referenced by ContentModelLogFormatter\getActionLinks(), MergeLogFormatter\getActionLinks(), MoveLogFormatter\getActionLinks(), DeleteLogFormatter\getActionLinks(), ImportLogFormatter\getMessageKey(), MoveLogFormatter\getMessageKey(), ProtectLogFormatter\getMessageKey(), RenameuserLogFormatter\getMessageKey(), getMessageParameters(), MergeLogFormatter\getPreloadTitles(), MoveLogFormatter\getPreloadTitles(), ProtectLogFormatter\getPreloadTitles(), and RenameuserLogFormatter\getPreloadTitles().
LogFormatter::formatParametersForApi | ( | ) |
Format parameters for API output.
The result array should generally map named keys to values. Index and type should be omitted, e.g. "4::foo" should be returned as "foo" in the output. Values should generally be unformatted.
Renames or removals of keys besides from the legacy numeric format to modern named style should be avoided. Any renames should be announced to the mediawiki-api-announce mailing list.
Reimplemented in DeleteLogFormatter, BlockLogFormatter, RightsLogFormatter, and ProtectLogFormatter.
Definition at line 815 of file LogFormatter.php.
References $value, as, captcha-old\count, formatParameterValueForApi(), getParametersForApi(), ApiResult\setArrayType(), ApiResult\setIndexedTagName(), and wfLogWarning().
|
protected |
Formats parameters values dependent to their type.
string | $type | The type of the value. Valid are currently:
|
mixed | $value | The parameter value that should be formatted |
Definition at line 589 of file LogFormatter.php.
References $linkFlood, $title, $type, $user, $value, makePageLink(), makeUserLink(), msg(), User\newFromName(), Title\newFromText(), and setShowUserToolLinks().
Referenced by extractParameters().
|
protected |
Format a single parameter value for API output.
string | $name | |
string | $type | |
string | $value |
Definition at line 845 of file LogFormatter.php.
References $name, $title, $type, $user, $value, ApiQueryBase\addTitleInfo(), SpecialPage\getTitleFor(), msg(), User\newFromName(), Title\newFromText(), ApiResult\setArrayType(), and wfTimestamp().
Referenced by BlockLogFormatter\formatParametersForApi(), and formatParametersForApi().
LogFormatter::getActionLinks | ( | ) |
Returns extra links that comes after the action text, like "revert", etc.
Reimplemented in LegacyLogFormatter, BlockLogFormatter, DeleteLogFormatter, ProtectLogFormatter, MoveLogFormatter, MergeLogFormatter, and ContentModelLogFormatter.
Definition at line 489 of file LogFormatter.php.
|
protected |
Returns a sentence describing the log action.
Usually a Message object is returned, but old style log types and entries might return pre-escaped HTML string.
Reimplemented in LegacyLogFormatter, and WikitextLogFormatter.
Definition at line 463 of file LogFormatter.php.
References getMessageKey(), getMessageParameters(), and msg().
Referenced by getActionText().
LogFormatter::getActionText | ( | ) |
Gets the log action, including username.
Definition at line 438 of file LogFormatter.php.
References canView(), LogPage\DELETED_ACTION, getActionMessage(), getPerformerElement(), getRestrictedElement(), msg(), and styleRestricedElement().
Referenced by getPlainActionText().
LogFormatter::getComment | ( | ) |
Gets the user provided comment.
Reimplemented in LegacyLogFormatter, and NewUsersLogFormatter.
Definition at line 689 of file LogFormatter.php.
References canView(), Linker\commentBlock(), LogPage\DELETED_COMMENT, getRestrictedElement(), and styleRestricedElement().
LogFormatter::getIRCActionComment | ( | ) |
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
Definition at line 202 of file LogFormatter.php.
References getIRCActionText(), and wfMessage().
LogFormatter::getIRCActionText | ( | ) |
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
Definition at line 223 of file LogFormatter.php.
References $entry, captcha-old\count, BlockLogFormatter\formatBlockFlags(), LogEntry\getParameters(), getPlainActionText(), LogEntry\getSubtype(), LogEntry\getTarget(), LogEntry\getTimestamp(), LogEntry\getType(), LogEntryBase\isLegacy(), text, wfMessage(), and wfTimestamp().
Referenced by getIRCActionComment().
LogFormatter::getLinkRenderer | ( | ) |
Definition at line 136 of file LogFormatter.php.
References $linkRenderer.
Referenced by ContentModelLogFormatter\getActionLinks(), MergeLogFormatter\getActionLinks(), MoveLogFormatter\getActionLinks(), ProtectLogFormatter\getActionLinks(), DeleteLogFormatter\getActionLinks(), BlockLogFormatter\getActionLinks(), TagLogFormatter\getMessageParameters(), PatrolLogFormatter\getMessageParameters(), makePageLink(), and RenameuserLogFormatter\myPageLink().
|
protected |
Returns a key to be used for formatting the action sentence.
Default is logentry-TYPE-SUBTYPE for modern logs. Legacy log types will use custom keys, and subclasses can also alter the key depending on the entry itself.
Reimplemented in BlockLogFormatter, RenameuserLogFormatter, TagLogFormatter, RightsLogFormatter, ProtectLogFormatter, MoveLogFormatter, DeleteLogFormatter, PatrolLogFormatter, and ImportLogFormatter.
Definition at line 477 of file LogFormatter.php.
References $type.
Referenced by getActionMessage().
|
protected |
Formats parameters intented for action message from array of all parameters.
There are three hardcoded parameters (array is zero-indexed, this list not):
Reimplemented in RightsLogFormatter, ProtectLogFormatter, DeleteLogFormatter, MoveLogFormatter, PatrolLogFormatter, MergeLogFormatter, TagLogFormatter, NewUsersLogFormatter, PageLangLogFormatter, BlockLogFormatter, InterwikiLogFormatter, RenameuserLogFormatter, SpamBlacklistLogFormatter, and ContentModelLogFormatter.
Definition at line 545 of file LogFormatter.php.
References $entry, $params, $parsedParameters, canView(), LogPage\DELETED_USER, extractParameters(), LogEntry\getPerformer(), getPerformerElement(), LogEntry\getTarget(), and makePageLink().
Referenced by getActionMessage(), and getMessageParametersForTesting().
LogFormatter::getMessageParametersForTesting | ( | ) |
Definition at line 785 of file LogFormatter.php.
References getMessageParameters().
|
protected |
Get the array of parameters, converted from legacy format if necessary.
Reimplemented in DeleteLogFormatter, BlockLogFormatter, RightsLogFormatter, ProtectLogFormatter, MoveLogFormatter, MergeLogFormatter, PatrolLogFormatter, and UploadLogFormatter.
Definition at line 797 of file LogFormatter.php.
Referenced by formatParametersForApi().
LogFormatter::getPerformerElement | ( | ) |
Provides the name of the user who performed the log action.
Used as part of log action message or standalone, depending which parts of the log entry has been hidden.
Definition at line 671 of file LogFormatter.php.
References canView(), LogPage\DELETED_USER, getRestrictedElement(), makeUserLink(), and styleRestricedElement().
Referenced by LegacyLogFormatter\getActionMessage(), getActionText(), and getMessageParameters().
LogFormatter::getPlainActionText | ( | ) |
Ugly hack to produce plaintext version of the message.
Usually you also want to set extraneous request context to avoid formatting for any particular user.
Definition at line 188 of file LogFormatter.php.
References getActionText().
Referenced by getIRCActionText().
LogFormatter::getPreloadTitles | ( | ) |
Reimplemented in BlockLogFormatter, RenameuserLogFormatter, NewUsersLogFormatter, ProtectLogFormatter, MoveLogFormatter, and MergeLogFormatter.
Definition at line 778 of file LogFormatter.php.
|
protected |
Helper method for displaying restricted element.
string | $message |
Definition at line 710 of file LogFormatter.php.
References $attribs, $content, and msg().
Referenced by getActionText(), getComment(), and getPerformerElement().
Helper to make a link to the page, taking the plaintext value in consideration.
Title | null | $title | The page |
array | $parameters | Query parameters |
string | null | $html | Linktext of the link as raw html |
Reimplemented in RightsLogFormatter.
Definition at line 645 of file LogFormatter.php.
References $html, $link, $title, getLinkRenderer(), and msg().
Referenced by formatParameterValue(), BlockLogFormatter\getMessageParameters(), MergeLogFormatter\getMessageParameters(), MoveLogFormatter\getMessageParameters(), ProtectLogFormatter\getMessageParameters(), and getMessageParameters().
|
protected |
User | $user | |
int | $toolFlags | Combination of Linker::TOOL_LINKS_* flags |
Definition at line 750 of file LogFormatter.php.
References $user, false, Linker\userLink(), and Linker\userToolLinks().
Referenced by formatParameterValue(), BlockLogFormatter\getMessageParameters(), NewUsersLogFormatter\getMessageParameters(), and getPerformerElement().
|
protected |
Shortcut for wfMessage which honors local context.
string | $key |
Definition at line 740 of file LogFormatter.php.
Referenced by formatParameterValue(), formatParameterValueForApi(), RightsLogFormatter\formatRightsList(), ContentModelLogFormatter\getActionLinks(), MergeLogFormatter\getActionLinks(), MoveLogFormatter\getActionLinks(), ProtectLogFormatter\getActionLinks(), DeleteLogFormatter\getActionLinks(), BlockLogFormatter\getActionLinks(), getActionMessage(), LegacyLogFormatter\getActionMessage(), getActionText(), BlockLogFormatter\getMessageParameters(), PageLangLogFormatter\getMessageParameters(), DeleteLogFormatter\getMessageParameters(), RightsLogFormatter\getMessageParameters(), getRestrictedElement(), and makePageLink().
|
static |
Constructs a new formatter suitable for given entry.
LogEntry | $entry |
Definition at line 50 of file LogFormatter.php.
References $entry, $handler, $wgLogActionsHandlers, LogEntryBase\getFullType(), and LogEntry\getType().
Referenced by LogPage\addEntry(), LogFormatterTest\assertIRCComment(), ApiQueryLogEvents\extractRowInfo(), RevDelLogItem\getApiData(), ManualLogEntry\getRecentChange(), LogEventsList\logLine(), MovePage\moveToInternal(), newFromRow(), SpecialChangeContentModel\onSubmit(), LocalFile\recordUpload2(), LogFormatterTest\testApiParamFormatting(), LogFormatterTest\testLogComment(), LogFormatterTest\testLogParamsTypeMsg(), LogFormatterTest\testLogParamsTypeMsgContent(), LogFormatterTest\testLogParamsTypeNumber(), LogFormatterTest\testLogParamsTypePlain(), LogFormatterTest\testLogParamsTypeRaw(), LogFormatterTest\testLogParamsTypeTitleLink(), LogFormatterTest\testLogParamsTypeUserLink(), and LogFormatterTest\testNormalLogParams().
|
static |
Handy shortcut for constructing a formatter directly from database row.
stdClass | array | $row |
Definition at line 70 of file LogFormatter.php.
References newFromEntry(), and DatabaseLogEntry\newFromRow().
Referenced by LogFormatterTestCase\doTestLogFormatter(), ChangesListSpecialPage\execute(), ApiQueryWatchlist\extractOutputData(), ApiQueryRecentChanges\extractRowInfo(), FeedUtils\formatDiff(), ChangeTagsLogItem\getHTML(), RevDelLogItem\getHTML(), LogPager\getStartBody(), and ChangesList\insertLogEntry().
LogFormatter::setAudience | ( | $audience | ) |
Set the visibility restrictions for displaying content.
If set to public, and an item is deleted, then it will be replaced with a placeholder even if the context user is allowed to view it.
int | $audience | Const self::FOR_THIS_USER or self::FOR_PUBLIC |
Definition at line 150 of file LogFormatter.php.
References $audience, and FOR_THIS_USER.
LogFormatter::setContext | ( | IContextSource | $context | ) |
Replace the default context.
IContextSource | $context |
Definition at line 120 of file LogFormatter.php.
References $context.
LogFormatter::setLinkRenderer | ( | LinkRenderer | $linkRenderer | ) |
LinkRenderer | $linkRenderer |
Definition at line 128 of file LogFormatter.php.
References $linkRenderer.
LogFormatter::setShowUserToolLinks | ( | $value | ) |
If set to true, will produce user tool links after the user name.
This should be replaced with generic CSS/JS solution.
bool | $value |
Definition at line 176 of file LogFormatter.php.
References $value.
Referenced by formatParameterValue().
|
protected |
Helper method for styling restricted element.
string | $content |
Definition at line 726 of file LogFormatter.php.
References $attribs, and $content.
Referenced by getActionText(), getComment(), and getPerformerElement().
|
protected |
Constant for handling log_deleted.
Definition at line 80 of file LogFormatter.php.
Referenced by setAudience().
IContextSource LogFormatter::$context |
|
protected |
Definition at line 77 of file LogFormatter.php.
Referenced by __construct(), extractParameters(), LegacyLogFormatter\getActionMessage(), getIRCActionText(), getMessageParameters(), UploadLogFormatter\getParametersForApi(), PatrolLogFormatter\getParametersForApi(), MergeLogFormatter\getParametersForApi(), MoveLogFormatter\getParametersForApi(), ProtectLogFormatter\getParametersForApi(), RightsLogFormatter\getParametersForApi(), BlockLogFormatter\getParametersForApi(), DeleteLogFormatter\getParametersForApi(), and newFromEntry().
Definition at line 98 of file LogFormatter.php.
|
protected |
Whether to output user tool links.
Definition at line 86 of file LogFormatter.php.
Referenced by formatParameterValue().
|
private |
Definition at line 103 of file LogFormatter.php.
Referenced by ProtectLogFormatter\getActionLinks(), DeleteLogFormatter\getActionLinks(), BlockLogFormatter\getActionLinks(), getLinkRenderer(), and setLinkRenderer().
|
protected |
Definition at line 109 of file LogFormatter.php.
Referenced by getMessageParameters().
Set to true if we are constructing a message text that is going to be included in page history or send to IRC feed.
Links are replaced with plaintext or with [[pagename]] kind of syntax, that is parsed by page histories and IRC feeds.
Definition at line 95 of file LogFormatter.php.
const LogFormatter::FOR_PUBLIC = 1 |
Definition at line 40 of file LogFormatter.php.
const LogFormatter::FOR_THIS_USER = 2 |
Definition at line 41 of file LogFormatter.php.
Referenced by ChangeTagsLogItem\getHTML(), RevDelLogItem\getHTML(), and setAudience().