MediaWiki REL1_35
|
Implements the default log formatting. More...
Public Member Functions | |
canViewLogType () | |
Check if a log item type can be displayed. | |
formatParametersForApi () | |
Format parameters for API output. | |
getActionLinks () | |
Returns extra links that comes after the action text, like "revert", etc. | |
getActionText () | |
Gets the log action, including username. | |
getComment () | |
Gets the user provided comment Stable to override. | |
getIRCActionComment () | |
Even uglier hack to maintain backwards compatibility with IRC bots (T36508). | |
getIRCActionText () | |
Even uglier hack to maintain backwards compatibility with IRC bots (T36508). | |
getLinkRenderer () | |
getMessageParametersForTesting () | |
getPerformerElement () | |
Provides the name of the user who performed the log action. | |
getPlainActionText () | |
Ugly hack to produce plaintext version of the message. | |
getPreloadTitles () | |
Stable to override. | |
setAudience ( $audience) | |
Set the visibility restrictions for displaying content. | |
setContext (IContextSource $context) | |
Replace the default context. | |
setLinkRenderer (LinkRenderer $linkRenderer) | |
setShowUserToolLinks ( $value) | |
If set to true, will produce user tool links after the user name. | |
Static Public Member Functions | |
static | newFromEntry (LogEntry $entry) |
Constructs a new formatter suitable for given entry. | |
static | newFromRow ( $row) |
Handy shortcut for constructing a formatter directly from database row. | |
Public Attributes | |
IContextSource | $context |
Context for logging. | |
const | FOR_PUBLIC = 1 |
const | FOR_THIS_USER = 2 |
Protected Member Functions | |
__construct (LogEntry $entry) | |
Stable to call. | |
canView ( $field) | |
Check if a log item can be displayed. | |
extractParameters () | |
Extracts the optional extra parameters for use in action messages. | |
formatParameterValue ( $type, $value) | |
Formats parameters values dependent to their type. | |
formatParameterValueForApi ( $name, $type, $value) | |
Format a single parameter value for API output. | |
getActionMessage () | |
Returns a sentence describing the log action. | |
getMessageKey () | |
Returns a key to be used for formatting the action sentence. | |
getMessageParameters () | |
Formats parameters intented for action message from array of all parameters. | |
getParametersForApi () | |
Get the array of parameters, converted from legacy format if necessary. | |
getRestrictedElement ( $message) | |
Helper method for displaying restricted element. | |
makePageLink (Title $title=null, $parameters=[], $html=null) | |
Helper to make a link to the page, taking the plaintext value in consideration. | |
makeUserLink (User $user, $toolFlags=0) | |
msg ( $key,... $params) | |
Shortcut for wfMessage which honors local context. | |
styleRestricedElement ( $content) | |
Helper method for styling restricted element. | |
Protected Attributes | |
int | $audience = self::FOR_PUBLIC |
Constant for handling log_deleted. | |
LogEntryBase | $entry |
string | $irctext = false |
bool | $linkFlood = false |
Whether to output user tool links. | |
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. | |
Private Attributes | |
LinkRenderer null | $linkRenderer |
Implements the default log formatting.
Can be overridden by subclassing and setting:
Stable to extend
Definition at line 40 of file LogFormatter.php.
|
protected |
Stable to call.
LogEntry | $entry |
Definition at line 118 of file LogFormatter.php.
References $entry.
|
protected |
Check if a log item can be displayed.
int | $field | LogPage::DELETED_* constant |
Definition at line 183 of file LogFormatter.php.
References canViewLogType().
Referenced by getActionText(), getComment(), getMessageParameters(), and getPerformerElement().
LogFormatter::canViewLogType | ( | ) |
Check if a log item type can be displayed.
Definition at line 167 of file LogFormatter.php.
References $type.
Referenced by canView().
|
protected |
Extracts the optional extra parameters for use in action messages.
The array indexes start from number 3. Stable to override
Reimplemented in BlockLogFormatter.
Definition at line 525 of file LogFormatter.php.
References $entry, $type, formatParameterValue(), LogEntry\getParameters(), and LogEntryBase\isLegacy().
Referenced by ContentModelLogFormatter\getActionLinks(), DeleteLogFormatter\getActionLinks(), MergeLogFormatter\getActionLinks(), MoveLogFormatter\getActionLinks(), ImportLogFormatter\getMessageKey(), MoveLogFormatter\getMessageKey(), ProtectLogFormatter\getMessageKey(), getMessageParameters(), MergeLogFormatter\getPreloadTitles(), MoveLogFormatter\getPreloadTitles(), and ProtectLogFormatter\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 BlockLogFormatter, DeleteLogFormatter, ProtectLogFormatter, and RightsLogFormatter.
Definition at line 853 of file LogFormatter.php.
References formatParameterValueForApi(), getParametersForApi(), 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 617 of file LogFormatter.php.
References $linkFlood, $title, $type, makePageLink(), makeUserLink(), msg(), User\newFromName(), Message\numParam(), Message\rawParam(), and setShowUserToolLinks().
Referenced by extractParameters().
|
protected |
Format a single parameter value for API output.
string | $name | |
string | $type | |
string | $value |
Definition at line 883 of file LogFormatter.php.
References $title, $type, SpecialPage\getTitleFor(), msg(), User\newFromName(), and wfTimestamp().
Referenced by BlockLogFormatter\formatParametersForApi(), and formatParametersForApi().
LogFormatter::getActionLinks | ( | ) |
Returns extra links that comes after the action text, like "revert", etc.
Stable to override
Reimplemented in BlockLogFormatter, ContentModelLogFormatter, DeleteLogFormatter, LegacyLogFormatter, MergeLogFormatter, MoveLogFormatter, and ProtectLogFormatter.
Definition at line 515 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 487 of file LogFormatter.php.
References getMessageKey(), getMessageParameters(), and msg().
Referenced by getActionText().
LogFormatter::getActionText | ( | ) |
Gets the log action, including username.
Stable to override
Definition at line 462 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 Stable to override.
Reimplemented in LegacyLogFormatter, and NewUsersLogFormatter.
Definition at line 723 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 225 of file LogFormatter.php.
References getIRCActionText(), and wfMessage().
LogFormatter::getIRCActionText | ( | ) |
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
Definition at line 246 of file LogFormatter.php.
References $entry, BlockLogFormatter\formatBlockFlags(), LogEntry\getParameters(), getPlainActionText(), LogEntry\getSubtype(), LogEntry\getTarget(), LogEntry\getTimestamp(), LogEntry\getType(), LogEntryBase\isLegacy(), wfMessage(), and wfTimestamp().
Referenced by getIRCActionComment().
LogFormatter::getLinkRenderer | ( | ) |
Definition at line 143 of file LogFormatter.php.
References $linkRenderer.
Referenced by BlockLogFormatter\getActionLinks(), ContentModelLogFormatter\getActionLinks(), DeleteLogFormatter\getActionLinks(), MergeLogFormatter\getActionLinks(), MoveLogFormatter\getActionLinks(), ProtectLogFormatter\getActionLinks(), PatrolLogFormatter\getMessageParameters(), TagLogFormatter\getMessageParameters(), and makePageLink().
|
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. Stable to override
Reimplemented in BlockLogFormatter, DeleteLogFormatter, ImportLogFormatter, MoveLogFormatter, PatrolLogFormatter, ProtectLogFormatter, RightsLogFormatter, and TagLogFormatter.
Definition at line 502 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 BlockLogFormatter, ContentModelLogFormatter, DeleteLogFormatter, MergeLogFormatter, MoveLogFormatter, NewUsersLogFormatter, PageLangLogFormatter, PatrolLogFormatter, ProtectLogFormatter, RightsLogFormatter, and TagLogFormatter.
Definition at line 573 of file LogFormatter.php.
References $entry, $parsedParameters, canView(), LogPage\DELETED_USER, extractParameters(), LogEntry\getPerformer(), getPerformerElement(), LogEntry\getTarget(), makePageLink(), and Message\rawParam().
Referenced by getActionMessage(), and getMessageParametersForTesting().
LogFormatter::getMessageParametersForTesting | ( | ) |
Definition at line 821 of file LogFormatter.php.
References getMessageParameters().
|
protected |
Get the array of parameters, converted from legacy format if necessary.
Reimplemented in BlockLogFormatter, DeleteLogFormatter, MergeLogFormatter, MoveLogFormatter, PatrolLogFormatter, ProtectLogFormatter, RightsLogFormatter, and UploadLogFormatter.
Definition at line 834 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 704 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 211 of file LogFormatter.php.
References getActionText().
Referenced by getIRCActionText().
LogFormatter::getPreloadTitles | ( | ) |
Stable to override.
Reimplemented in BlockLogFormatter, MergeLogFormatter, MoveLogFormatter, NewUsersLogFormatter, and ProtectLogFormatter.
Definition at line 814 of file LogFormatter.php.
|
protected |
Helper method for displaying restricted element.
string | $message |
Definition at line 744 of file LogFormatter.php.
References $content, and msg().
Referenced by getActionText(), getComment(), and getPerformerElement().
|
protected |
Helper to make a link to the page, taking the plaintext value in consideration.
Stable to override
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 678 of file LogFormatter.php.
References $title, getLinkRenderer(), and msg().
Referenced by formatParameterValue(), BlockLogFormatter\getMessageParameters(), getMessageParameters(), MergeLogFormatter\getMessageParameters(), MoveLogFormatter\getMessageParameters(), and ProtectLogFormatter\getMessageParameters().
|
protected |
User | $user | |
int | $toolFlags | Combination of Linker::TOOL_LINKS_* flags |
Definition at line 785 of file LogFormatter.php.
References User\getEditCount(), User\getId(), User\getName(), Linker\userLink(), and Linker\userToolLinks().
Referenced by formatParameterValue(), BlockLogFormatter\getMessageParameters(), NewUsersLogFormatter\getMessageParameters(), and getPerformerElement().
|
protected |
Shortcut for wfMessage which honors local context.
string | $key | |
mixed | ...$params |
Definition at line 775 of file LogFormatter.php.
Referenced by formatParameterValue(), formatParameterValueForApi(), RightsLogFormatter\formatRightsList(), BlockLogFormatter\getActionLinks(), ContentModelLogFormatter\getActionLinks(), DeleteLogFormatter\getActionLinks(), MergeLogFormatter\getActionLinks(), MoveLogFormatter\getActionLinks(), ProtectLogFormatter\getActionLinks(), LegacyLogFormatter\getActionMessage(), getActionMessage(), getActionText(), BlockLogFormatter\getMessageParameters(), DeleteLogFormatter\getMessageParameters(), PageLangLogFormatter\getMessageParameters(), RightsLogFormatter\getMessageParameters(), getRestrictedElement(), and makePageLink().
|
static |
Constructs a new formatter suitable for given entry.
LogEntry | $entry |
Definition at line 52 of file LogFormatter.php.
References $entry, $wgLogActionsHandlers, LogEntryBase\getFullType(), and LogEntry\getType().
Referenced by LogPage\addEntry(), ContentModelChange\doContentModelChange(), ApiQueryLogEvents\extractRowInfo(), RevDelLogItem\getApiData(), ManualLogEntry\getRecentChange(), LogEventsList\logLine(), MovePage\moveToInternal(), and newFromRow().
|
static |
Handy shortcut for constructing a formatter directly from database row.
stdClass | array | $row |
Definition at line 72 of file LogFormatter.php.
References newFromEntry().
Referenced by 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 157 of file LogFormatter.php.
References $audience, FOR_PUBLIC, and FOR_THIS_USER.
LogFormatter::setContext | ( | IContextSource | $context | ) |
Replace the default context.
IContextSource | $context |
Definition at line 127 of file LogFormatter.php.
References $context.
LogFormatter::setLinkRenderer | ( | LinkRenderer | $linkRenderer | ) |
LinkRenderer | $linkRenderer |
Definition at line 135 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 199 of file LogFormatter.php.
Referenced by formatParameterValue().
|
protected |
Helper method for styling restricted element.
string | $content |
Definition at line 760 of file LogFormatter.php.
References $content.
Referenced by getActionText(), getComment(), and getPerformerElement().
|
protected |
Constant for handling log_deleted.
Definition at line 82 of file LogFormatter.php.
Referenced by setAudience().
IContextSource LogFormatter::$context |
|
protected |
Definition at line 79 of file LogFormatter.php.
Referenced by __construct(), extractParameters(), LegacyLogFormatter\getActionMessage(), getIRCActionText(), getMessageParameters(), BlockLogFormatter\getParametersForApi(), DeleteLogFormatter\getParametersForApi(), MergeLogFormatter\getParametersForApi(), MoveLogFormatter\getParametersForApi(), PatrolLogFormatter\getParametersForApi(), ProtectLogFormatter\getParametersForApi(), RightsLogFormatter\getParametersForApi(), UploadLogFormatter\getParametersForApi(), and newFromEntry().
|
protected |
Definition at line 100 of file LogFormatter.php.
|
protected |
Whether to output user tool links.
Definition at line 88 of file LogFormatter.php.
Referenced by formatParameterValue().
|
private |
Definition at line 105 of file LogFormatter.php.
Referenced by BlockLogFormatter\getActionLinks(), DeleteLogFormatter\getActionLinks(), ProtectLogFormatter\getActionLinks(), getLinkRenderer(), and setLinkRenderer().
|
protected |
Definition at line 111 of file LogFormatter.php.
Referenced by getMessageParameters().
|
protected |
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 97 of file LogFormatter.php.
const LogFormatter::FOR_PUBLIC = 1 |
Definition at line 42 of file LogFormatter.php.
Referenced by setAudience().
const LogFormatter::FOR_THIS_USER = 2 |
Definition at line 43 of file LogFormatter.php.
Referenced by ChangeTagsLogItem\getHTML(), RevDelLogItem\getHTML(), and setAudience().