5 * @subpackage SpecialPage
11 require_once( "QueryPage.php" );
16 * @subpackage SpecialPage
18 class NewPagesPage
extends QueryPage
{
24 function isExpensive() {
25 # Indexed on RC, and will *not* work with querycache yet.
27 #return parent::isExpensive();
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' ) );
37 # FIXME: text will break with compression
39 "SELECT 'Newpages' as type,
40 rc_namespace AS namespace,
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,
52 FROM $recentchanges,$page
53 WHERE rc_cur_id=page_id AND rc_new=1
54 AND rc_namespace=".NS_MAIN
." AND page_is_redirect=0";
57 function formatResult( $skin, $result ) {
58 global $wgLang, $wgContLang, $wgUser, $wgOnlySysopsCanPatrol, $wgUseRCPatrol;
60 $ut = $result->user_text
;
62 $length = wfMsg( "nbytes", $wgLang->formatNum( $result->length
) );
64 if ( $u == 0 ) { # not by a logged-in user
68 $ul = $skin->makeLink( $wgContLang->getNsText(NS_USER
) . ":{$ut}", $ut );
71 $d = $wgLang->timeanddate( $result->timestamp
, true );
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->isLoggedIn() &&
77 ( $wgUser->isAllowed('patrol') ||
!$wgOnlySysopsCanPatrol ) )
78 $link = $skin->makeKnownLink( $result->title
, '', "rcid={$result->rcid}" );
80 $link = $skin->makeKnownLink( $result->title
, '' );
82 $s = "{$d} {$link} ({$length}) . . {$ul}";
84 $s .= $skin->commentBlock( $result->comment
);
89 function feedItemDesc( $row ) {
90 if( isset( $row->rev_id
) ) {
91 $revision = Revision
::newFromId( $row->rev_id
);
93 return '<p>' . htmlspecialchars( wfMsg( 'summary' ) ) . ': ' . $text . "</p>\n<hr />\n<div>" .
94 nl2br( htmlspecialchars( $revision->getText() ) ) . "</div>";
97 return parent
::feedItemDesc( $row );
104 function wfSpecialNewpages($par, $specialPage)
107 list( $limit, $offset ) = wfCheckLimits();
109 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
110 foreach ( $bits as $bit ) {
111 if ( 'shownav' == $bit ) $shownavigation = 1;
112 if ( is_numeric( $bit ) ) {
116 if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
117 $limit = intval($m[1]);
119 if ( preg_match( '/^offset=(\d+)$/', $bit, $m ) ) {
120 $offset = intval($m[1]);
124 if(!isset($shownavigation)) {
125 $shownavigation=!$specialPage->including();
128 $npp = new NewPagesPage();
130 if( !$npp->doFeed( $wgRequest->getVal( 'feed' ) ) ) {
131 $npp->doQuery( $offset, $limit, $shownavigation );