Minor resource loader changes:
[lhc/web/wiklou.git] / includes / LogEventsList.php
index 045644d..dd20d50 100644 (file)
@@ -1,21 +1,27 @@
 <?php
-# Copyright (C) 2004 Brion Vibber <brion@pobox.com>, 2008 Aaron Schulz
-# http://www.mediawiki.org/
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-# http://www.gnu.org/copyleft/gpl.html
+/**
+ * Contain classes to list log entries
+ *
+ * Copyright © 2004 Brion Vibber <brion@pobox.com>, 2008 Aaron Schulz
+ * http://www.mediawiki.org/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
 
 class LogEventsList {
        const NO_ACTION_LINK = 1;
@@ -41,7 +47,7 @@ class LogEventsList {
                if( !isset( $this->message ) ) {
                        $messages = array( 'revertmerge', 'protect_change', 'unblocklink', 'change-blocklink',
                                'revertmove', 'undeletelink', 'undeleteviewlink', 'revdel-restore', 'hist', 'diff',
-                               'pipe-separator' );
+                               'pipe-separator', 'revdel-restore-deleted', 'revdel-restore-visible' );
                        foreach( $messages as $msg ) {
                                $this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
                        }
@@ -65,6 +71,7 @@ class LogEventsList {
 
        /**
         * Show options for the log list
+        *
         * @param $types string or Array
         * @param $user String
         * @param $page String
@@ -107,7 +114,7 @@ class LogEventsList {
 
                // Tag filter
                if ($tagSelector) {
-                       $html .= Xml::tags( 'p', null, implode( '&nbsp;', $tagSelector ) );
+                       $html .= Xml::tags( 'p', null, implode( '&#160;', $tagSelector ) );
                }
 
                // Filter links
@@ -356,7 +363,7 @@ class LogEventsList {
 
        // @TODO: split up!
        private function logActionLinks( $row, $title, $paramArray, &$comment ) {
-               global $wgUser, $wgLang;
+               global $wgUser;
                if( ( $this->flags & self::NO_ACTION_LINK ) // we don't want to see the action
                        || self::isDeleted( $row, LogPage::DELETED_ACTION ) ) // action is hidden
                {
@@ -450,57 +457,8 @@ class LogEventsList {
                        ) . ')';
                // If an edit was hidden from a page give a review link to the history
                } else if( self::typeAction( $row, array( 'delete', 'suppress' ), 'revision', 'deletedhistory' ) ) {
-                       if( count($paramArray) >= 2 ) {
-                               // Different revision types use different URL params...
-                               $key = $paramArray[0];
-                               // $paramArray[1] is a CSV of the IDs
-                               $Ids = explode( ',', $paramArray[1] );
-                               $query = $paramArray[1];
-                               $revert = array();
-                               // Diff link for single rev deletions
-                               if( count($Ids) == 1 ) {
-                                       // Live revision diffs...
-                                       if( in_array( $key, array( 'oldid', 'revision' ) ) ) {
-                                               $revert[] = $this->skin->link(
-                                                       $title,
-                                                       $this->message['diff'],
-                                                       array(),
-                                                       array(
-                                                               'diff' => intval( $Ids[0] ),
-                                                               'unhide' => 1
-                                                       ),
-                                                       array( 'known', 'noclasses' )
-                                               );
-                                       // Deleted revision diffs...
-                                       } else if( in_array( $key, array( 'artimestamp','archive' ) ) ) {
-                                               $revert[] = $this->skin->link(
-                                                       SpecialPage::getTitleFor( 'Undelete' ),
-                                                       $this->message['diff'], 
-                                                       array(),
-                                                       array(
-                                                               'target'    => $title->getPrefixedDBKey(),
-                                                               'diff'      => 'prev',
-                                                               'timestamp' => $Ids[0]
-                                                       ),
-                                                       array( 'known', 'noclasses' )
-                                               );
-                                       }
-                               }
-                               // View/modify link...
-                               $revert[] = $this->skin->link(
-                                       SpecialPage::getTitleFor( 'Revisiondelete' ),
-                                       $this->message['revdel-restore'],
-                                       array(),
-                                       array(
-                                               'target' => $title->getPrefixedText(),
-                                               'type' => $key,
-                                               'ids' => $query
-                                       ),
-                                       array( 'known', 'noclasses' )
-                               );
-                               // Pipe links
-                               $revert = wfMsg( 'parentheses', $wgLang->pipeList( $revert ) );
-                       }
+                       $revert = RevisionDeleter::getLogLinks( $title, $paramArray,
+                                                               $this->skin, $this->message );
                // Hidden log items, give review link
                } else if( self::typeAction( $row, array( 'delete', 'suppress' ), 'event', 'deletedhistory' ) ) {
                        if( count($paramArray) >= 1 ) {
@@ -585,7 +543,7 @@ class LogEventsList {
         * @param $type Mixed: string/array
         * @param $action Mixed: string/array
         * @param $right string
-        * @return bool
+        * @return Boolean
         */
        public static function typeAction( $row, $type, $action, $right='' ) {
                $match = is_array($type) ?
@@ -604,6 +562,7 @@ class LogEventsList {
        /**
         * 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
         * @return Boolean
@@ -611,10 +570,11 @@ class LogEventsList {
        public static function userCan( $row, $field ) {
                return self::userCanBitfield( $row->log_deleted, $field );
        }
-       
+
        /**
         * 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
         * @return Boolean
@@ -646,6 +606,7 @@ class LogEventsList {
 
        /**
         * Show log extract. Either with text and a box (set $msgKey) or without (don't set $msgKey)
+        *
         * @param $out OutputPage or String-by-reference
         * @param $types String or Array
         * @param $page String The page title to show log entries for
@@ -755,9 +716,10 @@ class LogEventsList {
 
        /**
         * SQL clause to skip forbidden log types for this user
+        *
         * @param $db Database
         * @param $audience string, public/user
-        * @return mixed (string or false)
+        * @return Mixed: string or false
         */
        public static function getExcludeClause( $db, $audience = 'public' ) {
                global $wgLogRestrictions, $wgUser;
@@ -788,15 +750,17 @@ class LogPager extends ReverseChronologicalPager {
        public $mLogEventsList;
 
        /**
-        * constructor
+        * Constructor
+        *
         * @param $list LogEventsList
-        * @param $types String or Array log types to show
-        * @param $user String The user who made the log entries
-        * @param $title String The page title the log entries are for
-        * @param $pattern String Do a prefix search rather than an exact title match
-        * @param $conds Array Extra conditions for the query
-        * @param $year Integer The year to start from
-        * @param $month Integer The month to start from
+        * @param $types String or Array: log types to show
+        * @param $user String: the user who made the log entries
+        * @param $title String: the page title the log entries are for
+        * @param $pattern String: do a prefix search rather than an exact title match
+        * @param $conds Array: extra conditions for the query
+        * @param $year Integer: the year to start from
+        * @param $month Integer: the month to start from
+        * @param $tagFilter String: tag
         */
        public function __construct( $list, $types = array(), $user = '', $title = '', $pattern = '',
                $conds = array(), $year = false, $month = false, $tagFilter = '' ) 
@@ -844,6 +808,7 @@ class LogPager extends ReverseChronologicalPager {
        /**
         * Set the log reader to return only entries of the given type.
         * Type restrictions enforced here
+        *
         * @param $types String or array: Log types ('upload', 'delete', etc);
         *   empty string means no restriction
         */
@@ -876,6 +841,7 @@ class LogPager extends ReverseChronologicalPager {
 
        /**
         * Set the log reader to return only entries by the given user.
+        *
         * @param $name String: (In)valid user name
         */
        private function limitUser( $name ) {
@@ -909,6 +875,7 @@ class LogPager extends ReverseChronologicalPager {
        /**
         * Set the log reader to return only entries affecting the given page.
         * (For the block and rights logs, this is a user page.)
+        *
         * @param $page String: Title name as text
         * @param $pattern String
         */
@@ -952,7 +919,6 @@ class LogPager extends ReverseChronologicalPager {
        }
 
        public function getQueryInfo() {
-               global $wgOut;
                $tables = array( 'logging', 'user' );
                $this->mConds[] = 'user_id = log_user';
                $index = array();
@@ -1063,6 +1029,7 @@ class LogPager extends ReverseChronologicalPager {
  */
 class LogReader {
        var $pager;
+
        /**
         * @param $request WebRequest: for internal use use a FauxRequest object to pass arbitrary parameters.
         */
@@ -1127,6 +1094,7 @@ class LogViewer {
         * Take over the whole output page in $wgOut with the log display.
         */
        public function show() {
+               global $wgOut;
                # Set title and add header
                $this->list->showHeader( $pager->getType() );
                # Show form options
@@ -1151,6 +1119,7 @@ class LogViewer {
         * Output just the list of entries given by the linked LogReader,
         * with extraneous UI elements. Use for displaying log fragments in
         * another page (eg at Special:Undelete)
+        *
         * @param $out OutputPage: where to send output
         */
        public function showList( &$out ) {