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