Verify known image types on upload.
[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->isSysop() || !$wgOnlySysopsCanPatrol ) ) ? 1 : 0;
34 $dbr =& wfGetDB( DB_SLAVE );
35 extract( $dbr->tableNames( 'recentchanges', 'cur' ) );
36
37 return
38 "SELECT 'Newpages' as type,
39 rc_namespace AS namespace,
40 rc_title AS title,
41 rc_cur_id AS value,
42 rc_user AS user,
43 rc_user_text AS user_text,
44 rc_comment as comment,
45 rc_timestamp AS timestamp,
46 '{$usepatrol}' as usepatrol,
47 rc_patrolled AS patrolled,
48 rc_id AS rcid,
49 length(cur_text) as length,
50 cur_text as text
51 FROM $recentchanges,$cur
52 WHERE rc_cur_id=cur_id AND rc_new=1
53 AND rc_namespace=0 AND cur_is_redirect=0";
54 }
55
56 function formatResult( $skin, $result ) {
57 global $wgLang, $wgUser, $wgOnlySysopsCanPatrol, $wgUseRCPatrol;
58 $u = $result->user;
59 $ut = $result->user_text;
60
61 $length = wfMsg( "nbytes", $wgLang->formatNum( $result->length ) );
62 $c = $skin->formatComment($result->comment );
63
64 if ( $u == 0 ) { # not by a logged-in user
65 $ul = $ut;
66 }
67 else {
68 $ul = $skin->makeLink( $wgLang->getNsText(NS_USER) . ":{$ut}", $ut );
69 }
70
71 $d = $wgLang->timeanddate( $result->timestamp, true );
72
73 # Since there is no diff link, we need to give users a way to
74 # mark the article as patrolled if it isn't already
75 if ( $wgUseRCPatrol && !is_null ( $result->usepatrol ) && $result->usepatrol &&
76 $result->patrolled == 0 && $wgUser->getID() != 0 &&
77 ( $wgUser->isSysop() || !$wgOnlySysopsCanPatrol ) )
78 $link = $skin->makeKnownLink( $result->title, '', "rcid={$result->rcid}" );
79 else
80 $link = $skin->makeKnownLink( $result->title, '' );
81
82 $s = "{$d} {$link} ({$length}) . . {$ul}";
83
84 if ( "" != $c && "*" != $c ) {
85 $s .= " <em>({$c})</em>";
86 }
87
88 return $s;
89 }
90 }
91
92 /**
93 * constructor
94 */
95 function wfSpecialNewpages()
96 {
97 global $wgRequest;
98 list( $limit, $offset ) = wfCheckLimits();
99
100 $npp = new NewPagesPage();
101
102 if( !$npp->doFeed( $wgRequest->getVal( 'feed' ) ) ) {
103 $npp->doQuery( $offset, $limit );
104 }
105 }
106
107 ?>