Merge "ChangesListSpecialPage: Implement doMainQuery()"
[lhc/web/wiklou.git] / includes / logging / LogPage.php
index 7f87dc2..f5798e2 100644 (file)
@@ -34,32 +34,51 @@ class LogPage {
        const DELETED_COMMENT = 2;
        const DELETED_USER = 4;
        const DELETED_RESTRICTED = 8;
+
        // Convenience fields
        const SUPPRESSED_USER = 12;
        const SUPPRESSED_ACTION = 9;
-       /* @access private */
-       var $type, $action, $comment, $params;
 
-       /**
-        * @var User
-        */
-       var $doer;
+       /** @var bool */
+       public $updateRecentChanges;
 
-       /**
-        * @var Title
+       /** @var bool */
+       public $sendToUDP;
+
+       /** @var string Plaintext version of the message for IRC */
+       private $ircActionText;
+
+       /** @var string Plaintext version of the message */
+       private $actionText;
+
+       /** @var string One of '', 'block', 'protect', 'rights', 'delete',
+        *    'upload', 'move'
         */
-       var $target;
+       private $type;
+
+       /** @var string One of '', 'block', 'protect', 'rights', 'delete',
+        *   'upload', 'move', 'move_redir' */
+       private $action;
+
+       /** @var string Comment associated with action */
+       private $comment;
+
+       /** @var string Blob made of a parameters array */
+       private $params;
 
-       /* @access public */
-       var $updateRecentChanges, $sendToUDP;
+       /** @var User The user doing the action */
+       private $doer;
+
+       /** @var Title */
+       private $target;
 
        /**
         * Constructor
         *
-        * @param string $type one of '', 'block', 'protect', 'rights', 'delete',
-        *               'upload', 'move'
-        * @param $rc Boolean: whether to update recent changes as well as the logging table
-        * @param string $udp pass 'UDP' to send to the UDP feed if NOT sent to RC
+        * @param string $type One of '', 'block', 'protect', 'rights', 'delete',
+        *   'upload', 'move'
+        * @param bool $rc Whether to update recent changes as well as the logging table
+        * @param string $udp Pass 'UDP' to send to the UDP feed if NOT sent to RC
         */
        public function __construct( $type, $rc = true, $udp = 'skipUDP' ) {
                $this->type = $type;
@@ -76,6 +95,7 @@ class LogPage {
                $dbw = wfGetDB( DB_MASTER );
                $log_id = $dbw->nextSequenceValue( 'logging_log_id_seq' );
 
+               // @todo FIXME private/protected/public property?
                $this->timestamp = $now = wfTimestampNow();
                $data = array(
                        'log_id' => $log_id,
@@ -116,7 +136,7 @@ class LogPage {
                                $this->type, $this->action, $this->target, $this->comment,
                                $this->params, $newId, $this->getRcCommentIRC()
                        );
-                       $rc->notifyRC2UDP();
+                       $rc->notifyRCFeeds();
                }
 
                return $newId;
@@ -172,7 +192,7 @@ class LogPage {
        /**
         * Get the list of valid log types
         *
-        * @return Array of strings
+        * @return array of strings
         */
        public static function validTypes() {
                global $wgLogTypes;
@@ -183,8 +203,8 @@ class LogPage {
        /**
         * Is $type a valid log type
         *
-        * @param string $type log type to check
-        * @return Boolean
+        * @param string $type Log type to check
+        * @return bool
         */
        public static function isLogType( $type ) {
                return in_array( $type, LogPage::validTypes() );
@@ -193,13 +213,15 @@ class LogPage {
        /**
         * Get the name for the given log type
         *
-        * @param string $type logtype
-        * @return String: log name
+        * @param string $type Log type
+        * @return string Log name
         * @deprecated in 1.19, warnings in 1.21. Use getName()
         */
        public static function logName( $type ) {
                global $wgLogNames;
 
+               wfDeprecated( __METHOD__, '1.21' );
+
                if ( isset( $wgLogNames[$type] ) ) {
                        return str_replace( '_', ' ', wfMessage( $wgLogNames[$type] )->text() );
                } else {
@@ -213,12 +235,14 @@ class LogPage {
         *
         * @todo handle missing log types
         * @param string $type logtype
-        * @return String: headertext of this logtype
+        * @return string Header text of this logtype
         * @deprecated in 1.19, warnings in 1.21. Use getDescription()
         */
        public static function logHeader( $type ) {
                global $wgLogHeaders;
 
+               wfDeprecated( __METHOD__, '1.21' );
+
                return wfMessage( $wgLogHeaders[$type] )->parse();
        }
 
@@ -228,12 +252,12 @@ class LogPage {
         *
         * @param string $type log type
         * @param string $action log action
-        * @param $title Mixed: Title object or null
-        * @param $skin Mixed: Skin object or null. If null, we want to use the wiki
-        *              content language, since that will go to the IRC feed.
+        * @param Title|null $title Title object or null
+        * @param Skin|null $skin Skin object or null. If null, we want to use the wiki
+        *   content language, since that will go to the IRC feed.
         * @param array $params parameters
-        * @param $filterWikilinks Boolean: whether to filter wiki links
-        * @return HTML string
+        * @param bool $filterWikilinks Whether to filter wiki links
+        * @return string HTML
         */
        public static function actionText( $type, $action, $title = null, $skin = null,
                $params = array(), $filterWikilinks = false
@@ -257,7 +281,8 @@ class LogPage {
                                $titleLink = self::getTitleLink( $type, $langObjOrNull, $title, $params );
 
                                if ( count( $params ) == 0 ) {
-                                       $rv = wfMessage( $wgLogActions[$key] )->rawParams( $titleLink )->inLanguage( $langObj )->escaped();
+                                       $rv = wfMessage( $wgLogActions[$key] )->rawParams( $titleLink )
+                                               ->inLanguage( $langObj )->escaped();
                                } else {
                                        $details = '';
                                        array_unshift( $params, $titleLink );
@@ -297,7 +322,8 @@ class LogPage {
                                                }
                                        }
 
-                                       $rv = wfMessage( $wgLogActions[$key] )->rawParams( $params )->inLanguage( $langObj )->escaped() . $details;
+                                       $rv = wfMessage( $wgLogActions[$key] )->rawParams( $params )
+                                                       ->inLanguage( $langObj )->escaped() . $details;
                                }
                        }
                } else {
@@ -331,12 +357,12 @@ class LogPage {
        }
 
        /**
-        * TODO document
-        * @param  $type String
-        * @param  $lang Language or null
-        * @param  $title Title
-        * @param  $params Array
-        * @return String
+        * @todo Document
+        * @param  string $type
+        * @param  Language|null $lang
+        * @param  Title $title
+        * @param  array $params
+        * @return string
         */
        protected static function getTitleLink( $type, $lang, $title, &$params ) {
                if ( !$lang ) {
@@ -414,11 +440,12 @@ class LogPage {
        /**
         * Add a log entry
         *
-        * @param string $action one of '', 'block', 'protect', 'rights', 'delete', 'upload', 'move', 'move_redir'
-        * @param $target Title object
+        * @param string $action one of '', 'block', 'protect', 'rights', 'delete',
+        *   'upload', 'move', 'move_redir'
+        * @param Title $target Title object
         * @param string $comment description associated
         * @param array $params parameters passed later to wfMessage function
-        * @param $doer User object: the user doing the action
+        * @param null|int|User $doer The user doing the action. null for $wgUser
         *
         * @return int log_id of the inserted log entry
         */
@@ -471,10 +498,10 @@ class LogPage {
        /**
         * Add relations to log_search table
         *
-        * @param $field String
-        * @param $values Array
-        * @param $logid Integer
-        * @return Boolean
+        * @param string $field
+        * @param array $values
+        * @param int $logid
+        * @return bool
         */
        public function addRelations( $field, $values, $logid ) {
                if ( !strlen( $field ) || empty( $values ) ) {
@@ -500,8 +527,8 @@ class LogPage {
        /**
         * Create a blob from a parameter array
         *
-        * @param $params Array
-        * @return String
+        * @param array $params
+        * @return string
         */
        public static function makeParamBlob( $params ) {
                return implode( "\n", $params );
@@ -510,8 +537,8 @@ class LogPage {
        /**
         * Extract a parameter array from a blob
         *
-        * @param $blob String
-        * @return Array
+        * @param string $blob
+        * @return array
         */
        public static function extractParams( $blob ) {
                if ( $blob === '' ) {
@@ -526,8 +553,8 @@ class LogPage {
         * into a more readable (and translated) form
         *
         * @param string $flags Flags to format
-        * @param $lang Language object to use
-        * @return String
+        * @param Language $lang
+        * @return string
         */
        public static function formatBlockFlags( $flags, $lang ) {
                $flags = trim( $flags );
@@ -535,8 +562,9 @@ class LogPage {
                        return ''; //nothing to do
                }
                $flags = explode( ',', $flags );
+               $flagsCount = count( $flags );
 
-               for ( $i = 0; $i < count( $flags ); $i++ ) {
+               for ( $i = 0; $i < $flagsCount; $i++ ) {
                        $flags[$i] = self::formatBlockFlag( $flags[$i], $lang );
                }
 
@@ -548,8 +576,8 @@ class LogPage {
         * Translate a block log flag if possible
         *
         * @param int $flag Flag to translate
-        * @param $lang Language object to use
-        * @return String
+        * @param Language $lang Language object to use
+        * @return string
         */
        public static function formatBlockFlag( $flag, $lang ) {
                static $messages = array();