Follow-up on r56284: LogEventsList::showLogExtract gets associative array for additio...
authorTobias <churchofemacs@users.mediawiki.org>
Wed, 16 Sep 2009 17:17:16 +0000 (17:17 +0000)
committerTobias <churchofemacs@users.mediawiki.org>
Wed, 16 Sep 2009 17:17:16 +0000 (17:17 +0000)
includes/Article.php
includes/EditPage.php
includes/HistoryPage.php
includes/LogEventsList.php
includes/specials/SpecialBlockip.php
includes/specials/SpecialContributions.php
includes/specials/SpecialMovepage.php
includes/specials/SpecialRevisiondelete.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index 9a00059..846061a 100644 (file)
@@ -1209,19 +1209,14 @@ class Article {
                                $wgOut->wrapWikiMsg( '<div class="mw-userpage-userdoesnotexist error">$1</div>',
                                        array( 'userpage-userdoesnotexist-view', $this->mTitle->getBaseText() ) );
                        }
-
                }
                wfRunHooks( 'ShowMissingArticle', array( $this ) );
                # Show delete and move logs
-               LogEventsList::showLogExtract(
-                       $wgOut,
-                       array( 'delete', 'move' ), 
-                       $this->mTitle->getPrefixedText(),
-                       '',
-                       10,
-                       array( "log_action != 'revision'" ),
-                       false,
-                       array( 'moveddeleted-notice' )
+               LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' ), $this->mTitle->getPrefixedText(), '',
+                       array(  'lim' => 10,
+                               'conds' => array( "log_action != 'revision'" ),
+                               'showIfEmpty' => false,
+                               'msgKey' => array( 'moveddeleted-notice' ) ) 
                );
 
                # Show error message
index ed0966a..bf7bb63 100644 (file)
@@ -730,8 +730,12 @@ class EditPage {
                }
                # Give a notice if the user is editing a deleted/moved page...
                if ( !$this->mTitle->exists() ) {
-                       LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' ), 
-                               $this->mTitle->getPrefixedText(), '', 10, array( "log_action != 'revision'" ), false, 'recreate-moveddeleted-warn');
+                       LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' ), $this->mTitle->getPrefixedText(), 
+                               '', array( 'lim' => 10, 
+                                          'conds' => array( "log_action != 'revision'" ), 
+                                          'showIfEmpty' => false, 
+                                          'msgKey' => array( 'recreate-moveddeleted-warn') ) 
+                       );
                }
        }
 
@@ -1278,10 +1282,8 @@ class EditPage {
                                $noticeMsg = 'protectedpagewarning';
                                $classes[] = 'mw-textarea-protected';
                        }
-                       $wgOut->addHTML( "<div class='mw-warning-with-logexcerpt'>\n" );
-                       $wgOut->addWikiMsg( $noticeMsg );
-                       LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle->getPrefixedText(), '', 1 );
-                       $wgOut->addHTML( "</div>\n" );
+                       LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle->getPrefixedText(), '', 
+                               array( 'lim' => 1, 'msgKey' => array( $noticeMsg ) ) );
                }
                if ( $this->mTitle->isCascadeProtected() ) {
                        # Is this page under cascading protection from some source pages?
index 9e8988e..81ab58b 100644 (file)
@@ -105,7 +105,13 @@ class HistoryPage {
                 */
                if( !$this->title->exists() ) {
                        $wgOut->addWikiMsg( 'nohistory' );
-                       $this->article->showLogs(); // show deletion/move log if there is an entry
+                       # show deletion/move log if there is an entry
+                       LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' ), $this->title->getPrefixedText(), '',
+                               array(  'lim' => 10,
+                                       'conds' => array( "log_action != 'revision'" ),
+                                       'showIfEmpty' => false,
+                                       'msgKey' => array( 'moveddeleted-notice' ) ) 
+                       );
                        wfProfileOut( __METHOD__ );
                        return;
                }
index 700c140..c5abc23 100644 (file)
@@ -571,26 +571,36 @@ class LogEventsList {
         * @param $types String or Array
         * @param $page String The page title to show log entries for
         * @param $user String The user who made the log entries
-        * @param $lim Integer Limit of items to show, default is 50
-        * @param $conds Array Extra conditions for the query
-        * @param $showIfEmpty boolean Set to false if you don't want any output in case the loglist is empty
+        * @param $param Associative Array with the following additional options:
+        *      lim Integer Limit of items to show, default is 50
+        *      conds Array Extra conditions for the query (e.g. "log_action != 'revision'")
+        *      showIfEmpty boolean Set to false if you don't want any output in case the loglist is empty
         *              if set to true (default), "No matching items in log" is displayed if loglist is empty
-        * @param $msgKey Array If you want a nice box with a message, set this
+        *      msgKey Array If you want a nice box with a message, set this
         *              to the key of the message. First element is the message
         *              key, additional optional elements are parameters for the
         *              key that are processed with wgMsgExt and option 'parse'
         * @return Integer Number of total log items (not limited by $lim)
         */
-       public static function showLogExtract( &$out, $types=array(), $page='', $user='', $lim=0, $conds=array(), $showIfEmpty = true, $msgKey = array() ) {
+       public static function showLogExtract( &$out, $types=array(), $page='', $user='', 
+                       $param = array( 'lim' => 0, 'conds' => array(), 'showIfEmpty' => true, 'msgKey' => array('') ) ) {
+
                global $wgUser, $wgOut;
-               # Insert list of top 50 or so items
+               # Convert $param array to individual variables
+               $lim = $param['lim'];
+               $conds = $param['conds'];
+               $showIfEmpty = $param['showIfEmpty'];
+               $msgKey = $param['msgKey'];
+               if ( !(is_array($msgKey)) )
+                       $msgKey = array( $msgKey );
+               # Insert list of top 50 (or top $lim) items
                $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 );
                $pager = new LogPager( $loglist, $types, $user, $page, '', $conds );
                if( $lim > 0 ) $pager->mLimit = $lim;
                $logBody = $pager->getBody();
                $s = '';
                if( $logBody ) {
-                       if ( $msgKey ) {
+                       if ( $msgKey[0] ) {
                                $s = '<div class="mw-warning-with-logexcerpt">';
 
                                if ( count( $msgKey ) == 1 ) {
@@ -627,7 +637,7 @@ class LogEventsList {
                        );
 
                }
-               if ( $logBody && $msgKey )
+               if ( $logBody && $msgKey[0] )
                        $s .= '</div>';
 
                if( $out instanceof OutputPage ){
index e319ba7..03a4bd3 100644 (file)
@@ -585,22 +585,13 @@ class IPBlockForm {
 
        private function showLogFragment( $out, $title ) {
                global $wgUser;
-               $out->addHTML( Xml::element( 'h2', NULL, LogPage::logName( 'block' ) ) );
-               $count = LogEventsList::showLogExtract( $out, 'block', $title->getPrefixedText(), '', 10 );
-               if( $count > 10 ) {
-                       $out->addHTML( $wgUser->getSkin()->link(
-                               SpecialPage::getTitleFor( 'Log' ),
-                               wfMsgHtml( 'blocklog-fulllog' ),
-                               array(),
-                               array(
-                                       'type' => 'block',
-                                       'page' => $title->getPrefixedText() ) ) );
-               }
+               LogEventsList::showLogExtract( $out, 'block', $title->getPrefixedText(), '', 
+                       array( 'lim' => 10, 'msgKey' => array( 'blocklog-showlog' ) ) );
                // Add suppression block entries if allowed
-               if( $wgUser->isAllowed('hideuser') ) {
-                       $out->addHTML( Xml::element( 'h2', NULL, LogPage::logName( 'suppress' ) ) );
+               if( $wgUser->isAllowed( 'hideuser' ) ) {
                        LogEventsList::showLogExtract( $out, 'suppress', $title->getPrefixedText(), '',
-                               10, array('log_action' => array('block','reblock','unblock')) );
+                               array('lim' => 10, 'conds' => array('log_action' => array('block','reblock','unblock')), 
+                               'msgKey' => array( 'blocklog-showsuppresslog' ) ) );
                }
        }
 
index f918131..1d6a591 100644 (file)
@@ -226,8 +226,8 @@ class SpecialContributions extends SpecialPage {
 
                        // Show a note if the user is blocked and display the last block log entry.
                        if ( User::newFromID( $id )->isBlocked() )
-                               LogEventsList::showLogExtract( $wgOut, 'block', $nt->getPrefixedText(), '', 1, 
-                                       array(), false, 'sp-contributions-blocked-notice' );
+                               LogEventsList::showLogExtract( $wgOut, 'block', $nt->getPrefixedText(), '',
+                                       array( 'lim' => 1, 'showIfEmpty' => false, 'msgKey' => array( 'sp-contributions-blocked-notice' ) ) );
                }
        
                // Old message 'contribsub' had one parameter, but that doesn't work for
index 68ba065..e973ff5 100644 (file)
@@ -180,7 +180,7 @@ class MovePageForm {
                        }
                        $wgOut->addHTML( "<div class='mw-warning-with-logexcerpt'>\n" );
                        $wgOut->addWikiMsg( $noticeMsg );
-                       LogEventsList::showLogExtract( $wgOut, 'protect', $this->oldTitle->getPrefixedText(), '', 1 );
+                       LogEventsList::showLogExtract( $wgOut, 'protect', $this->oldTitle->getPrefixedText(), '', array( 'lim' => 1 ) );
                        $wgOut->addHTML( "</div>\n" );
                }
 
index c4656b3..aeb0e3d 100644 (file)
@@ -184,12 +184,12 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                # Show relevant lines from the deletion log
                $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" );
                LogEventsList::showLogExtract( $wgOut, 'delete',
-                       $this->targetObj->getPrefixedText(), '', 25, $qc );
+                       $this->targetObj->getPrefixedText(), '', array( 'lim' => 25, 'conds' => $qc ) );
                # Show relevant lines from the suppression log
                if( $wgUser->isAllowed( 'suppressionlog' ) ) {
                        $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'suppress' ) ) . "</h2>\n" );
                        LogEventsList::showLogExtract( $wgOut, 'suppress',
-                               $this->targetObj->getPrefixedText(), '', 25, $qc );
+                               $this->targetObj->getPrefixedText(), '', array( 'lim' => 25, 'conds' => $qc ) );
                }
        }
 
index b4749ef..d986f5b 100644 (file)
@@ -2945,7 +2945,8 @@ See [[Special:IPBlockList|IP block list]] to review blocks.',
 'autoblocker'                     => 'Autoblocked because your IP address has been recently used by "[[User:$1|$1]]".
 The reason given for $1\'s block is: "$2"',
 'blocklogpage'                    => 'Block log',
-'blocklog-fulllog'                => 'Full block log',
+'blocklog-showlog'                => 'This user has been blocked previously. The block log is provided below for reference:',
+'blocklog-showsuppresslog'        => 'This user has been blocked and hidden previously. The suppress log is provided below for reference:',
 'blocklogentry'                   => 'blocked [[$1]] with an expiry time of $2 $3',
 'reblock-logentry'                => 'changed block settings for [[$1]] with an expiry time of $2 $3',
 'blocklogtext'                    => 'This is a log of user blocking and unblocking actions.
index d1ef3c3..2dcd6df 100644 (file)
@@ -1987,7 +1987,8 @@ $wgMessageStructure = array(
                'contribslink',
                'autoblocker',
                'blocklogpage',
-               'blocklog-fulllog',
+               'blocklog-showlog',
+               'blocklog-showsuppresslog',
                'blocklogentry',
                'reblock-logentry',
                'blocklogtext',