From: Tobias Date: Wed, 16 Sep 2009 17:17:16 +0000 (+0000) Subject: Follow-up on r56284: LogEventsList::showLogExtract gets associative array for additio... X-Git-Tag: 1.31.0-rc.0~39711 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_aide%28?a=commitdiff_plain;h=bebaf1325dd70f28048898439f3b394e258590ab;p=lhc%2Fweb%2Fwiklou.git Follow-up on r56284: LogEventsList::showLogExtract gets associative array for additional parameters. Adjusted all calls that use additional parameters. Also improved Special:Blockip, which now uses those new parameters instead of using own functions. Fixed HistoryPage which was broken with r56251. --- diff --git a/includes/Article.php b/includes/Article.php index 9a000599a2..846061a42c 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1209,19 +1209,14 @@ class Article { $wgOut->wrapWikiMsg( '
$1
', 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 diff --git a/includes/EditPage.php b/includes/EditPage.php index ed0966aafa..bf7bb63c50 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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( "
\n" ); - $wgOut->addWikiMsg( $noticeMsg ); - LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle->getPrefixedText(), '', 1 ); - $wgOut->addHTML( "
\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? diff --git a/includes/HistoryPage.php b/includes/HistoryPage.php index 9e8988ec8d..81ab58b2c3 100644 --- a/includes/HistoryPage.php +++ b/includes/HistoryPage.php @@ -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; } diff --git a/includes/LogEventsList.php b/includes/LogEventsList.php index 700c140642..c5abc23f2a 100644 --- a/includes/LogEventsList.php +++ b/includes/LogEventsList.php @@ -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 = '
'; if ( count( $msgKey ) == 1 ) { @@ -627,7 +637,7 @@ class LogEventsList { ); } - if ( $logBody && $msgKey ) + if ( $logBody && $msgKey[0] ) $s .= '
'; if( $out instanceof OutputPage ){ diff --git a/includes/specials/SpecialBlockip.php b/includes/specials/SpecialBlockip.php index e319ba7954..03a4bd3486 100644 --- a/includes/specials/SpecialBlockip.php +++ b/includes/specials/SpecialBlockip.php @@ -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' ) ) ); } } diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index f918131590..1d6a591eec 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -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 diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index 68ba065932..e973ff5d26 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -180,7 +180,7 @@ class MovePageForm { } $wgOut->addHTML( "
\n" ); $wgOut->addWikiMsg( $noticeMsg ); - LogEventsList::showLogExtract( $wgOut, 'protect', $this->oldTitle->getPrefixedText(), '', 1 ); + LogEventsList::showLogExtract( $wgOut, 'protect', $this->oldTitle->getPrefixedText(), '', array( 'lim' => 1 ) ); $wgOut->addHTML( "
\n" ); } diff --git a/includes/specials/SpecialRevisiondelete.php b/includes/specials/SpecialRevisiondelete.php index c4656b3e0f..aeb0e3d1c9 100644 --- a/includes/specials/SpecialRevisiondelete.php +++ b/includes/specials/SpecialRevisiondelete.php @@ -184,12 +184,12 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { # Show relevant lines from the deletion log $wgOut->addHTML( "

" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "

\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( "

" . htmlspecialchars( LogPage::logName( 'suppress' ) ) . "

\n" ); LogEventsList::showLogExtract( $wgOut, 'suppress', - $this->targetObj->getPrefixedText(), '', 25, $qc ); + $this->targetObj->getPrefixedText(), '', array( 'lim' => 25, 'conds' => $qc ) ); } } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index b4749ef2bc..d986f5b835 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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. diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index d1ef3c3126..2dcd6df170 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1987,7 +1987,8 @@ $wgMessageStructure = array( 'contribslink', 'autoblocker', 'blocklogpage', - 'blocklog-fulllog', + 'blocklog-showlog', + 'blocklog-showsuppresslog', 'blocklogentry', 'reblock-logentry', 'blocklogtext',