/**
* Constructs a new formatter suitable for given entry.
- * @param $entry LogEntry
+ * @param LogEntry $entry
* @return LogFormatter
*/
public static function newFromEntry( LogEntry $entry ) {
// Nonstatic->
- /// @var LogEntry
+ /** @var LogEntryBase */
protected $entry;
/// Integer constant for handling log_deleted
* 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.
- * @var boolean
+ * @var string
*/
protected $plaintext = false;
+ /** @var string */
protected $irctext = false;
protected function __construct( LogEntry $entry ) {
/**
* Replace the default context
- * @param $context IContextSource
+ * @param IContextSource $context
*/
public function setContext( IContextSource $context ) {
$this->context = $context;
* 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.
- * @param $audience integer self::FOR_THIS_USER or self::FOR_PUBLIC
+ * @param int $audience self::FOR_THIS_USER or self::FOR_PUBLIC
*/
public function setAudience( $audience ) {
$this->audience = ( $audience == self::FOR_THIS_USER )
/**
* Check if a log item can be displayed
- * @param $field integer LogPage::DELETED_* constant
+ * @param int $field LogPage::DELETED_* constant
* @return bool
*/
protected function canView( $field ) {
* If set to true, will produce user tool links after
* the user name. This should be replaced with generic
* CSS/JS solution.
- * @param $value boolean
+ * @param bool $value
*/
public function setShowUserToolLinks( $value ) {
$this->linkFlood = $value;
* Usually you also want to set extraneous request context
* to avoid formatting for any particular user.
* @see getActionText()
- * @return string text
+ * @return string Plain text
*/
public function getPlainActionText() {
$this->plaintext = true;
$text = $this->getActionText();
$this->plaintext = false;
+
return $text;
}
// Text of title the action is aimed at.
$target = $entry->getTarget()->getPrefixedText();
$text = null;
- switch( $entry->getType() ) {
+ switch ( $entry->getType() ) {
case 'move':
- switch( $entry->getSubtype() ) {
+ switch ( $entry->getSubtype() ) {
case 'move':
$movesource = $parameters['4::target'];
$text = wfMessage( '1movedto2' )
break;
case 'delete':
- switch( $entry->getSubtype() ) {
+ switch ( $entry->getSubtype() ) {
case 'delete':
$text = wfMessage( 'deletedarticle' )
->rawParams( $target )->inContentLanguage()->escaped();
$text = wfMessage( 'undeletedarticle' )
->rawParams( $target )->inContentLanguage()->escaped();
break;
+ // @codingStandardsIgnoreStart Long line
//case 'revision': // Revision deletion
//case 'event': // Log deletion
- // see https://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/LogPage.php?&pathrev=97044&r1=97043&r2=97044
+ // see https://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/LogPage.php?&pathrev=97044&r1=97043&r2=97044
//default:
+ // @codingStandardsIgnoreEnd
}
break;
case 'patrol':
+ // @codingStandardsIgnoreStart Long line
// https://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/PatrolLog.php?&pathrev=97495&r1=97494&r2=97495
+ // @codingStandardsIgnoreEnd
// Create a diff link to the patrolled revision
if ( $entry->getSubtype() === 'patrol' ) {
$diffLink = htmlspecialchars(
break;
case 'protect':
- switch( $entry->getSubtype() ) {
- case 'protect':
- $text = wfMessage( 'protectedarticle' )
- ->rawParams( $target . ' ' . $parameters[0] )->inContentLanguage()->escaped();
- break;
- case 'unprotect':
- $text = wfMessage( 'unprotectedarticle' )
- ->rawParams( $target )->inContentLanguage()->escaped();
- break;
- case 'modify':
- $text = wfMessage( 'modifiedarticleprotection' )
- ->rawParams( $target . ' ' . $parameters[0] )->inContentLanguage()->escaped();
- break;
+ switch ( $entry->getSubtype() ) {
+ case 'protect':
+ $text = wfMessage( 'protectedarticle' )
+ ->rawParams( $target . ' ' . $parameters[0] )->inContentLanguage()->escaped();
+ break;
+ case 'unprotect':
+ $text = wfMessage( 'unprotectedarticle' )
+ ->rawParams( $target )->inContentLanguage()->escaped();
+ break;
+ case 'modify':
+ $text = wfMessage( 'modifiedarticleprotection' )
+ ->rawParams( $target . ' ' . $parameters[0] )->inContentLanguage()->escaped();
+ break;
}
break;
case 'newusers':
- switch( $entry->getSubtype() ) {
+ switch ( $entry->getSubtype() ) {
case 'newusers':
case 'create':
$text = wfMessage( 'newuserlog-create-entry' )
break;
case 'upload':
- switch( $entry->getSubtype() ) {
+ switch ( $entry->getSubtype() ) {
case 'upload':
$text = wfMessage( 'uploadedimage' )
->rawParams( $target )->inContentLanguage()->escaped();
} else {
$newgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
}
- switch( $entry->getSubtype() ) {
+ switch ( $entry->getSubtype() ) {
case 'rights':
$text = wfMessage( 'rightslogentry' )
->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
break;
}
break;
-
- // case 'suppress' --private log -- aaron (sign your messages so we know who to blame in a few years :-D)
+ // case 'suppress' --private log -- aaron (so we know who to blame in a few years :-D)
// default:
}
if ( is_null( $text ) ) {
$this->plaintext = false;
$this->irctext = false;
+
return $text;
}
/**
* 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.
- * @return Message|string pre-escaped html
+ * and entries might return pre-escaped HTML string.
+ * @return Message|string Pre-escaped HTML
*/
protected function getActionMessage() {
$message = $this->msg( $this->getMessageKey() );
$message->params( $this->getMessageParameters() );
+
return $message;
}
* 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.
- * @return string message key
+ * @return string Message key
*/
protected function getMessageKey() {
$type = $this->entry->getType();
}
}
}
+
return $params;
}
// Bad things happens if the numbers are not in correct order
ksort( $params );
+
return $this->parsedParameters = $params;
}
* * number: Format value as number
* @param string $value The parameter value that should
* be formated
- * @return string or Message::numParam or Message::rawParam
+ * @return string|Message::numParam|Message::rawParam
* Formated value
* @since 1.21
*/
protected function formatParameterValue( $type, $value ) {
$saveLinkFlood = $this->linkFlood;
- switch( strtolower( trim( $type ) ) ) {
+ switch ( strtolower( trim( $type ) ) ) {
case 'raw':
$value = Message::rawParam( $value );
break;
/**
* Helper to make a link to the page, taking the plaintext
* value in consideration.
- * @param $title Title the page
- * @param array $parameters query parameters
+ * @param Title $title The page
+ * @param array $parameters Query parameters
* @throws MWException
- * @return String
+ * @return string
*/
protected function makePageLink( Title $title = null, $parameters = array() ) {
if ( !$this->plaintext ) {
}
$link = '[[' . $title->getPrefixedText() . ']]';
}
+
return $link;
}
* 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.
- * @return String
+ * @return string
*/
public function getPerformerElement() {
if ( $this->canView( LogPage::DELETED_USER ) ) {
/**
* Helper method for displaying restricted element.
- * @param $message string
- * @return string HTML or wikitext
+ * @param string $message
+ * @return string HTML or wiki text
*/
protected function getRestrictedElement( $message ) {
if ( $this->plaintext ) {
$content = $this->msg( $message )->escaped();
$attribs = array( 'class' => 'history-deleted' );
+
return Html::rawElement( 'span', $attribs, $content );
}
/**
* Helper method for styling restricted element.
- * @param $content string
- * @return string HTML or wikitext
+ * @param string $content
+ * @return string HTML or wiki text
*/
protected function styleRestricedElement( $content ) {
if ( $this->plaintext ) {
return $content;
}
$attribs = array( 'class' => 'history-deleted' );
+
return Html::rawElement( 'span', $attribs, $content );
}
/**
* Shortcut for wfMessage which honors local context.
- * @todo Would it be better to require replacing the global context instead?
- * @param $key string
+ * @param string $key
* @return Message
*/
protected function msg( $key ) {
);
}
}
+
return $element;
}
/**
- * @return Array of titles that should be preloaded with LinkBatch.
+ * @return array of titles that should be preloaded with LinkBatch.
*/
public function getPreloadTitles() {
return array();
}
/**
- * @return Output of getMessageParameters() for testing
+ * @return array Output of getMessageParameters() for testing
*/
public function getMessageParametersForTesting() {
// This function was added because getMessageParameters() is
// problems with extensions
return $this->getMessageParameters();
}
-
}
/**
* @since 1.19
*/
class LegacyLogFormatter extends LogFormatter {
-
/**
* Backward compatibility for extension changing the comment from
* the LogLine hook. This will be set by the first call on getComment(),
$subtype = $this->entry->getSubtype();
// Show unblock/change block link
- if ( ( $type == 'block' || $type == 'suppress' ) && ( $subtype == 'block' || $subtype == 'reblock' ) ) {
+ if ( ( $type == 'block' || $type == 'suppress' )
+ && ( $subtype == 'block' || $subtype == 'reblock' )
+ ) {
if ( !$this->context->getUser()->isAllowed( 'block' ) ) {
return '';
}
$this->msg( 'change-blocklink' )->escaped()
)
);
+
return $this->msg( 'parentheses' )->rawParams(
$this->context->getLanguage()->pipeList( $links ) )->escaped();
// Show change protection link
- } elseif ( $type == 'protect' && ( $subtype == 'protect' || $subtype == 'modify' || $subtype == 'unprotect' ) ) {
+ } elseif ( $type == 'protect'
+ && ( $subtype == 'protect' || $subtype == 'modify' || $subtype == 'unprotect' )
+ ) {
$links = array(
Linker::link( $title,
$this->msg( 'hist' )->escaped(),
array( 'action' => 'protect' )
);
}
+
return $this->msg( 'parentheses' )->rawParams(
$this->context->getLanguage()->pipeList( $links ) )->escaped();
// Show unmerge link
'mergepoint' => $params[4]
)
);
+
return $this->msg( 'parentheses' )->rawParams( $revert )->escaped();
}
return $this->revert;
}
}
-