In QueryPage: fixing a misleading comment. value needn't be numeric.
[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 && !is_null ( $result->usepatrol ) && $result->usepatrol &&
63 $result->patrolled == 0 && $wgUser->getID() != 0 &&
64 ( $wgUser->isSysop() || !$wgOnlySysopsCanPatrol ) )
65 $link = $skin->makeKnownLink( $result->title, '', "rcid={$result->rcid}" );
66 else
67 $link = $skin->makeKnownLink( $result->title, '' );
68
69 $s = "{$d} {$link} ({$length}) . . {$ul}";
70
71 if ( "" != $c && "*" != $c ) {
72 $s .= " <em>({$c})</em>";
73 }
74
75 return $s;
76 }
77 }
78
79 function wfSpecialNewpages()
80 {
81 global $wgRequest;
82 list( $limit, $offset ) = wfCheckLimits();
83
84 $npp = new NewPagesPage();
85
86 if( !$npp->doFeed( $wgRequest->getVal( 'feed' ) ) ) {
87 $npp->doQuery( $offset, $limit );
88 }
89 }
90
91 ?>