]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - includes/specials/SpecialLog.php
MediaWiki 1.14.0
[autoinstalls/mediawiki.git] / includes / specials / SpecialLog.php
1 <?php
2 # Copyright (C) 2008 Aaron Schulz
3 # http://www.mediawiki.org/
4 #
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.
9 #
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.
14 #
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
19
20 /**
21  * @file
22  * @ingroup SpecialPage
23  */
24
25 /**
26  * constructor
27  */
28 function wfSpecialLog( $par = '' ) {
29         global $wgRequest, $wgOut, $wgUser, $wgLogTypes;
30
31         # Get parameters
32         $parms = explode( '/', ($par = ( $par !== null ) ? $par : '' ) );
33         $symsForAll = array( '*', 'all' );
34         if ( $parms[0] != '' && ( in_array( $par, $wgLogTypes ) || in_array( $par, $symsForAll ) ) ) {
35                 $type = $par;
36                 $user = $wgRequest->getText( 'user' );
37         } else if ( count( $parms ) == 2 ) {
38                 $type = $parms[0];
39                 $user = $parms[1];
40         } else {
41                 $type = $wgRequest->getVal( 'type' );
42                 $user = ( $par != '' ) ? $par : $wgRequest->getText( 'user' );
43         }
44         $title = $wgRequest->getText( 'page' );
45         $pattern = $wgRequest->getBool( 'pattern' );
46         $y = $wgRequest->getIntOrNull( 'year' );
47         $m = $wgRequest->getIntOrNull( 'month' );
48         # Don't let the user get stuck with a certain date
49         $skip = $wgRequest->getText( 'offset' ) || $wgRequest->getText( 'dir' ) == 'prev';
50         if( $skip ) {
51                 $y = '';
52                 $m = '';
53         }
54         # Create a LogPager item to get the results and a LogEventsList item to format them...
55         $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 );
56         $pager = new LogPager( $loglist, $type, $user, $title, $pattern, array(), $y, $m );
57         # Set title and add header
58         $loglist->showHeader( $pager->getType() );
59         # Show form options
60         $loglist->showOptions( $pager->getType(), $pager->getUser(), $pager->getPage(), $pager->getPattern(),
61                 $pager->getYear(), $pager->getMonth(), $pager->getFilterParams() );
62         # Insert list
63         $logBody = $pager->getBody();
64         if( $logBody ) {
65                 $wgOut->addHTML(
66                         $pager->getNavigationBar() .
67                         $loglist->beginLogEventsList() .
68                         $logBody .
69                         $loglist->endLogEventsList() .
70                         $pager->getNavigationBar()
71                 );
72         } else {
73                 $wgOut->addWikiMsg( 'logempty' );
74         }
75 }