Revert r28215: incorrectly moved files
[lhc/web/wiklou.git] / includes / LogPage.php
index dcfe587..7c89df7 100644 (file)
@@ -55,44 +55,52 @@ class LogPage {
 
                $dbw = wfGetDB( DB_MASTER );
                $uid = $wgUser->getID();
-                $log_id = $dbw->nextSequenceValue( 'log_log_id_seq' );
+               $log_id = $dbw->nextSequenceValue( 'log_log_id_seq' );
 
                $this->timestamp = $now = wfTimestampNow();
-               $dbw->insert( 'logging',
-                       array(
-                               'log_id' => $log_id,
-                               'log_type' => $this->type,
-                               'log_action' => $this->action,
-                               'log_timestamp' => $dbw->timestamp( $now ),
-                               'log_user' => $uid,
-                               'log_namespace' => $this->target->getNamespace(),
-                               'log_title' => $this->target->getDBkey(),
-                               'log_comment' => $this->comment,
-                               'log_params' => $this->params
-                       ), $fname
+               $data = array(
+                       'log_type' => $this->type,
+                       'log_action' => $this->action,
+                       'log_timestamp' => $dbw->timestamp( $now ),
+                       'log_user' => $uid,
+                       'log_namespace' => $this->target->getNamespace(),
+                       'log_title' => $this->target->getDBkey(),
+                       'log_comment' => $this->comment,
+                       'log_params' => $this->params
                );
 
+               # log_id doesn't exist on Wikimedia servers yet, and it's a tricky 
+               # schema update to do. Hack it for now to ignore the field on MySQL.
+               if ( !is_null( $log_id ) ) {
+                       $data['log_id'] = $log_id;
+               }
+               $dbw->insert( 'logging', $data, $fname );
+
                # And update recentchanges
                if ( $this->updateRecentChanges ) {
                        $titleObj = SpecialPage::getTitleFor( 'Log', $this->type );
-                       $rcComment = $this->actionText;
-                       if( '' != $this->comment ) {
-                               if ($rcComment == '')
-                                       $rcComment = $this->comment;
-                               else
-                                       $rcComment .= ': ' . $this->comment;
-                       }
-
+                       $rcComment = $this->getRcComment();
                        RecentChange::notifyLog( $now, $titleObj, $wgUser, $rcComment, '',
                                $this->type, $this->action, $this->target, $this->comment, $this->params );
                }
                return true;
        }
 
+       public function getRcComment() {
+               $rcComment = $this->actionText;
+               if( '' != $this->comment ) {
+                       if ($rcComment == '')
+                               $rcComment = $this->comment;
+                       else
+                               $rcComment .= ': ' . $this->comment;
+               }
+               return $rcComment;
+       }
+
        /**
         * @static
         */
-       function validTypes() {
+       public static function validTypes() {
                global $wgLogTypes;
                return $wgLogTypes;
        }
@@ -100,7 +108,7 @@ class LogPage {
        /**
         * @static
         */
-       function isLogType( $type ) {
+       public static function isLogType( $type ) {
                return in_array( $type, LogPage::validTypes() );
        }
 
@@ -108,9 +116,10 @@ class LogPage {
         * @static
         */
        public static function logName( $type ) {
-               global $wgLogNames;
+               global $wgLogNames, $wgMessageCache;
 
                if( isset( $wgLogNames[$type] ) ) {
+                       $wgMessageCache->loadAllMessages();
                        return str_replace( '_', ' ', wfMsg( $wgLogNames[$type] ) );
                } else {
                        // Bogus log types? Perhaps an extension was removed.
@@ -122,7 +131,7 @@ class LogPage {
         * @todo handle missing log types
         * @static
         */
-       function logHeader( $type ) {
+       static function logHeader( $type ) {
                global $wgLogHeaders;
                return wfMsg( $wgLogHeaders[$type] );
        }
@@ -130,7 +139,7 @@ class LogPage {
        /**
         * @static
         */
-       function actionText( $type, $action, $title = NULL, $skin = NULL, $params = array(), $filterWikilinks=false, $translate=false ) {
+       static function actionText( $type, $action, $title = NULL, $skin = NULL, $params = array(), $filterWikilinks=false ) {
                global $wgLang, $wgContLang, $wgLogActions;
 
                $key = "$type/$action";
@@ -147,20 +156,28 @@ class LogPage {
                                        switch( $type ) {
                                                case 'move':
                                                        $titleLink = $skin->makeLinkObj( $title, $title->getPrefixedText(), 'redirect=no' );
-                                                       $params[0] = $skin->makeLinkObj( Title::newFromText( $params[0] ), $params[0] );
+                                                       $params[0] = $skin->makeLinkObj( Title::newFromText( $params[0] ), htmlspecialchars( $params[0] ) );
                                                        break;
                                                case 'block':
                                                        if( substr( $title->getText(), 0, 1 ) == '#' ) {
                                                                $titleLink = $title->getText();
                                                        } else {
-                                                               $titleLink = $skin->makeLinkObj( $title, $title->getText() );
-                                                               $titleLink .= ' (' . $skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Contributions', $title->getDBkey() ), wfMsg( 'contribslink' ) ) . ')';
+                                                               // TODO: Store the user identifier in the parameters
+                                                               // to make this faster for future log entries
+                                                               $id = User::idFromName( $title->getText() );
+                                                               $titleLink = $skin->userLink( $id, $title->getText() )
+                                                                       . $skin->userToolLinks( $id, $title->getText(), false, Linker::TOOL_LINKS_NOBLOCK );
                                                        }
                                                        break;
                                                case 'rights':
                                                        $text = $wgContLang->ucfirst( $title->getText() );
                                                        $titleLink = $skin->makeLinkObj( Title::makeTitle( NS_USER, $text ) );
                                                        break;
+                                               case 'merge':
+                                                       $titleLink = $skin->makeLinkObj( $title, $title->getPrefixedText(), 'redirect=no' );
+                                                       $params[0] = $skin->makeLinkObj( Title::newFromText( $params[0] ), htmlspecialchars( $params[0] ) );
+                                                       $params[1] = $wgLang->timeanddate( $params[1] );
+                                                       break;
                                                default:
                                                        $titleLink = $skin->makeLinkObj( $title );
                                        }
@@ -188,8 +205,10 @@ class LogPage {
                                } else {
                                        array_unshift( $params, $titleLink );
                                        if ( $key == 'block/block' ) {
-                                               if ( $translate ) {
-                                                       $params[1] = $wgLang->translateBlockExpiry( $params[1] );
+                                               if ( $skin ) {
+                                                       $params[1] = '<span title="' . htmlspecialchars( $params[1] ). '">' . $wgLang->translateBlockExpiry( $params[1] ) . '</span>';
+                                               } else {
+                                                       $params[1] = $wgContLang->translateBlockExpiry( $params[1] );
                                                }
                                                $params[2] = isset( $params[2] )
                                                                                ? self::formatBlockFlags( $params[2] )
@@ -235,7 +254,7 @@ class LogPage {
         * Create a blob from a parameter array
         * @static
         */
-       function makeParamBlob( $params ) {
+       static function makeParamBlob( $params ) {
                return implode( "\n", $params );
        }
 
@@ -243,7 +262,7 @@ class LogPage {
         * Extract a parameter array from a blob
         * @static
         */
-       function extractParams( $blob ) {
+       static function extractParams( $blob ) {
                if ( $blob === '' ) {
                        return array();
                } else {
@@ -287,4 +306,4 @@ class LogPage {
        
 }
 
-?>
+