Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -2115,55 +2115,4 @@ |
2116 | 2116 | } |
2117 | 2117 | $this->addHTML( $this->parse( $s, /*linestart*/true, /*uilang*/true ) ); |
2118 | 2118 | } |
2119 | | - /* |
2120 | | - * Show log excerpt. All parameters are optional |
2121 | | - * (but it makes sense to define at least $page OR $user) |
2122 | | - * @param String $page Page title for filtering the log |
2123 | | - * @param String $user Username for filtering the log |
2124 | | - * @param String $logtypes Log types, like delete, move, etc. |
2125 | | - * May be a single log type or an array of log types |
2126 | | - * @param int $numEntries Number of log entries to show at maximum (default: 10) |
2127 | | - * If there are too many entries, a "View full log" link is displayed |
2128 | | - * @return boolean Returns true if there was something in the log |
2129 | | - */ |
2130 | | - public function showLogs( $page = '', $user = '', $logtypes = array(), $msgKey = '' , $numEntries = 10 ) { |
2131 | | - global $wgUser, $wgOut; |
2132 | | - $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut ); |
2133 | | - $pager = new LogPager( $loglist, $logtypes, $user, $page); |
2134 | | - if( $pager->getNumRows() > 0 ) { |
2135 | | - $pager->mLimit = $numEntries; |
2136 | | - $wgOut->addHTML( '<div class="mw-warning-with-logexcerpt">' ); |
2137 | | - if ( $msgKey ) |
2138 | | - $wgOut->addWikiMsg( $msgKey ); |
2139 | | - $wgOut->addHTML( |
2140 | | - $loglist->beginLogEventsList() . |
2141 | | - $pager->getBody() . |
2142 | | - $loglist->endLogEventsList() |
2143 | | - ); |
2144 | | - if( $pager->getNumRows() > $numEntries ) { # Show "Full log" link |
2145 | | - $urlParam = array(); |
2146 | | - if ( $page != '') |
2147 | | - $urlParam['page'] = $page; |
2148 | | - if ( $user != '') |
2149 | | - $urlParam['user'] = $user; |
2150 | | - if ( !is_array( $logtypes ) ) # Make it an array, if it isn't |
2151 | | - $logtypes = array( $logtypes ); |
2152 | | - # If there is exactly one log type, we can link to Special:Log/type |
2153 | | - if ( count( $logtypes ) == 1 ) |
2154 | | - $urlParam['type'] = $logtypes[0]; |
2155 | | - $wgOut->addHTML( $wgUser->getSkin()->link( |
2156 | | - SpecialPage::getTitleFor( 'Log' ), |
2157 | | - wfMsgHtml( 'log-fulllog' ), |
2158 | | - array(), |
2159 | | - $urlParam |
2160 | | - ) ); |
2161 | | - |
2162 | | - } |
2163 | | - $wgOut->addHTML( '</div>' ); |
2164 | | - return true; |
2165 | | - } |
2166 | | - return false; |
2167 | | - } |
2168 | | - |
2169 | | - |
2170 | 2119 | } |
Index: trunk/phase3/includes/specials/SpecialContributions.php |
— | — | @@ -226,8 +226,8 @@ |
227 | 227 | |
228 | 228 | // Show a note if the user is blocked and display the last block log entry. |
229 | 229 | if ( User::newFromID( $id )->isBlocked() ) |
230 | | - $wgOut->showLogs( $nt->getPrefixedText(), '', array( 'block' ), |
231 | | - 'sp-contributions-blocked-notice', 1 ); |
| 230 | + LogEventsList::showLogExtract( $wgOut, 'block', $nt->getPrefixedText(), '', 1, |
| 231 | + array(), false, 'sp-contributions-blocked-notice' ); |
232 | 232 | } |
233 | 233 | |
234 | 234 | // Old message 'contribsub' had one parameter, but that doesn't work for |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -1211,12 +1211,13 @@ |
1212 | 1212 | |
1213 | 1213 | # Show rename log because user does not exist. |
1214 | 1214 | $parent = $this->mTitle->getNsText() . ":" . $this->mTitle->getBaseText(); |
1215 | | - $wgOut->showLogs( $parent, '', array( 'renameuser' ), 'renamed-notice' ); |
| 1215 | + LogEventsList::showLogExtract( $wgOut, 'renameuser', $parent, '', 10, array(), false, 'renamed-notice' ); |
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | } |
1219 | 1219 | # Show delete and move logs |
1220 | | - $wgOut->showLogs( $this->mTitle->getPrefixedText(), '', array( 'delete', 'move' ), 'moveddeleted-notice' ); |
| 1220 | + LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' ), |
| 1221 | + $this->mTitle->getPrefixedText(), '', 10, array( "log_action != 'revision'" ), false, 'moveddeleted-notice'); |
1221 | 1222 | |
1222 | 1223 | # Show error message |
1223 | 1224 | $oldid = $this->getOldID(); |
Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -730,7 +730,8 @@ |
731 | 731 | } |
732 | 732 | # Give a notice if the user is editing a deleted/moved page... |
733 | 733 | if ( !$this->mTitle->exists() ) { |
734 | | - $wgOut->showLogs( $this->mTitle->getPrefixedText(), '', array( 'delete', 'move' ), 'recreate-moveddeleted-warn' ); |
| 734 | + LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' ), |
| 735 | + $this->mTitle->getPrefixedText(), '', 10, array( "log_action != 'revision'" ), false, 'recreate-moveddeleted-warn'); |
735 | 736 | } |
736 | 737 | } |
737 | 738 | |
Index: trunk/phase3/includes/LogEventsList.php |
— | — | @@ -556,15 +556,19 @@ |
557 | 557 | } |
558 | 558 | |
559 | 559 | /** |
560 | | - * Quick function to show a short log extract |
| 560 | + * Show log extract. Either with text and a box (set $msgKey) or without (don't set $msgKey) |
561 | 561 | * @param $out OutputPage or String-by-reference |
562 | 562 | * @param $types String or Array |
563 | 563 | * @param $page String |
564 | 564 | * @param $user String |
565 | | - * @param $lim Integer |
| 565 | + * @param $lim Integer Limit of items to show, default is 50 |
566 | 566 | * @param $conds Array |
| 567 | + * @param $showIfEmpty boolean Set to false if you don't want any output in case the loglist is empty |
| 568 | + * if set to true (default), "No matching items in log" is displayed if loglist is empty |
| 569 | + * @param $msgKey String if you want a nice box with a message, set this to the key of the message |
| 570 | + * @return Integer Number of total log items (not limited by $lim) |
567 | 571 | */ |
568 | | - public static function showLogExtract( &$out, $types=array(), $page='', $user='', $lim=0, $conds=array() ) { |
| 572 | + public static function showLogExtract( &$out, $types=array(), $page='', $user='', $lim=0, $conds=array(), $showIfEmpty = true, $msgKey = '' ) { |
569 | 573 | global $wgUser, $wgOut; |
570 | 574 | # Insert list of top 50 or so items |
571 | 575 | $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 ); |
— | — | @@ -572,12 +576,37 @@ |
573 | 577 | if( $lim > 0 ) $pager->mLimit = $lim; |
574 | 578 | $logBody = $pager->getBody(); |
575 | 579 | if( $logBody ) { |
576 | | - $s = $loglist->beginLogEventsList() . |
| 580 | + if ( $msgKey ) |
| 581 | + $s = '<div class="mw-warning-with-logexcerpt">' . wfMsg( $msgKey ) ; |
| 582 | + $s .= $loglist->beginLogEventsList() . |
577 | 583 | $logBody . |
578 | 584 | $loglist->endLogEventsList(); |
579 | 585 | } else { |
580 | | - $s = wfMsgExt( 'logempty', array('parse') ); |
| 586 | + if ( $showIfEmpty ) |
| 587 | + $s = wfMsgExt( 'logempty', array('parse') ); |
581 | 588 | } |
| 589 | + if( $pager->getNumRows() > $pager->mLimit ) { # Show "Full log" link |
| 590 | + $urlParam = array(); |
| 591 | + if ( $page != '') |
| 592 | + $urlParam['page'] = $page; |
| 593 | + if ( $user != '') |
| 594 | + $urlParam['user'] = $user; |
| 595 | + if ( !is_array( $types ) ) # Make it an array, if it isn't |
| 596 | + $types = array( $types ); |
| 597 | + # If there is exactly one log type, we can link to Special:Log?type=foo |
| 598 | + if ( count( $types ) == 1 ) |
| 599 | + $urlParam['type'] = $types[0]; |
| 600 | + $s .= $wgUser->getSkin()->link( |
| 601 | + SpecialPage::getTitleFor( 'Log' ), |
| 602 | + wfMsgHtml( 'log-fulllog' ), |
| 603 | + array(), |
| 604 | + $urlParam |
| 605 | + ); |
| 606 | + |
| 607 | + } |
| 608 | + if ( $logBody && $msgKey ) |
| 609 | + $s .= '</div>'; |
| 610 | + |
582 | 611 | if( $out instanceof OutputPage ){ |
583 | 612 | $out->addHTML( $s ); |
584 | 613 | } else { |