Index: SpecialNewpages.php =================================================================== --- SpecialNewpages.php (revision 26372) +++ SpecialNewpages.php (working copy) @@ -12,10 +12,18 @@ var $namespace; var $username = ''; + var $hidebots = false; + var $hidemine = false; + var $hidepatrolled = false; + var $hideregistered = false; - function NewPagesPage( $namespace = NS_MAIN, $username = '' ) { + function NewPagesPage( $namespace = NS_MAIN, $username = '', $hidebots = false, $hidemine = false, $hidepatrolled = false, $hideregistered = false ) { $this->namespace = $namespace; $this->username = $username; + $this->hidebots = $hidebots; + $this->hidemine = $hidemine; + $this->hidepatrolled = $hidepatrolled; + $this->hideregistered = $hideregistered; } function getName() { @@ -41,6 +49,35 @@ ? ' AND rc_namespace = ' . intval( $this->namespace ) : ''; } + + private function makeHidebotsWhere() { + return $this->hidebots + ? ' AND rc_bot = 0' + : ''; + } + + private function makeHidemineWhere( &$dbo ) { + if (!$this->hidemine) return ''; + global $wgUser; + $uid = $wgUser->getID(); + if( $uid ) + return 'AND rc_user <> ' . $uid; + else + return 'AND rc_user_text <> ' . $dbo->addQuotes( $wgUser->getName() ); + } + + private function makeHidepatrolledWhere() { + global $wgUseRCPatrol; + return $this->hidepatrolled && $wgUseRCPatrol + ? ' AND rc_patrolled = 0' + : ''; + } + + private function makeHideregisteredWhere() { + return $this->hideregistered + ? ' AND rc_user = 0' + : ''; + } function getSQL() { global $wgUser, $wgUseRCPatrol; @@ -50,6 +87,10 @@ $nsfilter = $this->makeNamespaceWhere(); $uwhere = $this->makeUserWhere( $dbr ); + $hidebots = $this->makeHidebotsWhere(); + $hidemine = $this->makeHidemineWhere( $dbr ); + $hidepatrolled = $this->makeHidepatrolledWhere(); + $hideregistered = $this->makeHideregisteredWhere(); # FIXME: text will break with compression return @@ -71,7 +112,8 @@ WHERE rc_cur_id=page_id AND rc_new=1 {$nsfilter} AND page_is_redirect = 0 - {$uwhere}"; + {$uwhere} {$hidebots} {$hidemine} + {$hidepatrolled} {$hideregistered}"; } function preprocessResults( &$dbo, &$res ) { @@ -138,7 +180,7 @@ * @return string */ function getPageHeader() { - global $wgScript, $wgContLang; + global $wgScript, $wgContLang, $wgUseRCPatrol; $align = $wgContLang->isRTL() ? 'left' : 'right'; $self = SpecialPage::getTitleFor( $this->getName() ); $form = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) . @@ -162,6 +204,35 @@ + + " . + Xml::check( 'hidebots', $this->hidebots ) . + Xml::label( wfMsgHtml( 'rcshowhidebots', wfMsg('hide') ), 'hidebots' ) . + "  " . + Xml::check( 'hidemine', $this->hidemine ) . + Xml::label( wfMsgHtml( 'rcshowhidemine', wfMsg('hide') ), 'hidemine' ) . + + " + + + + + + "; + if ( $wgUseRCPatrol ) { + $form .= Xml::check( 'hidepatrolled', $this->hidepatrolled ) . + Xml::label( wfMsgHtml( 'rcshowhidepatr', wfMsg('hide') ), 'hidepatrolled' ) . + "  "; + } + $form .= + Xml::check( 'hideregistered', $this->hideregistered ) . + Xml::label( wfMsgHtml( 'rcshowhideliu', wfMsg('hide') ), 'hideregistered' ) . + + " + + + + " . Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . " @@ -179,7 +250,8 @@ * @return array */ function linkParameters() { - return( array( 'namespace' => $this->namespace, 'username' => $this->username ) ); + return( array( 'namespace' => $this->namespace, 'username' => $this->username, 'hidebots' => $this->hidebots, 'hidemine' => $this->hidemine, + 'hidepatrolled' => $this->hidepatrolled, 'hideregistered' => $this->hideregistered ) ); } } @@ -188,11 +260,15 @@ * constructor */ function wfSpecialNewpages($par, $specialPage) { - global $wgRequest, $wgContLang; + global $wgRequest, $wgContLang, $wgUseRCPatrol; list( $limit, $offset ) = wfCheckLimits(); $namespace = NS_MAIN; $username = ''; + $hidebots = false; + $hidemine = false; + $hidepatrolled = false; + $hideregistered = false; if ( $par ) { $bits = preg_split( '/\s*,\s*/', trim( $par ) ); @@ -213,18 +289,29 @@ $namespace = $ns; } } + if ( preg_match( '/^hide(bots|mine|patrolled|registered)$/', $bit, $m ) ) { + eval( '$hide' . $m[1] . ' = true;' ); + } } } else { if( $ns = $wgRequest->getText( 'namespace', NS_MAIN ) ) $namespace = $ns; if( $un = $wgRequest->getText( 'username' ) ) $username = $un; + if( $hb = $wgRequest->getBool( 'hidebots' ) ) + $hidebots = $hb; + if( $hm = $wgRequest->getBool( 'hidemine' ) ) + $hidemine = $hm; + if( $hp = $wgRequest->getBool( 'hidepatrolled' ) && $wgUseRCPatrol) + $hidepatrolled = $hp; + if( $hr = $wgRequest->getBool( 'hideregistered' ) ) + $hideregistered = $hr; } if ( ! isset( $shownavigation ) ) $shownavigation = ! $specialPage->including(); - $npp = new NewPagesPage( $namespace, $username ); + $npp = new NewPagesPage( $namespace, $username, $hidebots, $hidemine, $hidepatrolled, $hideregistered ); if ( ! $npp->doFeed( $wgRequest->getVal( 'feed' ), $limit ) ) $npp->doQuery( $offset, $limit, $shownavigation );