Re-establishing validation feature (the beginnings)
[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->isLoggedIn() &&
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
65 if ( $u == 0 ) { # not by a logged-in user
66 $ul = $ut;
67 }
68 else {
69 $ul = $skin->makeLink( $wgContLang->getNsText(NS_USER) . ":{$ut}", $ut );
70 }
71
72 $d = $wgLang->timeanddate( $result->timestamp, true );
73
74 # Since there is no diff link, we need to give users a way to
75 # mark the article as patrolled if it isn't already
76 if ( $wgUseRCPatrol && !is_null ( $result->usepatrol ) && $result->usepatrol &&
77 $result->patrolled == 0 && $wgUser->isLoggedIn() &&
78 ( $wgUser->isAllowed('patrol') || !$wgOnlySysopsCanPatrol ) )
79 $link = $skin->makeKnownLink( $result->title, '', "rcid={$result->rcid}" );
80 else
81 $link = $skin->makeKnownLink( $result->title, '' );
82
83 $s = "{$d} {$link} ({$length}) . . {$ul}";
84
85 $s .= $skin->commentBlock( $result->comment );
86
87 return $s;
88 }
89 }
90
91 /**
92 * constructor
93 */
94 function wfSpecialNewpages()
95 {
96 global $wgRequest;
97 list( $limit, $offset ) = wfCheckLimits();
98
99 $npp = new NewPagesPage();
100
101 if( !$npp->doFeed( $wgRequest->getVal( 'feed' ) ) ) {
102 $npp->doQuery( $offset, $limit );
103 }
104 }
105
106 ?>