X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FLogEventsList.php;h=ac6c9fc91d359499d4846934b0e09c36c3bf8693;hb=10500033b7264ac2ec2fdfacfbb72450888e8e81;hp=2e9fc2124c14f9500df1e5ccb4912cb28e089c7d;hpb=a45494196f14d61fce2e376e2614027dd4b15778;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/LogEventsList.php b/includes/LogEventsList.php index 2e9fc2124c..ac6c9fc91d 100644 --- a/includes/LogEventsList.php +++ b/includes/LogEventsList.php @@ -24,7 +24,7 @@ class LogEventsList { 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; @@ -38,9 +38,11 @@ class LogEventsList { private function preCacheMessages() { // Precache various messages if( !isset( $this->message ) ) { - $messages = 'revertmerge protect_change unblocklink change-blocklink 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', 'diff', + 'pipe-separator' ); + foreach( $messages as $msg ) { + $this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) ); } } } @@ -64,16 +66,19 @@ class LogEventsList { * @param $pattern String * @param $year Integer: year * @param $month Integer: month - * @param $filter Boolean + * @param $filter: array + * @param $tagFilter: array? */ public function showOptions( $type = '', $user = '', $page = '', $pattern = '', $year = '', - $month = '', $filter = null ) + $month = '', $filter = null, $tagFilter='' ) { global $wgScript, $wgMiserMode; $action = htmlspecialchars( $wgScript ); $title = SpecialPage::getTitleFor( 'Log' ); $special = htmlspecialchars( $title->getPrefixedDBkey() ); + $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter ); + $this->out->addHTML( "
" ); } private function getFilterLinks( $logType, $filter ) { - global $wgTitle; + global $wgTitle, $wgLang; // show/hide links $messages = array( wfMsgHtml( 'show' ), wfMsgHtml( 'hide' ) ); // Option value -> message mapping $links = array(); + $hiddens = ''; // keep track for "go" button foreach( $filter as $type => $val ) { $hideVal = 1 - intval($val); $link = $this->skin->makeKnownLinkObj( $wgTitle, $messages[$hideVal], wfArrayToCGI( array( "hide_{$type}_log" => $hideVal ), $this->getDefaultQuery() ) ); $links[$type] = wfMsgHtml( "log-show-hide-{$type}", $link ); + $hiddens .= Xml::hidden( "hide_{$type}_log", $val ) . "\n"; } // Build links - return implode( ' | ', $links ); + return ''.$wgLang->pipeList( $links ) . '' . $hiddens; } private function getDefaultQuery() { @@ -162,7 +170,7 @@ class LogEventsList { * @return String: Formatted HTML */ private function getUserInput( $user ) { - return Xml::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'user', 15, $user ); + return Xml::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'mw-log-user', 15, $user ); } /** @@ -170,38 +178,7 @@ class LogEventsList { * @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 - */ - private function getDateMenu( $year, $month ) { - # Offset overrides year/month selection - if( $month && $month !== -1 ) { - $encMonth = intval( $month ); - } else { - $encMonth = ''; - } - if ( $year ) { - $encYear = intval( $year ); - } else if( $encMonth ) { - $thisMonth = intval( gmdate( 'n' ) ); - $thisYear = intval( gmdate( 'Y' ) ); - if( intval($encMonth) > $thisMonth ) { - $thisYear--; - } - $encYear = $thisYear; - } else { - $encYear = ''; - } - return Xml::label( wfMsg( 'year' ), 'year' ) . ' '. - Xml::input( 'year', 4, $encYear, array('id' => 'year', 'maxlength' => 4) ) . - ' '. - Xml::label( wfMsg( 'month' ), 'month' ) . ' '. - Xml::monthSelector( $encMonth, -1 ); + return Xml::inputLabel( wfMsg( 'speciallogtitlelabel' ), 'page', 'mw-log-page', 20, $title ); } /** @@ -229,6 +206,7 @@ class LogEventsList { global $wgLang, $wgUser, $wgContLang; $title = Title::makeTitle( $row->log_namespace, $row->log_title ); + $classes = array( "mw-logline-{$row->log_type}" ); $time = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->log_timestamp), true ); // User links if( self::isDeleted($row,LogPage::DELETED_USER) ) { @@ -247,7 +225,7 @@ class LogEventsList { $paramArray = LogPage::extractParams( $row->log_params ); $revert = $del = ''; // Some user can hide log items and have review links - if( $wgUser->isAllowed( 'deleterevision' ) ) { + if( !($this->flags & self::NO_ACTION_LINK) && $wgUser->isAllowed( 'deleterevision' ) ) { $del = $this->getShowHideLinks( $row ) . ' '; } // Add review links and such... @@ -273,21 +251,29 @@ class LogEventsList { $this->skin->link( SpecialPage::getTitleFor( 'Ipblocklist' ), $this->message['unblocklink'], array(), - array( 'action' => 'unblock', 'ip' => urlencode( $row->log_title ) ), + array( 'action' => 'unblock', 'ip' => $row->log_title ), 'known' ) - . ' ' . wfMsg( 'pipe-separator' ) . ' ' . - $this->skin->link( SpecialPage::getTitleFor( 'Blockip', htmlspecialchars( $row->log_title ) ), + . $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','mergehistory') ) { $merge = SpecialPage::getTitleFor( 'Mergehistory' ); @@ -296,31 +282,36 @@ class LogEventsList { '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','deleterevision') ) { - if( count($paramArray) == 2 ) { + if( count($paramArray) >= 2 ) { $revdel = SpecialPage::getTitleFor( 'Revisiondelete' ); // Different revision types use different URL params... $key = $paramArray[0]; - // Link to each hidden object ID, $paramArray[1] is the url param + // $paramArray[1] is a CVS of the IDs $Ids = explode( ',', $paramArray[1] ); - $revParams = ''; - foreach( $Ids as $n => $id ) { - $revParams .= '&' . urlencode($key) . '[]=' . urlencode($id); + $query = urlencode($paramArray[1]); + $revert = array(); + // Diff link for single rev deletions + if( $key === 'oldid' && count($Ids) == 1 ) { + $token = urlencode( $wgUser->editToken( intval($Ids[0]) ) ); + $revert[] = $this->skin->makeKnownLinkObj( $title, $this->message['diff'], + 'diff='.intval($Ids[0])."&unhide=1&token=$token" ); } - $revert = '(' . $this->skin->makeKnownLinkObj( $revdel, $this->message['revdel-restore'], - 'target=' . $title->getPrefixedUrl() . $revParams ) . ')'; + // View/modify link... + $revert[] = $this->skin->makeKnownLinkObj( $revdel, $this->message['revdel-restore'], + 'target='.$title->getPrefixedUrl()."&$key=$query" ); + // Pipe links + $revert = '(' . implode(' | ',$revert) . ')'; } // Hidden log items, give review link } else if( self::typeAction($row,array('delete','suppress'),'event','deleterevision') ) { - if( count($paramArray) == 1 ) { + if( count($paramArray) >= 1 ) { $revdel = SpecialPage::getTitleFor( 'Revisiondelete' ); + // $paramArray[1] is a CVS of the IDs $Ids = explode( ',', $paramArray[0] ); + $query = urlencode($paramArray[0]); // Link to each hidden object ID, $paramArray[1] is the url param - $logParams = ''; - foreach( $Ids as $n => $id ) { - $logParams .= '&logid[]=' . intval($id); - } $revert = '(' . $this->skin->makeKnownLinkObj( $revdel, $this->message['revdel-restore'], - 'target=' . $title->getPrefixedUrl() . $logParams ) . ')'; + 'target='.$title->getPrefixedUrl()."&logid=$query" ) . ')'; } // Self-created users } else if( self::typeAction($row,'newusers','create2') ) { @@ -331,7 +322,8 @@ class LogEventsList { $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. @@ -343,10 +335,20 @@ class LogEventsList { if( self::isDeleted($row,LogPage::DELETED_ACTION) ) { $action = '' . wfMsgHtml('rev-deleted-event') . ''; } 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 ); + } + + // Any tags... + list($tagDisplay, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'logevent' ); + $classes = array_merge( $classes, $newClasses ); + + if( $revert != '' ) { + $revert = '' . $revert . ''; } - return "