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( 'escape' ) );
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 Boolean
70 public function showOptions( $type = '', $user = '', $page = '', $pattern = '', $year = '',
71 $month = '', $filter = null, $tagFilter='' )
73 global $wgScript, $wgMiserMode;
74 $action = htmlspecialchars( $wgScript );
75 $title = SpecialPage
::getTitleFor( 'Log' );
76 $special = htmlspecialchars( $title->getPrefixedDBkey() );
78 $tagSelector = ChangeTags
::buildTagFilterSelector( $tagFilter );
80 $this->out
->addHTML( "<form action=\"$action\" method=\"get\"><fieldset>" .
81 Xml
::element( 'legend', array(), wfMsg( 'log' ) ) .
82 Xml
::hidden( 'title', $special ) . "\n" .
83 $this->getTypeMenu( $type ) . "\n" .
84 $this->getUserInput( $user ) . "\n" .
85 $this->getTitleInput( $page ) . "\n" .
86 ( !$wgMiserMode ?
($this->getTitlePattern( $pattern )."\n") : "" ) .
87 "<p>" . $this->getDateMenu( $year, $month ) . "\n" .
88 ( $tagSelector ? Xml
::tags( 'p', null, implode( ' ', $tagSelector ) ) :'' ). "\n" .
89 ( $filter ?
"</p><p>".$this->getFilterLinks( $type, $filter )."\n" : "" ) . "\n" .
90 Xml
::submitButton( wfMsg( 'allpagessubmit' ) ) . "</p>\n" .
95 private function getFilterLinks( $logType, $filter ) {
96 global $wgTitle, $wgLang;
98 $messages = array( wfMsgHtml( 'show' ), wfMsgHtml( 'hide' ) );
99 // Option value -> message mapping
101 foreach( $filter as $type => $val ) {
102 $hideVal = 1 - intval($val);
103 $link = $this->skin
->makeKnownLinkObj( $wgTitle, $messages[$hideVal],
104 wfArrayToCGI( array( "hide_{$type}_log" => $hideVal ), $this->getDefaultQuery() )
106 $links[$type] = wfMsgHtml( "log-show-hide-{$type}", $link );
109 return $wgLang->pipeList( $links );
112 private function getDefaultQuery() {
113 if ( !isset( $this->mDefaultQuery
) ) {
114 $this->mDefaultQuery
= $_GET;
115 unset( $this->mDefaultQuery
['title'] );
116 unset( $this->mDefaultQuery
['dir'] );
117 unset( $this->mDefaultQuery
['offset'] );
118 unset( $this->mDefaultQuery
['limit'] );
119 unset( $this->mDefaultQuery
['order'] );
120 unset( $this->mDefaultQuery
['month'] );
121 unset( $this->mDefaultQuery
['year'] );
123 return $this->mDefaultQuery
;
127 * @param $queryType String
128 * @return String: Formatted HTML
130 private function getTypeMenu( $queryType ) {
131 global $wgLogRestrictions, $wgUser;
133 $html = "<select name='type'>\n";
135 $validTypes = LogPage
::validTypes();
136 $typesByName = array(); // Temporary array
138 // First pass to load the log names
139 foreach( $validTypes as $type ) {
140 $text = LogPage
::logName( $type );
141 $typesByName[$text] = $type;
144 // Second pass to sort by name
147 // Third pass generates sorted XHTML content
148 foreach( $typesByName as $text => $type ) {
149 $selected = ($type == $queryType);
151 if ( isset($wgLogRestrictions[$type]) ) {
152 if ( $wgUser->isAllowed( $wgLogRestrictions[$type] ) ) {
153 $html .= Xml
::option( $text, $type, $selected ) . "\n";
156 $html .= Xml
::option( $text, $type, $selected ) . "\n";
160 $html .= '</select>';
165 * @param $user String
166 * @return String: Formatted HTML
168 private function getUserInput( $user ) {
169 return Xml
::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'user', 15, $user );
173 * @param $title String
174 * @return String: Formatted HTML
176 private function getTitleInput( $title ) {
177 return Xml
::inputLabel( wfMsg( 'speciallogtitlelabel' ), 'page', 'page', 20, $title );
181 * @param $year Integer
182 * @param $month Integer
183 * @return string Formatted HTML
185 private function getDateMenu( $year, $month ) {
186 # Offset overrides year/month selection
187 if( $month && $month !== -1 ) {
188 $encMonth = intval( $month );
193 $encYear = intval( $year );
194 } else if( $encMonth ) {
195 $thisMonth = intval( gmdate( 'n' ) );
196 $thisYear = intval( gmdate( 'Y' ) );
197 if( intval($encMonth) > $thisMonth ) {
200 $encYear = $thisYear;
204 return Xml
::label( wfMsg( 'year' ), 'year' ) . ' '.
205 Xml
::input( 'year', 4, $encYear, array('id' => 'year', 'maxlength' => 4) ) .
207 Xml
::label( wfMsg( 'month' ), 'month' ) . ' '.
208 Xml
::monthSelector( $encMonth, -1 );
212 * @return boolean Checkbox
214 private function getTitlePattern( $pattern ) {
215 return '<span style="white-space: nowrap">' .
216 Xml
::checkLabel( wfMsg( 'log-title-wildcard' ), 'pattern', 'pattern', $pattern ) .
220 public function beginLogEventsList() {
224 public function endLogEventsList() {
229 * @param $row Row: a single row from the result set
230 * @return String: Formatted HTML list item
232 public function logLine( $row ) {
233 global $wgLang, $wgUser, $wgContLang;
235 $title = Title
::makeTitle( $row->log_namespace
, $row->log_title
);
236 $classes = array( "mw-logline-{$row->log_type}" );
237 $time = $wgLang->timeanddate( wfTimestamp(TS_MW
, $row->log_timestamp
), true );
239 if( self
::isDeleted($row,LogPage
::DELETED_USER
) ) {
240 $userLink = '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
242 $userLink = $this->skin
->userLink( $row->log_user
, $row->user_name
) .
243 $this->skin
->userToolLinks( $row->log_user
, $row->user_name
, true, 0, $row->user_editcount
);
246 if( self
::isDeleted($row,LogPage
::DELETED_COMMENT
) ) {
247 $comment = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>';
249 $comment = $wgContLang->getDirMark() . $this->skin
->commentBlock( $row->log_comment
);
251 // Extract extra parameters
252 $paramArray = LogPage
::extractParams( $row->log_params
);
254 // Some user can hide log items and have review links
255 if( $wgUser->isAllowed( 'deleterevision' ) ) {
256 $del = $this->getShowHideLinks( $row ) . ' ';
258 // Add review links and such...
259 if( ($this->flags
& self
::NO_ACTION_LINK
) ||
($row->log_deleted
& LogPage
::DELETED_ACTION
) ) {
260 // Action text is suppressed...
261 } else if( self
::typeAction($row,'move','move','move') && !empty($paramArray[0]) ) {
262 $destTitle = Title
::newFromText( $paramArray[0] );
264 $revert = '(' . $this->skin
->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
265 $this->message
['revertmove'],
266 'wpOldTitle=' . urlencode( $destTitle->getPrefixedDBkey() ) .
267 '&wpNewTitle=' . urlencode( $title->getPrefixedDBkey() ) .
268 '&wpReason=' . urlencode( wfMsgForContent( 'revertmove' ) ) .
269 '&wpMovetalk=0' ) . ')';
271 // Show undelete link
272 } else if( self
::typeAction($row,array('delete','suppress'),'delete','delete') ) {
273 $revert = '(' . $this->skin
->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Undelete' ),
274 $this->message
['undeletelink'], 'target='. urlencode( $title->getPrefixedDBkey() ) ) . ')';
275 // Show unblock/change block link
276 } else if( self
::typeAction($row,array('block','suppress'),array('block','reblock'),'block') ) {
278 $this->skin
->link( SpecialPage
::getTitleFor( 'Ipblocklist' ),
279 $this->message
['unblocklink'],
281 array( 'action' => 'unblock', 'ip' => $row->log_title
),
283 . $this->message
['pipe-separator'] .
284 $this->skin
->link( SpecialPage
::getTitleFor( 'Blockip', $row->log_title
),
285 $this->message
['change-blocklink'],
286 array(), array(), 'known' ) .
288 // Show change protection link
289 } else if( self
::typeAction( $row, 'protect', array( 'modify', 'protect', 'unprotect' ) ) ) {
291 $this->skin
->link( $title,
292 $this->message
['hist'],
294 array( 'action' => 'history', 'offset' => $row->log_timestamp
) );
295 if( $wgUser->isAllowed( 'protect' ) ) {
296 $revert .= $this->message
['pipe-separator'] .
297 $this->skin
->link( $title,
298 $this->message
['protect_change'],
300 array( 'action' => 'protect' ),
305 } else if( self
::typeAction($row,'merge','merge','mergehistory') ) {
306 $merge = SpecialPage
::getTitleFor( 'Mergehistory' );
307 $revert = '(' . $this->skin
->makeKnownLinkObj( $merge, $this->message
['revertmerge'],
308 wfArrayToCGI( array('target' => $paramArray[0], 'dest' => $title->getPrefixedDBkey(),
309 'mergepoint' => $paramArray[1] ) ) ) . ')';
310 // If an edit was hidden from a page give a review link to the history
311 } else if( self
::typeAction($row,array('delete','suppress'),'revision','deleterevision') ) {
312 if( count($paramArray) == 2 ) {
313 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
314 // Different revision types use different URL params...
315 $key = $paramArray[0];
316 // Link to each hidden object ID, $paramArray[1] is the url param
317 $Ids = explode( ',', $paramArray[1] );
319 foreach( $Ids as $n => $id ) {
320 $revParams .= '&' . urlencode($key) . '[]=' . urlencode($id);
322 $revert = '(' . $this->skin
->makeKnownLinkObj( $revdel, $this->message
['revdel-restore'],
323 'target=' . $title->getPrefixedUrl() . $revParams ) . ')';
325 // Hidden log items, give review link
326 } else if( self
::typeAction($row,array('delete','suppress'),'event','deleterevision') ) {
327 if( count($paramArray) == 1 ) {
328 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
329 $Ids = explode( ',', $paramArray[0] );
330 // Link to each hidden object ID, $paramArray[1] is the url param
332 foreach( $Ids as $n => $id ) {
333 $logParams .= '&logid[]=' . intval($id);
335 $revert = '(' . $this->skin
->makeKnownLinkObj( $revdel, $this->message
['revdel-restore'],
336 'target=' . $title->getPrefixedUrl() . $logParams ) . ')';
338 // Self-created users
339 } else if( self
::typeAction($row,'newusers','create2') ) {
340 if( isset( $paramArray[0] ) ) {
341 $revert = $this->skin
->userToolLinks( $paramArray[0], $title->getDBkey(), true );
343 # Fall back to a blue contributions link
344 $revert = $this->skin
->userToolLinks( 1, $title->getDBkey() );
346 if( $time < '20080129000000' ) {
347 # Suppress $comment from old entries (before 2008-01-29),
348 # not needed and can contain incorrect links
351 // Do nothing. The implementation is handled by the hook modifiying the passed-by-ref parameters.
353 wfRunHooks( 'LogLine', array( $row->log_type
, $row->log_action
, $title, $paramArray,
354 &$comment, &$revert, $row->log_timestamp
) );
357 if( self
::isDeleted($row,LogPage
::DELETED_ACTION
) ) {
358 $action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
360 $action = LogPage
::actionText( $row->log_type
, $row->log_action
, $title,
361 $this->skin
, $paramArray, true );
365 list($tagDisplay, $newClasses) = ChangeTags
::formatSummaryRow( $row->ts_tags
, 'logevent' );
366 $classes = array_merge( $classes, $newClasses );
368 if( $revert != '' ) {
369 $revert = '<span class="mw-logevent-actionlink">' . $revert . '</span>';
372 return Xml
::tags( 'li', array( "class" => implode( ' ', $classes ) ),
373 $del . $time . ' ' . $userLink . ' ' . $action . ' ' . $comment . ' ' . $revert . " $tagDisplay" ) . "\n";
380 private function getShowHideLinks( $row ) {
381 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
382 // If event was hidden from sysops
383 if( !self
::userCan( $row, LogPage
::DELETED_RESTRICTED
) ) {
384 $del = Xml
::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), '('.$this->message
['rev-delundel'].')' );
385 } else if( $row->log_type
== 'suppress' ) {
386 // No one should be hiding from the oversight log
387 $del = Xml
::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), '('.$this->message
['rev-delundel'].')' );
389 $target = SpecialPage
::getTitleFor( 'Log', $row->log_type
);
390 $query = array( 'target' => $target->getPrefixedDBkey(),
391 'logid' => $row->log_id
393 $del = $this->skin
->revDeleteLink( $query, self
::isDeleted( $row, LogPage
::DELETED_RESTRICTED
) );
400 * @param $type Mixed: string/array
401 * @param $action Mixed: string/array
402 * @param $right string
405 public static function typeAction( $row, $type, $action, $right='' ) {
406 $match = is_array($type) ?
in_array($row->log_type
,$type) : $row->log_type
== $type;
408 $match = is_array($action) ?
409 in_array($row->log_action
,$action) : $row->log_action
== $action;
410 if( $match && $right ) {
412 $match = $wgUser->isAllowed( $right );
419 * Determine if the current user is allowed to view a particular
420 * field of this log row, if it's marked as deleted.
422 * @param $field Integer
425 public static function userCan( $row, $field ) {
426 if( ( $row->log_deleted
& $field ) == $field ) {
428 $permission = ( $row->log_deleted
& LogPage
::DELETED_RESTRICTED
) == LogPage
::DELETED_RESTRICTED
431 wfDebug( "Checking for $permission due to $field match on $row->log_deleted\n" );
432 return $wgUser->isAllowed( $permission );
440 * @param $field Integer: one of DELETED_* bitfield constants
443 public static function isDeleted( $row, $field ) {
444 return ($row->log_deleted
& $field) == $field;
448 * Quick function to show a short log extract
449 * @param $out OutputPage
450 * @param $type String
451 * @param $page String
452 * @param $user String
453 * @param $lim Integer
454 * @param $conds Array
456 public static function showLogExtract( $out, $type='', $page='', $user='', $lim=0, $conds=array() ) {
458 # Insert list of top 50 or so items
459 $loglist = new LogEventsList( $wgUser->getSkin(), $out, 0 );
460 $pager = new LogPager( $loglist, $type, $user, $page, '', $conds );
461 if( $lim > 0 ) $pager->mLimit
= $lim;
462 $logBody = $pager->getBody();
465 $loglist->beginLogEventsList() .
467 $loglist->endLogEventsList()
470 $out->addWikiMsg( 'logempty' );
472 return $pager->getNumRows();
476 * SQL clause to skip forbidden log types for this user
477 * @param $db Database
478 * @return mixed (string or false)
480 public static function getExcludeClause( $db ) {
481 global $wgLogRestrictions, $wgUser;
482 // Reset the array, clears extra "where" clauses when $par is used
483 $hiddenLogs = array();
484 // Don't show private logs to unprivileged users
485 foreach( $wgLogRestrictions as $logType => $right ) {
486 if( !$wgUser->isAllowed($right) ) {
487 $safeType = $db->strencode( $logType );
488 $hiddenLogs[] = $safeType;
491 if( count($hiddenLogs) == 1 ) {
492 return 'log_type != ' . $db->addQuotes( $hiddenLogs[0] );
493 } elseif( $hiddenLogs ) {
494 return 'log_type NOT IN (' . $db->makeList($hiddenLogs) . ')';
503 class LogPager
extends ReverseChronologicalPager
{
504 private $type = '', $user = '', $title = '', $pattern = '';
505 public $mLogEventsList;
509 * @param $list LogEventsList
510 * @param $type String
511 * @param $user String
512 * @param $title String
513 * @param $pattern String
514 * @param $conds Array
515 * @param $year Integer
516 * @param $month Integer
518 public function __construct( $list, $type = '', $user = '', $title = '', $pattern = '',
519 $conds = array(), $year = false, $month = false, $tagFilter = '' )
521 parent
::__construct();
522 $this->mConds
= $conds;
524 $this->mLogEventsList
= $list;
526 $this->limitType( $type );
527 $this->limitUser( $user );
528 $this->limitTitle( $title, $pattern );
529 $this->getDateCond( $year, $month );
530 $this->mTagFilter
= $tagFilter;
533 public function getDefaultQuery() {
534 $query = parent
::getDefaultQuery();
535 $query['type'] = $this->type
;
536 $query['user'] = $this->user
;
537 $query['month'] = $this->mMonth
;
538 $query['year'] = $this->mYear
;
542 public function getFilterParams() {
543 global $wgFilterLogTypes, $wgUser, $wgRequest;
548 foreach( $wgFilterLogTypes as $type => $default ) {
549 // Avoid silly filtering
550 if( $type !== 'patrol' ||
$wgUser->useNPPatrol() ) {
551 $hide = $wgRequest->getInt( "hide_{$type}_log", $default );
552 $filters[$type] = $hide;
554 $this->mConds
[] = 'log_type != ' . $this->mDb
->addQuotes( $type );
561 * Set the log reader to return only entries of the given type.
562 * Type restrictions enforced here
563 * @param $type String: A log type ('upload', 'delete', etc)
565 private function limitType( $type ) {
566 global $wgLogRestrictions, $wgUser;
567 // Don't even show header for private logs; don't recognize it...
568 if( isset($wgLogRestrictions[$type]) && !$wgUser->isAllowed($wgLogRestrictions[$type]) ) {
571 // Don't show private logs to unpriviledged users
572 $hideLogs = LogEventsList
::getExcludeClause( $this->mDb
);
573 if( $hideLogs !== false ) {
574 $this->mConds
[] = $hideLogs;
580 $this->mConds
['log_type'] = $type;
584 * Set the log reader to return only entries by the given user.
585 * @param $name String: (In)valid user name
587 private function limitUser( $name ) {
591 $usertitle = Title
::makeTitleSafe( NS_USER
, $name );
592 if( is_null($usertitle) ) {
595 /* Fetch userid at first, if known, provides awesome query plan afterwards */
596 $userid = User
::idFromName( $name );
598 /* It should be nicer to abort query at all,
599 but for now it won't pass anywhere behind the optimizer */
600 $this->mConds
[] = "NULL";
602 $this->mConds
['log_user'] = $userid;
603 // Paranoia: avoid brute force searches (bug 17342)
604 $this->mConds
[] = 'log_deleted & ' . LogPage
::DELETED_USER
. ' = 0';
605 $this->user
= $usertitle->getText();
610 * Set the log reader to return only entries affecting the given page.
611 * (For the block and rights logs, this is a user page.)
612 * @param $page String: Title name as text
613 * @param $pattern String
615 private function limitTitle( $page, $pattern ) {
618 $title = Title
::newFromText( $page );
619 if( strlen($page) == 0 ||
!$title instanceof Title
)
622 $this->title
= $title->getPrefixedText();
623 $ns = $title->getNamespace();
624 # Using the (log_namespace, log_title, log_timestamp) index with a
625 # range scan (LIKE) on the first two parts, instead of simple equality,
626 # makes it unusable for sorting. Sorted retrieval using another index
627 # would be possible, but then we might have to scan arbitrarily many
628 # nodes of that index. Therefore, we need to avoid this if $wgMiserMode
631 # This is not a problem with simple title matches, because then we can
632 # use the page_time index. That should have no more than a few hundred
633 # log entries for even the busiest pages, so it can be safely scanned
634 # in full to satisfy an impossible condition on user or similar.
635 if( $pattern && !$wgMiserMode ) {
636 # use escapeLike to avoid expensive search patterns like 't%st%'
637 $safetitle = $this->mDb
->escapeLike( $title->getDBkey() );
638 $this->mConds
['log_namespace'] = $ns;
639 $this->mConds
[] = "log_title LIKE '$safetitle%'";
640 $this->pattern
= $pattern;
642 $this->mConds
['log_namespace'] = $ns;
643 $this->mConds
['log_title'] = $title->getDBkey();
645 // Paranoia: avoid brute force searches (bug 17342)
646 $this->mConds
[] = 'log_deleted & ' . LogPage
::DELETED_ACTION
. ' = 0';
649 public function getQueryInfo() {
650 $this->mConds
[] = 'user_id = log_user';
651 # Don't use the wrong logging index
652 if( $this->title ||
$this->pattern ||
$this->user
) {
653 $index = array( 'USE INDEX' => array( 'logging' => array('page_time','user_time') ) );
654 } else if( $this->type
) {
655 $index = array( 'USE INDEX' => array( 'logging' => 'type_time' ) );
657 $index = array( 'USE INDEX' => array( 'logging' => 'times' ) );
660 'tables' => array( 'logging', 'user' ),
661 'fields' => array( 'log_type', 'log_action', 'log_user', 'log_namespace', 'log_title', 'log_params',
662 'log_comment', 'log_id', 'log_deleted', 'log_timestamp', 'user_name', 'user_editcount' ),
663 'conds' => $this->mConds
,
665 'join_conds' => array( 'user' => array( 'INNER JOIN', 'user_id=log_user' ) ),
668 ChangeTags
::modifyDisplayQuery( $info['tables'], $info['fields'], $info['conds'], $info['join_conds'], $this->mTagFilter
);
673 function getIndexField() {
674 return 'log_timestamp';
677 public function getStartBody() {
678 wfProfileIn( __METHOD__
);
679 # Do a link batch query
680 if( $this->getNumRows() > 0 ) {
682 while( $row = $this->mResult
->fetchObject() ) {
683 $lb->add( $row->log_namespace
, $row->log_title
);
684 $lb->addObj( Title
::makeTitleSafe( NS_USER
, $row->user_name
) );
685 $lb->addObj( Title
::makeTitleSafe( NS_USER_TALK
, $row->user_name
) );
688 $this->mResult
->seek( 0 );
690 wfProfileOut( __METHOD__
);
694 public function formatRow( $row ) {
695 return $this->mLogEventsList
->logLine( $row );
698 public function getType() {
702 public function getUser() {
706 public function getPage() {
710 public function getPattern() {
711 return $this->pattern
;
714 public function getYear() {
718 public function getMonth() {
719 return $this->mMonth
;
722 public function getTagFilter() {
723 return $this->mTagFilter
;
729 * @ingroup SpecialPage
734 * @param $request WebRequest: for internal use use a FauxRequest object to pass arbitrary parameters.
736 function __construct( $request ) {
737 global $wgUser, $wgOut;
738 wfDeprecated(__METHOD__
);
740 $type = $request->getVal( 'type' );
741 $user = $request->getText( 'user' );
742 $title = $request->getText( 'page' );
743 $pattern = $request->getBool( 'pattern' );
744 $year = $request->getIntOrNull( 'year' );
745 $month = $request->getIntOrNull( 'month' );
746 $tagFilter = $request->getVal( 'tagfilter' );
747 # Don't let the user get stuck with a certain date
748 $skip = $request->getText( 'offset' ) ||
$request->getText( 'dir' ) == 'prev';
753 # Use new list class to output results
754 $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 );
755 $this->pager
= new LogPager( $loglist, $type, $user, $title, $pattern, $year, $month, $tagFilter );
759 * Is there at least one row?
762 public function hasRows() {
763 return isset($this->pager
) ?
($this->pager
->getNumRows() > 0) : false;
769 * @ingroup SpecialPage
772 const NO_ACTION_LINK
= 1;
780 * @param &$reader LogReader: where to get our data from
781 * @param $flags Integer: Bitwise combination of flags:
782 * LogEventsList::NO_ACTION_LINK Don't show restore/unblock/block links
784 function __construct( &$reader, $flags = 0 ) {
786 wfDeprecated(__METHOD__
);
787 $this->reader
=& $reader;
788 $this->reader
->pager
->mLogEventsList
->flags
= $flags;
789 # Aliases for shorter code...
790 $this->pager
=& $this->reader
->pager
;
791 $this->list =& $this->reader
->pager
->mLogEventsList
;
795 * Take over the whole output page in $wgOut with the log display.
797 public function show() {
798 # Set title and add header
799 $this->list->showHeader( $pager->getType() );
801 $this->list->showOptions( $this->pager
->getType(), $this->pager
->getUser(), $this->pager
->getPage(),
802 $this->pager
->getPattern(), $this->pager
->getYear(), $this->pager
->getMonth() );
804 $logBody = $this->pager
->getBody();
807 $this->pager
->getNavigationBar() .
808 $this->list->beginLogEventsList() .
810 $this->list->endLogEventsList() .
811 $this->pager
->getNavigationBar()
814 $wgOut->addWikiMsg( 'logempty' );
819 * Output just the list of entries given by the linked LogReader,
820 * with extraneous UI elements. Use for displaying log fragments in
821 * another page (eg at Special:Undelete)
822 * @param $out OutputPage: where to send output
824 public function showList( &$out ) {
825 $logBody = $this->pager
->getBody();
828 $this->list->beginLogEventsList() .
830 $this->list->endLogEventsList()
833 $out->addWikiMsg( 'logempty' );