private $out;
public $flags;
- function __construct( $skin, $out, $flags = 0 ) {
+ public function __construct( $skin, $out, $flags = 0 ) {
$this->skin = $skin;
$this->out = $out;
$this->flags = $flags;
private function preCacheMessages() {
// Precache various messages
if( !isset( $this->message ) ) {
- $messages = 'revertmerge protect_change unblocklink revertmove undeletelink revdel-restore rev-delundel hist';
- foreach( explode( ' ', $messages ) as $msg ) {
- $this->message[$msg] = wfMsgExt( $msg, array( 'escape') );
+ $messages = array( 'revertmerge', 'protect_change', 'unblocklink', 'change-blocklink',
+ 'revertmove', 'undeletelink', 'revdel-restore', 'rev-delundel', 'hist', 'pipe-separator' );
+ foreach( $messages as $msg ) {
+ $this->message[$msg] = wfMsgExt( $msg, array( 'escape' ) );
}
}
}
/**
* Set page title and show header for this log type
- * @param string $type
+ * @param $type String
*/
public function showHeader( $type ) {
if( LogPage::isLogType( $type ) ) {
$this->out->setPageTitle( LogPage::logName( $type ) );
- $this->out->addHtml( LogPage::logHeader( $type ) );
+ $this->out->addHTML( LogPage::logHeader( $type ) );
}
}
/**
* Show options for the log list
- * @param string $type,
- * @param string $user,
- * @param string $page,
- * @param string $pattern
- * @param int $year year
- * @param int $month month
- * @param bool $filter
+ * @param $type String
+ * @param $user String
+ * @param $page String
+ * @param $pattern String
+ * @param $year Integer: year
+ * @param $month Integer: month
+ * @param $filter Boolean
*/
public function showOptions( $type = '', $user = '', $page = '', $pattern = '', $year = '',
$month = '', $filter = null )
}
/**
- * @return string Formatted HTML
- * @param string $queryType
+ * @param $queryType String
+ * @return String: Formatted HTML
*/
private function getTypeMenu( $queryType ) {
global $wgLogRestrictions, $wgUser;
}
/**
- * @return string Formatted HTML
- * @param string $user
+ * @param $user String
+ * @return String: Formatted HTML
*/
private function getUserInput( $user ) {
return Xml::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'user', 15, $user );
}
/**
- * @return string Formatted HTML
- * @param string $title
+ * @param $title String
+ * @return String: Formatted HTML
*/
private function getTitleInput( $title ) {
return Xml::inputLabel( wfMsg( 'speciallogtitlelabel' ), 'page', 'page', 20, $title );
}
/**
+ * @param $year Integer
+ * @param $month Integer
* @return string Formatted HTML
- * @param int $year
- * @param int $month
*/
private function getDateMenu( $year, $month ) {
# Offset overrides year/month selection
return "</ul>\n";
}
- /**
- * @param Row $row a single row from the result set
- * @return string Formatted HTML list item
- * @private
+ /**
+ * @param $row Row: a single row from the result set
+ * @return String: Formatted HTML list item
*/
public function logLine( $row ) {
global $wgLang, $wgUser, $wgContLang;
// Add review links and such...
if( ($this->flags & self::NO_ACTION_LINK) || ($row->log_deleted & LogPage::DELETED_ACTION) ) {
// Action text is suppressed...
- } else if( self::typeAction($row,'move','move') && !empty($paramArray[0]) && $wgUser->isAllowed( 'move' ) ) {
+ } else if( self::typeAction($row,'move','move','move') && !empty($paramArray[0]) ) {
$destTitle = Title::newFromText( $paramArray[0] );
if( $destTitle ) {
$revert = '(' . $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Movepage' ),
'&wpMovetalk=0' ) . ')';
}
// Show undelete link
- } else if( self::typeAction($row,array('delete','suppress'),'delete') && $wgUser->isAllowed( 'delete' ) ) {
+ } else if( self::typeAction($row,array('delete','suppress'),'delete','delete') ) {
$revert = '(' . $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Undelete' ),
$this->message['undeletelink'], 'target='. urlencode( $title->getPrefixedDBkey() ) ) . ')';
- // Show unblock link
- } else if( self::typeAction($row,array('block','suppress'),'block') && $wgUser->isAllowed( 'block' ) ) {
- $revert = '(' . $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Ipblocklist' ),
- $this->message['unblocklink'],
- 'action=unblock&ip=' . urlencode( $row->log_title ) ) . ')';
+ // Show unblock/change block link
+ } else if( self::typeAction($row,array('block','suppress'),array('block','reblock'),'block') ) {
+ $revert = '(' .
+ $this->skin->link( SpecialPage::getTitleFor( 'Ipblocklist' ),
+ $this->message['unblocklink'],
+ array(),
+ array( 'action' => 'unblock', 'ip' => $row->log_title ),
+ 'known' )
+ . ' ' . $this->message['pipe-separator'] . ' ' .
+ $this->skin->link( SpecialPage::getTitleFor( 'Blockip', $row->log_title ),
+ $this->message['change-blocklink'],
+ array(), array(), 'known' ) .
+ ')';
// Show change protection link
- } else if( self::typeAction($row,'protect',array('modify','protect','unprotect')) ) {
- $revert .= ' (' . $this->skin->makeKnownLinkObj( $title, $this->message['hist'],
- 'action=history&offset=' . urlencode($row->log_timestamp) ) . ')';
- if( $wgUser->isAllowed('protect') && $row->log_action != 'unprotect' ) {
- $revert .= ' (' . $this->skin->makeKnownLinkObj( $title, $this->message['protect_change'],
- 'action=unprotect' ) . ')';
+ } else if( self::typeAction( $row, 'protect', array( 'modify', 'protect', 'unprotect' ) ) ) {
+ $revert .= ' (' .
+ $this->skin->link( $title,
+ $this->message['hist'],
+ array(),
+ array( 'action' => 'history', 'offset' => $row->log_timestamp ) );
+ if( $wgUser->isAllowed( 'protect' ) ) {
+ $revert .= ' ' . $this->message['pipe-separator'] . ' ' .
+ $this->skin->link( $title,
+ $this->message['protect_change'],
+ array(),
+ array( 'action' => 'protect' ),
+ 'known' );
}
+ $revert .= ')';
// Show unmerge link
- } else if ( self::typeAction($row,'merge','merge') ) {
+ } else if( self::typeAction($row,'merge','merge','mergehistory') ) {
$merge = SpecialPage::getTitleFor( 'Mergehistory' );
$revert = '(' . $this->skin->makeKnownLinkObj( $merge, $this->message['revertmerge'],
wfArrayToCGI( array('target' => $paramArray[0], 'dest' => $title->getPrefixedDBkey(),
'mergepoint' => $paramArray[1] ) ) ) . ')';
// If an edit was hidden from a page give a review link to the history
- } else if( self::typeAction($row,array('delete','suppress'),'revision') && $wgUser->isAllowed( 'deleterevision' ) ) {
+ } else if( self::typeAction($row,array('delete','suppress'),'revision','deleterevision') ) {
if( count($paramArray) == 2 ) {
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
// Different revision types use different URL params...
'target=' . $title->getPrefixedUrl() . $revParams ) . ')';
}
// Hidden log items, give review link
- } else if( self::typeAction($row,array('delete','suppress'),'event') && $wgUser->isAllowed( 'deleterevision' ) ) {
+ } else if( self::typeAction($row,array('delete','suppress'),'event','deleterevision') ) {
if( count($paramArray) == 1 ) {
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
$Ids = explode( ',', $paramArray[0] );
$revert = $this->skin->userToolLinks( 1, $title->getDBkey() );
}
if( $time < '20080129000000' ) {
- # Suppress $comment from old entries (before 2008-01-29), not needed and can contain incorrect links
+ # Suppress $comment from old entries (before 2008-01-29),
+ # not needed and can contain incorrect links
$comment = '';
}
// Do nothing. The implementation is handled by the hook modifiying the passed-by-ref parameters.
if( self::isDeleted($row,LogPage::DELETED_ACTION) ) {
$action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
} else {
- $action = LogPage::actionText( $row->log_type, $row->log_action, $title, $this->skin, $paramArray, true );
+ $action = LogPage::actionText( $row->log_type, $row->log_action, $title,
+ $this->skin, $paramArray, true );
+ }
+
+ if( $revert != '' ) {
+ $revert = '<span class="mw-logevent-actionlink">' . $revert . '</span>';
}
return "<li>$del$time $userLink $action $comment $revert</li>\n";
}
/**
- * @param Row $row
+ * @param $row Row
* @return string
*/
private function getShowHideLinks( $row ) {
}
/**
- * @param Row $row
- * @param mixed $type (string/array)
- * @param mixed $action (string/array)
+ * @param $row Row
+ * @param $type Mixed: string/array
+ * @param $action Mixed: string/array
+ * @param $right string
* @return bool
*/
- public static function typeAction( $row, $type, $action ) {
+ public static function typeAction( $row, $type, $action, $right='' ) {
$match = is_array($type) ? in_array($row->log_type,$type) : $row->log_type == $type;
if( $match ) {
- $match = is_array($action) ? in_array($row->log_action,$action) : $row->log_action == $action;
+ $match = is_array($action) ?
+ in_array($row->log_action,$action) : $row->log_action == $action;
+ if( $match && $right ) {
+ global $wgUser;
+ $match = $wgUser->isAllowed( $right );
+ }
}
return $match;
}
/**
* Determine if the current user is allowed to view a particular
* field of this log row, if it's marked as deleted.
- * @param Row $row
- * @param int $field
- * @return bool
+ * @param $row Row
+ * @param $field Integer
+ * @return Boolean
*/
public static function userCan( $row, $field ) {
if( ( $row->log_deleted & $field ) == $field ) {
}
/**
- * @param Row $row
- * @param int $field one of DELETED_* bitfield constants
- * @return bool
+ * @param $row Row
+ * @param $field Integer: one of DELETED_* bitfield constants
+ * @return Boolean
*/
public static function isDeleted( $row, $field ) {
return ($row->log_deleted & $field) == $field;
/**
* Quick function to show a short log extract
- * @param OutputPage $out
- * @param string $type
- * @param string $page
- * @param string $user
- * @param int $lim
- * @param array $conds
+ * @param $out OutputPage
+ * @param $type String
+ * @param $page String
+ * @param $user String
+ * @param $lim Integer
+ * @param $conds Array
*/
public static function showLogExtract( $out, $type='', $page='', $user='', $lim=0, $conds=array() ) {
global $wgUser;
return $pager->getNumRows();
}
- /**
+ /**
* SQL clause to skip forbidden log types for this user
- * @param Database $db
- * @returns mixed (string or false)
+ * @param $db Database
+ * @return mixed (string or false)
*/
public static function getExcludeClause( $db ) {
global $wgLogRestrictions, $wgUser;
class LogPager extends ReverseChronologicalPager {
private $type = '', $user = '', $title = '', $pattern = '';
public $mLogEventsList;
+
/**
- * constructor
- * @param LogEventsList $loglist,
- * @param string $type,
- * @param string $user,
- * @param string $page,
- * @param string $pattern
- * @param array $conds
- */
- function __construct( $list, $type = '', $user = '', $title = '', $pattern = '',
- $conds = array(), $year = false, $month = false )
+ * constructor
+ * @param $list LogEventsList
+ * @param $type String
+ * @param $user String
+ * @param $title String
+ * @param $pattern String
+ * @param $conds Array
+ * @param $year Integer
+ * @param $month Integer
+ */
+ public function __construct( $list, $type = '', $user = '', $title = '', $pattern = '',
+ $conds = array(), $year = false, $month = false )
{
parent::__construct();
$this->mConds = $conds;
/**
* Set the log reader to return only entries of the given type.
* Type restrictions enforced here
- * @param string $type A log type ('upload', 'delete', etc)
- * @private
+ * @param $type String: A log type ('upload', 'delete', etc)
*/
private function limitType( $type ) {
global $wgLogRestrictions, $wgUser;
/**
* Set the log reader to return only entries by the given user.
- * @param string $name (In)valid user name
- * @private
+ * @param $name String: (In)valid user name
*/
private function limitUser( $name ) {
if( $name == '' ) {
/**
* Set the log reader to return only entries affecting the given page.
* (For the block and rights logs, this is a user page.)
- * @param string $page Title name as text
- * @private
+ * @param $page String: Title name as text
+ * @param $pattern String
*/
private function limitTitle( $page, $pattern ) {
global $wgMiserMode;
class LogReader {
var $pager;
/**
- * @param WebRequest $request For internal use use a FauxRequest object to pass arbitrary parameters.
+ * @param $request WebRequest: for internal use use a FauxRequest object to pass arbitrary parameters.
*/
function __construct( $request ) {
global $wgUser, $wgOut;
+ wfDeprecated(__FUNCTION__);
# Get parameters
$type = $request->getVal( 'type' );
$user = $request->getText( 'user' );
*/
class LogViewer {
const NO_ACTION_LINK = 1;
+
/**
- * @var LogReader $reader
+ * LogReader object
*/
var $reader;
+
/**
- * @param LogReader &$reader where to get our data from
- * @param integer $flags Bitwise combination of flags:
+ * @param &$reader LogReader: where to get our data from
+ * @param $flags Integer: Bitwise combination of flags:
* LogEventsList::NO_ACTION_LINK Don't show restore/unblock/block links
*/
function __construct( &$reader, $flags = 0 ) {
global $wgUser;
+ wfDeprecated(__FUNCTION__);
$this->reader =& $reader;
$this->reader->pager->mLogEventsList->flags = $flags;
# Aliases for shorter code...
* Output just the list of entries given by the linked LogReader,
* with extraneous UI elements. Use for displaying log fragments in
* another page (eg at Special:Undelete)
- * @param OutputPage $out where to send output
+ * @param $out OutputPage: where to send output
*/
public function showList( &$out ) {
$logBody = $this->pager->getBody();