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 $userLink = $skin->makeLinkObj( Title
::makeTitle( NS_USER
, $ut ), htmlspecialchars( $ut ) );
69 $talkLink = $skin->makeLinkObj( Title
::makeTitle( NS_USER_TALK
, $ut ), $wgLang->getNsText( NS_TALK
) );
70 $contLink = $skin->makeLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Contributions' ), wfMsg( 'contribslink' ), 'target=' . urlencode( $ut ) );
71 $userTools = "$userLink ($talkLink | $contLink)";
73 $d = $wgLang->timeanddate( $result->timestamp
, true );
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 $ns = $wgContLang->getNsText( $result->namespace );
78 if( $wgUseRCPatrol && !is_null( $result->usepatrol
) && $result->usepatrol
&& $result->patrolled
== 0 && $wgUser->isAllowed( 'patrol' ) ) {
79 $link = $skin->makeKnownLink( $ns . ':' . $result->title
, '', "rcid={$result->rcid}" );
81 $link = $skin->makeKnownLink( $ns . ':' . $result->title
, '' );
84 $s = "{$d} {$link} ({$length}) . . {$userTools}";
85 $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) {
105 global $wgRequest, $wgContLang;
107 list( $limit, $offset ) = wfCheckLimits();
108 $namespace = NS_MAIN
;
111 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
112 foreach ( $bits as $bit ) {
113 if ( 'shownav' == $bit )
114 $shownavigation = true;
115 if ( is_numeric( $bit ) )
118 if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) )
119 $limit = intval($m[1]);
120 if ( preg_match( '/^offset=(\d+)$/', $bit, $m ) )
121 $offset = intval($m[1]);
122 if ( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) {
123 $ns = $wgContLang->getNsIndex( $m[1] );
124 if( $ns !== false ) {
130 if ( ! isset( $shownavigation ) )
131 $shownavigation = ! $specialPage->including();
133 $npp = new NewPagesPage( $namespace );
135 if ( ! $npp->doFeed( $wgRequest->getVal( 'feed' ) ) )
136 $npp->doQuery( $offset, $limit, $shownavigation );