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 {
|
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
|
|
|
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 ) {
|
|
|
|
|
// 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 );
|
2013-03-02 16:50:56 +00:00
|
|
|
$opts->add( 'limit', $this->getUser()->getIntOption( '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', '' );
|
2013-02-16 00:43:38 +00:00
|
|
|
$opts->add( 'invert', false );
|
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 ) );
|
2013-04-19 20:55:47 +00:00
|
|
|
foreach ( $this->customFilters as $key => $params ) {
|
2011-05-23 04:28:58 +00:00
|
|
|
$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() );
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( $par ) {
|
|
|
|
|
$this->parseParams( $par );
|
|
|
|
|
}
|
2008-05-11 21:43:16 +00:00
|
|
|
|
|
|
|
|
// Validate
|
|
|
|
|
$opts->validateIntBounds( 'limit', 0, 5000 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 ) ) {
|
2013-01-28 21:11:10 +00:00
|
|
|
$this->opts->setValue( 'offset', intval( $m[1] ) );
|
2011-02-19 02:07:10 +00:00
|
|
|
}
|
|
|
|
|
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] );
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( $ns !== false ) {
|
2013-01-28 21:11:10 +00:00
|
|
|
$this->opts->setValue( 'namespace', $ns );
|
2008-05-11 21:43:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
*
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param string $par
|
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
|
|
|
|
2013-04-19 20:55:47 +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' );
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( $feedType ) {
|
2012-12-09 03:16:14 +00:00
|
|
|
$this->feed( $feedType );
|
2013-05-09 14:51:30 +00:00
|
|
|
|
2012-12-09 03:16:14 +00:00
|
|
|
return;
|
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'] );
|
2013-01-28 18:04:20 +00:00
|
|
|
$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
|
|
|
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( $pager->getNumRows() ) {
|
2008-05-11 21:43:16 +00:00
|
|
|
$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() {
|
|
|
|
|
// 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
|
2012-10-04 16:17:46 +00:00
|
|
|
if ( !User::groupHasPermission( '*', 'createpage' ) ) {
|
2011-02-19 02:07:10 +00:00
|
|
|
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
|
|
|
|
2013-12-24 08:07:04 +00:00
|
|
|
$self = $this->getPageTitle();
|
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(),
|
2013-05-09 14:51:30 +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() {
|
|
|
|
|
// 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' );
|
2013-02-16 00:43:38 +00:00
|
|
|
$nsinvert = $this->opts->consumeValue( 'invert' );
|
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
|
|
|
|
2014-10-10 14:13:49 +00:00
|
|
|
$this->getOutput()->addModules( 'mediawiki.userSuggest' );
|
|
|
|
|
|
2014-08-04 00:20:30 +00:00
|
|
|
$form = Xml::openElement( 'form', array( 'action' => wfScript() ) ) .
|
2013-12-24 08:07:04 +00:00
|
|
|
Html::hidden( 'title', $this->getPageTitle()->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">' .
|
2013-05-09 14:51:30 +00:00
|
|
|
Xml::label( $this->msg( 'namespace' )->text(), 'namespace' ) .
|
|
|
|
|
'</td>
|
|
|
|
|
<td class="mw-input">' .
|
|
|
|
|
Html::namespaceSelector(
|
|
|
|
|
array(
|
|
|
|
|
'selected' => $namespace,
|
|
|
|
|
'all' => 'all',
|
|
|
|
|
), array(
|
|
|
|
|
'name' => 'namespace',
|
|
|
|
|
'id' => 'namespace',
|
|
|
|
|
'class' => 'namespaceselector',
|
|
|
|
|
)
|
|
|
|
|
) . ' ' .
|
|
|
|
|
Xml::checkLabel(
|
|
|
|
|
$this->msg( 'invert' )->text(),
|
|
|
|
|
'invert',
|
|
|
|
|
'nsinvert',
|
|
|
|
|
$nsinvert,
|
|
|
|
|
array( 'title' => $this->msg( 'tooltip-invert' )->text() )
|
|
|
|
|
) .
|
|
|
|
|
'</td>
|
2011-02-19 02:09:53 +00:00
|
|
|
</tr>' . ( $tagFilter ? (
|
|
|
|
|
'<tr>
|
|
|
|
|
<td class="mw-label">' .
|
2013-05-09 14:51:30 +00:00
|
|
|
$tagFilterLabel .
|
2011-02-19 02:09:53 +00:00
|
|
|
'</td>
|
|
|
|
|
<td class="mw-input">' .
|
2013-05-09 14:51:30 +00:00
|
|
|
$tagFilterSelector .
|
2011-02-19 02:09:53 +00:00
|
|
|
'</td>
|
|
|
|
|
</tr>' ) : '' ) .
|
2014-06-21 02:05:08 +00:00
|
|
|
'<tr>
|
2011-02-19 02:09:53 +00:00
|
|
|
<td class="mw-label">' .
|
2012-04-04 20:15:44 +00:00
|
|
|
Xml::label( $this->msg( 'newpages-username' )->text(), 'mw-np-username' ) .
|
2013-05-09 14:51:30 +00:00
|
|
|
'</td>
|
2011-02-19 02:09:53 +00:00
|
|
|
<td class="mw-input">' .
|
2014-10-10 14:13:49 +00:00
|
|
|
Xml::input( 'username', 30, $userText, array(
|
|
|
|
|
'id' => 'mw-np-username',
|
|
|
|
|
'class' => 'mw-autocomplete-user', // used by mediawiki.userSuggest
|
|
|
|
|
) ) .
|
2013-05-09 14:51:30 +00:00
|
|
|
'</td>
|
2014-06-21 02:05:08 +00:00
|
|
|
</tr>' .
|
2011-02-19 02:09:53 +00:00
|
|
|
'<tr> <td></td>
|
|
|
|
|
<td class="mw-submit">' .
|
2013-05-09 14:51:30 +00:00
|
|
|
Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) .
|
|
|
|
|
'</td>
|
|
|
|
|
</tr>' .
|
2011-02-19 02:09:53 +00:00
|
|
|
'<tr>
|
2008-05-11 21:43:16 +00:00
|
|
|
<td></td>
|
2011-02-19 02:09:53 +00:00
|
|
|
<td class="mw-input">' .
|
2013-05-09 14:51:30 +00:00
|
|
|
$this->filterLinks() .
|
|
|
|
|
'</td>
|
2011-02-19 02:09:53 +00:00
|
|
|
</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
|
|
|
/**
|
2013-05-09 14:51:30 +00:00
|
|
|
* Format a row, providing the timestamp, links to the page/history,
|
|
|
|
|
* size, user links, and a comment
|
2008-04-13 19:57:12 +00:00
|
|
|
*
|
2013-05-09 14:51:30 +00:00
|
|
|
* @param object $result Result row
|
2014-04-19 08:16:52 +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(
|
2013-02-03 19:28:43 +00:00
|
|
|
'comment' => $result->rc_comment,
|
|
|
|
|
'deleted' => $result->rc_deleted,
|
|
|
|
|
'user_text' => $result->rc_user_text,
|
|
|
|
|
'user' => $result->rc_user,
|
|
|
|
|
);
|
2011-03-18 20:44:29 +00:00
|
|
|
$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' );
|
|
|
|
|
|
2013-05-09 14:51:30 +00:00
|
|
|
// Linker::linkKnown() uses 'known' and 'noclasses' options.
|
|
|
|
|
// This breaks the colouration for stubs.
|
2012-10-12 06:36:47 +00:00
|
|
|
$plink = Linker::link(
|
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,
|
2012-10-12 06:36:47 +00:00
|
|
|
array( 'known' )
|
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
|
|
|
|
2013-05-09 14:51:30 +00:00
|
|
|
$length = Html::element(
|
|
|
|
|
'span',
|
|
|
|
|
array( 'class' => 'mw-newpages-length' ),
|
|
|
|
|
$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
|
|
|
|
2012-08-04 20:20:00 +00:00
|
|
|
# Tags, if any.
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( isset( $result->ts_tags ) ) {
|
2013-05-09 14:51:30 +00:00
|
|
|
list( $tagDisplay, $newClasses ) = ChangeTags::formatSummaryRow(
|
|
|
|
|
$result->ts_tags,
|
|
|
|
|
'newpages'
|
|
|
|
|
);
|
2010-07-23 22:37:52 +00:00
|
|
|
$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 );
|
2013-05-09 14:51:30 +00:00
|
|
|
|
2012-03-07 21:45:38 +00:00
|
|
|
if ( !$title->equals( $oldTitle ) ) {
|
2013-05-09 14:51:30 +00:00
|
|
|
$oldTitleText = $oldTitle->getPrefixedText();
|
|
|
|
|
$oldTitleText = $this->msg( 'rc-old-title' )->params( $oldTitleText )->escaped();
|
2012-03-02 20:58:10 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-09 19:34:55 +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?
|
|
|
|
|
*
|
2013-05-09 14:51:30 +00:00
|
|
|
* @param object $result Result row
|
2014-04-19 08:16:52 +00:00
|
|
|
* @return bool
|
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
|
|
|
*
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param string $type
|
2008-04-13 19:57:12 +00:00
|
|
|
*/
|
2008-06-06 16:42:23 +00:00
|
|
|
protected function feed( $type ) {
|
2014-08-04 00:20:30 +00:00
|
|
|
if ( !$this->getConfig()->get( 'Feed' ) ) {
|
2011-06-03 04:22:14 +00:00
|
|
|
$this->getOutput()->addWikiMsg( 'feed-unavailable' );
|
2013-05-09 14:51:30 +00:00
|
|
|
|
2008-04-13 19:57:12 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2014-08-04 00:20:30 +00:00
|
|
|
$feedClasses = $this->getConfig()->get( 'FeedClasses' );
|
|
|
|
|
if ( !isset( $feedClasses[$type] ) ) {
|
2011-06-03 04:22:14 +00:00
|
|
|
$this->getOutput()->addWikiMsg( 'feed-invalid' );
|
2013-05-09 14:51:30 +00:00
|
|
|
|
2008-04-13 19:57:12 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2014-08-04 00:20:30 +00:00
|
|
|
$feed = new $feedClasses[$type](
|
2008-04-13 19:57:12 +00:00
|
|
|
$this->feedTitle(),
|
2012-04-04 20:15:44 +00:00
|
|
|
$this->msg( 'tagline' )->text(),
|
2013-12-24 08:07:04 +00:00
|
|
|
$this->getPageTitle()->getFullURL()
|
2011-02-19 02:07:10 +00:00
|
|
|
);
|
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' );
|
2014-08-04 00:20:30 +00:00
|
|
|
$pager->mLimit = min( $limit, $this->getConfig()->get( 'FeedLimit' ) );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-13 19:57:12 +00:00
|
|
|
$feed->outHeader();
|
2013-04-19 20:55:47 +00:00
|
|
|
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() {
|
2011-04-17 10:44:44 +00:00
|
|
|
$desc = $this->getDescription();
|
2014-08-04 00:20:30 +00:00
|
|
|
$code = $this->getConfig()->get( 'LanguageCode' );
|
|
|
|
|
$sitename = $this->getConfig()->get( 'Sitename' );
|
2013-05-09 14:51:30 +00:00
|
|
|
|
2014-08-04 00:20:30 +00:00
|
|
|
return "$sitename - $desc [$code]";
|
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 );
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( $title ) {
|
2008-04-13 19:57:12 +00:00
|
|
|
$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 );
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( $revision ) {
|
2012-08-20 19:33:07 +00:00
|
|
|
//XXX: include content model/type in feed item?
|
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>" .
|
2012-08-20 19:33:07 +00:00
|
|
|
nl2br( htmlspecialchars( $revision->getContent()->serialize() ) ) . "</div>";
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
2013-05-09 14:51:30 +00:00
|
|
|
|
2008-04-13 19:57:12 +00:00
|
|
|
return '';
|
|
|
|
|
}
|
2013-03-07 20:15:54 +00:00
|
|
|
|
|
|
|
|
protected function getGroupName() {
|
|
|
|
|
return 'changes';
|
|
|
|
|
}
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
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() {
|
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 );
|
|
|
|
|
|
2013-12-10 06:20:33 +00:00
|
|
|
$rcIndexes = array();
|
|
|
|
|
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( $namespace !== false ) {
|
2013-02-16 00:43:38 +00:00
|
|
|
if ( $this->opts->getValue( 'invert' ) ) {
|
|
|
|
|
$conds[] = 'rc_namespace != ' . $this->mDb->addQuotes( $namespace );
|
|
|
|
|
} else {
|
|
|
|
|
$conds['rc_namespace'] = $namespace;
|
|
|
|
|
}
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
2008-11-02 22:58:35 +00:00
|
|
|
|
2014-06-21 02:05:08 +00:00
|
|
|
if ( $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';
|
2013-05-09 14:51:30 +00:00
|
|
|
} elseif ( User::groupHasPermission( '*', 'createpage' ) &&
|
|
|
|
|
$this->opts->getValue( 'hideliu' )
|
|
|
|
|
) {
|
|
|
|
|
# If anons cannot make new pages, don't "exclude logged in users"!
|
2008-05-13 03:59:42 +00:00
|
|
|
$conds['rc_user'] = 0;
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
2013-05-09 14:51:30 +00:00
|
|
|
|
2008-04-13 19:57:12 +00:00
|
|
|
# If this user cannot see patrolled edits or they are off, don't do dumb queries!
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( $this->opts->getValue( 'hidepatrolled' ) && $this->getUser()->useNPPatrol() ) {
|
2008-04-13 19:57:12 +00:00
|
|
|
$conds['rc_patrolled'] = 0;
|
|
|
|
|
}
|
2013-05-09 14:51:30 +00:00
|
|
|
|
2013-04-19 20:55:47 +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',
|
2013-04-19 20:55:47 +00:00
|
|
|
'rc_comment', 'rc_timestamp', 'rc_patrolled', 'rc_id', 'rc_deleted',
|
2012-08-04 20:20:00 +00:00
|
|
|
'length' => 'page_len', 'rev_id' => 'page_latest', '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
|
|
|
|
2013-12-10 06:20:33 +00:00
|
|
|
$options = array();
|
|
|
|
|
|
|
|
|
|
if ( $rcIndexes ) {
|
|
|
|
|
$options = array( 'USE INDEX' => array( 'recentchanges' => $rcIndexes ) );
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-28 19:08:18 +00:00
|
|
|
$info = array(
|
2013-04-19 20:55:47 +00:00
|
|
|
'tables' => $tables,
|
|
|
|
|
'fields' => $fields,
|
|
|
|
|
'conds' => $conds,
|
2013-12-10 06:20:33 +00:00
|
|
|
'options' => $options,
|
2011-05-23 04:28:58 +00:00
|
|
|
'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
|
|
|
// Modify query for tags
|
|
|
|
|
ChangeTags::modifyDisplayQuery(
|
|
|
|
|
$info['tables'],
|
2012-08-04 20:20:00 +00:00
|
|
|
$info['fields'],
|
2011-02-19 02:07:10 +00:00
|
|
|
$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();
|
2013-05-09 14:51:30 +00:00
|
|
|
|
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
|
|
|
}
|