2 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>, 2008 Aaron Schulz
3 # http://www.mediawiki.org/
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # http://www.gnu.org/copyleft/gpl.html
21 const NO_ACTION_LINK
= 1;
27 public function __construct( $skin, $out, $flags = 0 ) {
30 $this->flags
= $flags;
31 $this->preCacheMessages();
35 * As we use the same small set of messages in various methods and that
36 * they are called often, we call them once and save them in $this->message
38 private function preCacheMessages() {
39 // Precache various messages
40 if( !isset( $this->message
) ) {
41 $messages = array( 'revertmerge', 'protect_change', 'unblocklink', 'change-blocklink',
42 'revertmove', 'undeletelink', 'revdel-restore', 'rev-delundel', 'hist', 'pipe-separator' );
43 foreach( $messages as $msg ) {
44 $this->message
[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
50 * Set page title and show header for this log type
53 public function showHeader( $type ) {
54 if( LogPage
::isLogType( $type ) ) {
55 $this->out
->setPageTitle( LogPage
::logName( $type ) );
56 $this->out
->addHTML( LogPage
::logHeader( $type ) );
61 * Show options for the log list
65 * @param $pattern String
66 * @param $year Integer: year
67 * @param $month Integer: month
68 * @param $filter: array
69 * @param $tagFilter: array?
71 public function showOptions( $type = '', $user = '', $page = '', $pattern = '', $year = '',
72 $month = '', $filter = null, $tagFilter='' )
74 global $wgScript, $wgMiserMode;
75 $action = htmlspecialchars( $wgScript );
76 $title = SpecialPage
::getTitleFor( 'Log' );
77 $special = htmlspecialchars( $title->getPrefixedDBkey() );
79 $tagSelector = ChangeTags
::buildTagFilterSelector( $tagFilter );
81 $this->out
->addHTML( "<form action=\"$action\" method=\"get\"><fieldset>" .
82 Xml
::element( 'legend', array(), wfMsg( 'log' ) ) .
83 Xml
::hidden( 'title', $special ) . "\n" .
84 $this->getTypeMenu( $type ) . "\n" .
85 $this->getUserInput( $user ) . "\n" .
86 $this->getTitleInput( $page ) . "\n" .
87 ( !$wgMiserMode ?
($this->getTitlePattern( $pattern )."\n") : "" ) .
88 "<p>" . $this->getDateMenu( $year, $month ) . "\n" .
89 ( $tagSelector ? Xml
::tags( 'p', null, implode( ' ', $tagSelector ) ) :'' ). "\n" .
90 ( $filter ?
"</p><p>".$this->getFilterLinks( $type, $filter )."\n" : "" ) . "\n" .
91 Xml
::submitButton( wfMsg( 'allpagessubmit' ) ) . "</p>\n" .
96 private function getFilterLinks( $logType, $filter ) {
97 global $wgTitle, $wgLang;
99 $messages = array( wfMsgHtml( 'show' ), wfMsgHtml( 'hide' ) );
100 // Option value -> message mapping
102 $hiddens = ''; // keep track for "go" button
103 foreach( $filter as $type => $val ) {
104 $hideVal = 1 - intval($val);
105 $link = $this->skin
->makeKnownLinkObj( $wgTitle, $messages[$hideVal],
106 wfArrayToCGI( array( "hide_{$type}_log" => $hideVal ), $this->getDefaultQuery() )
108 $links[$type] = wfMsgHtml( "log-show-hide-{$type}", $link );
109 $hiddens .= Xml
::hidden( "hide_{$type}_log", $val ) . "\n";
112 return '<small>'.$wgLang->pipeList( $links ) . '</small>' . $hiddens;
115 private function getDefaultQuery() {
116 if ( !isset( $this->mDefaultQuery
) ) {
117 $this->mDefaultQuery
= $_GET;
118 unset( $this->mDefaultQuery
['title'] );
119 unset( $this->mDefaultQuery
['dir'] );
120 unset( $this->mDefaultQuery
['offset'] );
121 unset( $this->mDefaultQuery
['limit'] );
122 unset( $this->mDefaultQuery
['order'] );
123 unset( $this->mDefaultQuery
['month'] );
124 unset( $this->mDefaultQuery
['year'] );
126 return $this->mDefaultQuery
;
130 * @param $queryType String
131 * @return String: Formatted HTML
133 private function getTypeMenu( $queryType ) {
134 global $wgLogRestrictions, $wgUser;
136 $html = "<select name='type'>\n";
138 $validTypes = LogPage
::validTypes();
139 $typesByName = array(); // Temporary array
141 // First pass to load the log names
142 foreach( $validTypes as $type ) {
143 $text = LogPage
::logName( $type );
144 $typesByName[$text] = $type;
147 // Second pass to sort by name
150 // Third pass generates sorted XHTML content
151 foreach( $typesByName as $text => $type ) {
152 $selected = ($type == $queryType);
154 if ( isset($wgLogRestrictions[$type]) ) {
155 if ( $wgUser->isAllowed( $wgLogRestrictions[$type] ) ) {
156 $html .= Xml
::option( $text, $type, $selected ) . "\n";
159 $html .= Xml
::option( $text, $type, $selected ) . "\n";
163 $html .= '</select>';
168 * @param $user String
169 * @return String: Formatted HTML
171 private function getUserInput( $user ) {
172 return Xml
::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'user', 15, $user );
176 * @param $title String
177 * @return String: Formatted HTML
179 private function getTitleInput( $title ) {
180 return Xml
::inputLabel( wfMsg( 'speciallogtitlelabel' ), 'page', 'page', 20, $title );
184 * @param $year Integer
185 * @param $month Integer
186 * @return string Formatted HTML
188 private function getDateMenu( $year, $month ) {
189 return Xml
::dateMenu( $year, $month );
193 * @return boolean Checkbox
195 private function getTitlePattern( $pattern ) {
196 return '<span style="white-space: nowrap">' .
197 Xml
::checkLabel( wfMsg( 'log-title-wildcard' ), 'pattern', 'pattern', $pattern ) .
201 public function beginLogEventsList() {
205 public function endLogEventsList() {
210 * @param $row Row: a single row from the result set
211 * @return String: Formatted HTML list item
213 public function logLine( $row ) {
214 global $wgLang, $wgUser, $wgContLang;
216 $title = Title
::makeTitle( $row->log_namespace
, $row->log_title
);
217 $classes = array( "mw-logline-{$row->log_type}" );
218 $time = $wgLang->timeanddate( wfTimestamp(TS_MW
, $row->log_timestamp
), true );
220 if( self
::isDeleted($row,LogPage
::DELETED_USER
) ) {
221 $userLink = '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
223 $userLink = $this->skin
->userLink( $row->log_user
, $row->user_name
) .
224 $this->skin
->userToolLinks( $row->log_user
, $row->user_name
, true, 0, $row->user_editcount
);
227 if( self
::isDeleted($row,LogPage
::DELETED_COMMENT
) ) {
228 $comment = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>';
230 $comment = $wgContLang->getDirMark() . $this->skin
->commentBlock( $row->log_comment
);
232 // Extract extra parameters
233 $paramArray = LogPage
::extractParams( $row->log_params
);
235 // Some user can hide log items and have review links
236 if( $wgUser->isAllowed( 'deleterevision' ) ) {
237 $del = $this->getShowHideLinks( $row ) . ' ';
239 // Add review links and such...
240 if( ($this->flags
& self
::NO_ACTION_LINK
) ||
($row->log_deleted
& LogPage
::DELETED_ACTION
) ) {
241 // Action text is suppressed...
242 } else if( self
::typeAction($row,'move','move','move') && !empty($paramArray[0]) ) {
243 $destTitle = Title
::newFromText( $paramArray[0] );
245 $revert = '(' . $this->skin
->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
246 $this->message
['revertmove'],
247 'wpOldTitle=' . urlencode( $destTitle->getPrefixedDBkey() ) .
248 '&wpNewTitle=' . urlencode( $title->getPrefixedDBkey() ) .
249 '&wpReason=' . urlencode( wfMsgForContent( 'revertmove' ) ) .
250 '&wpMovetalk=0' ) . ')';
252 // Show undelete link
253 } else if( self
::typeAction($row,array('delete','suppress'),'delete','delete') ) {
254 $revert = '(' . $this->skin
->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Undelete' ),
255 $this->message
['undeletelink'], 'target='. urlencode( $title->getPrefixedDBkey() ) ) . ')';
256 // Show unblock/change block link
257 } else if( self
::typeAction($row,array('block','suppress'),array('block','reblock'),'block') ) {
259 $this->skin
->link( SpecialPage
::getTitleFor( 'Ipblocklist' ),
260 $this->message
['unblocklink'],
262 array( 'action' => 'unblock', 'ip' => $row->log_title
),
264 . $this->message
['pipe-separator'] .
265 $this->skin
->link( SpecialPage
::getTitleFor( 'Blockip', $row->log_title
),
266 $this->message
['change-blocklink'],
267 array(), array(), 'known' ) .
269 // Show change protection link
270 } else if( self
::typeAction( $row, 'protect', array( 'modify', 'protect', 'unprotect' ) ) ) {
272 $this->skin
->link( $title,
273 $this->message
['hist'],
275 array( 'action' => 'history', 'offset' => $row->log_timestamp
) );
276 if( $wgUser->isAllowed( 'protect' ) ) {
277 $revert .= $this->message
['pipe-separator'] .
278 $this->skin
->link( $title,
279 $this->message
['protect_change'],
281 array( 'action' => 'protect' ),
286 } else if( self
::typeAction($row,'merge','merge','mergehistory') ) {
287 $merge = SpecialPage
::getTitleFor( 'Mergehistory' );
288 $revert = '(' . $this->skin
->makeKnownLinkObj( $merge, $this->message
['revertmerge'],
289 wfArrayToCGI( array('target' => $paramArray[0], 'dest' => $title->getPrefixedDBkey(),
290 'mergepoint' => $paramArray[1] ) ) ) . ')';
291 // If an edit was hidden from a page give a review link to the history
292 } else if( self
::typeAction($row,array('delete','suppress'),'revision','deleterevision') ) {
293 if( count($paramArray) == 2 ) {
294 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
295 // Different revision types use different URL params...
296 $key = $paramArray[0];
297 // Link to each hidden object ID, $paramArray[1] is the url param
298 $Ids = explode( ',', $paramArray[1] );
300 foreach( $Ids as $n => $id ) {
301 $revParams .= '&' . urlencode($key) . '[]=' . urlencode($id);
303 $revert = '(' . $this->skin
->makeKnownLinkObj( $revdel, $this->message
['revdel-restore'],
304 'target=' . $title->getPrefixedUrl() . $revParams ) . ')';
306 // Hidden log items, give review link
307 } else if( self
::typeAction($row,array('delete','suppress'),'event','deleterevision') ) {
308 if( count($paramArray) == 1 ) {
309 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
310 $Ids = explode( ',', $paramArray[0] );
311 // Link to each hidden object ID, $paramArray[1] is the url param
313 foreach( $Ids as $n => $id ) {
314 $logParams .= '&logid[]=' . intval($id);
316 $revert = '(' . $this->skin
->makeKnownLinkObj( $revdel, $this->message
['revdel-restore'],
317 'target=' . $title->getPrefixedUrl() . $logParams ) . ')';
319 // Self-created users
320 } else if( self
::typeAction($row,'newusers','create2') ) {
321 if( isset( $paramArray[0] ) ) {
322 $revert = $this->skin
->userToolLinks( $paramArray[0], $title->getDBkey(), true );
324 # Fall back to a blue contributions link
325 $revert = $this->skin
->userToolLinks( 1, $title->getDBkey() );
327 if( $time < '20080129000000' ) {
328 # Suppress $comment from old entries (before 2008-01-29),
329 # not needed and can contain incorrect links
332 // Do nothing. The implementation is handled by the hook modifiying the passed-by-ref parameters.
334 wfRunHooks( 'LogLine', array( $row->log_type
, $row->log_action
, $title, $paramArray,
335 &$comment, &$revert, $row->log_timestamp
) );
338 if( self
::isDeleted($row,LogPage
::DELETED_ACTION
) ) {
339 $action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
341 $action = LogPage
::actionText( $row->log_type
, $row->log_action
, $title,
342 $this->skin
, $paramArray, true );
346 list($tagDisplay, $newClasses) = ChangeTags
::formatSummaryRow( $row->ts_tags
, 'logevent' );
347 $classes = array_merge( $classes, $newClasses );
349 if( $revert != '' ) {
350 $revert = '<span class="mw-logevent-actionlink">' . $revert . '</span>';
353 return Xml
::tags( 'li', array( "class" => implode( ' ', $classes ) ),
354 $del . $time . ' ' . $userLink . ' ' . $action . ' ' . $comment . ' ' . $revert . " $tagDisplay" ) . "\n";
361 private function getShowHideLinks( $row ) {
362 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
363 // If event was hidden from sysops
364 if( !self
::userCan( $row, LogPage
::DELETED_RESTRICTED
) ) {
365 $del = Xml
::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), '('.$this->message
['rev-delundel'].')' );
366 } else if( $row->log_type
== 'suppress' ) {
367 // No one should be hiding from the oversight log
368 $del = Xml
::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), '('.$this->message
['rev-delundel'].')' );
370 $target = SpecialPage
::getTitleFor( 'Log', $row->log_type
);
371 $query = array( 'target' => $target->getPrefixedDBkey(),
372 'logid' => $row->log_id
374 $del = $this->skin
->revDeleteLink( $query, self
::isDeleted( $row, LogPage
::DELETED_RESTRICTED
) );
381 * @param $type Mixed: string/array
382 * @param $action Mixed: string/array
383 * @param $right string
386 public static function typeAction( $row, $type, $action, $right='' ) {
387 $match = is_array($type) ?
in_array($row->log_type
,$type) : $row->log_type
== $type;
389 $match = is_array($action) ?
390 in_array($row->log_action
,$action) : $row->log_action
== $action;
391 if( $match && $right ) {
393 $match = $wgUser->isAllowed( $right );
400 * Determine if the current user is allowed to view a particular
401 * field of this log row, if it's marked as deleted.
403 * @param $field Integer
406 public static function userCan( $row, $field ) {
407 if( ( $row->log_deleted
& $field ) == $field ) {
409 $permission = ( $row->log_deleted
& LogPage
::DELETED_RESTRICTED
) == LogPage
::DELETED_RESTRICTED
412 wfDebug( "Checking for $permission due to $field match on $row->log_deleted\n" );
413 return $wgUser->isAllowed( $permission );
421 * @param $field Integer: one of DELETED_* bitfield constants
424 public static function isDeleted( $row, $field ) {
425 return ($row->log_deleted
& $field) == $field;
429 * Quick function to show a short log extract
430 * @param $out OutputPage
431 * @param $type String
432 * @param $page String
433 * @param $user String
434 * @param $lim Integer
435 * @param $conds Array
437 public static function showLogExtract( $out, $type='', $page='', $user='', $lim=0, $conds=array() ) {
439 # Insert list of top 50 or so items
440 $loglist = new LogEventsList( $wgUser->getSkin(), $out, 0 );
441 $pager = new LogPager( $loglist, $type, $user, $page, '', $conds );
442 if( $lim > 0 ) $pager->mLimit
= $lim;
443 $logBody = $pager->getBody();
446 $loglist->beginLogEventsList() .
448 $loglist->endLogEventsList()
451 $out->addWikiMsg( 'logempty' );
453 return $pager->getNumRows();
457 * SQL clause to skip forbidden log types for this user
458 * @param $db Database
459 * @return mixed (string or false)
461 public static function getExcludeClause( $db ) {
462 global $wgLogRestrictions, $wgUser;
463 // Reset the array, clears extra "where" clauses when $par is used
464 $hiddenLogs = array();
465 // Don't show private logs to unprivileged users
466 foreach( $wgLogRestrictions as $logType => $right ) {
467 if( !$wgUser->isAllowed($right) ) {
468 $safeType = $db->strencode( $logType );
469 $hiddenLogs[] = $safeType;
472 if( count($hiddenLogs) == 1 ) {
473 return 'log_type != ' . $db->addQuotes( $hiddenLogs[0] );
474 } elseif( $hiddenLogs ) {
475 return 'log_type NOT IN (' . $db->makeList($hiddenLogs) . ')';
484 class LogPager
extends ReverseChronologicalPager
{
485 private $type = '', $user = '', $title = '', $pattern = '';
486 public $mLogEventsList;
490 * @param $list LogEventsList
491 * @param $type String
492 * @param $user String
493 * @param $title String
494 * @param $pattern String
495 * @param $conds Array
496 * @param $year Integer
497 * @param $month Integer
499 public function __construct( $list, $type = '', $user = '', $title = '', $pattern = '',
500 $conds = array(), $year = false, $month = false, $tagFilter = '' )
502 parent
::__construct();
503 $this->mConds
= $conds;
505 $this->mLogEventsList
= $list;
507 $this->limitType( $type ); // excludes hidden types too
508 $this->limitUser( $user );
509 $this->limitTitle( $title, $pattern );
510 $this->getDateCond( $year, $month );
511 $this->mTagFilter
= $tagFilter;
514 public function getDefaultQuery() {
515 $query = parent
::getDefaultQuery();
519 public function getFilterParams() {
520 global $wgFilterLogTypes, $wgUser, $wgRequest;
525 foreach( $wgFilterLogTypes as $type => $default ) {
526 // Avoid silly filtering
527 if( $type !== 'patrol' ||
$wgUser->useNPPatrol() ) {
528 $hide = $wgRequest->getInt( "hide_{$type}_log", $default );
529 $filters[$type] = $hide;
531 $this->mConds
[] = 'log_type != ' . $this->mDb
->addQuotes( $type );
538 * Set the log reader to return only entries of the given type.
539 * Type restrictions enforced here
540 * @param $type String: A log type ('upload', 'delete', etc)
542 private function limitType( $type ) {
543 global $wgLogRestrictions, $wgUser;
544 // Don't even show header for private logs; don't recognize it...
545 if( isset($wgLogRestrictions[$type]) && !$wgUser->isAllowed($wgLogRestrictions[$type]) ) {
548 // Don't show private logs to unpriviledged users
549 $hideLogs = LogEventsList
::getExcludeClause( $this->mDb
);
550 if( $hideLogs !== false ) {
551 $this->mConds
[] = $hideLogs;
557 $this->mConds
['log_type'] = $type;
561 * Set the log reader to return only entries by the given user.
562 * @param $name String: (In)valid user name
564 private function limitUser( $name ) {
568 $usertitle = Title
::makeTitleSafe( NS_USER
, $name );
569 if( is_null($usertitle) ) {
572 /* Fetch userid at first, if known, provides awesome query plan afterwards */
573 $userid = User
::idFromName( $name );
575 /* It should be nicer to abort query at all,
576 but for now it won't pass anywhere behind the optimizer */
577 $this->mConds
[] = "NULL";
579 $this->mConds
['log_user'] = $userid;
580 // Paranoia: avoid brute force searches (bug 17342)
581 $this->mConds
[] = 'log_deleted & ' . LogPage
::DELETED_USER
. ' = 0';
582 $this->user
= $usertitle->getText();
587 * Set the log reader to return only entries affecting the given page.
588 * (For the block and rights logs, this is a user page.)
589 * @param $page String: Title name as text
590 * @param $pattern String
592 private function limitTitle( $page, $pattern ) {
595 $title = Title
::newFromText( $page );
596 if( strlen($page) == 0 ||
!$title instanceof Title
)
599 $this->title
= $title->getPrefixedText();
600 $ns = $title->getNamespace();
601 # Using the (log_namespace, log_title, log_timestamp) index with a
602 # range scan (LIKE) on the first two parts, instead of simple equality,
603 # makes it unusable for sorting. Sorted retrieval using another index
604 # would be possible, but then we might have to scan arbitrarily many
605 # nodes of that index. Therefore, we need to avoid this if $wgMiserMode
608 # This is not a problem with simple title matches, because then we can
609 # use the page_time index. That should have no more than a few hundred
610 # log entries for even the busiest pages, so it can be safely scanned
611 # in full to satisfy an impossible condition on user or similar.
612 if( $pattern && !$wgMiserMode ) {
613 # use escapeLike to avoid expensive search patterns like 't%st%'
614 $safetitle = $this->mDb
->escapeLike( $title->getDBkey() );
615 $this->mConds
['log_namespace'] = $ns;
616 $this->mConds
[] = "log_title LIKE '$safetitle%'";
617 $this->pattern
= $pattern;
619 $this->mConds
['log_namespace'] = $ns;
620 $this->mConds
['log_title'] = $title->getDBkey();
622 // Paranoia: avoid brute force searches (bug 17342)
623 $this->mConds
[] = 'log_deleted & ' . LogPage
::DELETED_ACTION
. ' = 0';
626 public function getQueryInfo() {
627 $this->mConds
[] = 'user_id = log_user';
628 # Don't use the wrong logging index
629 if( $this->title ||
$this->pattern ||
$this->user
) {
630 $index = array( 'USE INDEX' => array( 'logging' => array('page_time','user_time') ) );
631 } else if( $this->type
) {
632 $index = array( 'USE INDEX' => array( 'logging' => 'type_time' ) );
634 $index = array( 'USE INDEX' => array( 'logging' => 'times' ) );
637 'tables' => array( 'logging', 'user' ),
638 'fields' => array( 'log_type', 'log_action', 'log_user', 'log_namespace', 'log_title', 'log_params',
639 'log_comment', 'log_id', 'log_deleted', 'log_timestamp', 'user_name', 'user_editcount' ),
640 'conds' => $this->mConds
,
642 'join_conds' => array( 'user' => array( 'INNER JOIN', 'user_id=log_user' ) ),
645 ChangeTags
::modifyDisplayQuery( $info['tables'], $info['fields'], $info['conds'], $info['join_conds'], $this->mTagFilter
);
650 function getIndexField() {
651 return 'log_timestamp';
654 public function getStartBody() {
655 wfProfileIn( __METHOD__
);
656 # Do a link batch query
657 if( $this->getNumRows() > 0 ) {
659 while( $row = $this->mResult
->fetchObject() ) {
660 $lb->add( $row->log_namespace
, $row->log_title
);
661 $lb->addObj( Title
::makeTitleSafe( NS_USER
, $row->user_name
) );
662 $lb->addObj( Title
::makeTitleSafe( NS_USER_TALK
, $row->user_name
) );
665 $this->mResult
->seek( 0 );
667 wfProfileOut( __METHOD__
);
671 public function formatRow( $row ) {
672 return $this->mLogEventsList
->logLine( $row );
675 public function getType() {
679 public function getUser() {
683 public function getPage() {
687 public function getPattern() {
688 return $this->pattern
;
691 public function getYear() {
695 public function getMonth() {
696 return $this->mMonth
;
699 public function getTagFilter() {
700 return $this->mTagFilter
;
706 * @ingroup SpecialPage
711 * @param $request WebRequest: for internal use use a FauxRequest object to pass arbitrary parameters.
713 function __construct( $request ) {
714 global $wgUser, $wgOut;
715 wfDeprecated(__METHOD__
);
717 $type = $request->getVal( 'type' );
718 $user = $request->getText( 'user' );
719 $title = $request->getText( 'page' );
720 $pattern = $request->getBool( 'pattern' );
721 $year = $request->getIntOrNull( 'year' );
722 $month = $request->getIntOrNull( 'month' );
723 $tagFilter = $request->getVal( 'tagfilter' );
724 # Don't let the user get stuck with a certain date
725 $skip = $request->getText( 'offset' ) ||
$request->getText( 'dir' ) == 'prev';
730 # Use new list class to output results
731 $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 );
732 $this->pager
= new LogPager( $loglist, $type, $user, $title, $pattern, $year, $month, $tagFilter );
736 * Is there at least one row?
739 public function hasRows() {
740 return isset($this->pager
) ?
($this->pager
->getNumRows() > 0) : false;
746 * @ingroup SpecialPage
749 const NO_ACTION_LINK
= 1;
757 * @param &$reader LogReader: where to get our data from
758 * @param $flags Integer: Bitwise combination of flags:
759 * LogEventsList::NO_ACTION_LINK Don't show restore/unblock/block links
761 function __construct( &$reader, $flags = 0 ) {
763 wfDeprecated(__METHOD__
);
764 $this->reader
=& $reader;
765 $this->reader
->pager
->mLogEventsList
->flags
= $flags;
766 # Aliases for shorter code...
767 $this->pager
=& $this->reader
->pager
;
768 $this->list =& $this->reader
->pager
->mLogEventsList
;
772 * Take over the whole output page in $wgOut with the log display.
774 public function show() {
775 # Set title and add header
776 $this->list->showHeader( $pager->getType() );
778 $this->list->showOptions( $this->pager
->getType(), $this->pager
->getUser(), $this->pager
->getPage(),
779 $this->pager
->getPattern(), $this->pager
->getYear(), $this->pager
->getMonth() );
781 $logBody = $this->pager
->getBody();
784 $this->pager
->getNavigationBar() .
785 $this->list->beginLogEventsList() .
787 $this->list->endLogEventsList() .
788 $this->pager
->getNavigationBar()
791 $wgOut->addWikiMsg( 'logempty' );
796 * Output just the list of entries given by the linked LogReader,
797 * with extraneous UI elements. Use for displaying log fragments in
798 * another page (eg at Special:Undelete)
799 * @param $out OutputPage: where to send output
801 public function showList( &$out ) {
802 $logBody = $this->pager
->getBody();
805 $this->list->beginLogEventsList() .
807 $this->list->endLogEventsList()
810 $out->addWikiMsg( 'logempty' );