Merge "Update mediawiki.ui button styles"
[lhc/web/wiklou.git] / includes / logging / LogEventsList.php
index d316c5d..f0f297f 100644 (file)
@@ -40,10 +40,11 @@ class LogEventsList extends ContextSource {
         * The first two parameters used to be $skin and $out, but now only a context
         * is needed, that's why there's a second unused parameter.
         *
-        * @param $context IContextSource Context to use; formerly it was Skin object.
-        * @param $unused void Unused; used to be an OutputPage object.
-        * @param int $flags flags; can be a combinaison of self::NO_ACTION_LINK,
-        *        self::NO_EXTRA_USER_LINKS or self::USE_REVDEL_CHECKBOXES.
+        * @param IContextSource|Skin $context Context to use; formerly it was
+        *   a Skin object. Use of Skin is deprecated.
+        * @param null $unused Unused; used to be an OutputPage object.
+        * @param int $flags Can be a combination of self::NO_ACTION_LINK,
+        *   self::NO_EXTRA_USER_LINKS or self::USE_REVDEL_CHECKBOXES.
         */
        public function __construct( $context, $unused = null, $flags = 0 ) {
                if ( $context instanceof IContextSource ) {
@@ -60,7 +61,7 @@ class LogEventsList extends ContextSource {
         * Deprecated alias for getTitle(); do not use.
         *
         * @deprecated in 1.20; use getTitle() instead.
-        * @return Title object
+        * @return Title
         */
        public function getDisplayTitle() {
                wfDeprecated( __METHOD__, '1.20' );
@@ -69,7 +70,7 @@ class LogEventsList extends ContextSource {
 
        /**
         * Set page title and show header for this log type
-        * @param $type Array
+        * @param array $type
         * @deprecated in 1.19
         */
        public function showHeader( $type ) {
@@ -89,14 +90,14 @@ class LogEventsList extends ContextSource {
        /**
         * Show options for the log list
         *
-        * @param string $types or Array
-        * @param $user String
-        * @param $page String
-        * @param $pattern String
-        * @param $year Integer: year
-        * @param $month Integer: month
-        * @param $filter: array
-        * @param $tagFilter: array?
+        * @param array|string $types
+        * @param string $user
+        * @param string $page
+        * @param string $pattern
+        * @param int $year Year
+        * @param int $month Month
+        * @param array $filter
+        * @param string $tagFilter Tag to select by default
         */
        public function showOptions( $types = array(), $user = '', $page = '', $pattern = '', $year = 0,
                $month = 0, $filter = null, $tagFilter = ''
@@ -149,8 +150,8 @@ class LogEventsList extends ContextSource {
        }
 
        /**
-        * @param $filter Array
-        * @return String: Formatted HTML
+        * @param array $filter
+        * @return string Formatted HTML
         */
        private function getFilterLinks( $filter ) {
                // show/hide links
@@ -199,8 +200,8 @@ class LogEventsList extends ContextSource {
        }
 
        /**
-        * @param $queryTypes Array
-        * @return String: Formatted HTML
+        * @param array $queryTypes
+        * @return string Formatted HTML
         */
        private function getTypeMenu( $queryTypes ) {
                $queryType = count( $queryTypes ) == 1 ? $queryTypes[0] : '';
@@ -243,8 +244,8 @@ class LogEventsList extends ContextSource {
        }
 
        /**
-        * @param $user String
-        * @return String: Formatted HTML
+        * @param string $user
+        * @return string Formatted HTML
         */
        private function getUserInput( $user ) {
                $label = Xml::inputLabel(
@@ -259,8 +260,8 @@ class LogEventsList extends ContextSource {
        }
 
        /**
-        * @param $title String
-        * @return String: Formatted HTML
+        * @param string $title
+        * @return string Formatted HTML
         */
        private function getTitleInput( $title ) {
                $label = Xml::inputLabel(
@@ -285,7 +286,7 @@ class LogEventsList extends ContextSource {
        }
 
        /**
-        * @param $types
+        * @param array $types
         * @return string
         */
        private function getExtraInputs( $types ) {
@@ -317,8 +318,8 @@ class LogEventsList extends ContextSource {
        }
 
        /**
-        * @param $row Row: a single row from the result set
-        * @return String: Formatted HTML list item
+        * @param stdClass $row A single row from the result set
+        * @return string Formatted HTML list item
         */
        public function logLine( $row ) {
                $entry = DatabaseLogEntry::newFromRow( $row );
@@ -357,7 +358,7 @@ class LogEventsList extends ContextSource {
        }
 
        /**
-        * @param $row Row
+        * @param stdClass $row Row
         * @return string
         */
        private function getShowHideLinks( $row ) {
@@ -410,11 +411,11 @@ class LogEventsList extends ContextSource {
        }
 
        /**
-        * @param $row Row
-        * @param $type Mixed: string/array
-        * @param $action Mixed: string/array
-        * @param $right string
-        * @return Boolean
+        * @param stdClass $row Row
+        * @param string|array $type
+        * @param string|array $action
+        * @param string $right
+        * @return bool
         */
        public static function typeAction( $row, $type, $action, $right = '' ) {
                $match = is_array( $type ) ?
@@ -435,10 +436,10 @@ class LogEventsList extends ContextSource {
         * Determine if the current user is allowed to view a particular
         * field of this log row, if it's marked as deleted.
         *
-        * @param $row Row
-        * @param $field Integer
-        * @param $user User object to check, or null to use $wgUser
-        * @return Boolean
+        * @param stdClass $row Row
+        * @param int $field
+        * @param User $user User to check, or null to use $wgUser
+        * @return bool
         */
        public static function userCan( $row, $field, User $user = null ) {
                return self::userCanBitfield( $row->log_deleted, $field, $user );
@@ -448,10 +449,10 @@ class LogEventsList extends ContextSource {
         * Determine if the current user is allowed to view a particular
         * field of this log row, if it's marked as deleted.
         *
-        * @param $bitfield Integer (current field)
-        * @param $field Integer
-        * @param $user User object to check, or null to use $wgUser
-        * @return Boolean
+        * @param int $bitfield Current field
+        * @param int $field
+        * @param User $user User to check, or null to use $wgUser
+        * @return bool
         */
        public static function userCanBitfield( $bitfield, $field, User $user = null ) {
                if ( $bitfield & $field ) {
@@ -473,9 +474,9 @@ class LogEventsList extends ContextSource {
        }
 
        /**
-        * @param $row Row
-        * @param $field Integer: one of DELETED_* bitfield constants
-        * @return Boolean
+        * @param stdClass $row Row
+        * @param int $field One of DELETED_* bitfield constants
+        * @return bool
         */
        public static function isDeleted( $row, $field ) {
                return ( $row->log_deleted & $field ) == $field;
@@ -484,7 +485,7 @@ class LogEventsList extends ContextSource {
        /**
         * Show log extract. Either with text and a box (set $msgKey) or without (don't set $msgKey)
         *
-        * @param $out OutputPage|String-by-reference
+        * @param OutputPage|string $out By-reference
         * @param string|array $types Log types to show
         * @param string|Title $page The page title to show log entries for
         * @param string $user The user who made the log entries
@@ -501,7 +502,8 @@ class LogEventsList extends ContextSource {
         * - wrap String Wrap the message in html (usually something like "<div ...>$1</div>").
         * - flags Integer display flags (NO_ACTION_LINK,NO_EXTRA_USER_LINKS)
         * - useRequestParams boolean Set true to use Pager-related parameters in the WebRequest
-        * @return Integer Number of total log items (not limited by $lim)
+        * - useMaster boolean Use master DB
+        * @return int Number of total log items (not limited by $lim)
         */
        public static function showLogExtract(
                &$out, $types = array(), $page = '', $user = '', $param = array()
@@ -514,6 +516,7 @@ class LogEventsList extends ContextSource {
                        'wrap' => "$1",
                        'flags' => 0,
                        'useRequestParams' => false,
+                       'useMaster' => false,
                );
                # The + operator appends elements of remaining keys from the right
                # handed array to the left handed, whereas duplicated keys are NOT overwritten.
@@ -546,17 +549,31 @@ class LogEventsList extends ContextSource {
                        $pager->mOffset = "";
                        $pager->mIsBackwards = false;
                }
+
+               if ( $param['useMaster'] ) {
+                       $pager->mDb = wfGetDB( DB_MASTER );
+               }
                if ( isset( $param['offset'] ) ) { # Tell pager to ignore WebRequest offset
                        $pager->setOffset( $param['offset'] );
                }
+
                if ( $lim > 0 ) {
                        $pager->mLimit = $lim;
                }
+
                $logBody = $pager->getBody();
                $s = '';
+
                if ( $logBody ) {
                        if ( $msgKey[0] ) {
-                               $s = '<div class="mw-warning-with-logexcerpt">';
+                               $dir = $context->getLanguage()->getDir();
+                               $lang = $context->getLanguage()->getCode();
+
+                               $s = Xml::openElement( 'div', array(
+                                       'class' => "mw-warning-with-logexcerpt mw-content-$dir",
+                                       'dir' => $dir,
+                                       'lang' => $lang,
+                               ) );
 
                                if ( count( $msgKey ) == 1 ) {
                                        $s .= $context->msg( $msgKey[0] )->parseAsBlock();
@@ -573,6 +590,7 @@ class LogEventsList extends ContextSource {
                        $s = Html::rawElement( 'div', array( 'class' => 'mw-warning-logempty' ),
                                $context->msg( 'logempty' )->parse() );
                }
+
                if ( $pager->getNumRows() > $pager->mLimit ) { # Show "Full log" link
                        $urlParam = array();
                        if ( $page instanceof Title ) {
@@ -580,16 +598,20 @@ class LogEventsList extends ContextSource {
                        } elseif ( $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 .= Linker::link(
                                SpecialPage::getTitleFor( 'Log' ),
                                $context->msg( 'log-fulllog' )->escaped(),
@@ -597,6 +619,7 @@ class LogEventsList extends ContextSource {
                                $urlParam
                        );
                }
+
                if ( $logBody && $msgKey[0] ) {
                        $s .= '</div>';
                }
@@ -621,10 +644,10 @@ class LogEventsList extends ContextSource {
        /**
         * SQL clause to skip forbidden log types for this user
         *
-        * @param $db DatabaseBase
-        * @param $audience string, public/user
-        * @param $user User object to check, or null to use $wgUser
-        * @return Mixed: string or false
+        * @param DatabaseBase $db
+        * @param string $audience Public/user
+        * @param User $user User to check, or null to use $wgUser
+        * @return string|bool String on success, false on failure.
         */
        public static function getExcludeClause( $db, $audience = 'public', User $user = null ) {
                global $wgLogRestrictions;