New feature: Recent Changes Patrol. All edits and new pages are now highlighted on
[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;
19 $usepatrol = ( $wgUser->getID() != 0 && ( $wgUser->isSysop() || !$wgOnlySysopsCanPatrol ) ) ? 1 : 0;
20 $dbr =& wfGetDB( DB_SLAVE );
21 extract( $dbr->tableNames( 'recentchanges', 'cur' ) );
22
23 return
24 "SELECT 'Newpages' as type,
25 rc_namespace AS namespace,
26 rc_title AS title,
27 rc_cur_id AS value,
28 rc_user AS user,
29 rc_user_text AS user_text,
30 rc_comment as comment,
31 rc_timestamp AS timestamp,
32 '{$usepatrol}' as usepatrol,
33 rc_patrolled AS patrolled,
34 rc_id AS rcid,
35 length(cur_text) as length,
36 cur_text as text
37 FROM $recentchanges,$cur
38 WHERE rc_cur_id=cur_id AND rc_new=1
39 AND rc_namespace=0 AND cur_is_redirect=0";
40 }
41
42 function formatResult( $skin, $result ) {
43 global $wgLang, $wgUser, $wgOnlySysopsCanPatrol;
44 $u = $result->user;
45 $ut = $result->user_text;
46
47 $length = wfMsg( "nbytes", $wgLang->formatNum( $result->length ) );
48 $c = $skin->formatComment($result->comment );
49
50 if ( 0 == $u ) { # not by a logged-in user
51 $ul = $ut;
52 }
53 else {
54 $ul = $skin->makeLink( $wgLang->getNsText(NS_USER) . ":{$ut}", $ut );
55 }
56
57 $d = $wgLang->timeanddate( $result->timestamp, true );
58
59 # If it's a new article, there is no diff link, but if it hasn't been
60 # patrolled yet, we need to give users a way to do so
61 if ( $result->usepatrol && $result->patrolled == 0 && $wgUser->getID() != 0 &&
62 ( $wgUser->isSysop() || !$wgOnlySysopsCanPatrol ) )
63 $link = $skin->makeKnownLink( $result->title, '', "rcid={$result->rcid}" );
64 else
65 $link = $skin->makeKnownLink( $result->title, '' );
66
67 $s = "{$d} {$link} ({$length}) . . {$ul}";
68
69 if ( "" != $c && "*" != $c ) {
70 $s .= " <em>({$c})</em>";
71 }
72
73 return $s;
74 }
75 }
76
77 function wfSpecialNewpages()
78 {
79 global $wgRequest;
80 list( $limit, $offset ) = wfCheckLimits();
81
82 $npp = new NewPagesPage();
83
84 if( !$npp->doFeed( $wgRequest->getVal( 'feed' ) ) ) {
85 $npp->doQuery( $offset, $limit );
86 }
87 }
88
89 ?>