MediaWiki master
|
Implements the default log formatting. More...
Inherited by BlockLogFormatter, ContentModelLogFormatter, DeleteLogFormatter, ImportLogFormatter, InterwikiLogFormatter, LegacyLogFormatter, MergeLogFormatter, MoveLogFormatter, NewUsersLogFormatter, PageLangLogFormatter, PatrolLogFormatter, ProtectLogFormatter, RenameuserLogFormatter, RightsLogFormatter, TagLogFormatter, UploadLogFormatter, and WikitextLogFormatter.
Public Member Functions | |
__construct (LogEntry $entry) | |
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. | |
getCommentFormatter () | |
getContentLanguage () | |
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 () | |
getUserEditTracker () | |
setAudience ( $audience) | |
Set the visibility restrictions for displaying content. | |
setCommentFormatter (CommentFormatter $commentFormatter) | |
setContentLanguage (Language $contentLanguage) | |
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. | |
setUserEditTracker (UserEditTracker $userEditTracker) | |
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 | |
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 intended 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 (UserIdentity $user, $toolFlags=0) | |
msg ( $key,... $params) | |
Shortcut for wfMessage which honors local context. | |
styleRestrictedElement ( $content) | |
Helper method for styling restricted element. | |
Protected Attributes | |
int | $audience = self::FOR_PUBLIC |
Constant for handling log_deleted. | |
LogEntryBase | $entry |
bool | $irctext = false |
bool | $linkFlood = false |
Whether to output user tool links. | |
array null | $parsedParameters |
bool | $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. | |
Implements the default log formatting.
Can be overridden by subclassing and setting:
Definition at line 59 of file LogFormatter.php.
LogFormatter::__construct | ( | LogEntry | $entry | ) |
|
protected |
Check if a log item can be displayed.
int | $field | LogPage::DELETED_* constant |
Definition at line 265 of file LogFormatter.php.
LogFormatter::canViewLogType | ( | ) |
Check if a log item type can be displayed.
Definition at line 251 of file LogFormatter.php.
|
protected |
Extracts the optional extra parameters for use in action messages.
The array indexes start from number 3.
Reimplemented in BlockLogFormatter.
Definition at line 605 of file LogFormatter.php.
References $params.
Referenced by ContentModelLogFormatter\getActionLinks(), DeleteLogFormatter\getActionLinks(), MergeLogFormatter\getActionLinks(), MoveLogFormatter\getActionLinks(), ImportLogFormatter\getMessageKey(), MoveLogFormatter\getMessageKey(), ProtectLogFormatter\getMessageKey(), RenameuserLogFormatter\getMessageKey(), 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 BlockLogFormatter, DeleteLogFormatter, ProtectLogFormatter, and RightsLogFormatter.
Definition at line 945 of file LogFormatter.php.
References 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 704 of file LogFormatter.php.
|
protected |
Format a single parameter value for API output.
string | $name | |
string | $type | |
string | $value |
Definition at line 975 of file LogFormatter.php.
References wfTimestamp().
Referenced by BlockLogFormatter\formatParametersForApi().
LogFormatter::getActionLinks | ( | ) |
Returns extra links that comes after the action text, like "revert", etc.
Reimplemented in BlockLogFormatter, ContentModelLogFormatter, DeleteLogFormatter, LegacyLogFormatter, MergeLogFormatter, MoveLogFormatter, and ProtectLogFormatter.
Definition at line 595 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 567 of file LogFormatter.php.
LogFormatter::getActionText | ( | ) |
Gets the log action, including username.
Definition at line 542 of file LogFormatter.php.
LogFormatter::getComment | ( | ) |
Gets the user provided comment.
Reimplemented in LegacyLogFormatter, and NewUsersLogFormatter.
Definition at line 811 of file LogFormatter.php.
|
final |
Definition at line 206 of file LogFormatter.php.
References wfDeprecated().
|
final |
Definition at line 185 of file LogFormatter.php.
References wfDeprecated().
Referenced by ProtectLogFormatter\formatParametersForApi(), and RightsLogFormatter\makePageLink().
LogFormatter::getIRCActionComment | ( | ) |
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
Definition at line 307 of file LogFormatter.php.
References wfMessage().
LogFormatter::getIRCActionText | ( | ) |
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
Definition at line 329 of file LogFormatter.php.
References wfMessage(), and wfTimestamp().
LogFormatter::getLinkRenderer | ( | ) |
Definition at line 163 of file LogFormatter.php.
References wfDeprecated().
Referenced by BlockLogFormatter\getActionLinks(), ContentModelLogFormatter\getActionLinks(), DeleteLogFormatter\getActionLinks(), MergeLogFormatter\getActionLinks(), MoveLogFormatter\getActionLinks(), ProtectLogFormatter\getActionLinks(), PatrolLogFormatter\getMessageParameters(), TagLogFormatter\getMessageParameters(), 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, DeleteLogFormatter, ImportLogFormatter, MoveLogFormatter, PatrolLogFormatter, ProtectLogFormatter, RenameuserLogFormatter, RightsLogFormatter, and TagLogFormatter.
Definition at line 582 of file LogFormatter.php.
|
protected |
Formats parameters intended for action message from array of all parameters.
There are three hardcoded parameters:
The parameters are returned as a non-associative array that can be passed to Message::params(), so $logFormatter->getMessageParameters()[0] is the $1 parameter in the message and so on.
Reimplemented in BlockLogFormatter, ContentModelLogFormatter, DeleteLogFormatter, InterwikiLogFormatter, MergeLogFormatter, MoveLogFormatter, NewUsersLogFormatter, PageLangLogFormatter, PatrolLogFormatter, ProtectLogFormatter, RenameuserLogFormatter, RightsLogFormatter, and TagLogFormatter.
Definition at line 660 of file LogFormatter.php.
References $params.
LogFormatter::getMessageParametersForTesting | ( | ) |
Definition at line 913 of file LogFormatter.php.
|
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 926 of file LogFormatter.php.
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 792 of file LogFormatter.php.
Referenced by LegacyLogFormatter\getActionMessage().
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 293 of file LogFormatter.php.
LogFormatter::getPreloadTitles | ( | ) |
Reimplemented in BlockLogFormatter, MergeLogFormatter, MoveLogFormatter, NewUsersLogFormatter, ProtectLogFormatter, and RenameuserLogFormatter.
Definition at line 906 of file LogFormatter.php.
|
protected |
Helper method for displaying restricted element.
string | $message |
Definition at line 833 of file LogFormatter.php.
|
final |
Definition at line 227 of file LogFormatter.php.
References wfDeprecated().
|
protected |
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 766 of file LogFormatter.php.
Referenced by BlockLogFormatter\getMessageParameters(), MergeLogFormatter\getMessageParameters(), MoveLogFormatter\getMessageParameters(), and ProtectLogFormatter\getMessageParameters().
|
protected |
UserIdentity | $user | |
int | $toolFlags | Combination of Linker::TOOL_LINKS_* flags |
Definition at line 876 of file LogFormatter.php.
References MediaWiki\User\UserIdentity\getId(), and MediaWiki\User\UserIdentity\getName().
Referenced by BlockLogFormatter\getMessageParameters(), and NewUsersLogFormatter\getMessageParameters().
|
protected |
Shortcut for wfMessage which honors local context.
string | $key | @phpcs:ignore Generic.Files.LineLength |
MessageParam|MessageSpecifier|string|int|float|list<MessageParam|MessageSpecifier|string|int|float> | ...$params See Message::params() |
Definition at line 866 of file LogFormatter.php.
References $params.
Referenced by RightsLogFormatter\formatChangesToGroups(), BlockLogFormatter\getActionLinks(), ContentModelLogFormatter\getActionLinks(), DeleteLogFormatter\getActionLinks(), MergeLogFormatter\getActionLinks(), MoveLogFormatter\getActionLinks(), ProtectLogFormatter\getActionLinks(), LegacyLogFormatter\getActionMessage(), BlockLogFormatter\getMessageParameters(), DeleteLogFormatter\getMessageParameters(), PageLangLogFormatter\getMessageParameters(), and RightsLogFormatter\getMessageParameters().
|
static |
Constructs a new formatter suitable for given entry.
LogEntry | $entry |
Definition at line 72 of file LogFormatter.php.
References wfDeprecated().
|
static |
Handy shortcut for constructing a formatter directly from database row.
stdClass | array | $row |
Definition at line 85 of file LogFormatter.php.
References wfDeprecated().
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 241 of file LogFormatter.php.
|
final |
CommentFormatter | $commentFormatter |
Definition at line 198 of file LogFormatter.php.
|
final |
Language | $contentLanguage |
Definition at line 177 of file LogFormatter.php.
LogFormatter::setContext | ( | IContextSource | $context | ) |
Replace the default context.
Definition at line 147 of file LogFormatter.php.
LogFormatter::setLinkRenderer | ( | LinkRenderer | $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 281 of file LogFormatter.php.
|
final |
UserEditTracker | $userEditTracker |
Definition at line 219 of file LogFormatter.php.
|
protected |
Helper method for styling restricted element.
string | $content |
Definition at line 846 of file LogFormatter.php.
|
protected |
Constant for handling log_deleted.
Definition at line 96 of file LogFormatter.php.
IContextSource LogFormatter::$context |
Context for logging.
Definition at line 99 of file LogFormatter.php.
|
protected |
Definition at line 93 of file LogFormatter.php.
Referenced by LegacyLogFormatter\__construct(), PageLangLogFormatter\__construct(), LegacyLogFormatter\getActionMessage(), BlockLogFormatter\getParametersForApi(), DeleteLogFormatter\getParametersForApi(), MergeLogFormatter\getParametersForApi(), MoveLogFormatter\getParametersForApi(), PatrolLogFormatter\getParametersForApi(), ProtectLogFormatter\getParametersForApi(), RightsLogFormatter\getParametersForApi(), and UploadLogFormatter\getParametersForApi().
|
protected |
Definition at line 114 of file LogFormatter.php.
|
protected |
Whether to output user tool links.
Definition at line 102 of file LogFormatter.php.
|
protected |
Definition at line 132 of file LogFormatter.php.
|
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 111 of file LogFormatter.php.
const LogFormatter::FOR_PUBLIC = 1 |
Definition at line 61 of file LogFormatter.php.
const LogFormatter::FOR_THIS_USER = 2 |
Definition at line 62 of file LogFormatter.php.