Change tabs -> spaces
[lhc/web/wiklou.git] / includes / LogEventsList.php
index 05f5d25..b69f34e 100644 (file)
@@ -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,10 @@ 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', 'pipe-separator' );
+                       foreach( $messages as $msg ) {
+                               $this->message[$msg] = wfMsgExt( $msg, array( 'escape' ) );
                        }
                }
        }
@@ -253,7 +254,7 @@ class LogEventsList {
                // 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' ),
@@ -264,38 +265,46 @@ class LogEventsList {
                                        '&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/change block link
-               } else if( self::typeAction( $row, array( 'block', 'suppress' ), 'block' ) && $wgUser->isAllowed( 'block' ) ) {
+               } 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' => 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') ) {
+               } 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...
@@ -310,7 +319,7 @@ class LogEventsList {
                                        '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] );
@@ -331,7 +340,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 +353,16 @@ class LogEventsList {
                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";
+               return Xml::tags( 'li', array( "class" => "mw-logline-$row->log_type" ),
+                       $del . $time . ' ' . $userLink . ' ' . $action . ' ' . $comment . ' ' . $revert );
        }
 
        /**
@@ -376,12 +392,18 @@ class LogEventsList {
         * @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;
        }
@@ -486,8 +508,8 @@ class LogPager extends ReverseChronologicalPager {
         * @param $year Integer
         * @param $month Integer
         */
-       function __construct( $list, $type = '', $user = '', $title = '', $pattern = '', 
-                       $conds = array(), $year = false, $month = false ) 
+       public function __construct( $list, $type = '', $user = '', $title = '', $pattern = '', 
+               $conds = array(), $year = false, $month = false ) 
        {
                parent::__construct();
                $this->mConds = $conds;
@@ -691,6 +713,7 @@ class LogReader {
         */
        function __construct( $request ) {
                global $wgUser, $wgOut;
+               wfDeprecated(__METHOD__);
                # Get parameters
                $type = $request->getVal( 'type' );
                $user = $request->getText( 'user' );
@@ -737,6 +760,7 @@ class LogViewer {
         */
        function __construct( &$reader, $flags = 0 ) {
                global $wgUser;
+               wfDeprecated(__METHOD__);
                $this->reader =& $reader;
                $this->reader->pager->mLogEventsList->flags = $flags;
                # Aliases for shorter code...