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

Revision: 56251
Author:   churchofemacs
Date:     2009-09-13 02:07:21 +0000 (Sun, 13 Sep 2009)

Log Message:
-----------
Creating new function wgOutput->showLogs and including new information on 
viewing non-existant user pages. In detail:
Instead of copy&pasting the code in different files, there is now one function 
for showing logs.
This function is currently used for:
* Article and EditPage: Show deletion / move log
* Article: Show rename log on user(talk)pages (NEW in this revision)
* SpecialContributions: Show block log for blocked users
(Note: I removed the condition "log_action != 'revision'". AFAIK it isn't 
needed, log lists are checked for permission somewhere)

Additionally, on user (talk) pages a note is displayed, if the user does not 
exist.

Modified Paths:
--------------
    trunk/phase3/RELEASE-NOTES
    trunk/phase3/includes/Article.php
    trunk/phase3/includes/EditPage.php
    trunk/phase3/includes/OutputPage.php
    trunk/phase3/includes/specials/SpecialContributions.php
    trunk/phase3/languages/messages/MessagesEn.php
    trunk/phase3/maintenance/language/messages.inc

Modified: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES  2009-09-12 22:02:51 UTC (rev 56250)
+++ trunk/phase3/RELEASE-NOTES  2009-09-13 02:07:21 UTC (rev 56251)
@@ -222,6 +222,8 @@
   excerpt from the block log.
 * (bug 19646) New hook: ImgAuthBeforeStream for tests and functionality before
   file is streamed to user, but only when using img_auth
+* Note on non-existing user and user talk pages if user does not exist and show
+  renameuser log if the user has been renamed
 
 === Bug fixes in 1.16 ===
 

Modified: trunk/phase3/includes/Article.php
===================================================================
--- trunk/phase3/includes/Article.php   2009-09-12 22:02:51 UTC (rev 56250)
+++ trunk/phase3/includes/Article.php   2009-09-13 02:07:21 UTC (rev 56251)
@@ -1200,8 +1200,23 @@
         */
        public function showMissingArticle() {
                global $wgOut, $wgRequest, $wgUser;
+
+               # Show info in user (talk) namespace. Does the user exist and 
if not, has he been renamed.
+               if ( $this->mTitle->getNamespace() == NS_USER || 
$this->mTitle->getNamespace() == NS_USER_TALK ) {
+                       $id = User::idFromName( $this->mTitle->getBaseText() );
+                       $ip = User::isIP( $this->mTitle->getBaseText() );
+                       if ( $id == 0 && !$ip ) { # User does not exist
+                               $wgOut->wrapWikiMsg( '<div 
class="mw-userpage-userdoesnotexist error">$1</div>',
+                                       array( 
'userpage-userdoesnotexist-view', $this->mTitle->getBaseText() ) );
+
+                               # Show rename log because user does not exist. 
+                               $parent = $this->mTitle->getNsText() . ":" . 
$this->mTitle->getBaseText();
+                               $wgOut->showLogs( $parent, '', array( 
'renameuser' ), 'renamed-notice' );
+                       }
+
+               }
                # Show delete and move logs
-               $this->showLogs();
+               $wgOut->showLogs( $this->mTitle->getPrefixedText(), '', array( 
'delete', 'move' ), 'moveddeleted-notice' );
 
                # Show error message
                $oldid = $this->getOldID();
@@ -1266,36 +1281,6 @@
                }
        }
 
-       /**
-        * Show an excerpt from the deletion and move logs. To be called from 
the 
-        * header section on page views of missing pages.
-        */
-       public function showLogs() {
-               global $wgUser, $wgOut;
-               $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut );
-               $pager = new LogPager( $loglist, array('move', 'delete'), false,
-                       $this->mTitle->getPrefixedText(), '', array( 
"log_action != 'revision'" ) );
-               if( $pager->getNumRows() > 0 ) {
-                       $pager->mLimit = 10;
-                       $wgOut->addHTML( '<div 
class="mw-warning-with-logexcerpt">' );
-                       $wgOut->addWikiMsg( 'moveddeleted-notice' );
-                       $wgOut->addHTML(
-                               $loglist->beginLogEventsList() .
-                               $pager->getBody() .
-                               $loglist->endLogEventsList()
-                       );
-                       if( $pager->getNumRows() > 10 ) {
-                               $wgOut->addHTML( $wgUser->getSkin()->link(
-                                       SpecialPage::getTitleFor( 'Log' ),
-                                       wfMsgHtml( 'log-fulllog' ),
-                                       array(),
-                                       array( 'page' => 
$this->mTitle->getPrefixedText() )
-                               ) );
-                       }
-                       $wgOut->addHTML( '</div>' );
-               }
-       }
-
        /*
        * Should the parser cache be used?
        */

Modified: trunk/phase3/includes/EditPage.php
===================================================================
--- trunk/phase3/includes/EditPage.php  2009-09-12 22:02:51 UTC (rev 56250)
+++ trunk/phase3/includes/EditPage.php  2009-09-13 02:07:21 UTC (rev 56251)
@@ -730,7 +730,7 @@
                }
                # Give a notice if the user is editing a deleted/moved page...
                if ( !$this->mTitle->exists() ) {
-                       $this->showLogs( $wgOut );
+                       $wgOut->showLogs( $this->mTitle->getPrefixedText(), '', 
array( 'delete', 'move' ), 'recreate-moveddeleted-warn' );
                }
        }
 
@@ -2482,42 +2482,6 @@
        }
 
        /**
-        * If there are rows in the deletion/move log for this page, show them,
-        * along with a nice little note for the user
-        *
-        * @param OutputPage $out
-        */
-       protected function showLogs( $out ) {
-               global $wgUser;
-               $loglist = new LogEventsList( $wgUser->getSkin(), $out );
-               $pager = new LogPager( $loglist, array('move', 'delete'), false,
-                       $this->mTitle->getPrefixedText(), '', array( 
"log_action != 'revision'" ) );
-
-               $count = $pager->getNumRows();
-               if ( $count > 0 ) {
-                       $pager->mLimit = 10;
-                       $out->addHTML( '<div 
class="mw-warning-with-logexcerpt">' );
-                       $out->addWikiMsg( 'recreate-moveddeleted-warn' );
-                       $out->addHTML(
-                               $loglist->beginLogEventsList() .
-                               $pager->getBody() .
-                               $loglist->endLogEventsList()
-                       );
-                       if($count > 10){
-                               $out->addHTML( $wgUser->getSkin()->link(
-                                       SpecialPage::getTitleFor( 'Log' ),
-                                       wfMsgHtml( 'log-fulllog' ),
-                                       array(),
-                                       array( 'page' => 
$this->mTitle->getPrefixedText() ) ) );
-                       }
-                       $out->addHTML( '</div>' );
-                       return true;
-               }
-               
-               return false;
-       }
-
-       /**
         * Attempt submission
         * @return bool false if output is done, true if the rest of the form 
should be displayed
         */

Modified: trunk/phase3/includes/OutputPage.php
===================================================================
--- trunk/phase3/includes/OutputPage.php        2009-09-12 22:02:51 UTC (rev 
56250)
+++ trunk/phase3/includes/OutputPage.php        2009-09-13 02:07:21 UTC (rev 
56251)
@@ -2115,4 +2115,55 @@
                }
                $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-12 
22:02:51 UTC (rev 56250)
+++ trunk/phase3/includes/specials/SpecialContributions.php     2009-09-13 
02:07:21 UTC (rev 56251)
@@ -147,7 +147,7 @@
        * @return String: appropriately-escaped HTML to be output literally
        */
        protected function contributionsSub( $nt, $id ) {
-               global $wgSysopUserBans, $wgLang, $wgUser;
+               global $wgSysopUserBans, $wgLang, $wgUser, $wgOut;
 
                $sk = $wgUser->getSkin();
 
@@ -223,7 +223,11 @@
                        wfRunHooks( 'ContributionsToolLinks', array( $id, $nt, 
&$tools ) );
        
                        $links = $wgLang->pipeList( $tools );
-                       $this->showBlock( $nt, $id );
+
+                       // 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 );
                }
        
                // Old message 'contribsub' had one parameter, but that doesn't 
work for
@@ -238,40 +242,6 @@
        }
 
        /**
-        * Show a note if the user is blocked and display the last block log 
entry.
-        * @param Title $title Title object for the target
-        * @param $userId ID of the user
-        */
-       protected function showBlock( $title, $userId ) {
-               global  $wgUser, $wgOut;
-               if ( !User::newFromID( $userId )->isBlocked() )
-                       return; # User is not blocked, nothing to do here
-               $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut );
-               $pager = new LogPager( $loglist, 'block', false, 
$title->getPrefixedText() );
-               // Check if there is something in the block log.
-               // If this is not the case, either the user is not blocked,
-               // or the account has been hidden via hideuser.
-               if( $pager->getNumRows() > 0 ) {
-                       $pager->mLimit = 1; # Show only latest log entry.
-                       $wgOut->addHTML( '<div 
class="mw-warning-with-logexcerpt">' );
-                       $wgOut->addWikiMsg( 'sp-contributions-blocked-notice' );
-                       $wgOut->addHTML(
-                               $loglist->beginLogEventsList() .
-                               $pager->getBody() .
-                               $loglist->endLogEventsList()
-                       );
-                       if( $pager->getNumRows() > $pager->mLimit ) {
-                               $wgOut->addHTML( $wgUser->getSkin()->link(
-                                       SpecialPage::getTitleFor( 'Log', 
'block' ),
-                                       wfMsgHtml( 'log-fulllog' ),
-                                       array(),
-                                       array( 'page' => 
$title->getPrefixedText() )
-                               ) );
-                       }
-                       $wgOut->addHTML( '</div>' );
-               }
-       }
-       /**
         * Generates the namespace selector form with hidden attributes.
         * @param $this->opts Array: the options to be included.
         */

Modified: trunk/phase3/languages/messages/MessagesEn.php
===================================================================
--- trunk/phase3/languages/messages/MessagesEn.php      2009-09-12 22:02:51 UTC 
(rev 56250)
+++ trunk/phase3/languages/messages/MessagesEn.php      2009-09-13 02:07:21 UTC 
(rev 56251)
@@ -1253,6 +1253,7 @@
 'noarticletextanon'                => '{{int:noarticletext}}', # do not 
translate or duplicate this message to other languages
 'userpage-userdoesnotexist'        => 'User account "$1" is not registered.
 Please check if you want to create/edit this page.',
+'userpage-userdoesnotexist-view'        => 'User account "$1" is not 
registered.',
 'clearyourcache'                   => "'''Note - After saving, you may have to 
bypass your browser's cache to see the changes.'''
 '''Mozilla / Firefox / Safari:''' hold ''Shift'' while clicking ''Reload'', or 
press either ''Ctrl-F5'' or ''Ctrl-R'' (''Command-R'' on a Macintosh);
 '''Konqueror: '''click ''Reload'' or press ''F5'';
@@ -1341,6 +1342,8 @@
 The deletion and move log for this page are provided here for convenience:",
 'moveddeleted-notice'              => 'This page has been deleted.
 The deletion and move log for the page are provided below for reference.',
+'renamed-notice'                   => 'This user has been renamed.
+The rename log is provided below for reference.',
 'log-fulllog'                      => 'View full log',
 'edit-hook-aborted'                => 'Edit aborted by hook.
 It gave no explanation.',

Modified: trunk/phase3/maintenance/language/messages.inc
===================================================================
--- trunk/phase3/maintenance/language/messages.inc      2009-09-12 22:02:51 UTC 
(rev 56250)
+++ trunk/phase3/maintenance/language/messages.inc      2009-09-13 02:07:21 UTC 
(rev 56251)
@@ -540,6 +540,7 @@
                'noarticletext-nopermission',
                'noarticletextanon',
                'userpage-userdoesnotexist',
+               'userpage-userdoesnotexist-view',
                'clearyourcache',
                'usercssyoucanpreview',
                'userjsyoucanpreview',
@@ -588,6 +589,7 @@
                'permissionserrorstext-withaction',
                'recreate-moveddeleted-warn',
                'moveddeleted-notice',
+               'renamed-notice',
                'log-fulllog',
                'edit-hook-aborted',
                'edit-gone-missing',



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

Reply via email to