* Also preferably pass a Language object instead of a Skin one or boolean indicating whether it's for content. No other calls to these methods in core or extensions.
$hideVal = 1 - intval($val);
$query[$queryKey] = $hideVal;
- $link = $this->skin->link(
+ $link = Linker::link(
$this->getDisplayTitle(),
$messages[$hideVal],
array(),
$userLinks = '<span class="history-deleted">' .
wfMsgHtml( 'rev-deleted-user' ) . '</span>';
} else {
- $userLinks = $this->skin->userLink( $row->log_user, $row->user_name );
+ $userLinks = Linker::userLink( $row->log_user, $row->user_name );
// Talk|Contribs links...
if( !( $this->flags & self::NO_EXTRA_USER_LINKS ) ) {
- $userLinks .= $this->skin->userToolLinks(
+ $userLinks .= Linker::userToolLinks(
$row->log_user, $row->user_name, true, 0, $row->user_editcount );
}
}
} else {
global $wgLang;
$comment = $wgLang->getDirMark() .
- $this->skin->commentBlock( $row->log_comment );
+ Linker::commentBlock( $row->log_comment );
}
return $comment;
}
if( self::typeAction( $row, 'move', 'move', 'move' ) && !empty( $paramArray[0] ) ) {
$destTitle = Title::newFromText( $paramArray[0] );
if( $destTitle ) {
- $revert = '(' . $this->skin->link(
+ $revert = '(' . Linker::link(
SpecialPage::getTitleFor( 'Movepage' ),
$this->message['revertmove'],
array(),
} else {
$viewdeleted = $this->message['undeletelink'];
}
- $revert = '(' . $this->skin->link(
+ $revert = '(' . Linker::link(
SpecialPage::getTitleFor( 'Undelete' ),
$viewdeleted,
array(),
// Show unblock/change block link
} elseif( self::typeAction( $row, array( 'block', 'suppress' ), array( 'block', 'reblock' ), 'block' ) ) {
$revert = '(' .
- $this->skin->link(
+ Linker::link(
SpecialPage::getTitleFor( 'Unblock', $row->log_title ),
$this->message['unblocklink'],
array(),
'known'
) .
$this->message['pipe-separator'] .
- $this->skin->link(
+ Linker::link(
SpecialPage::getTitleFor( 'Block', $row->log_title ),
$this->message['change-blocklink'],
array(),
// Show change protection link
} elseif( self::typeAction( $row, 'protect', array( 'modify', 'protect', 'unprotect' ) ) ) {
$revert .= ' (' .
- $this->skin->link( $title,
+ Linker::link( $title,
$this->message['hist'],
array(),
array(
);
if( $wgUser->isAllowed( 'protect' ) ) {
$revert .= $this->message['pipe-separator'] .
- $this->skin->link( $title,
+ Linker::link( $title,
$this->message['protect_change'],
array(),
array( 'action' => 'protect' ),
$revert .= ')';
// Show unmerge link
} elseif( self::typeAction( $row, 'merge', 'merge', 'mergehistory' ) ) {
- $revert = '(' . $this->skin->link(
+ $revert = '(' . Linker::link(
SpecialPage::getTitleFor( 'MergeHistory' ),
$this->message['revertmerge'],
array(),
// $paramArray[1] is a CSV of the IDs
$query = $paramArray[0];
// Link to each hidden object ID, $paramArray[1] is the url param
- $revert = '(' . $this->skin->link(
+ $revert = '(' . Linker::link(
$revdel,
$this->message['revdel-restore'],
array(),
// Self-created users
} elseif( self::typeAction( $row, 'newusers', 'create2' ) ) {
if( isset( $paramArray[0] ) ) {
- $revert = $this->skin->userToolLinks( $paramArray[0], $title->getDBkey(), true );
+ $revert = Linker::userToolLinks( $paramArray[0], $title->getDBkey(), true );
} else {
# Fall back to a blue contributions link
- $revert = $this->skin->userToolLinks( 1, $title->getDBkey() );
+ $revert = Linker::userToolLinks( 1, $title->getDBkey() );
}
if( wfTimestamp( TS_MW, $row->log_timestamp ) < '20080129000000' ) {
# Suppress $comment from old entries (before 2008-01-29),
$canHide = $wgUser->isAllowed( 'deleterevision' );
// If event was hidden from sysops
if( !self::userCan( $row, LogPage::DELETED_RESTRICTED ) ) {
- $del = $this->skin->revDeleteLinkDisabled( $canHide );
+ $del = Linker::revDeleteLinkDisabled( $canHide );
} else {
$target = SpecialPage::getTitleFor( 'Log', $row->log_type );
$query = array(
'type' => 'logging',
'ids' => $row->log_id,
);
- $del = $this->skin->revDeleteLink( $query,
+ $del = Linker::revDeleteLink( $query,
self::isDeleted( $row, LogPage::DELETED_RESTRICTED ), $canHide );
}
}
# If there is exactly one log type, we can link to Special:Log?type=foo
if ( count( $types ) == 1 )
$urlParam['type'] = $types[0];
- $s .= $wgUser->getSkin()->link(
+ $s .= Linker::link(
SpecialPage::getTitleFor( 'Log' ),
wfMsgHtml( 'log-fulllog' ),
array(),
{
global $wgLang, $wgContLang, $wgLogActions;
+ if ( is_null( $skin ) ) {
+ $langObj = $wgContLang;
+ $langObjOrNull = null;
+ } else {
+ $langObj = $wgLang;
+ $langObjOrNull = $wgLang;
+ }
+
$key = "$type/$action";
# Defer patrol log to PatrolLog class
if( $key == 'patrol/patrol' ) {
- return PatrolLog::makeActionText( $title, $params, $skin );
+ return PatrolLog::makeActionText( $title, $params, $langObjOrNull );
}
if( isset( $wgLogActions[$key] ) ) {
if( is_null( $title ) ) {
- $rv = wfMsgHtml( $wgLogActions[$key] );
+ $rv = wfMsgExt( $wgLogActions[$key], array( 'parsemag', 'escape', 'language' => $langObj ) );
} else {
- $titleLink = self::getTitleLink( $type, $skin, $title, $params );
+ $titleLink = self::getTitleLink( $type, $langObjOrNull, $title, $params );
if( preg_match( '/^rights\/(rights|autopromote)/', $key ) ) {
+ $rightsnone = wfMsgExt( 'rightsnone', array( 'parsemag', 'language' => $langObj ) );
if( $skin ) {
- $rightsnone = wfMsg( 'rightsnone' );
foreach ( $params as &$param ) {
$groupArray = array_map( 'trim', explode( ',', $param ) );
$groupArray = array_map( array( 'User', 'getGroupMember' ), $groupArray );
$param = $wgLang->listToText( $groupArray );
}
- } else {
- $rightsnone = wfMsgForContent( 'rightsnone' );
}
if( !isset( $params[0] ) || trim( $params[0] ) == '' ) {
$params[0] = $rightsnone;
}
}
if( count( $params ) == 0 ) {
- if ( $skin ) {
- $rv = wfMsgHtml( $wgLogActions[$key], $titleLink );
- } else {
- $rv = wfMsgExt( $wgLogActions[$key], array( 'parsemag', 'escape', 'replaceafter', 'content' ), $titleLink );
- }
+ $rv = wfMsgExt( $wgLogActions[$key], array( 'parsemag', 'escape', 'replaceafter', 'language' => $langObj ), $titleLink );
} else {
$details = '';
array_unshift( $params, $titleLink );
$params[1] = $wgContLang->translateBlockExpiry( $params[1] );
}
$params[2] = isset( $params[2] ) ?
- self::formatBlockFlags( $params[2], is_null( $skin ) ) : '';
+ self::formatBlockFlags( $params[2], $langObj ) : '';
// Page protections
} elseif ( $type == 'protect' && count($params) == 3 ) {
}
// Cascading flag...
if( $params[2] ) {
- if ( $skin ) {
- $details .= ' [' . wfMsg( 'protect-summary-cascade' ) . ']';
- } else {
- $details .= ' [' . wfMsgForContent( 'protect-summary-cascade' ) . ']';
- }
+ $details .= ' [' . wfMsgExt( 'protect-summary-cascade', array( 'parsemag', 'language' => $langObj ) ) . ']';
}
// Page moves
} elseif ( $type == 'move' && count( $params ) == 3 ) {
if( $params[2] ) {
- if ( $skin ) {
- $details .= ' [' . wfMsg( 'move-redirect-suppressed' ) . ']';
- } else {
- $details .= ' [' . wfMsgForContent( 'move-redirect-suppressed' ) . ']';
- }
+ $details .= ' [' . wfMsgExt( 'move-redirect-suppressed', array( 'parsemag', 'language' => $langObj ) ) . ']';
}
// Revision deletion
$count = substr_count( $params[2], ',' ) + 1; // revisions
$ofield = intval( substr( $params[3], 7 ) ); // <ofield=x>
$nfield = intval( substr( $params[4], 7 ) ); // <nfield=x>
- $details .= ': ' . RevisionDeleter::getLogMessage( $count, $nfield, $ofield, false, is_null( $skin ) );
+ $details .= ': ' . RevisionDeleter::getLogMessage( $count, $nfield, $ofield, $langObj, false );
// Log deletion
} elseif ( preg_match( '/^(delete|suppress)\/event$/', $key ) && count( $params ) == 4 ) {
$count = substr_count( $params[1], ',' ) + 1; // log items
$ofield = intval( substr( $params[2], 7 ) ); // <ofield=x>
$nfield = intval( substr( $params[3], 7 ) ); // <nfield=x>
- $details .= ': ' . RevisionDeleter::getLogMessage( $count, $nfield, $ofield, true, is_null( $skin ) );
+ $details .= ': ' . RevisionDeleter::getLogMessage( $count, $nfield, $ofield, $langObj, true );
}
- if ( $skin ) {
- $rv = wfMsgHtml( $wgLogActions[$key], $params ) . $details;
- } else {
- $rv = wfMsgExt( $wgLogActions[$key], array( 'parsemag', 'escape', 'replaceafter', 'content' ), $params ) . $details;
- }
+ $rv = wfMsgExt( $wgLogActions[$key], array( 'parsemag', 'escape', 'replaceafter', 'language' => $langObj ), $params ) . $details;
}
}
} else {
/**
* TODO document
* @param $type String
- * @param $skin Skin
+ * @param $lang Language or null
* @param $title Title
* @param $params Array
* @return String
*/
- protected static function getTitleLink( $type, $skin, $title, &$params ) {
- global $wgLang, $wgContLang, $wgUserrightsInterwikiDelimiter;
- if( !$skin ) {
+ protected static function getTitleLink( $type, $lang, $title, &$params ) {
+ global $wgContLang, $wgUserrightsInterwikiDelimiter;
+ if( !$lang ) {
return $title->getPrefixedText();
}
switch( $type ) {
Title::newFromText( $params[0] ),
htmlspecialchars( $params[0] )
);
- $params[1] = $wgLang->timeanddate( $params[1] );
+ $params[1] = $lang->timeanddate( $params[1] );
break;
default:
if( $title->getNamespace() == NS_SPECIAL ) {
* into a more readable (and translated) form
*
* @param $flags Flags to format
- * @param $forContent Whether to localize the message depending of the user
- * language
+ * @param $lang Language object to use
* @return String
*/
- public static function formatBlockFlags( $flags, $forContent = false ) {
- global $wgLang;
-
+ public static function formatBlockFlags( $flags, $lang ) {
$flags = explode( ',', trim( $flags ) );
if( count( $flags ) > 0 ) {
for( $i = 0; $i < count( $flags ); $i++ ) {
- $flags[$i] = self::formatBlockFlag( $flags[$i], $forContent );
+ $flags[$i] = self::formatBlockFlag( $flags[$i], $lang );
}
- return '(' . $wgLang->commaList( $flags ) . ')';
+ return '(' . $lang->commaList( $flags ) . ')';
} else {
return '';
}
* Translate a block log flag if possible
*
* @param $flag int Flag to translate
- * @param $forContent Whether to localize the message depending of the user
- * language
+ * @param $lang Language object to use
* @return String
*/
- public static function formatBlockFlag( $flag, $forContent = false ) {
+ public static function formatBlockFlag( $flag, $lang ) {
static $messages = array();
if( !isset( $messages[$flag] ) ) {
$messages[$flag] = htmlspecialchars( $flag ); // Fallback
- $msg = wfMessage( 'block-log-flags-' . $flag );
- if ( $forContent ) {
- $msg->inContentLanguage();
- }
+ $msg = wfMessage( 'block-log-flags-' . $flag )->inLanguage( $lang );
if ( $msg->exists() ) {
$messages[$flag] = $msg->escaped();
}
*
* @param $title Title of the page that was patrolled
* @param $params Array: log parameters (from logging.log_params)
- * @param $skin Skin to use for building links, etc.
+ * @param $lang Language object to use, or false
* @return String
*/
- public static function makeActionText( $title, $params, $skin ) {
- global $wgLang;
-
+ public static function makeActionText( $title, $params, $lang ) {
list( $cur, /* $prev */, $auto ) = $params;
- if( is_object( $skin ) ) {
+ if( is_object( $lang ) ) {
# Standard link to the page in question
- $link = $skin->link( $title );
+ $link = Linker::link( $title );
if( $title->exists() ) {
# Generate a diff link
$query = array(
'diff' => 'prev'
);
- $diff = $skin->link(
+ $diff = Linker::link(
$title,
- htmlspecialchars( wfMsg( 'patrol-log-diff', $wgLang->formatNum( $cur, true ) ) ),
+ htmlspecialchars( wfMsg( 'patrol-log-diff', $lang->formatNum( $cur, true ) ) ),
array(),
$query,
array( 'known', 'noclasses' )
* @param $count Integer: The number of effected revisions.
* @param $nbitfield Integer: The new bitfield for the revision.
* @param $obitfield Integer: The old bitfield for the revision.
+ * @param $language Language object to use
* @param $isForLog Boolean
- * @param $forContent Boolean
*/
- public static function getLogMessage( $count, $nbitfield, $obitfield, $isForLog = false, $forContent = false ) {
- global $wgLang, $wgContLang;
-
- $lang = $forContent ? $wgContLang : $wgLang;
- $msgFunc = $forContent ? "wfMsgForContent" : "wfMsg";
-
+ public static function getLogMessage( $count, $nbitfield, $obitfield, $language, $isForLog = false ) {
$changes = self::getChanges( $nbitfield, $obitfield );
- array_walk( $changes, array( __CLASS__, 'expandMessageArray' ), $forContent );
+ array_walk( $changes, array( __CLASS__, 'expandMessageArray' ), $language );
$changesText = array();
if( count( $changes[0] ) ) {
- $changesText[] = $msgFunc( 'revdelete-hid', $lang->commaList( $changes[0] ) );
+ $changesText[] = wfMsgExt( 'revdelete-hid', array( 'parsemag', 'language' => $language ), $language->commaList( $changes[0] ) );
}
if( count( $changes[1] ) ) {
- $changesText[] = $msgFunc( 'revdelete-unhid', $lang->commaList( $changes[1] ) );
+ $changesText[] = wfMsgExt( 'revdelete-unhid', array( 'parsemag', 'language' => $language ), $language->commaList( $changes[1] ) );
}
- $s = $lang->semicolonList( $changesText );
+ $s = $language->semicolonList( $changesText );
if( count( $changes[2] ) ) {
$s .= $s ? ' (' . $changes[2][0] . ')' : ' ' . $changes[2][0];
}
$msg = $isForLog ? 'logdelete-log-message' : 'revdelete-log-message';
- return wfMsgExt( $msg, $forContent ? array( 'parsemag', 'content' ) : array( 'parsemag' ), $s, $lang->formatNum($count) );
+ return wfMsgExt( $msg, array( 'parsemag', 'language' => $language ), $s, $language->formatNum($count) );
}
- private static function expandMessageArray(& $msg, $key, $forContent) {
+ private static function expandMessageArray( &$msg, $key, $language ) {
if ( is_array ( $msg ) ) {
- array_walk( $msg, array( __CLASS__, 'expandMessageArray' ), $forContent );
+ array_walk( $msg, array( __CLASS__, 'expandMessageArray' ), $language );
} else {
- if ( $forContent ) {
- $msg = wfMsgForContent($msg);
- } else {
- $msg = wfMsg($msg);
- }
+ $msg = wfMsgExt( $msg, array( 'parsemag', 'language' => $language ) );
}
}