2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2010-06-21 12:59:04 +00:00
|
|
|
/**
|
2010-08-15 07:16:58 +00:00
|
|
|
* Implements Special:Newpages
|
2010-06-21 12:59:04 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
2010-06-21 13:16:32 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2010-06-21 12:59:04 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-08-15 07:16:58 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
* @ingroup SpecialPage
|
2010-06-21 12:59:04 +00:00
|
|
|
*/
|
2007-12-15 20:22:16 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2010-08-15 07:16:58 +00:00
|
|
|
* A special page that list newly created pages
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup SpecialPage
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2010-07-17 19:04:07 +00:00
|
|
|
class SpecialNewpages extends IncludableSpecialPage {
|
2008-05-11 21:43:16 +00:00
|
|
|
|
|
|
|
|
// Stored objects
|
2011-02-21 17:03:18 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var FormOptions
|
|
|
|
|
*/
|
|
|
|
|
protected $opts;
|
2011-05-23 04:28:58 +00:00
|
|
|
protected $customFilters;
|
2011-02-21 17:03:18 +00:00
|
|
|
|
2008-05-11 21:43:16 +00:00
|
|
|
// Some internal settings
|
|
|
|
|
protected $showNavigation = false;
|
|
|
|
|
|
2008-10-17 01:31:12 +00:00
|
|
|
public function __construct() {
|
2008-06-18 20:45:10 +00:00
|
|
|
parent::__construct( 'Newpages' );
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-11 21:43:16 +00:00
|
|
|
protected function setup( $par ) {
|
2011-04-03 05:46:42 +00:00
|
|
|
global $wgEnableNewpagesUserFilter;
|
2008-05-11 21:43:16 +00:00
|
|
|
|
|
|
|
|
// Options
|
|
|
|
|
$opts = new FormOptions();
|
2008-05-14 05:18:27 +00:00
|
|
|
$this->opts = $opts; // bind
|
2008-05-11 21:43:16 +00:00
|
|
|
$opts->add( 'hideliu', false );
|
2011-04-03 05:46:42 +00:00
|
|
|
$opts->add( 'hidepatrolled', $this->getUser()->getBoolOption( 'newpageshidepatrolled' ) );
|
2009-04-19 21:03:30 +00:00
|
|
|
$opts->add( 'hidebots', false );
|
2008-11-02 22:58:35 +00:00
|
|
|
$opts->add( 'hideredirs', true );
|
2011-04-03 05:46:42 +00:00
|
|
|
$opts->add( 'limit', (int)$this->getUser()->getOption( 'rclimit' ) );
|
2008-05-14 13:28:46 +00:00
|
|
|
$opts->add( 'offset', '' );
|
2008-05-11 21:43:16 +00:00
|
|
|
$opts->add( 'namespace', '0' );
|
|
|
|
|
$opts->add( 'username', '' );
|
|
|
|
|
$opts->add( 'feed', '' );
|
2009-01-28 19:08:18 +00:00
|
|
|
$opts->add( 'tagfilter', '' );
|
2008-05-11 21:43:16 +00:00
|
|
|
|
2011-05-23 04:28:58 +00:00
|
|
|
$this->customFilters = array();
|
|
|
|
|
wfRunHooks( 'SpecialNewPagesFilters', array( $this, &$this->customFilters ) );
|
|
|
|
|
foreach( $this->customFilters as $key => $params ) {
|
|
|
|
|
$opts->add( $key, $params['default'] );
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-11 21:43:16 +00:00
|
|
|
// Set values
|
2011-04-03 05:46:42 +00:00
|
|
|
$opts->fetchValuesFromRequest( $this->getRequest() );
|
2008-05-11 21:43:16 +00:00
|
|
|
if ( $par ) $this->parseParams( $par );
|
|
|
|
|
|
|
|
|
|
// Validate
|
|
|
|
|
$opts->validateIntBounds( 'limit', 0, 5000 );
|
|
|
|
|
if( !$wgEnableNewpagesUserFilter ) {
|
|
|
|
|
$opts->setValue( 'username', '' );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function parseParams( $par ) {
|
|
|
|
|
$bits = preg_split( '/\s*,\s*/', trim( $par ) );
|
|
|
|
|
foreach ( $bits as $bit ) {
|
2011-02-19 02:07:10 +00:00
|
|
|
if ( 'shownav' == $bit ) {
|
2008-05-11 21:43:16 +00:00
|
|
|
$this->showNavigation = true;
|
2011-02-19 02:07:10 +00:00
|
|
|
}
|
|
|
|
|
if ( 'hideliu' === $bit ) {
|
2008-05-11 21:43:16 +00:00
|
|
|
$this->opts->setValue( 'hideliu', true );
|
2011-02-19 02:07:10 +00:00
|
|
|
}
|
|
|
|
|
if ( 'hidepatrolled' == $bit ) {
|
2008-05-11 21:43:16 +00:00
|
|
|
$this->opts->setValue( 'hidepatrolled', true );
|
2011-02-19 02:07:10 +00:00
|
|
|
}
|
|
|
|
|
if ( 'hidebots' == $bit ) {
|
2008-05-11 21:43:16 +00:00
|
|
|
$this->opts->setValue( 'hidebots', true );
|
2011-02-19 02:07:10 +00:00
|
|
|
}
|
|
|
|
|
if ( 'showredirs' == $bit ) {
|
2008-11-02 22:58:35 +00:00
|
|
|
$this->opts->setValue( 'hideredirs', false );
|
2011-02-19 02:07:10 +00:00
|
|
|
}
|
|
|
|
|
if ( is_numeric( $bit ) ) {
|
2008-05-11 21:43:16 +00:00
|
|
|
$this->opts->setValue( 'limit', intval( $bit ) );
|
2011-02-19 02:07:10 +00:00
|
|
|
}
|
2008-05-11 21:43:16 +00:00
|
|
|
|
|
|
|
|
$m = array();
|
2011-02-19 02:07:10 +00:00
|
|
|
if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
|
|
|
|
|
$this->opts->setValue( 'limit', intval( $m[1] ) );
|
|
|
|
|
}
|
2008-05-14 13:28:46 +00:00
|
|
|
// PG offsets not just digits!
|
2011-02-19 02:07:10 +00:00
|
|
|
if ( preg_match( '/^offset=([^=]+)$/', $bit, $m ) ) {
|
|
|
|
|
$this->opts->setValue( 'offset', intval( $m[1] ) );
|
|
|
|
|
}
|
|
|
|
|
if ( preg_match( '/^username=(.*)$/', $bit, $m ) ) {
|
2009-01-06 23:46:32 +00:00
|
|
|
$this->opts->setValue( 'username', $m[1] );
|
2011-02-19 02:07:10 +00:00
|
|
|
}
|
2008-05-11 21:43:16 +00:00
|
|
|
if ( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) {
|
2011-11-21 16:13:21 +00:00
|
|
|
$ns = $this->getLanguage()->getNsIndex( $m[1] );
|
2008-05-11 21:43:16 +00:00
|
|
|
if( $ns !== false ) {
|
|
|
|
|
$this->opts->setValue( 'namespace', $ns );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-21 06:49:23 +00:00
|
|
|
/**
|
2006-07-10 08:38:48 +00:00
|
|
|
* Show a form for filtering namespace and username
|
2006-04-21 06:49:23 +00:00
|
|
|
*
|
2010-05-04 19:28:13 +00:00
|
|
|
* @param $par String
|
|
|
|
|
* @return String
|
2008-02-10 10:05:49 +00:00
|
|
|
*/
|
2008-06-18 20:45:10 +00:00
|
|
|
public function execute( $par ) {
|
2011-04-03 05:46:42 +00:00
|
|
|
$out = $this->getOutput();
|
2007-11-01 16:18:17 +00:00
|
|
|
|
2008-06-18 20:45:10 +00:00
|
|
|
$this->setHeaders();
|
|
|
|
|
$this->outputHeader();
|
|
|
|
|
|
|
|
|
|
$this->showNavigation = !$this->including(); // Maybe changed in setup
|
2008-05-11 21:43:16 +00:00
|
|
|
$this->setup( $par );
|
2007-12-15 20:22:16 +00:00
|
|
|
|
2008-06-18 20:45:10 +00:00
|
|
|
if( !$this->including() ) {
|
2008-05-14 05:18:27 +00:00
|
|
|
// Settings
|
|
|
|
|
$this->form();
|
2007-12-15 20:22:16 +00:00
|
|
|
|
2008-05-11 21:43:16 +00:00
|
|
|
$feedType = $this->opts->getValue( 'feed' );
|
|
|
|
|
if( $feedType ) {
|
2008-06-06 16:42:23 +00:00
|
|
|
return $this->feed( $feedType );
|
2008-04-15 20:42:42 +00:00
|
|
|
}
|
2011-10-03 14:21:20 +00:00
|
|
|
|
2012-04-04 20:51:51 +00:00
|
|
|
$allValues = $this->opts->getAllValues();
|
|
|
|
|
unset( $allValues['feed'] );
|
|
|
|
|
$out->setFeedAppendQuery( wfArrayToCGI( $allValues ) );
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-11 21:43:16 +00:00
|
|
|
$pager = new NewPagesPager( $this, $this->opts );
|
|
|
|
|
$pager->mLimit = $this->opts->getValue( 'limit' );
|
|
|
|
|
$pager->mOffset = $this->opts->getValue( 'offset' );
|
2007-12-15 20:22:16 +00:00
|
|
|
|
2008-05-11 21:43:16 +00:00
|
|
|
if( $pager->getNumRows() ) {
|
|
|
|
|
$navigation = '';
|
2011-02-19 02:07:10 +00:00
|
|
|
if ( $this->showNavigation ) {
|
|
|
|
|
$navigation = $pager->getNavigationBar();
|
|
|
|
|
}
|
2011-04-03 05:46:42 +00:00
|
|
|
$out->addHTML( $navigation . $pager->getBody() . $navigation );
|
2008-05-11 21:43:16 +00:00
|
|
|
} else {
|
2011-04-03 05:46:42 +00:00
|
|
|
$out->addWikiMsg( 'specialpage-empty' );
|
2008-04-30 23:49:28 +00:00
|
|
|
}
|
2008-05-11 21:43:16 +00:00
|
|
|
}
|
2008-04-15 20:42:42 +00:00
|
|
|
|
2008-05-11 21:43:16 +00:00
|
|
|
protected function filterLinks() {
|
2011-10-12 09:12:22 +00:00
|
|
|
global $wgGroupPermissions;
|
2008-04-15 20:42:42 +00:00
|
|
|
|
2008-05-11 21:43:16 +00:00
|
|
|
// show/hide links
|
2012-04-04 20:15:44 +00:00
|
|
|
$showhide = array( $this->msg( 'show' )->escaped(), $this->msg( 'hide' )->escaped() );
|
2007-11-01 16:18:17 +00:00
|
|
|
|
2008-05-11 21:43:16 +00:00
|
|
|
// Option value -> message mapping
|
|
|
|
|
$filters = array(
|
|
|
|
|
'hideliu' => 'rcshowhideliu',
|
|
|
|
|
'hidepatrolled' => 'rcshowhidepatr',
|
2008-11-02 22:58:35 +00:00
|
|
|
'hidebots' => 'rcshowhidebots',
|
2008-11-03 18:23:42 +00:00
|
|
|
'hideredirs' => 'whatlinkshere-hideredirs'
|
2008-05-11 21:43:16 +00:00
|
|
|
);
|
2011-05-23 04:28:58 +00:00
|
|
|
foreach ( $this->customFilters as $key => $params ) {
|
|
|
|
|
$filters[$key] = $params['msg'];
|
|
|
|
|
}
|
2008-04-15 20:42:42 +00:00
|
|
|
|
2008-05-11 21:43:16 +00:00
|
|
|
// Disable some if needed
|
2011-05-17 22:03:20 +00:00
|
|
|
# @todo FIXME: Throws E_NOTICEs if not set; and doesn't obey hooks etc.
|
2011-02-19 02:07:10 +00:00
|
|
|
if ( $wgGroupPermissions['*']['createpage'] !== true ) {
|
|
|
|
|
unset( $filters['hideliu'] );
|
|
|
|
|
}
|
2011-04-03 05:46:42 +00:00
|
|
|
if ( !$this->getUser()->useNPPatrol() ) {
|
2011-02-19 02:07:10 +00:00
|
|
|
unset( $filters['hidepatrolled'] );
|
|
|
|
|
}
|
2008-04-13 19:57:12 +00:00
|
|
|
|
2008-05-11 21:43:16 +00:00
|
|
|
$links = array();
|
|
|
|
|
$changed = $this->opts->getChangedValues();
|
2011-02-19 02:07:10 +00:00
|
|
|
unset( $changed['offset'] ); // Reset offset if query type changes
|
2008-05-11 21:43:16 +00:00
|
|
|
|
2008-06-18 20:45:10 +00:00
|
|
|
$self = $this->getTitle();
|
2008-05-11 21:43:16 +00:00
|
|
|
foreach ( $filters as $key => $msg ) {
|
2011-02-19 02:07:10 +00:00
|
|
|
$onoff = 1 - $this->opts->getValue( $key );
|
2011-09-20 20:00:05 +00:00
|
|
|
$link = Linker::link( $self, $showhide[$onoff], array(),
|
2011-02-19 02:07:10 +00:00
|
|
|
array( $key => $onoff ) + $changed
|
2008-04-16 15:12:44 +00:00
|
|
|
);
|
2012-04-04 20:15:44 +00:00
|
|
|
$links[$key] = $this->msg( $msg )->rawParams( $link )->escaped();
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
2008-05-11 21:43:16 +00:00
|
|
|
|
2011-11-21 16:13:21 +00:00
|
|
|
return $this->getLanguage()->pipeList( $links );
|
2008-05-11 21:43:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function form() {
|
2011-04-03 05:46:42 +00:00
|
|
|
global $wgEnableNewpagesUserFilter, $wgScript;
|
2008-05-11 21:43:16 +00:00
|
|
|
|
|
|
|
|
// Consume values
|
2008-05-11 21:55:43 +00:00
|
|
|
$this->opts->consumeValue( 'offset' ); // don't carry offset, DWIW
|
2008-05-11 21:43:16 +00:00
|
|
|
$namespace = $this->opts->consumeValue( 'namespace' );
|
|
|
|
|
$username = $this->opts->consumeValue( 'username' );
|
2009-07-27 10:45:18 +00:00
|
|
|
$tagFilterVal = $this->opts->consumeValue( 'tagfilter' );
|
2008-05-11 21:43:16 +00:00
|
|
|
|
|
|
|
|
// Check username input validity
|
|
|
|
|
$ut = Title::makeTitleSafe( NS_USER, $username );
|
|
|
|
|
$userText = $ut ? $ut->getText() : '';
|
|
|
|
|
|
|
|
|
|
// Store query values in hidden fields so that form submission doesn't lose them
|
|
|
|
|
$hidden = array();
|
|
|
|
|
foreach ( $this->opts->getUnconsumedValues() as $key => $value ) {
|
2010-10-31 16:20:48 +00:00
|
|
|
$hidden[] = Html::hidden( $key, $value );
|
2008-05-11 21:43:16 +00:00
|
|
|
}
|
|
|
|
|
$hidden = implode( "\n", $hidden );
|
|
|
|
|
|
2012-01-13 21:57:52 +00:00
|
|
|
$tagFilter = ChangeTags::buildTagFilterSelector( $tagFilterVal );
|
2011-02-19 02:07:10 +00:00
|
|
|
if ( $tagFilter ) {
|
2012-01-13 21:57:52 +00:00
|
|
|
list( $tagFilterLabel, $tagFilterSelector ) = $tagFilter;
|
2011-02-19 02:07:10 +00:00
|
|
|
}
|
2009-01-28 19:08:18 +00:00
|
|
|
|
2008-05-11 21:43:16 +00:00
|
|
|
$form = Xml::openElement( 'form', array( 'action' => $wgScript ) ) .
|
2010-10-31 16:33:48 +00:00
|
|
|
Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) .
|
2012-04-04 20:15:44 +00:00
|
|
|
Xml::fieldset( $this->msg( 'newpages' )->text() ) .
|
2008-05-11 21:43:16 +00:00
|
|
|
Xml::openElement( 'table', array( 'id' => 'mw-newpages-table' ) ) .
|
2011-02-19 02:09:53 +00:00
|
|
|
'<tr>
|
|
|
|
|
<td class="mw-label">' .
|
2012-04-04 20:15:44 +00:00
|
|
|
Xml::label( $this->msg( 'namespace' )->text(), 'namespace' ) .
|
2011-02-19 02:09:53 +00:00
|
|
|
'</td>
|
|
|
|
|
<td class="mw-input">' .
|
2012-03-19 12:30:52 +00:00
|
|
|
Html::namespaceSelector(
|
|
|
|
|
array(
|
|
|
|
|
'selected' => $namespace,
|
|
|
|
|
'all' => 'all',
|
|
|
|
|
), array(
|
|
|
|
|
'name' => 'namespace',
|
|
|
|
|
'id' => 'namespace',
|
|
|
|
|
'class' => 'namespaceselector',
|
|
|
|
|
)
|
|
|
|
|
) .
|
2011-02-19 02:09:53 +00:00
|
|
|
'</td>
|
|
|
|
|
</tr>' . ( $tagFilter ? (
|
|
|
|
|
'<tr>
|
|
|
|
|
<td class="mw-label">' .
|
2009-01-28 19:08:18 +00:00
|
|
|
$tagFilterLabel .
|
2011-02-19 02:09:53 +00:00
|
|
|
'</td>
|
|
|
|
|
<td class="mw-input">' .
|
2009-01-28 19:08:18 +00:00
|
|
|
$tagFilterSelector .
|
2011-02-19 02:09:53 +00:00
|
|
|
'</td>
|
|
|
|
|
</tr>' ) : '' ) .
|
2011-02-19 02:07:10 +00:00
|
|
|
( $wgEnableNewpagesUserFilter ?
|
2011-02-19 02:09:53 +00:00
|
|
|
'<tr>
|
|
|
|
|
<td class="mw-label">' .
|
2012-04-04 20:15:44 +00:00
|
|
|
Xml::label( $this->msg( 'newpages-username' )->text(), 'mw-np-username' ) .
|
2011-02-19 02:09:53 +00:00
|
|
|
'</td>
|
|
|
|
|
<td class="mw-input">' .
|
2008-05-11 21:43:16 +00:00
|
|
|
Xml::input( 'username', 30, $userText, array( 'id' => 'mw-np-username' ) ) .
|
2011-02-19 02:09:53 +00:00
|
|
|
'</td>
|
|
|
|
|
</tr>' : '' ) .
|
|
|
|
|
'<tr> <td></td>
|
|
|
|
|
<td class="mw-submit">' .
|
2012-04-04 20:15:44 +00:00
|
|
|
Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) .
|
2011-02-19 02:09:53 +00:00
|
|
|
'</td>
|
|
|
|
|
</tr>' .
|
|
|
|
|
'<tr>
|
2008-05-11 21:43:16 +00:00
|
|
|
<td></td>
|
2011-02-19 02:09:53 +00:00
|
|
|
<td class="mw-input">' .
|
2008-05-11 21:43:16 +00:00
|
|
|
$this->filterLinks() .
|
2011-02-19 02:09:53 +00:00
|
|
|
'</td>
|
|
|
|
|
</tr>' .
|
2008-05-11 21:43:16 +00:00
|
|
|
Xml::closeElement( 'table' ) .
|
|
|
|
|
Xml::closeElement( 'fieldset' ) .
|
|
|
|
|
$hidden .
|
|
|
|
|
Xml::closeElement( 'form' );
|
|
|
|
|
|
2011-04-03 05:46:42 +00:00
|
|
|
$this->getOutput()->addHTML( $form );
|
2008-05-11 21:43:16 +00:00
|
|
|
}
|
|
|
|
|
|
2008-04-13 19:57:12 +00:00
|
|
|
/**
|
|
|
|
|
* Format a row, providing the timestamp, links to the page/history, size, user links, and a comment
|
|
|
|
|
*
|
|
|
|
|
* @param $result Result row
|
2010-05-04 19:28:13 +00:00
|
|
|
* @return String
|
2008-04-13 19:57:12 +00:00
|
|
|
*/
|
|
|
|
|
public function formatRow( $result ) {
|
2012-05-26 19:10:52 +00:00
|
|
|
$title = Title::newFromRow( $result );
|
|
|
|
|
|
2011-03-18 20:44:29 +00:00
|
|
|
# Revision deletion works on revisions, so we should cast one
|
|
|
|
|
$row = array(
|
|
|
|
|
'comment' => $result->rc_comment,
|
|
|
|
|
'deleted' => $result->rc_deleted,
|
|
|
|
|
'user_text' => $result->rc_user_text,
|
|
|
|
|
'user' => $result->rc_user,
|
|
|
|
|
);
|
|
|
|
|
$rev = new Revision( $row );
|
2012-05-26 19:10:52 +00:00
|
|
|
$rev->setTitle( $title );
|
2011-03-18 20:44:29 +00:00
|
|
|
|
2009-01-28 19:08:18 +00:00
|
|
|
$classes = array();
|
2011-03-18 20:44:29 +00:00
|
|
|
|
2011-11-21 16:13:21 +00:00
|
|
|
$lang = $this->getLanguage();
|
2011-10-12 09:12:22 +00:00
|
|
|
$dm = $lang->getDirMark();
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2011-11-16 21:43:32 +00:00
|
|
|
$spanTime = Html::element( 'span', array( 'class' => 'mw-newpages-time' ),
|
2012-04-04 20:15:44 +00:00
|
|
|
$lang->userTimeAndDate( $result->rc_timestamp, $this->getUser() )
|
2010-08-09 19:04:14 +00:00
|
|
|
);
|
2011-11-16 21:43:32 +00:00
|
|
|
$time = Linker::linkKnown(
|
|
|
|
|
$title,
|
|
|
|
|
$spanTime,
|
|
|
|
|
array(),
|
|
|
|
|
array( 'oldid' => $result->rc_this_oldid ),
|
|
|
|
|
array()
|
|
|
|
|
);
|
2009-06-07 18:45:52 +00:00
|
|
|
|
|
|
|
|
$query = array( 'redirect' => 'no' );
|
|
|
|
|
|
2011-02-19 02:07:10 +00:00
|
|
|
if( $this->patrollable( $result ) ) {
|
2009-06-07 18:45:52 +00:00
|
|
|
$query['rcid'] = $result->rc_id;
|
2011-02-19 02:07:10 +00:00
|
|
|
}
|
2009-06-07 18:45:52 +00:00
|
|
|
|
2011-09-20 20:00:05 +00:00
|
|
|
$plink = Linker::linkKnown(
|
2009-06-07 18:45:52 +00:00
|
|
|
$title,
|
|
|
|
|
null,
|
2010-08-09 19:04:14 +00:00
|
|
|
array( 'class' => 'mw-newpages-pagename' ),
|
2010-08-09 20:36:21 +00:00
|
|
|
$query,
|
|
|
|
|
array( 'known' ) // Set explicitly to avoid the default of 'known','noclasses'. This breaks the colouration for stubs
|
2009-06-07 18:45:52 +00:00
|
|
|
);
|
2011-09-20 20:00:05 +00:00
|
|
|
$histLink = Linker::linkKnown(
|
2009-06-07 18:45:52 +00:00
|
|
|
$title,
|
2012-04-04 20:15:44 +00:00
|
|
|
$this->msg( 'hist' )->escaped(),
|
2009-06-07 18:45:52 +00:00
|
|
|
array(),
|
|
|
|
|
array( 'action' => 'history' )
|
|
|
|
|
);
|
2012-04-04 20:15:44 +00:00
|
|
|
$hist = Html::rawElement( 'span', array( 'class' => 'mw-newpages-history' ),
|
|
|
|
|
$this->msg( 'parentheses' )->rawParams( $histLink )->escaped() );
|
2010-08-09 19:04:14 +00:00
|
|
|
|
2011-10-12 09:12:22 +00:00
|
|
|
$length = Html::element( 'span', array( 'class' => 'mw-newpages-length' ),
|
2012-06-08 14:11:07 +00:00
|
|
|
$this->msg( 'brackets' )->params( $this->msg( 'nbytes' )->numParams( $result->length )->text() )
|
2010-08-09 19:04:14 +00:00
|
|
|
);
|
2011-03-18 20:44:29 +00:00
|
|
|
|
2011-09-20 20:00:05 +00:00
|
|
|
$ulink = Linker::revUserTools( $rev );
|
|
|
|
|
$comment = Linker::revComment( $rev );
|
2011-03-18 20:44:29 +00:00
|
|
|
|
2010-08-09 19:35:56 +00:00
|
|
|
if ( $this->patrollable( $result ) ) {
|
2009-01-28 19:08:18 +00:00
|
|
|
$classes[] = 'not-patrolled';
|
2010-08-09 19:35:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Add a class for zero byte pages
|
|
|
|
|
if ( $result->length == 0 ) {
|
|
|
|
|
$classes[] = 'mw-newpages-zero-byte-page';
|
|
|
|
|
}
|
2009-01-28 19:08:18 +00:00
|
|
|
|
2010-07-23 22:37:52 +00:00
|
|
|
# Tags, if any. check for including due to bug 23293
|
|
|
|
|
if ( !$this->including() ) {
|
|
|
|
|
list( $tagDisplay, $newClasses ) = ChangeTags::formatSummaryRow( $result->ts_tags, 'newpages' );
|
|
|
|
|
$classes = array_merge( $classes, $newClasses );
|
|
|
|
|
} else {
|
|
|
|
|
$tagDisplay = '';
|
|
|
|
|
}
|
2009-01-28 19:08:18 +00:00
|
|
|
|
2011-02-19 02:07:10 +00:00
|
|
|
$css = count( $classes ) ? ' class="' . implode( ' ', $classes ) . '"' : '';
|
2008-04-13 19:57:12 +00:00
|
|
|
|
2012-03-07 21:45:38 +00:00
|
|
|
# Display the old title if the namespace/title has been changed
|
2012-03-02 20:58:10 +00:00
|
|
|
$oldTitleText = '';
|
2012-03-07 21:45:38 +00:00
|
|
|
$oldTitle = Title::makeTitle( $result->rc_namespace, $result->rc_title );
|
|
|
|
|
if ( !$title->equals( $oldTitle ) ) {
|
2012-04-04 20:51:51 +00:00
|
|
|
$oldTitleText = $this->msg( 'rc-old-title' )->params( $oldTitle->getPrefixedText() )->escaped();
|
2012-03-02 20:58:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "<li{$css}>{$time} {$dm}{$plink} {$hist} {$dm}{$length} {$dm}{$ulink} {$comment} {$tagDisplay} {$oldTitleText}</li>\n";
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Should a specific result row provide "patrollable" links?
|
|
|
|
|
*
|
|
|
|
|
* @param $result Result row
|
2010-05-04 19:28:13 +00:00
|
|
|
* @return Boolean
|
2008-04-13 19:57:12 +00:00
|
|
|
*/
|
|
|
|
|
protected function patrollable( $result ) {
|
2011-04-03 05:46:42 +00:00
|
|
|
return ( $this->getUser()->useNPPatrol() && !$result->rc_patrolled );
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-13 19:57:12 +00:00
|
|
|
/**
|
|
|
|
|
* Output a subscription feed listing recent edits to this page.
|
2010-05-04 19:28:13 +00:00
|
|
|
*
|
|
|
|
|
* @param $type String
|
2008-04-13 19:57:12 +00:00
|
|
|
*/
|
2008-06-06 16:42:23 +00:00
|
|
|
protected function feed( $type ) {
|
2011-04-03 05:46:42 +00:00
|
|
|
global $wgFeed, $wgFeedClasses, $wgFeedLimit;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-13 19:57:12 +00:00
|
|
|
if ( !$wgFeed ) {
|
2011-06-03 04:22:14 +00:00
|
|
|
$this->getOutput()->addWikiMsg( 'feed-unavailable' );
|
2008-04-13 19:57:12 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-13 19:57:12 +00:00
|
|
|
if( !isset( $wgFeedClasses[$type] ) ) {
|
2011-06-03 04:22:14 +00:00
|
|
|
$this->getOutput()->addWikiMsg( 'feed-invalid' );
|
2008-04-13 19:57:12 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-13 19:57:12 +00:00
|
|
|
$feed = new $wgFeedClasses[$type](
|
|
|
|
|
$this->feedTitle(),
|
2012-04-04 20:15:44 +00:00
|
|
|
$this->msg( 'tagline' )->text(),
|
2011-02-19 02:07:10 +00:00
|
|
|
$this->getTitle()->getFullUrl()
|
|
|
|
|
);
|
2008-04-13 19:57:12 +00:00
|
|
|
|
2008-05-11 21:43:16 +00:00
|
|
|
$pager = new NewPagesPager( $this, $this->opts );
|
2008-05-16 21:34:46 +00:00
|
|
|
$limit = $this->opts->getValue( 'limit' );
|
2008-10-19 06:05:57 +00:00
|
|
|
$pager->mLimit = min( $limit, $wgFeedLimit );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-13 19:57:12 +00:00
|
|
|
$feed->outHeader();
|
|
|
|
|
if( $pager->getNumRows() > 0 ) {
|
2011-02-17 16:29:13 +00:00
|
|
|
foreach ( $pager->mResult as $row ) {
|
2008-04-13 19:57:12 +00:00
|
|
|
$feed->outItem( $this->feedItem( $row ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$feed->outFooter();
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-13 19:57:12 +00:00
|
|
|
protected function feedTitle() {
|
2010-09-07 22:37:55 +00:00
|
|
|
global $wgLanguageCode, $wgSitename;
|
2011-04-17 10:44:44 +00:00
|
|
|
$desc = $this->getDescription();
|
2010-09-07 22:37:55 +00:00
|
|
|
return "$wgSitename - $desc [$wgLanguageCode]";
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function feedItem( $row ) {
|
2012-05-05 14:08:47 +00:00
|
|
|
$title = Title::makeTitle( intval( $row->rc_namespace ), $row->rc_title );
|
2008-04-13 19:57:12 +00:00
|
|
|
if( $title ) {
|
|
|
|
|
$date = $row->rc_timestamp;
|
2008-06-05 14:20:59 +00:00
|
|
|
$comments = $title->getTalkPage()->getFullURL();
|
2008-04-13 19:57:12 +00:00
|
|
|
|
|
|
|
|
return new FeedItem(
|
|
|
|
|
$title->getPrefixedText(),
|
|
|
|
|
$this->feedItemDesc( $row ),
|
|
|
|
|
$title->getFullURL(),
|
|
|
|
|
$date,
|
|
|
|
|
$this->feedItemAuthor( $row ),
|
2011-02-19 02:07:10 +00:00
|
|
|
$comments
|
|
|
|
|
);
|
2008-04-13 19:57:12 +00:00
|
|
|
} else {
|
2009-12-11 21:07:27 +00:00
|
|
|
return null;
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-26 04:00:03 +00:00
|
|
|
protected function feedItemAuthor( $row ) {
|
2008-04-13 19:57:12 +00:00
|
|
|
return isset( $row->rc_user_text ) ? $row->rc_user_text : '';
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-13 19:57:12 +00:00
|
|
|
protected function feedItemDesc( $row ) {
|
2008-04-13 20:02:50 +00:00
|
|
|
$revision = Revision::newFromId( $row->rev_id );
|
|
|
|
|
if( $revision ) {
|
2012-04-04 20:15:44 +00:00
|
|
|
return '<p>' . htmlspecialchars( $revision->getUserText() ) .
|
|
|
|
|
$this->msg( 'colon-separator' )->inContentLanguage()->escaped() .
|
2011-06-30 02:59:43 +00:00
|
|
|
htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) .
|
2008-05-05 03:35:37 +00:00
|
|
|
"</p>\n<hr />\n<div>" .
|
2008-04-13 20:02:50 +00:00
|
|
|
nl2br( htmlspecialchars( $revision->getText() ) ) . "</div>";
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup SpecialPage Pager
|
2008-04-13 19:57:12 +00:00
|
|
|
*/
|
|
|
|
|
class NewPagesPager extends ReverseChronologicalPager {
|
2008-05-11 21:43:16 +00:00
|
|
|
// Stored opts
|
2011-06-30 02:59:43 +00:00
|
|
|
protected $opts;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var HtmlForm
|
|
|
|
|
*/
|
|
|
|
|
protected $mForm;
|
2008-05-11 21:43:16 +00:00
|
|
|
|
|
|
|
|
function __construct( $form, FormOptions $opts ) {
|
2011-09-20 20:00:05 +00:00
|
|
|
parent::__construct( $form->getContext() );
|
2008-04-13 19:57:12 +00:00
|
|
|
$this->mForm = $form;
|
2008-05-11 21:43:16 +00:00
|
|
|
$this->opts = $opts;
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getQueryInfo() {
|
2011-04-03 05:46:42 +00:00
|
|
|
global $wgEnableNewpagesUserFilter, $wgGroupPermissions;
|
2008-05-11 21:43:16 +00:00
|
|
|
$conds = array();
|
2008-04-13 19:57:12 +00:00
|
|
|
$conds['rc_new'] = 1;
|
2008-05-11 21:43:16 +00:00
|
|
|
|
|
|
|
|
$namespace = $this->opts->getValue( 'namespace' );
|
|
|
|
|
$namespace = ( $namespace === 'all' ) ? false : intval( $namespace );
|
|
|
|
|
|
|
|
|
|
$username = $this->opts->getValue( 'username' );
|
|
|
|
|
$user = Title::makeTitleSafe( NS_USER, $username );
|
|
|
|
|
|
|
|
|
|
if( $namespace !== false ) {
|
2008-08-25 09:44:20 +00:00
|
|
|
$conds['rc_namespace'] = $namespace;
|
2008-04-15 17:33:17 +00:00
|
|
|
$rcIndexes = array( 'new_name_timestamp' );
|
2008-04-13 19:57:12 +00:00
|
|
|
} else {
|
2008-04-15 17:33:17 +00:00
|
|
|
$rcIndexes = array( 'rc_timestamp' );
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
2008-11-02 22:58:35 +00:00
|
|
|
|
2008-05-13 03:59:42 +00:00
|
|
|
# $wgEnableNewpagesUserFilter - temp WMF hack
|
|
|
|
|
if( $wgEnableNewpagesUserFilter && $user ) {
|
2008-05-11 21:43:16 +00:00
|
|
|
$conds['rc_user_text'] = $user->getText();
|
2008-05-13 03:59:42 +00:00
|
|
|
$rcIndexes = 'rc_user_text';
|
|
|
|
|
# If anons cannot make new pages, don't "exclude logged in users"!
|
|
|
|
|
} elseif( $wgGroupPermissions['*']['createpage'] && $this->opts->getValue( 'hideliu' ) ) {
|
|
|
|
|
$conds['rc_user'] = 0;
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
|
|
|
|
# If this user cannot see patrolled edits or they are off, don't do dumb queries!
|
2011-04-03 05:46:42 +00:00
|
|
|
if( $this->opts->getValue( 'hidepatrolled' ) && $this->getUser()->useNPPatrol() ) {
|
2008-04-13 19:57:12 +00:00
|
|
|
$conds['rc_patrolled'] = 0;
|
|
|
|
|
}
|
2008-05-11 21:43:16 +00:00
|
|
|
if( $this->opts->getValue( 'hidebots' ) ) {
|
2008-04-13 19:57:12 +00:00
|
|
|
$conds['rc_bot'] = 0;
|
|
|
|
|
}
|
2009-04-19 21:03:30 +00:00
|
|
|
|
2008-11-02 22:58:35 +00:00
|
|
|
if ( $this->opts->getValue( 'hideredirs' ) ) {
|
|
|
|
|
$conds['page_is_redirect'] = 0;
|
|
|
|
|
}
|
2011-06-30 02:59:43 +00:00
|
|
|
|
2010-04-24 11:05:15 +00:00
|
|
|
// Allow changes to the New Pages query
|
2011-05-23 04:28:58 +00:00
|
|
|
$tables = array( 'recentchanges', 'page' );
|
|
|
|
|
$fields = array(
|
|
|
|
|
'rc_namespace', 'rc_title', 'rc_cur_id', 'rc_user', 'rc_user_text',
|
|
|
|
|
'rc_comment', 'rc_timestamp', 'rc_patrolled','rc_id', 'rc_deleted',
|
2012-08-15 13:16:09 +00:00
|
|
|
'length' => 'page_len', 'rev_id' => 'page_latest', 'ts_tags', 'rc_this_oldid',
|
2011-11-19 19:01:08 +00:00
|
|
|
'page_namespace', 'page_title'
|
2011-05-23 04:28:58 +00:00
|
|
|
);
|
|
|
|
|
$join_conds = array( 'page' => array( 'INNER JOIN', 'page_id=rc_cur_id' ) );
|
|
|
|
|
|
|
|
|
|
wfRunHooks( 'SpecialNewpagesConditions',
|
|
|
|
|
array( &$this, $this->opts, &$conds, &$tables, &$fields, &$join_conds ) );
|
2008-11-02 22:58:35 +00:00
|
|
|
|
2009-01-28 19:08:18 +00:00
|
|
|
$info = array(
|
2011-05-23 04:28:58 +00:00
|
|
|
'tables' => $tables,
|
|
|
|
|
'fields' => $fields,
|
|
|
|
|
'conds' => $conds,
|
|
|
|
|
'options' => array( 'USE INDEX' => array( 'recentchanges' => $rcIndexes ) ),
|
|
|
|
|
'join_conds' => $join_conds
|
2008-04-13 19:57:12 +00:00
|
|
|
);
|
2009-01-28 19:08:18 +00:00
|
|
|
|
2011-02-19 02:07:10 +00:00
|
|
|
// Empty array for fields, it'll be set by us anyway.
|
2009-01-28 19:08:18 +00:00
|
|
|
$fields = array();
|
|
|
|
|
|
2011-02-19 02:07:10 +00:00
|
|
|
// Modify query for tags
|
|
|
|
|
ChangeTags::modifyDisplayQuery(
|
|
|
|
|
$info['tables'],
|
|
|
|
|
$fields,
|
|
|
|
|
$info['conds'],
|
|
|
|
|
$info['join_conds'],
|
2012-01-13 21:57:52 +00:00
|
|
|
$info['options'],
|
|
|
|
|
$this->opts['tagfilter']
|
2011-02-19 02:07:10 +00:00
|
|
|
);
|
2009-01-28 19:08:18 +00:00
|
|
|
|
|
|
|
|
return $info;
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getIndexField() {
|
|
|
|
|
return 'rc_timestamp';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatRow( $row ) {
|
|
|
|
|
return $this->mForm->formatRow( $row );
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-13 19:57:12 +00:00
|
|
|
function getStartBody() {
|
|
|
|
|
# Do a batch existence check on pages
|
|
|
|
|
$linkBatch = new LinkBatch();
|
2010-10-13 23:11:40 +00:00
|
|
|
foreach ( $this->mResult as $row ) {
|
2008-04-13 19:57:12 +00:00
|
|
|
$linkBatch->add( NS_USER, $row->rc_user_text );
|
|
|
|
|
$linkBatch->add( NS_USER_TALK, $row->rc_user_text );
|
2008-08-25 09:44:20 +00:00
|
|
|
$linkBatch->add( $row->rc_namespace, $row->rc_title );
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
|
|
|
|
$linkBatch->execute();
|
2011-02-19 02:07:10 +00:00
|
|
|
return '<ul>';
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getEndBody() {
|
2011-02-19 02:07:10 +00:00
|
|
|
return '</ul>';
|
2006-04-21 06:49:23 +00:00
|
|
|
}
|
2008-02-10 10:05:49 +00:00
|
|
|
}
|