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.
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 ===
*/
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();
}
}
- /**
- * 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?
*/
}
# 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' );
}
}
$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( '<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
}
$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;
+ }
+
+
}
* @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();
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
}
}
- /**
- * 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.
'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'';
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.',
'noarticletext-nopermission',
'noarticletextanon',
'userpage-userdoesnotexist',
+ 'userpage-userdoesnotexist-view',
'clearyourcache',
'usercssyoucanpreview',
'userjsyoucanpreview',
'permissionserrorstext-withaction',
'recreate-moveddeleted-warn',
'moveddeleted-notice',
+ 'renamed-notice',
'log-fulllog',
'edit-hook-aborted',
'edit-gone-missing',