3 * Copyright (C) 2008 Aaron Schulz
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
22 * Implements Special:Log
23 * @ingroup SpecialPage
25 class SpecialLog
extends SpecialPage
{
27 public function __construct() {
28 parent
::__construct( 'Log' );
31 public function execute( $par ) {
35 $this->outputHeader();
37 $opts = new FormOptions
;
38 $opts->add( 'type', '' );
39 $opts->add( 'user', '' );
40 $opts->add( 'page', '' );
41 $opts->add( 'pattern', false );
42 $opts->add( 'year', null, FormOptions
::INTNULL
);
43 $opts->add( 'month', null, FormOptions
::INTNULL
);
44 $opts->add( 'tagfilter', '' );
45 $opts->add( 'offset', '' );
46 $opts->add( 'dir', '' );
47 $opts->add( 'offender', '' );
50 $opts->fetchValuesFromRequest( $wgRequest );
52 $this->parseParams( $opts, (string)$par );
55 # Don't let the user get stuck with a certain date
56 if ( $opts->getValue( 'offset' ) ||
$opts->getValue( 'dir' ) == 'prev' ) {
57 $opts->setValue( 'year', '' );
58 $opts->setValue( 'month', '' );
61 # Handle type-specific inputs
63 if ( $opts->getValue( 'type' ) == 'suppress' ) {
64 $offender = User
::newFromName( $opts->getValue( 'offender' ), false );
65 if ( $offender && $offender->getId() > 0 ) {
66 $qc = array( 'ls_field' => 'target_author_id', 'ls_value' => $offender->getId() );
67 } elseif ( $offender && IP
::isIPAddress( $offender->getName() ) ) {
68 $qc = array( 'ls_field' => 'target_author_ip', 'ls_value' => $offender->getName() );
72 $this->show( $opts, $qc );
75 private function parseParams( FormOptions
$opts, $par ) {
79 $parms = explode( '/', ($par = ( $par !== null ) ?
$par : '' ) );
80 $symsForAll = array( '*', 'all' );
81 if ( $parms[0] != '' && ( in_array( $par, $wgLogTypes ) ||
in_array( $par, $symsForAll ) ) ) {
82 $opts->setValue( 'type', $par );
83 } elseif ( count( $parms ) == 2 ) {
84 $opts->setValue( 'type', $parms[0] );
85 $opts->setValue( 'user', $parms[1] );
86 } elseif ( $par != '' ) {
87 $opts->setValue( 'user', $par );
91 private function show( FormOptions
$opts, array $extraConds ) {
92 global $wgOut, $wgUser;
94 # Create a LogPager item to get the results and a LogEventsList item to format them...
95 $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 );
96 $pager = new LogPager( $loglist, $opts->getValue( 'type' ), $opts->getValue( 'user' ),
97 $opts->getValue( 'page' ), $opts->getValue( 'pattern' ), $extraConds, $opts->getValue( 'year' ),
98 $opts->getValue( 'month' ), $opts->getValue( 'tagfilter' ) );
100 # Set title and add header
101 $loglist->showHeader( $pager->getType() );
104 $loglist->showOptions( $pager->getType(), $pager->getUser(), $pager->getPage(), $pager->getPattern(),
105 $pager->getYear(), $pager->getMonth(), $pager->getFilterParams(), $opts->getValue( 'tagfilter' ) );
108 $logBody = $pager->getBody();
111 $pager->getNavigationBar() .
112 $loglist->beginLogEventsList() .
114 $loglist->endLogEventsList() .
115 $pager->getNavigationBar()
118 $wgOut->addWikiMsg( 'logempty' );