From 1c676f6a63258698fe3302663b375ddb9c032e79 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 13 Sep 2009 02:07:21 +0000 Subject: [PATCH] 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. --- RELEASE-NOTES | 2 + includes/Article.php | 47 +++++++------------- includes/EditPage.php | 38 +--------------- includes/OutputPage.php | 51 ++++++++++++++++++++++ includes/specials/SpecialContributions.php | 42 +++--------------- languages/messages/MessagesEn.php | 3 ++ maintenance/language/messages.inc | 2 + 7 files changed, 81 insertions(+), 104 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index bb5253b6d3..69df20e874 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -222,6 +222,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN 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 === diff --git a/includes/Article.php b/includes/Article.php index efc3961066..175b540676 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1200,8 +1200,23 @@ class Article { */ 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( '
$1
', + 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 @@ class Article { } } - /** - * 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( '
' ); - $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( '
' ); - } - } - /* * Should the parser cache be used? */ diff --git a/includes/EditPage.php b/includes/EditPage.php index 001e04b3d8..1daf606c80 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -730,7 +730,7 @@ class EditPage { } # 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' ); } } @@ -2481,42 +2481,6 @@ END $wgOut->addWikiMsg( 'nocreatetext' ); } - /** - * 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( '
' ); - $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( '
' ); - return true; - } - - return false; - } - /** * Attempt submission * @return bool false if output is done, true if the rest of the form should be displayed diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 3843787c8b..2a54ddac5c 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2115,4 +2115,55 @@ class OutputPage { } $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( '
' ); + 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( '
' ); + return true; + } + return false; + } + + } diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index beed2a73fd..daf7413226 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -147,7 +147,7 @@ class SpecialContributions extends SpecialPage { * @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 @@ class SpecialContributions extends SpecialPage { 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 @@ -237,40 +241,6 @@ class SpecialContributions extends SpecialPage { } } - /** - * 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( '
' ); - $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( '
' ); - } - } /** * Generates the namespace selector form with hidden attributes. * @param $this->opts Array: the options to be included. diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 88dc8f4b10..d61351af30 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1253,6 +1253,7 @@ or [{{fullurl:{{#Special:Log}}|page={{urlencode:{{FULLP '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 @@ You should consider whether it is appropriate to continue editing this page. 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.', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index cdf2ff9bcd..5ed0e1ba04 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -540,6 +540,7 @@ $wgMessageStructure = array( 'noarticletext-nopermission', 'noarticletextanon', 'userpage-userdoesnotexist', + 'userpage-userdoesnotexist-view', 'clearyourcache', 'usercssyoucanpreview', 'userjsyoucanpreview', @@ -588,6 +589,7 @@ $wgMessageStructure = array( 'permissionserrorstext-withaction', 'recreate-moveddeleted-warn', 'moveddeleted-notice', + 'renamed-notice', 'log-fulllog', 'edit-hook-aborted', 'edit-gone-missing', -- 2.20.1