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