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 $hideVal = 1 - intval($val);
112 // FIXME: use link() here. Needs changes in getDefaultQuery()
113 $link = $this->skin
->makeKnownLinkObj( $wgTitle, $messages[$hideVal],
114 wfArrayToCGI( array( "hide_{$type}_log" => $hideVal ), $this->getDefaultQuery() )
116 $links[$type] = wfMsgHtml( "log-show-hide-{$type}", $link );
117 $hiddens .= Xml
::hidden( "hide_{$type}_log", $val ) . "\n";
120 return '<small>'.$wgLang->pipeList( $links ) . '</small>' . $hiddens;
123 private function getDefaultQuery() {
124 if ( !isset( $this->mDefaultQuery
) ) {
125 $this->mDefaultQuery
= $_GET;
126 unset( $this->mDefaultQuery
['title'] );
127 unset( $this->mDefaultQuery
['dir'] );
128 unset( $this->mDefaultQuery
['offset'] );
129 unset( $this->mDefaultQuery
['limit'] );
130 unset( $this->mDefaultQuery
['order'] );
131 unset( $this->mDefaultQuery
['month'] );
132 unset( $this->mDefaultQuery
['year'] );
134 return $this->mDefaultQuery
;
138 * @param $queryTypes Array
139 * @return String: Formatted HTML
141 private function getTypeMenu( $queryTypes ) {
142 global $wgLogRestrictions, $wgUser;
144 $html = "<select name='type'>\n";
146 $validTypes = LogPage
::validTypes();
147 $typesByName = array(); // Temporary array
149 // First pass to load the log names
150 foreach( $validTypes as $type ) {
151 $text = LogPage
::logName( $type );
152 $typesByName[$text] = $type;
155 // Second pass to sort by name
158 // Note the query type
159 $queryType = count($queryTypes) == 1 ?
$queryTypes[0] : '';
160 // Third pass generates sorted XHTML content
161 foreach( $typesByName as $text => $type ) {
162 $selected = ($type == $queryType);
164 if ( isset($wgLogRestrictions[$type]) ) {
165 if ( $wgUser->isAllowed( $wgLogRestrictions[$type] ) ) {
166 $html .= Xml
::option( $text, $type, $selected ) . "\n";
169 $html .= Xml
::option( $text, $type, $selected ) . "\n";
173 $html .= '</select>';
178 * @param $user String
179 * @return String: Formatted HTML
181 private function getUserInput( $user ) {
182 return Xml
::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'mw-log-user', 15, $user );
186 * @param $title String
187 * @return String: Formatted HTML
189 private function getTitleInput( $title ) {
190 return Xml
::inputLabel( wfMsg( 'speciallogtitlelabel' ), 'page', 'mw-log-page', 20, $title );
194 * @return boolean Checkbox
196 private function getTitlePattern( $pattern ) {
197 return '<span style="white-space: nowrap">' .
198 Xml
::checkLabel( wfMsg( 'log-title-wildcard' ), 'pattern', 'pattern', $pattern ) .
202 public function beginLogEventsList() {
206 public function endLogEventsList() {
211 * @param $row Row: a single row from the result set
212 * @return String: Formatted HTML list item
214 public function logLine( $row ) {
215 global $wgLang, $wgUser, $wgContLang;
217 $title = Title
::makeTitle( $row->log_namespace
, $row->log_title
);
218 $classes = array( "mw-logline-{$row->log_type}" );
219 $time = $wgLang->timeanddate( wfTimestamp(TS_MW
, $row->log_timestamp
), true );
221 if( self
::isDeleted($row,LogPage
::DELETED_USER
) ) {
222 $userLink = '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
224 $userLink = $this->skin
->userLink( $row->log_user
, $row->user_name
) .
225 $this->skin
->userToolLinks( $row->log_user
, $row->user_name
, true, 0, $row->user_editcount
);
228 if( self
::isDeleted($row,LogPage
::DELETED_COMMENT
) ) {
229 $comment = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>';
231 $comment = $wgContLang->getDirMark() . $this->skin
->commentBlock( $row->log_comment
);
233 // Extract extra parameters
234 $paramArray = LogPage
::extractParams( $row->log_params
);
236 // Some user can hide log items and have review links
237 if( !($this->flags
& self
::NO_ACTION_LINK
) && $wgUser->isAllowed( 'deleterevision' ) ) {
238 $del = $this->getShowHideLinks( $row ) . ' ';
240 // Add review links and such...
241 if( ($this->flags
& self
::NO_ACTION_LINK
) ||
($row->log_deleted
& LogPage
::DELETED_ACTION
) ) {
242 // Action text is suppressed...
243 } else if( self
::typeAction($row,'move','move','move') && !empty($paramArray[0]) ) {
244 $destTitle = Title
::newFromText( $paramArray[0] );
246 $revert = '(' . $this->skin
->link(
247 SpecialPage
::getTitleFor( 'Movepage' ),
248 $this->message
['revertmove'],
251 'wpOldTitle' => $destTitle->getPrefixedDBkey(),
252 'wpNewTitle' => $title->getPrefixedDBkey(),
253 'wpReason' => wfMsgForContent( 'revertmove' ),
256 array( 'known', 'noclasses' )
259 // Show undelete link
260 } else if( self
::typeAction($row,array('delete','suppress'),'delete','deletedhistory') ) {
261 if( !$wgUser->isAllowed( 'undelete' ) ) {
262 $viewdeleted = $this->message
['undeleteviewlink'];
264 $viewdeleted = $this->message
['undeletelink'];
267 $revert = '(' . $this->skin
->link(
268 SpecialPage
::getTitleFor( 'Undelete' ),
271 array( 'target' => $title->getPrefixedDBkey() ),
272 array( 'known', 'noclasses' )
274 // Show unblock/change block link
275 } else if( self
::typeAction($row,array('block','suppress'),array('block','reblock'),'block') ) {
278 SpecialPage
::getTitleFor( 'Ipblocklist' ),
279 $this->message
['unblocklink'],
282 'action' => 'unblock',
283 'ip' => $row->log_title
287 $this->message
['pipe-separator'] .
289 SpecialPage
::getTitleFor( 'Blockip', $row->log_title
),
290 $this->message
['change-blocklink'],
296 // Show change protection link
297 } else if( self
::typeAction( $row, 'protect', array( 'modify', 'protect', 'unprotect' ) ) ) {
299 $this->skin
->link( $title,
300 $this->message
['hist'],
303 'action' => 'history',
304 'offset' => $row->log_timestamp
307 if( $wgUser->isAllowed( 'protect' ) ) {
308 $revert .= $this->message
['pipe-separator'] .
309 $this->skin
->link( $title,
310 $this->message
['protect_change'],
312 array( 'action' => 'protect' ),
317 } else if( self
::typeAction($row,'merge','merge','mergehistory') ) {
318 $merge = SpecialPage
::getTitleFor( 'Mergehistory' );
319 $revert = '(' . $this->skin
->link(
321 $this->message
['revertmerge'],
324 'target' => $paramArray[0],
325 'dest' => $title->getPrefixedDBkey(),
326 'mergepoint' => $paramArray[1]
328 array( 'known', 'noclasses' )
330 // If an edit was hidden from a page give a review link to the history
331 } else if( self
::typeAction($row,array('delete','suppress'),'revision','deleterevision') ) {
332 if( count($paramArray) >= 2 ) {
333 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
334 // Different revision types use different URL params...
335 $key = $paramArray[0];
336 // $paramArray[1] is a CSV of the IDs
337 $Ids = explode( ',', $paramArray[1] );
338 $query = $paramArray[1];
340 // Diff link for single rev deletions
341 if( ( $key === 'oldid' ||
$key == 'revision' ) && count($Ids) == 1 ) {
342 $revert[] = $this->skin
->link(
344 $this->message
['diff'],
347 'diff' => intval( $Ids[0] ),
350 array( 'known', 'noclasses' )
353 // View/modify link...
354 $revert[] = $this->skin
->link(
356 $this->message
['revdel-restore'],
359 'target' => $title->getPrefixedUrl(),
363 array( 'known', 'noclasses' )
366 $revert = '(' . implode(' | ',$revert) . ')';
368 // Hidden log items, give review link
369 } else if( self
::typeAction($row,array('delete','suppress'),'event','deleterevision') ) {
370 if( count($paramArray) >= 1 ) {
371 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
372 // $paramArray[1] is a CSV of the IDs
373 $Ids = explode( ',', $paramArray[0] );
374 $query = $paramArray[0];
375 // Link to each hidden object ID, $paramArray[1] is the url param
376 $revert = '(' . $this->skin
->link(
378 $this->message
['revdel-restore'],
381 'target' => $title->getPrefixedUrl(),
385 array( 'known', 'noclasses' )
388 // Self-created users
389 } else if( self
::typeAction($row,'newusers','create2') ) {
390 if( isset( $paramArray[0] ) ) {
391 $revert = $this->skin
->userToolLinks( $paramArray[0], $title->getDBkey(), true );
393 # Fall back to a blue contributions link
394 $revert = $this->skin
->userToolLinks( 1, $title->getDBkey() );
396 if( $time < '20080129000000' ) {
397 # Suppress $comment from old entries (before 2008-01-29),
398 # not needed and can contain incorrect links
401 // Do nothing. The implementation is handled by the hook modifiying the passed-by-ref parameters.
403 wfRunHooks( 'LogLine', array( $row->log_type
, $row->log_action
, $title, $paramArray,
404 &$comment, &$revert, $row->log_timestamp
) );
407 if( self
::isDeleted($row,LogPage
::DELETED_ACTION
) ) {
408 $action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
410 $action = LogPage
::actionText( $row->log_type
, $row->log_action
, $title,
411 $this->skin
, $paramArray, true );
415 list($tagDisplay, $newClasses) = ChangeTags
::formatSummaryRow( $row->ts_tags
, 'logevent' );
416 $classes = array_merge( $classes, $newClasses );
418 if( $revert != '' ) {
419 $revert = '<span class="mw-logevent-actionlink">' . $revert . '</span>';
422 $time = htmlspecialchars( $time );
424 return Xml
::tags( 'li', array( "class" => implode( ' ', $classes ) ),
425 $del . $time . ' ' . $userLink . ' ' . $action . ' ' . $comment . ' ' . $revert . " $tagDisplay" ) . "\n";
432 private function getShowHideLinks( $row ) {
433 // If event was hidden from sysops
434 if( !self
::userCan( $row, LogPage
::DELETED_RESTRICTED
) ) {
435 $del = Xml
::tags( 'span', array( 'class'=>'mw-revdelundel-link' ),
436 '('.$this->message
['rev-delundel'].')' );
437 } else if( $row->log_type
== 'suppress' ) {
438 $del = ''; // No one should be hiding from the oversight log
440 $target = SpecialPage
::getTitleFor( 'Log', $row->log_type
);
441 $page = Title
::makeTitle( $row->log_namespace
, $row->log_title
);
443 'target' => $target->getPrefixedDBkey(),
445 'ids' => $row->log_id
,
447 $del = $this->skin
->revDeleteLink( $query,
448 self
::isDeleted( $row, LogPage
::DELETED_RESTRICTED
) );
455 * @param $type Mixed: string/array
456 * @param $action Mixed: string/array
457 * @param $right string
460 public static function typeAction( $row, $type, $action, $right='' ) {
461 $match = is_array($type) ?
462 in_array($row->log_type
,$type) : $row->log_type
== $type;
464 $match = is_array($action) ?
465 in_array($row->log_action
,$action) : $row->log_action
== $action;
466 if( $match && $right ) {
468 $match = $wgUser->isAllowed( $right );
475 * Determine if the current user is allowed to view a particular
476 * field of this log row, if it's marked as deleted.
478 * @param $field Integer
481 public static function userCan( $row, $field ) {
482 if( ( $row->log_deleted
& $field ) == $field ) {
484 $permission = ( $row->log_deleted
& LogPage
::DELETED_RESTRICTED
) == LogPage
::DELETED_RESTRICTED
487 wfDebug( "Checking for $permission due to $field match on $row->log_deleted\n" );
488 return $wgUser->isAllowed( $permission );
496 * @param $field Integer: one of DELETED_* bitfield constants
499 public static function isDeleted( $row, $field ) {
500 return ($row->log_deleted
& $field) == $field;
504 * Quick function to show a short log extract
505 * @param $out OutputPage
506 * @param $types String or Array
507 * @param $page String
508 * @param $user String
509 * @param $lim Integer
510 * @param $conds Array
512 public static function showLogExtract( $out, $types=array(), $page='', $user='', $lim=0, $conds=array() ) {
514 # Insert list of top 50 or so items
515 $loglist = new LogEventsList( $wgUser->getSkin(), $out, 0 );
516 $pager = new LogPager( $loglist, $types, $user, $page, '', $conds );
517 if( $lim > 0 ) $pager->mLimit
= $lim;
518 $logBody = $pager->getBody();
521 $loglist->beginLogEventsList() .
523 $loglist->endLogEventsList()
526 $out->addWikiMsg( 'logempty' );
528 return $pager->getNumRows();
532 * SQL clause to skip forbidden log types for this user
533 * @param $db Database
534 * @param $audience string, public/user
535 * @return mixed (string or false)
537 public static function getExcludeClause( $db, $audience = 'public' ) {
538 global $wgLogRestrictions, $wgUser;
539 // Reset the array, clears extra "where" clauses when $par is used
540 $hiddenLogs = array();
541 // Don't show private logs to unprivileged users
542 foreach( $wgLogRestrictions as $logType => $right ) {
543 if( $audience == 'public' ||
!$wgUser->isAllowed($right) ) {
544 $safeType = $db->strencode( $logType );
545 $hiddenLogs[] = $safeType;
548 if( count($hiddenLogs) == 1 ) {
549 return 'log_type != ' . $db->addQuotes( $hiddenLogs[0] );
550 } elseif( $hiddenLogs ) {
551 return 'log_type NOT IN (' . $db->makeList($hiddenLogs) . ')';
560 class LogPager
extends ReverseChronologicalPager
{
561 private $types = array(), $user = '', $title = '', $pattern = '';
562 private $typeCGI = '';
563 public $mLogEventsList;
567 * @param $list LogEventsList
568 * @param $types String or Array
569 * @param $user String
570 * @param $title String
571 * @param $pattern String
572 * @param $conds Array
573 * @param $year Integer
574 * @param $month Integer
576 public function __construct( $list, $types = array(), $user = '', $title = '', $pattern = '',
577 $conds = array(), $year = false, $month = false, $tagFilter = '' )
579 parent
::__construct();
580 $this->mConds
= $conds;
582 $this->mLogEventsList
= $list;
584 $this->limitType( $types ); // also excludes hidden types
585 $this->limitUser( $user );
586 $this->limitTitle( $title, $pattern );
587 $this->getDateCond( $year, $month );
588 $this->mTagFilter
= $tagFilter;
591 public function getDefaultQuery() {
592 $query = parent
::getDefaultQuery();
593 $query['type'] = $this->typeCGI
; // arrays won't work here
594 $query['user'] = $this->user
;
595 $query['month'] = $this->mMonth
;
596 $query['year'] = $this->mYear
;
600 // Call ONLY after calling $this->limitType() already!
601 public function getFilterParams() {
602 global $wgFilterLogTypes, $wgUser, $wgRequest;
604 if( count($this->types
) ) {
607 foreach( $wgFilterLogTypes as $type => $default ) {
608 // Avoid silly filtering
609 if( $type !== 'patrol' ||
$wgUser->useNPPatrol() ) {
610 $hide = $wgRequest->getInt( "hide_{$type}_log", $default );
611 $filters[$type] = $hide;
613 $this->mConds
[] = 'log_type != ' . $this->mDb
->addQuotes( $type );
620 * Set the log reader to return only entries of the given type.
621 * Type restrictions enforced here
622 * @param $types String or array: Log types ('upload', 'delete', etc);
623 * empty string means no restriction
625 private function limitType( $types ) {
626 global $wgLogRestrictions, $wgUser;
627 // If $types is not an array, make it an array
628 $types = ($types === '') ?
array() : (array)$types;
629 // Don't even show header for private logs; don't recognize it...
630 foreach ( $types as $type ) {
631 if( isset( $wgLogRestrictions[$type] ) && !$wgUser->isAllowed($wgLogRestrictions[$type]) ) {
632 $types = array_diff( $types, array( $type ) );
635 // Don't show private logs to unprivileged users.
636 // Also, only show them upon specific request to avoid suprises.
637 $audience = $types ?
'user' : 'public';
638 $hideLogs = LogEventsList
::getExcludeClause( $this->mDb
, $audience );
639 if( $hideLogs !== false ) {
640 $this->mConds
[] = $hideLogs;
642 if( count($types) ) {
643 $this->types
= $types;
644 $this->mConds
['log_type'] = $types;
645 // Set typeCGI; used in url param for paging
646 if( count($types) == 1 ) $this->typeCGI
= $types[0];
651 * Set the log reader to return only entries by the given user.
652 * @param $name String: (In)valid user name
654 private function limitUser( $name ) {
658 $usertitle = Title
::makeTitleSafe( NS_USER
, $name );
659 if( is_null($usertitle) ) {
662 /* Fetch userid at first, if known, provides awesome query plan afterwards */
663 $userid = User
::idFromName( $name );
665 /* It should be nicer to abort query at all,
666 but for now it won't pass anywhere behind the optimizer */
667 $this->mConds
[] = "NULL";
670 $this->mConds
['log_user'] = $userid;
671 // Paranoia: avoid brute force searches (bug 17342)
672 if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
673 $this->mConds
[] = 'log_deleted & ' . LogPage
::DELETED_USER
. ' = 0';
675 $this->user
= $usertitle->getText();
680 * Set the log reader to return only entries affecting the given page.
681 * (For the block and rights logs, this is a user page.)
682 * @param $page String: Title name as text
683 * @param $pattern String
685 private function limitTitle( $page, $pattern ) {
686 global $wgMiserMode, $wgUser;
688 $title = Title
::newFromText( $page );
689 if( strlen($page) == 0 ||
!$title instanceof Title
)
692 $this->title
= $title->getPrefixedText();
693 $ns = $title->getNamespace();
694 # Using the (log_namespace, log_title, log_timestamp) index with a
695 # range scan (LIKE) on the first two parts, instead of simple equality,
696 # makes it unusable for sorting. Sorted retrieval using another index
697 # would be possible, but then we might have to scan arbitrarily many
698 # nodes of that index. Therefore, we need to avoid this if $wgMiserMode
701 # This is not a problem with simple title matches, because then we can
702 # use the page_time index. That should have no more than a few hundred
703 # log entries for even the busiest pages, so it can be safely scanned
704 # in full to satisfy an impossible condition on user or similar.
705 if( $pattern && !$wgMiserMode ) {
706 # use escapeLike to avoid expensive search patterns like 't%st%'
707 $safetitle = $this->mDb
->escapeLike( $title->getDBkey() );
708 $this->mConds
['log_namespace'] = $ns;
709 $this->mConds
[] = "log_title LIKE '$safetitle%'";
710 $this->pattern
= $pattern;
712 $this->mConds
['log_namespace'] = $ns;
713 $this->mConds
['log_title'] = $title->getDBkey();
715 // Paranoia: avoid brute force searches (bug 17342)
716 if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
717 $this->mConds
[] = 'log_deleted & ' . LogPage
::DELETED_ACTION
. ' = 0';
721 public function getQueryInfo() {
722 $tables = array( 'logging', 'user' );
723 $this->mConds
[] = 'user_id = log_user';
725 # Add log_search table if there are conditions on it
726 if( array_key_exists('ls_field',$this->mConds
) ) {
727 $tables[] = 'log_search';
728 $index = array( 'log_search' => 'PRIMARY', 'logging' => 'PRIMARY' );
729 $groupBy = 'ls_log_id';
730 # Don't use the wrong logging index
731 } else if( $this->title ||
$this->pattern ||
$this->user
) {
732 $index = array( 'logging' => array('page_time','user_time') );
733 } else if( $this->types
) {
734 $index = array( 'logging' => 'type_time' );
736 $index = array( 'logging' => 'times' );
738 $options = array( 'USE INDEX' => $index );
739 # Don't show duplicate rows when using log_search
740 if( $groupBy ) $options['GROUP BY'] = $groupBy;
743 'fields' => array( 'log_type', 'log_action', 'log_user', 'log_namespace',
744 'log_title', 'log_params', 'log_comment', 'log_id', 'log_deleted',
745 'log_timestamp', 'user_name', 'user_editcount' ),
746 'conds' => $this->mConds
,
747 'options' => $options,
748 'join_conds' => array(
749 'user' => array( 'INNER JOIN', 'user_id=log_user' ),
750 'log_search' => array( 'INNER JOIN', 'ls_log_id=log_id' )
753 # Add ChangeTags filter query
754 ChangeTags
::modifyDisplayQuery( $info['tables'], $info['fields'], $info['conds'],
755 $info['join_conds'], $info['options'], $this->mTagFilter
);
760 function getIndexField() {
761 return 'log_timestamp';
764 public function getStartBody() {
765 wfProfileIn( __METHOD__
);
766 # Do a link batch query
767 if( $this->getNumRows() > 0 ) {
769 while( $row = $this->mResult
->fetchObject() ) {
770 $lb->add( $row->log_namespace
, $row->log_title
);
771 $lb->addObj( Title
::makeTitleSafe( NS_USER
, $row->user_name
) );
772 $lb->addObj( Title
::makeTitleSafe( NS_USER_TALK
, $row->user_name
) );
775 $this->mResult
->seek( 0 );
777 wfProfileOut( __METHOD__
);
781 public function formatRow( $row ) {
782 return $this->mLogEventsList
->logLine( $row );
785 public function getType() {
789 public function getUser() {
793 public function getPage() {
797 public function getPattern() {
798 return $this->pattern
;
801 public function getYear() {
805 public function getMonth() {
806 return $this->mMonth
;
809 public function getTagFilter() {
810 return $this->mTagFilter
;
813 public function doQuery() {
814 // Workaround MySQL optimizer bug
815 $this->mDb
->setBigSelects();
817 $this->mDb
->setBigSelects( 'default' );
823 * @ingroup SpecialPage
828 * @param $request WebRequest: for internal use use a FauxRequest object to pass arbitrary parameters.
830 function __construct( $request ) {
831 global $wgUser, $wgOut;
832 wfDeprecated(__METHOD__
);
834 $type = $request->getVal( 'type' );
835 $user = $request->getText( 'user' );
836 $title = $request->getText( 'page' );
837 $pattern = $request->getBool( 'pattern' );
838 $year = $request->getIntOrNull( 'year' );
839 $month = $request->getIntOrNull( 'month' );
840 $tagFilter = $request->getVal( 'tagfilter' );
841 # Don't let the user get stuck with a certain date
842 $skip = $request->getText( 'offset' ) ||
$request->getText( 'dir' ) == 'prev';
847 # Use new list class to output results
848 $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 );
849 $this->pager
= new LogPager( $loglist, $type, $user, $title, $pattern, $year, $month, $tagFilter );
853 * Is there at least one row?
856 public function hasRows() {
857 return isset($this->pager
) ?
($this->pager
->getNumRows() > 0) : false;
863 * @ingroup SpecialPage
866 const NO_ACTION_LINK
= 1;
874 * @param &$reader LogReader: where to get our data from
875 * @param $flags Integer: Bitwise combination of flags:
876 * LogEventsList::NO_ACTION_LINK Don't show restore/unblock/block links
878 function __construct( &$reader, $flags = 0 ) {
879 wfDeprecated(__METHOD__
);
880 $this->reader
=& $reader;
881 $this->reader
->pager
->mLogEventsList
->flags
= $flags;
882 # Aliases for shorter code...
883 $this->pager
=& $this->reader
->pager
;
884 $this->list =& $this->reader
->pager
->mLogEventsList
;
888 * Take over the whole output page in $wgOut with the log display.
890 public function show() {
891 # Set title and add header
892 $this->list->showHeader( $pager->getType() );
894 $this->list->showOptions( $this->pager
->getType(), $this->pager
->getUser(), $this->pager
->getPage(),
895 $this->pager
->getPattern(), $this->pager
->getYear(), $this->pager
->getMonth() );
897 $logBody = $this->pager
->getBody();
900 $this->pager
->getNavigationBar() .
901 $this->list->beginLogEventsList() .
903 $this->list->endLogEventsList() .
904 $this->pager
->getNavigationBar()
907 $wgOut->addWikiMsg( 'logempty' );
912 * Output just the list of entries given by the linked LogReader,
913 * with extraneous UI elements. Use for displaying log fragments in
914 * another page (eg at Special:Undelete)
915 * @param $out OutputPage: where to send output
917 public function showList( &$out ) {
918 $logBody = $this->pager
->getBody();
921 $this->list->beginLogEventsList() .
923 $this->list->endLogEventsList()
926 $out->addWikiMsg( 'logempty' );