5 * @subpackage SpecialPage
11 require_once( 'QueryPage.php' );
16 * @subpackage SpecialPage
18 class NewPagesPage
extends QueryPage
{
22 function NewPagesPage( $namespace = NS_MAIN
) {
23 $this->namespace = $namespace;
30 function isExpensive() {
31 # Indexed on RC, and will *not* work with querycache yet.
36 global $wgUser, $wgUseRCPatrol;
37 $usepatrol = ( $wgUseRCPatrol && $wgUser->isAllowed( 'patrol' ) ) ?
1 : 0;
38 $dbr =& wfGetDB( DB_SLAVE
);
39 extract( $dbr->tableNames( 'recentchanges', 'page', 'text' ) );
41 # FIXME: text will break with compression
43 "SELECT 'Newpages' as type,
44 rc_namespace AS namespace,
48 rc_user_text AS user_text,
49 rc_comment as comment,
50 rc_timestamp AS timestamp,
51 rc_timestamp AS value,
52 '{$usepatrol}' as usepatrol,
53 rc_patrolled AS patrolled,
57 FROM $recentchanges,$page
58 WHERE rc_cur_id=page_id AND rc_new=1
59 AND rc_namespace=" . $this->namespace . " AND page_is_redirect=0";
62 function preprocessResults( &$dbo, &$res ) {
63 # Do a batch existence check on the user and talk pages
64 $linkBatch = new LinkBatch();
65 while( $row = $dbo->fetchObject( $res ) ) {
66 $linkBatch->addObj( Title
::makeTitleSafe( NS_USER
, $row->user_text
) );
67 $linkBatch->addObj( Title
::makeTitleSafe( NS_USER_TALK
, $row->user_text
) );
69 $linkBatch->execute();
71 if( $dbo->numRows( $res ) > 0 )
72 $dbo->dataSeek( $res, 0 );
75 function formatResult( $skin, $result ) {
76 global $wgLang, $wgContLang, $wgUser, $wgUseRCPatrol;
78 $ut = $result->user_text
;
79 $dirmark = $wgContLang->getDirMark(); // To keep text in correct order
81 $length = wfMsgExt( 'nbytes', array('parsemag', 'escape'),
82 $wgLang->formatNum( $result->length
) );
83 $d = $wgLang->timeanddate( $result->timestamp
, true );
85 # Since there is no diff link, we need to give users a way to
86 # mark the article as patrolled if it isn't already
87 $ns = $wgContLang->getNsText( $result->namespace );
88 if( $wgUseRCPatrol && !is_null( $result->usepatrol
) && $result->usepatrol
&& $result->patrolled
== 0 && $wgUser->isAllowed( 'patrol' ) ) {
89 $link = $skin->makeKnownLink( $ns . ':' . $result->title
, '', "rcid={$result->rcid}" );
91 $link = $skin->makeKnownLink( $ns . ':' . $result->title
, '' );
94 $userLink = $skin->userLink( $u, $ut );
95 $userTools = $skin->userToolLinks( $u, $ut );
97 $s = "{$d} {$dirmark}{$link} {$dirmark}({$length}) . . " .
98 "{$dirmark}{$userLink}{$dirmark}{$userTools}";
99 $s .= $dirmark . $skin->commentBlock( $result->comment
);
103 function feedItemDesc( $row ) {
104 if( isset( $row->rev_id
) ) {
105 $revision = Revision
::newFromId( $row->rev_id
);
107 return '<p>' . htmlspecialchars( wfMsg( 'summary' ) ) . ': ' .
108 htmlspecialchars( $revision->getComment() ) . "</p>\n<hr />\n<div>" .
109 nl2br( htmlspecialchars( $revision->getText() ) ) . "</div>";
112 return parent
::feedItemDesc( $row );
116 * Show a namespace selection form for filtering
120 function getPageHeader() {
121 $thisTitle = Title
::makeTitle( NS_SPECIAL
, $this->getName() );
122 $form = wfOpenElement( 'form', array(
124 'action' => $thisTitle->getLocalUrl() ) );
125 $form .= wfElement( 'label', array( 'for' => 'namespace' ),
126 wfMsg( 'namespace' ) ) . ' ';
127 $form .= HtmlNamespaceSelector( $this->namespace );
128 # Preserve the offset and limit
129 $form .= wfElement( 'input', array(
132 'value' => $this->offset
) );
133 $form .= wfElement( 'input', array(
136 'value' => $this->limit
) );
137 $form .= wfElement( 'input', array(
141 'value' => wfMsg( 'allpagessubmit' ) ) );
142 $form .= wfCloseElement( 'form' );
151 function linkParameters() {
152 return( array( 'namespace' => $this->namespace ) );
160 function wfSpecialNewpages($par, $specialPage) {
161 global $wgRequest, $wgContLang;
163 list( $limit, $offset ) = wfCheckLimits();
164 $namespace = NS_MAIN
;
167 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
168 foreach ( $bits as $bit ) {
169 if ( 'shownav' == $bit )
170 $shownavigation = true;
171 if ( is_numeric( $bit ) )
174 if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) )
175 $limit = intval($m[1]);
176 if ( preg_match( '/^offset=(\d+)$/', $bit, $m ) )
177 $offset = intval($m[1]);
178 if ( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) {
179 $ns = $wgContLang->getNsIndex( $m[1] );
180 if( $ns !== false ) {
186 if( $ns = $wgRequest->getInt( 'namespace', 0 ) )
190 if ( ! isset( $shownavigation ) )
191 $shownavigation = ! $specialPage->including();
193 $npp = new NewPagesPage( $namespace );
195 if ( ! $npp->doFeed( $wgRequest->getVal( 'feed' ), $limit ) )
196 $npp->doQuery( $offset, $limit, $shownavigation );