Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -591,6 +591,7 @@ |
592 | 592 | 'SpecialImport' => 'includes/specials/SpecialImport.php', |
593 | 593 | 'SpecialListGroupRights' => 'includes/specials/SpecialListgrouprights.php', |
594 | 594 | 'SpecialLockdb' => 'includes/specials/SpecialLockdb.php', |
| 595 | + 'SpecialLog' => 'includes/specials/SpecialLog.php', |
595 | 596 | 'SpecialMergeHistory' => 'includes/specials/SpecialMergeHistory.php', |
596 | 597 | 'SpecialMostlinkedtemplates' => 'includes/specials/SpecialMostlinkedtemplates.php', |
597 | 598 | 'SpecialPreferences' => 'includes/specials/SpecialPreferences.php', |
Index: trunk/phase3/includes/specials/SpecialLog.php |
— | — | @@ -19,69 +19,103 @@ |
20 | 20 | */ |
21 | 21 | |
22 | 22 | /** |
23 | | - * @file |
| 23 | + * Implements Special:Log |
24 | 24 | * @ingroup SpecialPage |
25 | 25 | */ |
| 26 | +class SpecialLog extends SpecialPage { |
26 | 27 | |
27 | | -/** |
28 | | - * constructor |
29 | | - */ |
30 | | -function wfSpecialLog( $par = '' ) { |
31 | | - global $wgRequest, $wgOut, $wgUser, $wgLogTypes; |
| 28 | + public function __construct() { |
| 29 | + parent::__construct( 'Log' ); |
| 30 | + } |
32 | 31 | |
33 | | - # Get parameters |
34 | | - $parms = explode( '/', ($par = ( $par !== null ) ? $par : '' ) ); |
35 | | - $symsForAll = array( '*', 'all' ); |
36 | | - if ( $parms[0] != '' && ( in_array( $par, $wgLogTypes ) || in_array( $par, $symsForAll ) ) ) { |
37 | | - $type = $par; |
38 | | - $user = $wgRequest->getText( 'user' ); |
39 | | - } else if ( count( $parms ) == 2 ) { |
40 | | - $type = $parms[0]; |
41 | | - $user = $parms[1]; |
42 | | - } else { |
43 | | - $type = $wgRequest->getVal( 'type' ); |
44 | | - $user = ( $par != '' ) ? $par : $wgRequest->getText( 'user' ); |
| 32 | + public function execute( $par ) { |
| 33 | + global $wgRequest; |
| 34 | + |
| 35 | + $this->setHeaders(); |
| 36 | + $this->outputHeader(); |
| 37 | + |
| 38 | + $opts = new FormOptions; |
| 39 | + $opts->add( 'type', '' ); |
| 40 | + $opts->add( 'user', '' ); |
| 41 | + $opts->add( 'page', '' ); |
| 42 | + $opts->add( 'pattern', false ); |
| 43 | + $opts->add( 'year', null, FormOptions::INTNULL ); |
| 44 | + $opts->add( 'month', null, FormOptions::INTNULL ); |
| 45 | + $opts->add( 'tagfilter', '' ); |
| 46 | + $opts->add( 'offset', '' ); |
| 47 | + $opts->add( 'dir', '' ); |
| 48 | + $opts->add( 'offender', '' ); |
| 49 | + |
| 50 | + // Set values |
| 51 | + $opts->fetchValuesFromRequest( $wgRequest ); |
| 52 | + if ( $par ) { |
| 53 | + $this->parseParams( $opts, (string)$par ); |
| 54 | + } |
| 55 | + |
| 56 | + # Don't let the user get stuck with a certain date |
| 57 | + if ( $opts->getValue( 'offset' ) || $opts->getValue( 'dir' ) == 'prev' ) { |
| 58 | + $opts->setValue( 'year', '' ); |
| 59 | + $opts->setValue( 'month', '' ); |
| 60 | + } |
| 61 | + |
| 62 | + # Handle type-specific inputs |
| 63 | + $qc = array(); |
| 64 | + if ( $opts->getValue( 'type' ) == 'suppress' ) { |
| 65 | + $offender = User::newFromName( $opts->getValue( 'offender' ), false ); |
| 66 | + if ( $offender && $offender->getId() > 0 ) { |
| 67 | + $qc = array( 'ls_field' => 'target_author_id', 'ls_value' => $offender->getId() ); |
| 68 | + } elseif ( $offender && IP::isIPAddress( $offender->getName() ) ) { |
| 69 | + $qc = array( 'ls_field' => 'target_author_ip', 'ls_value' => $offender->getName() ); |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + $this->show( $opts, $qc ); |
45 | 74 | } |
46 | | - $title = $wgRequest->getText( 'page' ); |
47 | | - $pattern = $wgRequest->getBool( 'pattern' ); |
48 | | - $y = $wgRequest->getIntOrNull( 'year' ); |
49 | | - $m = $wgRequest->getIntOrNull( 'month' ); |
50 | | - $tagFilter = $wgRequest->getVal( 'tagfilter' ); |
51 | | - # Don't let the user get stuck with a certain date |
52 | | - $skip = $wgRequest->getText( 'offset' ) || $wgRequest->getText( 'dir' ) == 'prev'; |
53 | | - if( $skip ) { |
54 | | - $y = ''; |
55 | | - $m = ''; |
| 75 | + |
| 76 | + private function parseParams( FormOptions $opts, $par ) { |
| 77 | + global $wgLogTypes; |
| 78 | + |
| 79 | + # Get parameters |
| 80 | + $parms = explode( '/', ($par = ( $par !== null ) ? $par : '' ) ); |
| 81 | + $symsForAll = array( '*', 'all' ); |
| 82 | + if ( $parms[0] != '' && ( in_array( $par, $wgLogTypes ) || in_array( $par, $symsForAll ) ) ) { |
| 83 | + $opts->setValue( 'type', $par ); |
| 84 | + } elseif ( count( $parms ) == 2 ) { |
| 85 | + $opts->setValue( 'type', $parms[0] ); |
| 86 | + $opts->setValue( 'user', $parms[1] ); |
| 87 | + } elseif ( $par != '' ) { |
| 88 | + $opts->setValue( 'user', $par ); |
| 89 | + } |
56 | 90 | } |
57 | | - # Handle type-specific inputs |
58 | | - $qc = array(); |
59 | | - if( $type == 'suppress' ) { |
60 | | - $offender = User::newFromName( $wgRequest->getVal('offender'), false ); |
61 | | - if( $offender && $offender->getId() > 0 ) { |
62 | | - $qc = array( 'ls_field' => 'target_author_id', 'ls_value' => $offender->getId() ); |
63 | | - } else if( $offender && IP::isIPAddress( $offender->getName() ) ) { |
64 | | - $qc = array( 'ls_field' => 'target_author_ip', 'ls_value' => $offender->getName() ); |
| 91 | + |
| 92 | + private function show( FormOptions $opts, array $extraConds ) { |
| 93 | + global $wgOut, $wgUser; |
| 94 | + |
| 95 | + # Create a LogPager item to get the results and a LogEventsList item to format them... |
| 96 | + $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 ); |
| 97 | + $pager = new LogPager( $loglist, $opts->getValue( 'type' ), $opts->getValue( 'user' ), |
| 98 | + $opts->getValue( 'page' ), $opts->getValue( 'pattern' ), $extraConds, $opts->getValue( 'year' ), |
| 99 | + $opts->getValue( 'month' ), $opts->getValue( 'tagfilter' ) ); |
| 100 | + |
| 101 | + # Set title and add header |
| 102 | + $loglist->showHeader( $pager->getType() ); |
| 103 | + |
| 104 | + # Show form options |
| 105 | + $loglist->showOptions( $pager->getType(), $pager->getUser(), $pager->getPage(), $pager->getPattern(), |
| 106 | + $pager->getYear(), $pager->getMonth(), $pager->getFilterParams(), $opts->getValue( 'tagfilter' ) ); |
| 107 | + |
| 108 | + # Insert list |
| 109 | + $logBody = $pager->getBody(); |
| 110 | + if ( $logBody ) { |
| 111 | + $wgOut->addHTML( |
| 112 | + $pager->getNavigationBar() . |
| 113 | + $loglist->beginLogEventsList() . |
| 114 | + $logBody . |
| 115 | + $loglist->endLogEventsList() . |
| 116 | + $pager->getNavigationBar() |
| 117 | + ); |
| 118 | + } else { |
| 119 | + $wgOut->addWikiMsg( 'logempty' ); |
65 | 120 | } |
66 | 121 | } |
67 | | - # Create a LogPager item to get the results and a LogEventsList item to format them... |
68 | | - $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 ); |
69 | | - $pager = new LogPager( $loglist, $type, $user, $title, $pattern, $qc, $y, $m, $tagFilter ); |
70 | | - # Set title and add header |
71 | | - $loglist->showHeader( $pager->getType() ); |
72 | | - # Show form options |
73 | | - $loglist->showOptions( $pager->getType(), $pager->getUser(), $pager->getPage(), $pager->getPattern(), |
74 | | - $pager->getYear(), $pager->getMonth(), $pager->getFilterParams(), $tagFilter ); |
75 | | - # Insert list |
76 | | - $logBody = $pager->getBody(); |
77 | | - if( $logBody ) { |
78 | | - $wgOut->addHTML( |
79 | | - $pager->getNavigationBar() . |
80 | | - $loglist->beginLogEventsList() . |
81 | | - $logBody . |
82 | | - $loglist->endLogEventsList() . |
83 | | - $pager->getNavigationBar() |
84 | | - ); |
85 | | - } else { |
86 | | - $wgOut->addWikiMsg( 'logempty' ); |
87 | | - } |
88 | 122 | } |
Index: trunk/phase3/includes/SpecialPage.php |
— | — | @@ -134,7 +134,7 @@ |
135 | 135 | |
136 | 136 | # Recent changes and logs |
137 | 137 | 'Newimages' => array( 'IncludableSpecialPage', 'Newimages' ), |
138 | | - 'Log' => array( 'SpecialPage', 'Log' ), |
| 138 | + 'Log' => 'SpecialLog', |
139 | 139 | 'Watchlist' => array( 'SpecialPage', 'Watchlist' ), |
140 | 140 | 'Newpages' => 'SpecialNewpages', |
141 | 141 | 'Recentchanges' => 'SpecialRecentchanges', |