5 * @subpackage SpecialPage
11 require_once( 'QueryPage.php' );
16 * @subpackage SpecialPage
18 class NewPagesPage
extends QueryPage
{
21 function NewPagesPage( $namespace = NS_MAIN
) {
22 $this->namespace = $namespace;
29 function isExpensive() {
30 # Indexed on RC, and will *not* work with querycache yet.
35 global $wgUser, $wgUseRCPatrol;
36 $usepatrol = ( $wgUseRCPatrol && $wgUser->isAllowed( 'patrol' ) ) ?
1 : 0;
37 $dbr =& wfGetDB( DB_SLAVE
);
38 extract( $dbr->tableNames( 'recentchanges', 'page', 'text' ) );
40 # FIXME: text will break with compression
42 "SELECT 'Newpages' as type,
43 rc_namespace AS namespace,
47 rc_user_text AS user_text,
48 rc_comment as comment,
49 rc_timestamp AS timestamp,
50 rc_timestamp AS value,
51 '{$usepatrol}' as usepatrol,
52 rc_patrolled AS patrolled,
56 FROM $recentchanges,$page
57 WHERE rc_cur_id=page_id AND rc_new=1
58 AND rc_namespace=" . $this->namespace . " AND page_is_redirect=0";
61 function formatResult( $skin, $result ) {
62 global $wgLang, $wgContLang, $wgUser, $wgUseRCPatrol;
64 $ut = $result->user_text
;
66 $length = wfMsg( 'nbytes', $wgLang->formatNum( $result->length
) );
68 if ( $u == 0 ) { # not by a logged-in user
69 $userPage = Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
70 $linkParams = 'target=' . urlencode( $ut );
72 $userPage = Title
::makeTitle( NS_USER
, $ut );
75 $ul = $skin->makeLinkObj( $userPage, htmlspecialchars( $ut ), $linkParams );
77 $d = $wgLang->timeanddate( $result->timestamp
, true );
79 # Since there is no diff link, we need to give users a way to
80 # mark the article as patrolled if it isn't already
81 $ns = $wgContLang->getNsText( $result->namespace );
82 if( $wgUseRCPatrol && !is_null( $result->usepatrol
) && $result->usepatrol
&& $result->patrolled
== 0 && $wgUser->isAllowed( 'patrol' ) ) {
83 $link = $skin->makeKnownLink( $ns . ':' . $result->title
, '', "rcid={$result->rcid}" );
85 $link = $skin->makeKnownLink( $ns . ':' . $result->title
, '' );
88 $s = "{$d} {$link} ({$length}) . . {$ul}";
89 $s .= $skin->commentBlock( $result->comment
);
93 function feedItemDesc( $row ) {
94 if( isset( $row->rev_id
) ) {
95 $revision = Revision
::newFromId( $row->rev_id
);
97 return '<p>' . htmlspecialchars( wfMsg( 'summary' ) ) . ': ' . $text . "</p>\n<hr />\n<div>" .
98 nl2br( htmlspecialchars( $revision->getText() ) ) . "</div>";
101 return parent
::feedItemDesc( $row );
108 function wfSpecialNewpages($par, $specialPage) {
109 global $wgRequest, $wgContLang;
111 list( $limit, $offset ) = wfCheckLimits();
112 $namespace = NS_MAIN
;
115 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
116 foreach ( $bits as $bit ) {
117 if ( 'shownav' == $bit )
118 $shownavigation = true;
119 if ( is_numeric( $bit ) )
122 if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) )
123 $limit = intval($m[1]);
124 if ( preg_match( '/^offset=(\d+)$/', $bit, $m ) )
125 $offset = intval($m[1]);
126 if ( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) {
127 $ns = $wgContLang->getNsIndex( $m[1] );
128 if( $ns !== false ) {
134 if ( ! isset( $shownavigation ) )
135 $shownavigation = ! $specialPage->including();
137 $npp = new NewPagesPage( $namespace );
139 if ( ! $npp->doFeed( $wgRequest->getVal( 'feed' ) ) )
140 $npp->doQuery( $offset, $limit, $shownavigation );