/**
* Set page title and show header for this log type
- * @param $type String
+ * @param $type Array
*/
public function showHeader( $type ) {
- if( LogPage::isLogType( $type ) ) {
- $this->out->setPageTitle( LogPage::logName( $type ) );
- $this->out->addHTML( LogPage::logHeader( $type ) );
+ // If only one log type is used, then show a special message...
+ $headerType = (count($type) == 1) ? $type[0] : '';
+ if( LogPage::isLogType( $headerType ) ) {
+ $this->out->setPageTitle( LogPage::logName( $headerType ) );
+ $this->out->addHTML( LogPage::logHeader( $headerType ) );
+ } else {
+ $this->out->addHTML( wfMsgExt('alllogstext',array('parseinline')) );
}
}
$month = '', $filter = null, $tagFilter='' )
{
global $wgScript, $wgMiserMode;
- $action = htmlspecialchars( $wgScript );
+
+ $action = $wgScript;
$title = SpecialPage::getTitleFor( 'Log' );
- $special = htmlspecialchars( $title->getPrefixedDBkey() );
+ $special = $title->getPrefixedDBkey();
+
// For B/C, we take strings, but make sure they are converted...
$types = ($types === '') ? array() : (array)$types;
$tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter );
-
- $this->out->addHTML( "<form action=\"$action\" method=\"get\"><fieldset>" .
- Xml::element( 'legend', array(), wfMsg( 'log' ) ) .
- Xml::hidden( 'title', $special ) . "\n" .
- $this->getTypeMenu( $types ) . "\n" .
- $this->getUserInput( $user ) . "\n" .
- $this->getTitleInput( $page ) . "\n" .
- ( !$wgMiserMode ? ($this->getTitlePattern( $pattern )."\n") : "" ) .
- "<p>" . Xml::dateMenu( $year, $month ) . "\n" .
- ( $tagSelector ? Xml::tags( 'p', null, implode( ' ', $tagSelector ) ) :'' ). "\n" .
- ( $filter ? "</p><p>".$this->getFilterLinks( $filter )."\n" : "" ) . "\n" .
- Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "</p>\n" .
- "</fieldset></form>"
- );
+
+ $html = '';
+ $html .= Xml::hidden( 'title', $special );
+
+ // Basic selectors
+ $html .= $this->getTypeMenu( $types ) . "\n";
+ $html .= $this->getUserInput( $user ) . "\n";
+ $html .= $this->getTitleInput( $page ) . "\n";
+ $html .= $this->getExtraInputs( $types ) . "\n";
+
+ // Title pattern, if allowed
+ if (!$wgMiserMode) {
+ $html .= $this->getTitlePattern( $pattern ) . "\n";
+ }
+
+ // date menu
+ $html .= Xml::tags( 'p', null, Xml::dateMenu( $year, $month ) );
+
+ // Tag filter
+ if ($tagSelector) {
+ $html .= Xml::tags( 'p', null, implode( ' ', $tagSelector ) );
+ }
+
+ // Filter links
+ if ($filter) {
+ $html .= Xml::tags( 'p', null, $this->getFilterLinks( $filter ) );
+ }
+
+ // Submit button
+ $html .= Xml::submitButton( wfMsg( 'allpagessubmit' ) );
+
+ // Fieldset
+ $html = Xml::fieldset( wfMsg( 'log' ), $html );
+
+ // Form wrapping
+ $html = Xml::tags( 'form', array( 'action' => $action, 'method' => 'get' ), $html );
+
+ $this->out->addHTML( $html );
}
/**
Xml::checkLabel( wfMsg( 'log-title-wildcard' ), 'pattern', 'pattern', $pattern ) .
'</span>';
}
+
+ private function getExtraInputs( $types ) {
+ global $wgRequest;
+ if( count($types) == 1 && $types[0] == 'suppress' ) {
+ return Xml::inputLabel( wfMsg('revdelete-offender'), 'offender',
+ 'mw-log-offender', 20, $wgRequest->getVal('offender') );
+ }
+ return '';
+ }
public function beginLogEventsList() {
return "<ul>\n";
// If an edit was hidden from a page give a review link to the history
} 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...
$key = $paramArray[0];
// $paramArray[1] is a CSV of the IDs
$query = $paramArray[1];
$revert = array();
// Diff link for single rev deletions
- if( ( $key === 'oldid' || $key == 'revision' ) && count($Ids) == 1 ) {
- $revert[] = $this->skin->link(
- $title,
- $this->message['diff'],
- array(),
- array(
- 'diff' => intval( $Ids[0] ),
- 'unhide' => 1
- ),
- array( 'known', 'noclasses' )
- );
+ if( count($Ids) == 1 ) {
+ // Live revision diffs...
+ if( in_array($key, array('oldid','revision')) ) {
+ $revert[] = $this->skin->link(
+ $title,
+ $this->message['diff'],
+ array(),
+ array(
+ 'diff' => intval( $Ids[0] ),
+ 'unhide' => 1
+ ),
+ array( 'known', 'noclasses' )
+ );
+ // Deleted revision diffs...
+ } else if( in_array($key, array('artimestamp','archive')) ) {
+ $revert[] = $this->skin->link(
+ SpecialPage::getTitleFor( 'Undelete' ),
+ $this->message['diff'],
+ array(),
+ array(
+ 'target' => $title->getPrefixedDBKey(),
+ 'diff' => 'prev',
+ 'timestamp' => $Ids[0]
+ ),
+ array( 'known', 'noclasses' )
+ );
+ }
}
// View/modify link...
$revert[] = $this->skin->link(
- $revdel,
+ SpecialPage::getTitleFor( 'Revisiondelete' ),
$this->message['revdel-restore'],
array(),
array(
),
array( 'known', 'noclasses' )
);
-
// Pipe links
$revert = wfMsg( 'parentheses', $wgLang->pipeList( $revert ) );
}
}
/**
- * Quick function to show a short log extract
- * @param $out OutputPage
+ * Show log extract. Either with text and a box (set $msgKey) or without (don't set $msgKey)
+ * @param $out OutputPage or String-by-reference
* @param $types String or Array
- * @param $page String
- * @param $user String
- * @param $lim Integer
- * @param $conds Array
+ * @param $page String The page title to show log entries for
+ * @param $user String The user who made the log entries
+ * @param $param Associative Array with the following additional options:
+ * lim Integer Limit of items to show, default is 50
+ * conds Array Extra conditions for the query (e.g. "log_action != 'revision'")
+ * showIfEmpty boolean Set to false if you don't want any output in case the loglist is empty
+ * if set to true (default), "No matching items in log" is displayed if loglist is empty
+ * msgKey Array If you want a nice box with a message, set this
+ * to the key of the message. First element is the message
+ * key, additional optional elements are parameters for the
+ * key that are processed with wgMsgExt and option 'parse'
+ * @return Integer Number of total log items (not limited by $lim)
*/
- public static function showLogExtract( $out, $types=array(), $page='', $user='', $lim=0, $conds=array() ) {
- global $wgUser;
- # Insert list of top 50 or so items
- $loglist = new LogEventsList( $wgUser->getSkin(), $out, 0 );
+ public static function showLogExtract( &$out, $types=array(), $page='', $user='',
+ $param = array() ) {
+
+ $defaultParameters = array(
+ 'lim' => 0,
+ 'conds' => array(),
+ 'showIfEmpty' => true,
+ 'msgKey' => array('')
+ );
+
+ # The + operator appends elements of remaining keys from the right
+ # handed array to the left handed, whereas duplicated keys are NOT overwritten.
+ $param += $defaultParameters;
+
+ global $wgUser, $wgOut;
+ # Convert $param array to individual variables
+ $lim = $param['lim'];
+ $conds = $param['conds'];
+ $showIfEmpty = $param['showIfEmpty'];
+ $msgKey = $param['msgKey'];
+ if ( !is_array($msgKey) )
+ $msgKey = array( $msgKey );
+ # Insert list of top 50 (or top $lim) items
+ $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 );
$pager = new LogPager( $loglist, $types, $user, $page, '', $conds );
if( $lim > 0 ) $pager->mLimit = $lim;
$logBody = $pager->getBody();
+ $s = '';
if( $logBody ) {
- $out->addHTML(
- $loglist->beginLogEventsList() .
- $logBody .
- $loglist->endLogEventsList()
+ if ( $msgKey[0] ) {
+ $s = '<div class="mw-warning-with-logexcerpt">';
+
+ if ( count( $msgKey ) == 1 ) {
+ $s .= wfMsgExt( $msgKey[0], array('parse') );
+ } else { // Process additional arguments
+ $args = $msgKey;
+ array_shift( $args );
+ $s .= wfMsgExt( $msgKey[0], array('parse'), $args );
+ }
+ }
+ $s .= $loglist->beginLogEventsList() .
+ $logBody .
+ $loglist->endLogEventsList();
+ } else {
+ if ( $showIfEmpty )
+ $s = wfMsgExt( 'logempty', array('parse') );
+ }
+ if( $pager->getNumRows() > $pager->mLimit ) { # Show "Full log" link
+ $urlParam = array();
+ if ( $page != '')
+ $urlParam['page'] = $page;
+ if ( $user != '')
+ $urlParam['user'] = $user;
+ if ( !is_array( $types ) ) # Make it an array, if it isn't
+ $types = array( $types );
+ # 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(
+ SpecialPage::getTitleFor( 'Log' ),
+ wfMsgHtml( 'log-fulllog' ),
+ array(),
+ $urlParam
);
+
+ }
+ if ( $logBody && $msgKey[0] )
+ $s .= '</div>';
+
+ if( $out instanceof OutputPage ){
+ $out->addHTML( $s );
} else {
- $out->addWikiMsg( 'logempty' );
+ $out = $s;
}
return $pager->getNumRows();
}
/**
* constructor
* @param $list LogEventsList
- * @param $types String or Array
- * @param $user String
- * @param $title String
- * @param $pattern String
- * @param $conds Array
- * @param $year Integer
- * @param $month Integer
+ * @param $types String or Array log types to show
+ * @param $user String The user who made the log entries
+ * @param $title String The page title the log entries are for
+ * @param $pattern String Do a prefix search rather than an exact title match
+ * @param $conds Array Extra conditions for the query
+ * @param $year Integer The year to start from
+ * @param $month Integer The month to start from
*/
public function __construct( $list, $types = array(), $user = '', $title = '', $pattern = '',
$conds = array(), $year = false, $month = false, $tagFilter = '' )
global $wgUser;
$this->mConds['log_user'] = $userid;
// Paranoia: avoid brute force searches (bug 17342)
- if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
+ if( !$wgUser->isAllowed( 'deleterevision' ) ) {
$this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::DELETED_USER) . ' = 0';
+ } else if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
+ $this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::SUPPRESSED_USER) .
+ ' != ' . LogPage::SUPPRESSED_USER;
}
$this->user = $usertitle->getText();
}
$this->mConds['log_title'] = $title->getDBkey();
}
// Paranoia: avoid brute force searches (bug 17342)
- if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
+ if( !$wgUser->isAllowed( 'deleterevision' ) ) {
$this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::DELETED_ACTION) . ' = 0';
+ } else if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
+ $this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::SUPPRESSED_ACTION) .
+ ' != ' . LogPage::SUPPRESSED_ACTION;
}
}