If you really must have a useless $wgUseRCPatrol option, might as well use it
[lhc/web/wiklou.git] / includes / SpecialNewpages.php
1 <?php
2
3 require_once( "QueryPage.php" );
4
5 class NewPagesPage extends QueryPage {
6
7 function getName() {
8 return "Newpages";
9 }
10
11 function isExpensive() {
12 # Indexed on RC, and will *not* work with querycache yet.
13 return false;
14 #return parent::isExpensive();
15 }
16
17 function getSQL() {
18 global $wgUser, $wgOnlySysopsCanPatrol, $wgUseRCPatrol;
19 $usepatrol = ( $wgUseRCPatrol && $wgUser->getID() != 0 &&
20 ( $wgUser->isSysop() || !$wgOnlySysopsCanPatrol ) ) ? 1 : 0;
21 $dbr =& wfGetDB( DB_SLAVE );
22 extract( $dbr->tableNames( 'recentchanges', 'cur' ) );
23
24 return
25 "SELECT 'Newpages' as type,
26 rc_namespace AS namespace,
27 rc_title AS title,
28 rc_cur_id AS value,
29 rc_user AS user,
30 rc_user_text AS user_text,
31 rc_comment as comment,
32 rc_timestamp AS timestamp,
33 '{$usepatrol}' as usepatrol,
34 rc_patrolled AS patrolled,
35 rc_id AS rcid,
36 length(cur_text) as length,
37 cur_text as text
38 FROM $recentchanges,$cur
39 WHERE rc_cur_id=cur_id AND rc_new=1
40 AND rc_namespace=0 AND cur_is_redirect=0";
41 }
42
43 function formatResult( $skin, $result ) {
44 global $wgLang, $wgUser, $wgOnlySysopsCanPatrol, $wgUseRCPatrol;
45 $u = $result->user;
46 $ut = $result->user_text;
47
48 $length = wfMsg( "nbytes", $wgLang->formatNum( $result->length ) );
49 $c = $skin->formatComment($result->comment );
50
51 if ( $u == 0 ) { # not by a logged-in user
52 $ul = $ut;
53 }
54 else {
55 $ul = $skin->makeLink( $wgLang->getNsText(NS_USER) . ":{$ut}", $ut );
56 }
57
58 $d = $wgLang->timeanddate( $result->timestamp, true );
59
60 # Since there is no diff link, we need to give users a way to
61 # mark the article as patrolled if it isn't already
62 if ( $wgUseRCPatrol && $result->usepatrol && $result->patrolled == 0 &&
63 $wgUser->getID() != 0 && ( $wgUser->isSysop() || !$wgOnlySysopsCanPatrol ) )
64 $link = $skin->makeKnownLink( $result->title, '', "rcid={$result->rcid}" );
65 else
66 $link = $skin->makeKnownLink( $result->title, '' );
67
68 $s = "{$d} {$link} ({$length}) . . {$ul}";
69
70 if ( "" != $c && "*" != $c ) {
71 $s .= " <em>({$c})</em>";
72 }
73
74 return $s;
75 }
76 }
77
78 function wfSpecialNewpages()
79 {
80 global $wgRequest;
81 list( $limit, $offset ) = wfCheckLimits();
82
83 $npp = new NewPagesPage();
84
85 if( !$npp->doFeed( $wgRequest->getVal( 'feed' ) ) ) {
86 $npp->doQuery( $offset, $limit );
87 }
88 }
89
90 ?>