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 preprocessResults( &$dbo, &$res ) {
62 # Do a batch existence check on the user and talk pages
63 $linkBatch = new LinkBatch();
64 while( $row = $dbo->fetchObject( $res ) ) {
65 $linkBatch->addObj( Title
::makeTitleSafe( NS_USER
, $row->user_text
) );
66 $linkBatch->addObj( Title
::makeTitleSafe( NS_USER_TALK
, $row->user_text
) );
68 $linkBatch->execute();
70 if( $dbo->numRows( $res ) > 0 )
71 $dbo->dataSeek( $res, 0 );
74 function formatResult( $skin, $result ) {
75 global $wgLang, $wgContLang, $wgUser, $wgUseRCPatrol;
77 $ut = $result->user_text
;
79 $length = wfMsgHtml( 'nbytes', htmlspecialchars( $wgLang->formatNum( $result->length
) ) );
80 $d = $wgLang->timeanddate( $result->timestamp
, true );
82 # Since there is no diff link, we need to give users a way to
83 # mark the article as patrolled if it isn't already
84 $ns = $wgContLang->getNsText( $result->namespace );
85 if( $wgUseRCPatrol && !is_null( $result->usepatrol
) && $result->usepatrol
&& $result->patrolled
== 0 && $wgUser->isAllowed( 'patrol' ) ) {
86 $link = $skin->makeKnownLink( $ns . ':' . $result->title
, '', "rcid={$result->rcid}" );
88 $link = $skin->makeKnownLink( $ns . ':' . $result->title
, '' );
91 $userTools = $skin->userLink( $u, $ut ) . $skin->userToolLinks( $u, $ut );
93 $s = "{$d} {$link} ({$length}) . . {$userTools}";
94 $s .= $skin->commentBlock( $result->comment
);
98 function feedItemDesc( $row ) {
99 if( isset( $row->rev_id
) ) {
100 $revision = Revision
::newFromId( $row->rev_id
);
102 return '<p>' . htmlspecialchars( wfMsg( 'summary' ) ) . ': ' .
103 htmlspecialchars( $revision->getComment() ) . "</p>\n<hr />\n<div>" .
104 nl2br( htmlspecialchars( $revision->getText() ) ) . "</div>";
107 return parent
::feedItemDesc( $row );
111 * Show a namespace selection form for filtering
115 function getPageHeader() {
116 $thisTitle = Title
::makeTitle( NS_SPECIAL
, $this->getName() );
117 $form = wfOpenElement( 'form', array(
119 'action' => $thisTitle->getLocalUrl() ) );
120 $form .= wfElement( 'label', array( 'for' => 'namespace' ),
121 wfMsg( 'namespace' ) ) . ' ';
122 $form .= HtmlNamespaceSelector( $this->namespace );
123 # Preserve the offset and limit
124 $form .= wfElement( 'input', array(
127 'value' => $this->offset
) );
128 $form .= wfElement( 'input', array(
131 'value' => $this->limit
) );
132 $form .= wfElement( 'input', array(
136 'value' => wfMsg( 'allpagessubmit' ) ) );
137 $form .= wfCloseElement( 'form' );
146 function linkParameters() {
147 return( array( 'namespace' => $this->namespace ) );
155 function wfSpecialNewpages($par, $specialPage) {
156 global $wgRequest, $wgContLang;
158 list( $limit, $offset ) = wfCheckLimits();
159 $namespace = NS_MAIN
;
162 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
163 foreach ( $bits as $bit ) {
164 if ( 'shownav' == $bit )
165 $shownavigation = true;
166 if ( is_numeric( $bit ) )
169 if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) )
170 $limit = intval($m[1]);
171 if ( preg_match( '/^offset=(\d+)$/', $bit, $m ) )
172 $offset = intval($m[1]);
173 if ( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) {
174 $ns = $wgContLang->getNsIndex( $m[1] );
175 if( $ns !== false ) {
181 if( $ns = $wgRequest->getInt( 'namespace', 0 ) )
185 if ( ! isset( $shownavigation ) )
186 $shownavigation = ! $specialPage->including();
188 $npp = new NewPagesPage( $namespace );
190 if ( ! $npp->doFeed( $wgRequest->getVal( 'feed' ), $limit ) )
191 $npp->doQuery( $offset, $limit, $shownavigation );