http://www.mediawiki.org/wiki/Special:Code/MediaWiki/56284

Revision: 56284
Author:   churchofemacs
Date:     2009-09-13 22:21:11 +0000 (Sun, 13 Sep 2009)

Log Message:
-----------
Follow-up on r56251 - merging showLogs and showLogExtract

Modified Paths:
--------------
    trunk/phase3/includes/Article.php
    trunk/phase3/includes/EditPage.php
    trunk/phase3/includes/LogEventsList.php
    trunk/phase3/includes/OutputPage.php
    trunk/phase3/includes/specials/SpecialContributions.php

Modified: trunk/phase3/includes/Article.php
===================================================================
--- trunk/phase3/includes/Article.php   2009-09-13 21:17:38 UTC (rev 56283)
+++ trunk/phase3/includes/Article.php   2009-09-13 22:21:11 UTC (rev 56284)
@@ -1211,12 +1211,13 @@
 
                                # Show rename log because user does not exist. 
                                $parent = $this->mTitle->getNsText() . ":" . 
$this->mTitle->getBaseText();
-                               $wgOut->showLogs( $parent, '', array( 
'renameuser' ), 'renamed-notice' );
+                               LogEventsList::showLogExtract( $wgOut, 
'renameuser', $parent, '', 10, array(), false, 'renamed-notice' );
                        }
 
                }
                # Show delete and move logs
-               $wgOut->showLogs( $this->mTitle->getPrefixedText(), '', array( 
'delete', 'move' ), 'moveddeleted-notice' );
+               LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' 
), 
+                       $this->mTitle->getPrefixedText(), '', 10, array( 
"log_action != 'revision'" ), false, 'moveddeleted-notice');
 
                # Show error message
                $oldid = $this->getOldID();

Modified: trunk/phase3/includes/EditPage.php
===================================================================
--- trunk/phase3/includes/EditPage.php  2009-09-13 21:17:38 UTC (rev 56283)
+++ trunk/phase3/includes/EditPage.php  2009-09-13 22:21:11 UTC (rev 56284)
@@ -730,7 +730,8 @@
                }
                # Give a notice if the user is editing a deleted/moved page...
                if ( !$this->mTitle->exists() ) {
-                       $wgOut->showLogs( $this->mTitle->getPrefixedText(), '', 
array( 'delete', 'move' ), 'recreate-moveddeleted-warn' );
+                       LogEventsList::showLogExtract( $wgOut, array( 'delete', 
'move' ), 
+                               $this->mTitle->getPrefixedText(), '', 10, 
array( "log_action != 'revision'" ), false, 'recreate-moveddeleted-warn');
                }
        }
 

Modified: trunk/phase3/includes/LogEventsList.php
===================================================================
--- trunk/phase3/includes/LogEventsList.php     2009-09-13 21:17:38 UTC (rev 
56283)
+++ trunk/phase3/includes/LogEventsList.php     2009-09-13 22:21:11 UTC (rev 
56284)
@@ -556,15 +556,19 @@
        }
 
        /**
-        * Quick function to show a short log extract
+        * 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
         * @param $user String
-        * @param $lim Integer
+        * @param $lim Integer Limit of items to show, default is 50
         * @param $conds Array
+        * @param $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 String if you want a nice box with a message, set 
this to the key of the message
+        * @return Integer Number of total log items (not limited by $lim)
         */
-       public static function showLogExtract( &$out, $types=array(), $page='', 
$user='', $lim=0, $conds=array() ) {
+       public static function showLogExtract( &$out, $types=array(), $page='', 
$user='', $lim=0, $conds=array(), $showIfEmpty = true, $msgKey = '' ) {
                global $wgUser, $wgOut;
                # Insert list of top 50 or so items
                $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 );
@@ -572,12 +576,37 @@
                if( $lim > 0 ) $pager->mLimit = $lim;
                $logBody = $pager->getBody();
                if( $logBody ) {
-                       $s = $loglist->beginLogEventsList() .
+                       if ( $msgKey )
+                               $s = '<div class="mw-warning-with-logexcerpt">' 
. wfMsg( $msgKey ) ;
+                       $s .= $loglist->beginLogEventsList() .
                                 $logBody .
                                 $loglist->endLogEventsList();
                } else {
-                       $s = wfMsgExt( 'logempty', array('parse') );
+                       if ( $showIfEmpty )
+                               $s = wfMsgExt( 'logempty', array('parse') );
                }
+               if( $pager->getNumRows() > $pager->mLimit ) { # Show "Full log" 
link
+                       $urlParam = array();
+                       if ( $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 .= $wgUser->getSkin()->link(
+                               SpecialPage::getTitleFor( 'Log' ),
+                               wfMsgHtml( 'log-fulllog' ),
+                               array(),
+                               $urlParam
+                       );
+
+               }
+               if ( $logBody && $msgKey )
+                       $s .= '</div>';
+
                if( $out instanceof OutputPage ){
                        $out->addHTML( $s );
                } else {

Modified: trunk/phase3/includes/OutputPage.php
===================================================================
--- trunk/phase3/includes/OutputPage.php        2009-09-13 21:17:38 UTC (rev 
56283)
+++ trunk/phase3/includes/OutputPage.php        2009-09-13 22:21:11 UTC (rev 
56284)
@@ -2115,55 +2115,4 @@
                }
                $this->addHTML( $this->parse( $s, /*linestart*/true, 
/*uilang*/true ) );
        }
-       /*
-        * Show log excerpt. All parameters are optional 
-        * (but it makes sense to define at least $page OR $user)
-        * @param String $page Page title for filtering the log
-        * @param String $user Username for filtering the log
-        * @param String $logtypes Log types, like delete, move, etc.
-        *      May be a single log type or an array of log types
-        * @param int $numEntries Number of log entries to show at maximum 
(default: 10)
-        *      If there are too many entries, a "View full log" link is 
displayed
-        * @return boolean Returns true if there was something in the log
-        */
-       public function showLogs( $page = '', $user = '', $logtypes = array(), 
$msgKey = '' , $numEntries = 10 ) {
-               global $wgUser, $wgOut;
-               $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut );
-               $pager = new LogPager( $loglist, $logtypes, $user, $page);
-               if( $pager->getNumRows() > 0 ) {
-                       $pager->mLimit = $numEntries;
-                       $wgOut->addHTML( '<div 
class="mw-warning-with-logexcerpt">' );
-                       if ( $msgKey )
-                               $wgOut->addWikiMsg( $msgKey );
-                       $wgOut->addHTML(
-                               $loglist->beginLogEventsList() .
-                               $pager->getBody() .
-                               $loglist->endLogEventsList()
-                       );
-                       if( $pager->getNumRows() > $numEntries ) { # Show "Full 
log" link
-                               $urlParam = array();
-                               if ( $page != '')
-                                       $urlParam['page'] = $page;
-                               if ( $user != '')
-                                       $urlParam['user'] = $user;
-                               if ( !is_array( $logtypes ) ) # Make it an 
array, if it isn't
-                                       $logtypes = array( $logtypes );
-                               # If there is exactly one log type, we can link 
to Special:Log/type
-                               if ( count( $logtypes ) == 1 )
-                                       $urlParam['type'] = $logtypes[0];
-                               $wgOut->addHTML( $wgUser->getSkin()->link(
-                                       SpecialPage::getTitleFor( 'Log' ),
-                                       wfMsgHtml( 'log-fulllog' ),
-                                       array(),
-                                       $urlParam
-                               ) );
-
-                       }
-                       $wgOut->addHTML( '</div>' );
-                       return true;
-               }
-               return false;
-       }
-
-
 }

Modified: trunk/phase3/includes/specials/SpecialContributions.php
===================================================================
--- trunk/phase3/includes/specials/SpecialContributions.php     2009-09-13 
21:17:38 UTC (rev 56283)
+++ trunk/phase3/includes/specials/SpecialContributions.php     2009-09-13 
22:21:11 UTC (rev 56284)
@@ -226,8 +226,8 @@
 
                        // Show a note if the user is blocked and display the 
last block log entry.
                        if ( User::newFromID( $id )->isBlocked() )
-                               $wgOut->showLogs( $nt->getPrefixedText(), '', 
array( 'block' ), 
-                                               
'sp-contributions-blocked-notice', 1 );
+                               LogEventsList::showLogExtract( $wgOut, 'block', 
$nt->getPrefixedText(), '', 1, 
+                                       array(), false, 
'sp-contributions-blocked-notice' );
                }
        
                // Old message 'contribsub' had one parameter, but that doesn't 
work for



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to