5 * @subpackage SpecialPage
11 * @subpackage SpecialPage
13 class NewPagesPage
extends QueryPage
{
16 function NewPagesPage( $namespace = NS_MAIN
) {
17 $this->namespace = $namespace;
24 function isExpensive() {
25 # Indexed on RC, and will *not* work with querycache yet.
30 global $wgUser, $wgUseRCPatrol;
31 $usepatrol = ( $wgUseRCPatrol && $wgUser->isAllowed( 'patrol' ) ) ?
1 : 0;
32 $dbr =& wfGetDB( DB_SLAVE
);
33 extract( $dbr->tableNames( 'recentchanges', 'page', 'text' ) );
35 # FIXME: text will break with compression
37 "SELECT 'Newpages' as type,
38 rc_namespace AS namespace,
42 rc_user_text AS user_text,
43 rc_comment as comment,
44 rc_timestamp AS timestamp,
45 rc_timestamp AS value,
46 '{$usepatrol}' as usepatrol,
47 rc_patrolled AS patrolled,
51 FROM $recentchanges,$page
52 WHERE rc_cur_id=page_id AND rc_new=1
53 AND rc_namespace=" . $this->namespace . " AND page_is_redirect=0";
56 function preprocessResults( &$dbo, &$res ) {
57 # Do a batch existence check on the user and talk pages
58 $linkBatch = new LinkBatch();
59 while( $row = $dbo->fetchObject( $res ) ) {
60 $linkBatch->addObj( Title
::makeTitleSafe( NS_USER
, $row->user_text
) );
61 $linkBatch->addObj( Title
::makeTitleSafe( NS_USER_TALK
, $row->user_text
) );
63 $linkBatch->execute();
65 if( $dbo->numRows( $res ) > 0 )
66 $dbo->dataSeek( $res, 0 );
69 function formatResult( $skin, $result ) {
70 global $wgLang, $wgContLang, $wgUser, $wgUseRCPatrol;
72 $ut = $result->user_text
;
73 $dirmark = $wgContLang->getDirMark(); // To keep text in correct order
75 $length = wfMsgExt( 'nbytes', array('parsemag', 'escape'),
76 $wgLang->formatNum( $result->length
) );
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 $userLink = $skin->userLink( $u, $ut );
89 $userTools = $skin->userToolLinks( $u, $ut );
91 $s = "{$d} {$dirmark}{$link} {$dirmark}({$length}) . . " .
92 "{$dirmark}{$userLink}{$dirmark}{$userTools}";
93 $s .= $dirmark . $skin->commentBlock( $result->comment
);
97 function feedItemDesc( $row ) {
98 if( isset( $row->rev_id
) ) {
99 $revision = Revision
::newFromId( $row->rev_id
);
101 return '<p>' . htmlspecialchars( wfMsg( 'summary' ) ) . ': ' .
102 htmlspecialchars( $revision->getComment() ) . "</p>\n<hr />\n<div>" .
103 nl2br( htmlspecialchars( $revision->getText() ) ) . "</div>";
106 return parent
::feedItemDesc( $row );
110 * Show a namespace selection form for filtering
114 function getPageHeader() {
115 $thisTitle = Title
::makeTitle( NS_SPECIAL
, $this->getName() );
116 $form = wfOpenElement( 'form', array(
118 'action' => $thisTitle->getLocalUrl() ) );
119 $form .= wfElement( 'label', array( 'for' => 'namespace' ),
120 wfMsg( 'namespace' ) ) . ' ';
121 $form .= HtmlNamespaceSelector( $this->namespace );
122 # Preserve the offset and limit
123 $form .= wfElement( 'input', array(
126 'value' => $this->offset
) );
127 $form .= wfElement( 'input', array(
130 'value' => $this->limit
) );
131 $form .= wfElement( 'input', array(
135 'value' => wfMsg( 'allpagessubmit' ) ) );
136 $form .= wfCloseElement( 'form' );
145 function linkParameters() {
146 return( array( 'namespace' => $this->namespace ) );
154 function wfSpecialNewpages($par, $specialPage) {
155 global $wgRequest, $wgContLang;
157 list( $limit, $offset ) = wfCheckLimits();
158 $namespace = NS_MAIN
;
161 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
162 foreach ( $bits as $bit ) {
163 if ( 'shownav' == $bit )
164 $shownavigation = true;
165 if ( is_numeric( $bit ) )
168 if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) )
169 $limit = intval($m[1]);
170 if ( preg_match( '/^offset=(\d+)$/', $bit, $m ) )
171 $offset = intval($m[1]);
172 if ( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) {
173 $ns = $wgContLang->getNsIndex( $m[1] );
174 if( $ns !== false ) {
180 if( $ns = $wgRequest->getInt( 'namespace', 0 ) )
184 if ( ! isset( $shownavigation ) )
185 $shownavigation = ! $specialPage->including();
187 $npp = new NewPagesPage( $namespace );
189 if ( ! $npp->doFeed( $wgRequest->getVal( 'feed' ), $limit ) )
190 $npp->doQuery( $offset, $limit, $shownavigation );