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', 'undeleteviewlink', 'revdel-restore', 'rev-delundel', 'hist', 'diff',
44 foreach( $messages as $msg ) {
45 $this->message
[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
51 * Set page title and show header for this log type
54 public function showHeader( $type ) {
55 if( LogPage
::isLogType( $type ) ) {
56 $this->out
->setPageTitle( LogPage
::logName( $type ) );
57 $this->out
->addHTML( LogPage
::logHeader( $type ) );
62 * Show options for the log list
63 * @param $types string or Array
66 * @param $pattern String
67 * @param $year Integer: year
68 * @param $month Integer: month
69 * @param $filter: array
70 * @param $tagFilter: array?
72 public function showOptions( $types=array(), $user='', $page='', $pattern='', $year='',
73 $month = '', $filter = null, $tagFilter='' )
75 global $wgScript, $wgMiserMode;
76 $action = htmlspecialchars( $wgScript );
77 $title = SpecialPage
::getTitleFor( 'Log' );
78 $special = htmlspecialchars( $title->getPrefixedDBkey() );
79 // For B/C, we take strings, but make sure they are converted...
80 $types = ($types === '') ?
array() : (array)$types;
82 $tagSelector = ChangeTags
::buildTagFilterSelector( $tagFilter );
84 $this->out
->addHTML( "<form action=\"$action\" method=\"get\"><fieldset>" .
85 Xml
::element( 'legend', array(), wfMsg( 'log' ) ) .
86 Xml
::hidden( 'title', $special ) . "\n" .
87 $this->getTypeMenu( $types ) . "\n" .
88 $this->getUserInput( $user ) . "\n" .
89 $this->getTitleInput( $page ) . "\n" .
90 ( !$wgMiserMode ?
($this->getTitlePattern( $pattern )."\n") : "" ) .
91 "<p>" . Xml
::dateMenu( $year, $month ) . "\n" .
92 ( $tagSelector ? Xml
::tags( 'p', null, implode( ' ', $tagSelector ) ) :'' ). "\n" .
93 ( $filter ?
"</p><p>".$this->getFilterLinks( $filter )."\n" : "" ) . "\n" .
94 Xml
::submitButton( wfMsg( 'allpagessubmit' ) ) . "</p>\n" .
100 * @param $filter Array
101 * @return String: Formatted HTML
103 private function getFilterLinks( $filter ) {
104 global $wgTitle, $wgLang;
106 $messages = array( wfMsgHtml( 'show' ), wfMsgHtml( 'hide' ) );
107 // Option value -> message mapping
109 $hiddens = ''; // keep track for "go" button
110 foreach( $filter as $type => $val ) {
111 // Should the below assignment be outside the foreach?
112 // Then it would have to be copied. Not certain what is more expensive.
113 $query = $this->getDefaultQuery();
114 $queryKey = "hide_{$type}_log";
116 $hideVal = 1 - intval($val);
117 $query[$queryKey] = $hideVal;
119 $link = $this->skin
->link(
124 array( 'known', 'noclasses' )
127 $links[$type] = wfMsgHtml( "log-show-hide-{$type}", $link );
128 $hiddens .= Xml
::hidden( "hide_{$type}_log", $val ) . "\n";
131 return '<small>'.$wgLang->pipeList( $links ) . '</small>' . $hiddens;
134 private function getDefaultQuery() {
135 if ( !isset( $this->mDefaultQuery
) ) {
136 $this->mDefaultQuery
= $_GET;
137 unset( $this->mDefaultQuery
['title'] );
138 unset( $this->mDefaultQuery
['dir'] );
139 unset( $this->mDefaultQuery
['offset'] );
140 unset( $this->mDefaultQuery
['limit'] );
141 unset( $this->mDefaultQuery
['order'] );
142 unset( $this->mDefaultQuery
['month'] );
143 unset( $this->mDefaultQuery
['year'] );
145 return $this->mDefaultQuery
;
149 * @param $queryTypes Array
150 * @return String: Formatted HTML
152 private function getTypeMenu( $queryTypes ) {
153 global $wgLogRestrictions, $wgUser;
155 $html = "<select name='type'>\n";
157 $validTypes = LogPage
::validTypes();
158 $typesByName = array(); // Temporary array
160 // First pass to load the log names
161 foreach( $validTypes as $type ) {
162 $text = LogPage
::logName( $type );
163 $typesByName[$text] = $type;
166 // Second pass to sort by name
169 // Note the query type
170 $queryType = count($queryTypes) == 1 ?
$queryTypes[0] : '';
171 // Third pass generates sorted XHTML content
172 foreach( $typesByName as $text => $type ) {
173 $selected = ($type == $queryType);
175 if ( isset($wgLogRestrictions[$type]) ) {
176 if ( $wgUser->isAllowed( $wgLogRestrictions[$type] ) ) {
177 $html .= Xml
::option( $text, $type, $selected ) . "\n";
180 $html .= Xml
::option( $text, $type, $selected ) . "\n";
184 $html .= '</select>';
189 * @param $user String
190 * @return String: Formatted HTML
192 private function getUserInput( $user ) {
193 return Xml
::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'mw-log-user', 15, $user );
197 * @param $title String
198 * @return String: Formatted HTML
200 private function getTitleInput( $title ) {
201 return Xml
::inputLabel( wfMsg( 'speciallogtitlelabel' ), 'page', 'mw-log-page', 20, $title );
205 * @return boolean Checkbox
207 private function getTitlePattern( $pattern ) {
208 return '<span style="white-space: nowrap">' .
209 Xml
::checkLabel( wfMsg( 'log-title-wildcard' ), 'pattern', 'pattern', $pattern ) .
213 public function beginLogEventsList() {
217 public function endLogEventsList() {
222 * @param $row Row: a single row from the result set
223 * @return String: Formatted HTML list item
225 public function logLine( $row ) {
226 global $wgLang, $wgUser, $wgContLang;
228 $title = Title
::makeTitle( $row->log_namespace
, $row->log_title
);
229 $classes = array( "mw-logline-{$row->log_type}" );
230 $time = $wgLang->timeanddate( wfTimestamp(TS_MW
, $row->log_timestamp
), true );
232 if( self
::isDeleted($row,LogPage
::DELETED_USER
) ) {
233 $userLink = '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
235 $userLink = $this->skin
->userLink( $row->log_user
, $row->user_name
) .
236 $this->skin
->userToolLinks( $row->log_user
, $row->user_name
, true, 0, $row->user_editcount
);
239 if( self
::isDeleted($row,LogPage
::DELETED_COMMENT
) ) {
240 $comment = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>';
242 $comment = $wgContLang->getDirMark() . $this->skin
->commentBlock( $row->log_comment
);
244 // Extract extra parameters
245 $paramArray = LogPage
::extractParams( $row->log_params
);
247 // Some user can hide log items and have review links
248 if( !($this->flags
& self
::NO_ACTION_LINK
) && $wgUser->isAllowed( 'deleterevision' ) ) {
249 $del = $this->getShowHideLinks( $row ) . ' ';
251 // Add review links and such...
252 if( ($this->flags
& self
::NO_ACTION_LINK
) ||
($row->log_deleted
& LogPage
::DELETED_ACTION
) ) {
253 // Action text is suppressed...
254 } else if( self
::typeAction($row,'move','move','move') && !empty($paramArray[0]) ) {
255 $destTitle = Title
::newFromText( $paramArray[0] );
257 $revert = '(' . $this->skin
->link(
258 SpecialPage
::getTitleFor( 'Movepage' ),
259 $this->message
['revertmove'],
262 'wpOldTitle' => $destTitle->getPrefixedDBkey(),
263 'wpNewTitle' => $title->getPrefixedDBkey(),
264 'wpReason' => wfMsgForContent( 'revertmove' ),
267 array( 'known', 'noclasses' )
270 // Show undelete link
271 } else if( self
::typeAction($row,array('delete','suppress'),'delete','deletedhistory') ) {
272 if( !$wgUser->isAllowed( 'undelete' ) ) {
273 $viewdeleted = $this->message
['undeleteviewlink'];
275 $viewdeleted = $this->message
['undeletelink'];
278 $revert = '(' . $this->skin
->link(
279 SpecialPage
::getTitleFor( 'Undelete' ),
282 array( 'target' => $title->getPrefixedDBkey() ),
283 array( 'known', 'noclasses' )
285 // Show unblock/change block link
286 } else if( self
::typeAction($row,array('block','suppress'),array('block','reblock'),'block') ) {
289 SpecialPage
::getTitleFor( 'Ipblocklist' ),
290 $this->message
['unblocklink'],
293 'action' => 'unblock',
294 'ip' => $row->log_title
298 $this->message
['pipe-separator'] .
300 SpecialPage
::getTitleFor( 'Blockip', $row->log_title
),
301 $this->message
['change-blocklink'],
307 // Show change protection link
308 } else if( self
::typeAction( $row, 'protect', array( 'modify', 'protect', 'unprotect' ) ) ) {
310 $this->skin
->link( $title,
311 $this->message
['hist'],
314 'action' => 'history',
315 'offset' => $row->log_timestamp
318 if( $wgUser->isAllowed( 'protect' ) ) {
319 $revert .= $this->message
['pipe-separator'] .
320 $this->skin
->link( $title,
321 $this->message
['protect_change'],
323 array( 'action' => 'protect' ),
328 } else if( self
::typeAction($row,'merge','merge','mergehistory') ) {
329 $merge = SpecialPage
::getTitleFor( 'Mergehistory' );
330 $revert = '(' . $this->skin
->link(
332 $this->message
['revertmerge'],
335 'target' => $paramArray[0],
336 'dest' => $title->getPrefixedDBkey(),
337 'mergepoint' => $paramArray[1]
339 array( 'known', 'noclasses' )
341 // If an edit was hidden from a page give a review link to the history
342 } else if( self
::typeAction($row,array('delete','suppress'),'revision','deleterevision') ) {
343 if( count($paramArray) >= 2 ) {
344 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
345 // Different revision types use different URL params...
346 $key = $paramArray[0];
347 // $paramArray[1] is a CSV of the IDs
348 $Ids = explode( ',', $paramArray[1] );
349 $query = $paramArray[1];
351 // Diff link for single rev deletions
352 if( ( $key === 'oldid' ||
$key == 'revision' ) && count($Ids) == 1 ) {
353 $revert[] = $this->skin
->link(
355 $this->message
['diff'],
358 'diff' => intval( $Ids[0] ),
361 array( 'known', 'noclasses' )
364 // View/modify link...
365 $revert[] = $this->skin
->link(
367 $this->message
['revdel-restore'],
370 'target' => $title->getPrefixedText(),
374 array( 'known', 'noclasses' )
377 $revert = '(' . implode(' | ',$revert) . ')';
379 // Hidden log items, give review link
380 } else if( self
::typeAction($row,array('delete','suppress'),'event','deleterevision') ) {
381 if( count($paramArray) >= 1 ) {
382 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
383 // $paramArray[1] is a CSV of the IDs
384 $Ids = explode( ',', $paramArray[0] );
385 $query = $paramArray[0];
386 // Link to each hidden object ID, $paramArray[1] is the url param
387 $revert = '(' . $this->skin
->link(
389 $this->message
['revdel-restore'],
392 'target' => $title->getPrefixedText(),
396 array( 'known', 'noclasses' )
399 // Self-created users
400 } else if( self
::typeAction($row,'newusers','create2') ) {
401 if( isset( $paramArray[0] ) ) {
402 $revert = $this->skin
->userToolLinks( $paramArray[0], $title->getDBkey(), true );
404 # Fall back to a blue contributions link
405 $revert = $this->skin
->userToolLinks( 1, $title->getDBkey() );
407 if( $time < '20080129000000' ) {
408 # Suppress $comment from old entries (before 2008-01-29),
409 # not needed and can contain incorrect links
412 // Do nothing. The implementation is handled by the hook modifiying the passed-by-ref parameters.
414 wfRunHooks( 'LogLine', array( $row->log_type
, $row->log_action
, $title, $paramArray,
415 &$comment, &$revert, $row->log_timestamp
) );
418 if( self
::isDeleted($row,LogPage
::DELETED_ACTION
) ) {
419 $action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
421 $action = LogPage
::actionText( $row->log_type
, $row->log_action
, $title,
422 $this->skin
, $paramArray, true );
426 list($tagDisplay, $newClasses) = ChangeTags
::formatSummaryRow( $row->ts_tags
, 'logevent' );
427 $classes = array_merge( $classes, $newClasses );
429 if( $revert != '' ) {
430 $revert = '<span class="mw-logevent-actionlink">' . $revert . '</span>';
433 $time = htmlspecialchars( $time );
435 return Xml
::tags( 'li', array( "class" => implode( ' ', $classes ) ),
436 $del . $time . ' ' . $userLink . ' ' . $action . ' ' . $comment . ' ' . $revert . " $tagDisplay" ) . "\n";
443 private function getShowHideLinks( $row ) {
444 // If event was hidden from sysops
445 if( !self
::userCan( $row, LogPage
::DELETED_RESTRICTED
) ) {
446 $del = Xml
::tags( 'span', array( 'class'=>'mw-revdelundel-link' ),
447 '('.$this->message
['rev-delundel'].')' );
448 } else if( $row->log_type
== 'suppress' ) {
449 $del = ''; // No one should be hiding from the oversight log
451 $target = SpecialPage
::getTitleFor( 'Log', $row->log_type
);
452 $page = Title
::makeTitle( $row->log_namespace
, $row->log_title
);
454 'target' => $target->getPrefixedDBkey(),
456 'ids' => $row->log_id
,
458 $del = $this->skin
->revDeleteLink( $query,
459 self
::isDeleted( $row, LogPage
::DELETED_RESTRICTED
) );
466 * @param $type Mixed: string/array
467 * @param $action Mixed: string/array
468 * @param $right string
471 public static function typeAction( $row, $type, $action, $right='' ) {
472 $match = is_array($type) ?
473 in_array($row->log_type
,$type) : $row->log_type
== $type;
475 $match = is_array($action) ?
476 in_array($row->log_action
,$action) : $row->log_action
== $action;
477 if( $match && $right ) {
479 $match = $wgUser->isAllowed( $right );
486 * Determine if the current user is allowed to view a particular
487 * field of this log row, if it's marked as deleted.
489 * @param $field Integer
492 public static function userCan( $row, $field ) {
493 if( ( $row->log_deleted
& $field ) == $field ) {
495 $permission = ( $row->log_deleted
& LogPage
::DELETED_RESTRICTED
) == LogPage
::DELETED_RESTRICTED
498 wfDebug( "Checking for $permission due to $field match on $row->log_deleted\n" );
499 return $wgUser->isAllowed( $permission );
507 * @param $field Integer: one of DELETED_* bitfield constants
510 public static function isDeleted( $row, $field ) {
511 return ($row->log_deleted
& $field) == $field;
515 * Quick function to show a short log extract
516 * @param $out OutputPage
517 * @param $types String or Array
518 * @param $page String
519 * @param $user String
520 * @param $lim Integer
521 * @param $conds Array
523 public static function showLogExtract( $out, $types=array(), $page='', $user='', $lim=0, $conds=array() ) {
525 # Insert list of top 50 or so items
526 $loglist = new LogEventsList( $wgUser->getSkin(), $out, 0 );
527 $pager = new LogPager( $loglist, $types, $user, $page, '', $conds );
528 if( $lim > 0 ) $pager->mLimit
= $lim;
529 $logBody = $pager->getBody();
532 $loglist->beginLogEventsList() .
534 $loglist->endLogEventsList()
537 $out->addWikiMsg( 'logempty' );
539 return $pager->getNumRows();
543 * SQL clause to skip forbidden log types for this user
544 * @param $db Database
545 * @param $audience string, public/user
546 * @return mixed (string or false)
548 public static function getExcludeClause( $db, $audience = 'public' ) {
549 global $wgLogRestrictions, $wgUser;
550 // Reset the array, clears extra "where" clauses when $par is used
551 $hiddenLogs = array();
552 // Don't show private logs to unprivileged users
553 foreach( $wgLogRestrictions as $logType => $right ) {
554 if( $audience == 'public' ||
!$wgUser->isAllowed($right) ) {
555 $safeType = $db->strencode( $logType );
556 $hiddenLogs[] = $safeType;
559 if( count($hiddenLogs) == 1 ) {
560 return 'log_type != ' . $db->addQuotes( $hiddenLogs[0] );
561 } elseif( $hiddenLogs ) {
562 return 'log_type NOT IN (' . $db->makeList($hiddenLogs) . ')';
571 class LogPager
extends ReverseChronologicalPager
{
572 private $types = array(), $user = '', $title = '', $pattern = '';
573 private $typeCGI = '';
574 public $mLogEventsList;
578 * @param $list LogEventsList
579 * @param $types String or Array
580 * @param $user String
581 * @param $title String
582 * @param $pattern String
583 * @param $conds Array
584 * @param $year Integer
585 * @param $month Integer
587 public function __construct( $list, $types = array(), $user = '', $title = '', $pattern = '',
588 $conds = array(), $year = false, $month = false, $tagFilter = '' )
590 parent
::__construct();
591 $this->mConds
= $conds;
593 $this->mLogEventsList
= $list;
595 $this->limitType( $types ); // also excludes hidden types
596 $this->limitUser( $user );
597 $this->limitTitle( $title, $pattern );
598 $this->getDateCond( $year, $month );
599 $this->mTagFilter
= $tagFilter;
602 public function getDefaultQuery() {
603 $query = parent
::getDefaultQuery();
604 $query['type'] = $this->typeCGI
; // arrays won't work here
605 $query['user'] = $this->user
;
606 $query['month'] = $this->mMonth
;
607 $query['year'] = $this->mYear
;
611 // Call ONLY after calling $this->limitType() already!
612 public function getFilterParams() {
613 global $wgFilterLogTypes, $wgUser, $wgRequest;
615 if( count($this->types
) ) {
618 foreach( $wgFilterLogTypes as $type => $default ) {
619 // Avoid silly filtering
620 if( $type !== 'patrol' ||
$wgUser->useNPPatrol() ) {
621 $hide = $wgRequest->getInt( "hide_{$type}_log", $default );
622 $filters[$type] = $hide;
624 $this->mConds
[] = 'log_type != ' . $this->mDb
->addQuotes( $type );
631 * Set the log reader to return only entries of the given type.
632 * Type restrictions enforced here
633 * @param $types String or array: Log types ('upload', 'delete', etc);
634 * empty string means no restriction
636 private function limitType( $types ) {
637 global $wgLogRestrictions, $wgUser;
638 // If $types is not an array, make it an array
639 $types = ($types === '') ?
array() : (array)$types;
640 // Don't even show header for private logs; don't recognize it...
641 foreach ( $types as $type ) {
642 if( isset( $wgLogRestrictions[$type] ) && !$wgUser->isAllowed($wgLogRestrictions[$type]) ) {
643 $types = array_diff( $types, array( $type ) );
646 // Don't show private logs to unprivileged users.
647 // Also, only show them upon specific request to avoid suprises.
648 $audience = $types ?
'user' : 'public';
649 $hideLogs = LogEventsList
::getExcludeClause( $this->mDb
, $audience );
650 if( $hideLogs !== false ) {
651 $this->mConds
[] = $hideLogs;
653 if( count($types) ) {
654 $this->types
= $types;
655 $this->mConds
['log_type'] = $types;
656 // Set typeCGI; used in url param for paging
657 if( count($types) == 1 ) $this->typeCGI
= $types[0];
662 * Set the log reader to return only entries by the given user.
663 * @param $name String: (In)valid user name
665 private function limitUser( $name ) {
669 $usertitle = Title
::makeTitleSafe( NS_USER
, $name );
670 if( is_null($usertitle) ) {
673 /* Fetch userid at first, if known, provides awesome query plan afterwards */
674 $userid = User
::idFromName( $name );
676 /* It should be nicer to abort query at all,
677 but for now it won't pass anywhere behind the optimizer */
678 $this->mConds
[] = "NULL";
681 $this->mConds
['log_user'] = $userid;
682 // Paranoia: avoid brute force searches (bug 17342)
683 if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
684 $this->mConds
[] = $this->mDb
->bitAnd('log_deleted', LogPage
::DELETED_USER
) . ' = 0';
686 $this->user
= $usertitle->getText();
691 * Set the log reader to return only entries affecting the given page.
692 * (For the block and rights logs, this is a user page.)
693 * @param $page String: Title name as text
694 * @param $pattern String
696 private function limitTitle( $page, $pattern ) {
697 global $wgMiserMode, $wgUser;
699 $title = Title
::newFromText( $page );
700 if( strlen($page) == 0 ||
!$title instanceof Title
)
703 $this->title
= $title->getPrefixedText();
704 $ns = $title->getNamespace();
705 # Using the (log_namespace, log_title, log_timestamp) index with a
706 # range scan (LIKE) on the first two parts, instead of simple equality,
707 # makes it unusable for sorting. Sorted retrieval using another index
708 # would be possible, but then we might have to scan arbitrarily many
709 # nodes of that index. Therefore, we need to avoid this if $wgMiserMode
712 # This is not a problem with simple title matches, because then we can
713 # use the page_time index. That should have no more than a few hundred
714 # log entries for even the busiest pages, so it can be safely scanned
715 # in full to satisfy an impossible condition on user or similar.
716 if( $pattern && !$wgMiserMode ) {
717 # use escapeLike to avoid expensive search patterns like 't%st%'
718 $safetitle = $this->mDb
->escapeLike( $title->getDBkey() );
719 $this->mConds
['log_namespace'] = $ns;
720 $this->mConds
[] = "log_title LIKE '$safetitle%'";
721 $this->pattern
= $pattern;
723 $this->mConds
['log_namespace'] = $ns;
724 $this->mConds
['log_title'] = $title->getDBkey();
726 // Paranoia: avoid brute force searches (bug 17342)
727 if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
728 $this->mConds
[] = $this->mDb
->bitAnd('log_deleted', LogPage
::DELETED_ACTION
) . ' = 0';
732 public function getQueryInfo() {
733 $tables = array( 'logging', 'user' );
734 $this->mConds
[] = 'user_id = log_user';
736 # Add log_search table if there are conditions on it
737 if( array_key_exists('ls_field',$this->mConds
) ) {
738 $tables[] = 'log_search';
739 $index = array( 'log_search' => 'ls_field_val', 'logging' => 'PRIMARY' );
740 $groupBy = 'ls_log_id';
741 # Don't use the wrong logging index
742 } else if( $this->title ||
$this->pattern ||
$this->user
) {
743 $index = array( 'logging' => array('page_time','user_time') );
744 } else if( $this->types
) {
745 $index = array( 'logging' => 'type_time' );
747 $index = array( 'logging' => 'times' );
749 $options = array( 'USE INDEX' => $index );
750 # Don't show duplicate rows when using log_search
751 if( $groupBy ) $options['GROUP BY'] = $groupBy;
754 'fields' => array( 'log_type', 'log_action', 'log_user', 'log_namespace',
755 'log_title', 'log_params', 'log_comment', 'log_id', 'log_deleted',
756 'log_timestamp', 'user_name', 'user_editcount' ),
757 'conds' => $this->mConds
,
758 'options' => $options,
759 'join_conds' => array(
760 'user' => array( 'INNER JOIN', 'user_id=log_user' ),
761 'log_search' => array( 'INNER JOIN', 'ls_log_id=log_id' )
764 # Add ChangeTags filter query
765 ChangeTags
::modifyDisplayQuery( $info['tables'], $info['fields'], $info['conds'],
766 $info['join_conds'], $info['options'], $this->mTagFilter
);
771 function getIndexField() {
772 return 'log_timestamp';
775 public function getStartBody() {
776 wfProfileIn( __METHOD__
);
777 # Do a link batch query
778 if( $this->getNumRows() > 0 ) {
780 while( $row = $this->mResult
->fetchObject() ) {
781 $lb->add( $row->log_namespace
, $row->log_title
);
782 $lb->addObj( Title
::makeTitleSafe( NS_USER
, $row->user_name
) );
783 $lb->addObj( Title
::makeTitleSafe( NS_USER_TALK
, $row->user_name
) );
786 $this->mResult
->seek( 0 );
788 wfProfileOut( __METHOD__
);
792 public function formatRow( $row ) {
793 return $this->mLogEventsList
->logLine( $row );
796 public function getType() {
800 public function getUser() {
804 public function getPage() {
808 public function getPattern() {
809 return $this->pattern
;
812 public function getYear() {
816 public function getMonth() {
817 return $this->mMonth
;
820 public function getTagFilter() {
821 return $this->mTagFilter
;
824 public function doQuery() {
825 // Workaround MySQL optimizer bug
826 $this->mDb
->setBigSelects();
828 $this->mDb
->setBigSelects( 'default' );
834 * @ingroup SpecialPage
839 * @param $request WebRequest: for internal use use a FauxRequest object to pass arbitrary parameters.
841 function __construct( $request ) {
842 global $wgUser, $wgOut;
843 wfDeprecated(__METHOD__
);
845 $type = $request->getVal( 'type' );
846 $user = $request->getText( 'user' );
847 $title = $request->getText( 'page' );
848 $pattern = $request->getBool( 'pattern' );
849 $year = $request->getIntOrNull( 'year' );
850 $month = $request->getIntOrNull( 'month' );
851 $tagFilter = $request->getVal( 'tagfilter' );
852 # Don't let the user get stuck with a certain date
853 $skip = $request->getText( 'offset' ) ||
$request->getText( 'dir' ) == 'prev';
858 # Use new list class to output results
859 $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 );
860 $this->pager
= new LogPager( $loglist, $type, $user, $title, $pattern, $year, $month, $tagFilter );
864 * Is there at least one row?
867 public function hasRows() {
868 return isset($this->pager
) ?
($this->pager
->getNumRows() > 0) : false;
874 * @ingroup SpecialPage
877 const NO_ACTION_LINK
= 1;
885 * @param &$reader LogReader: where to get our data from
886 * @param $flags Integer: Bitwise combination of flags:
887 * LogEventsList::NO_ACTION_LINK Don't show restore/unblock/block links
889 function __construct( &$reader, $flags = 0 ) {
890 wfDeprecated(__METHOD__
);
891 $this->reader
=& $reader;
892 $this->reader
->pager
->mLogEventsList
->flags
= $flags;
893 # Aliases for shorter code...
894 $this->pager
=& $this->reader
->pager
;
895 $this->list =& $this->reader
->pager
->mLogEventsList
;
899 * Take over the whole output page in $wgOut with the log display.
901 public function show() {
902 # Set title and add header
903 $this->list->showHeader( $pager->getType() );
905 $this->list->showOptions( $this->pager
->getType(), $this->pager
->getUser(), $this->pager
->getPage(),
906 $this->pager
->getPattern(), $this->pager
->getYear(), $this->pager
->getMonth() );
908 $logBody = $this->pager
->getBody();
911 $this->pager
->getNavigationBar() .
912 $this->list->beginLogEventsList() .
914 $this->list->endLogEventsList() .
915 $this->pager
->getNavigationBar()
918 $wgOut->addWikiMsg( 'logempty' );
923 * Output just the list of entries given by the linked LogReader,
924 * with extraneous UI elements. Use for displaying log fragments in
925 * another page (eg at Special:Undelete)
926 * @param $out OutputPage: where to send output
928 public function showList( &$out ) {
929 $logBody = $this->pager
->getBody();
932 $this->list->beginLogEventsList() .
934 $this->list->endLogEventsList()
937 $out->addWikiMsg( 'logempty' );