2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2007-04-20 08:55:14 +00:00
|
|
|
/**
|
2010-08-14 19:19:41 +00:00
|
|
|
* Implements Special:Allpages
|
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-14 19:19:41 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
* @ingroup SpecialPage
|
2010-06-21 12:59:04 +00:00
|
|
|
*/
|
2011-03-18 20:37:11 +00:00
|
|
|
|
2010-06-21 12:59:04 +00:00
|
|
|
/**
|
2010-08-14 19:19:41 +00:00
|
|
|
* Implements Special:Allpages
|
|
|
|
|
*
|
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
|
2007-04-20 08:55:14 +00:00
|
|
|
*/
|
2014-06-16 17:36:04 +00:00
|
|
|
class SpecialAllPages extends IncludableSpecialPage {
|
2008-08-23 20:32:46 +00:00
|
|
|
|
2007-12-24 11:21:37 +00:00
|
|
|
/**
|
2008-08-20 16:13:49 +00:00
|
|
|
* Maximum number of pages to show on single subpage.
|
2012-03-28 20:28:31 +00:00
|
|
|
*
|
|
|
|
|
* @var int $maxPerPage
|
2008-08-17 00:39:46 +00:00
|
|
|
*/
|
2008-08-20 17:50:13 +00:00
|
|
|
protected $maxPerPage = 345;
|
|
|
|
|
|
2007-12-24 11:21:37 +00:00
|
|
|
/**
|
2008-08-23 20:32:46 +00:00
|
|
|
* Determines, which message describes the input field 'nsfrom'.
|
2012-03-28 20:28:31 +00:00
|
|
|
*
|
|
|
|
|
* @var string $nsfromMsg
|
2007-12-24 11:21:37 +00:00
|
|
|
*/
|
2008-08-23 20:32:46 +00:00
|
|
|
protected $nsfromMsg = 'allpagesfrom';
|
|
|
|
|
|
2012-03-28 20:28:31 +00:00
|
|
|
/**
|
|
|
|
|
* Constructor
|
|
|
|
|
*
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param string $name name of the special page, as seen in links and URLs (default: 'Allpages')
|
2012-03-28 20:28:31 +00:00
|
|
|
*/
|
2013-01-26 18:15:35 +00:00
|
|
|
function __construct( $name = 'Allpages' ) {
|
2009-02-20 16:13:40 +00:00
|
|
|
parent::__construct( $name );
|
2008-08-23 20:32:46 +00:00
|
|
|
}
|
2007-12-24 11:21:37 +00:00
|
|
|
|
2008-08-20 16:13:49 +00:00
|
|
|
/**
|
2008-08-23 20:32:46 +00:00
|
|
|
* Entry point : initialise variables and call subfunctions.
|
2010-05-07 21:01:38 +00:00
|
|
|
*
|
2014-04-23 11:39:49 +00:00
|
|
|
* @param string $par becomes "FOO" when called like Special:Allpages/FOO (default null)
|
2008-08-20 16:13:49 +00:00
|
|
|
*/
|
2008-08-23 20:32:46 +00:00
|
|
|
function execute( $par ) {
|
2011-04-03 04:37:13 +00:00
|
|
|
$request = $this->getRequest();
|
|
|
|
|
$out = $this->getOutput();
|
2008-08-20 16:13:49 +00:00
|
|
|
|
2008-08-23 20:32:46 +00:00
|
|
|
$this->setHeaders();
|
|
|
|
|
$this->outputHeader();
|
2011-04-03 06:26:58 +00:00
|
|
|
$out->allowClickjacking();
|
2004-08-13 07:46:33 +00:00
|
|
|
|
2008-08-23 20:32:46 +00:00
|
|
|
# GET values
|
2011-04-03 04:37:13 +00:00
|
|
|
$from = $request->getVal( 'from', null );
|
|
|
|
|
$to = $request->getVal( 'to', null );
|
|
|
|
|
$namespace = $request->getInt( 'namespace' );
|
2012-03-28 20:28:31 +00:00
|
|
|
$hideredirects = $request->getBool( 'hideredirects', false );
|
2005-08-02 20:59:00 +00:00
|
|
|
|
2013-03-14 17:02:17 +00:00
|
|
|
$namespaces = $this->getContext()->getLanguage()->getNamespaces();
|
2008-08-23 20:32:46 +00:00
|
|
|
|
2011-10-27 20:23:16 +00:00
|
|
|
$out->setPageTitle(
|
2014-04-01 21:44:03 +00:00
|
|
|
( $namespace > 0 && array_key_exists( $namespace, $namespaces ) ) ?
|
2013-03-25 22:52:41 +00:00
|
|
|
$this->msg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) ) :
|
|
|
|
|
$this->msg( 'allarticles' )
|
2011-04-03 06:26:58 +00:00
|
|
|
);
|
|
|
|
|
$out->addModuleStyles( 'mediawiki.special' );
|
2008-08-23 20:32:46 +00:00
|
|
|
|
2013-03-25 22:52:41 +00:00
|
|
|
if ( $par !== null ) {
|
2012-03-28 20:28:31 +00:00
|
|
|
$this->showChunk( $namespace, $par, $to, $hideredirects );
|
2013-03-25 22:52:41 +00:00
|
|
|
} elseif ( $from !== null && $to === null ) {
|
2012-03-28 20:28:31 +00:00
|
|
|
$this->showChunk( $namespace, $from, $to, $hideredirects );
|
2008-08-23 20:32:46 +00:00
|
|
|
} else {
|
2012-03-28 20:28:31 +00:00
|
|
|
$this->showToplevel( $namespace, $from, $to, $hideredirects );
|
2008-08-23 20:32:46 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* HTML for the top form
|
2010-05-07 21:01:38 +00:00
|
|
|
*
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param int $namespace A namespace constant (default NS_MAIN).
|
|
|
|
|
* @param string $from DbKey we are starting listing at.
|
|
|
|
|
* @param string $to DbKey we are ending listing at.
|
|
|
|
|
* @param bool $hideredirects Dont show redirects (default false)
|
2012-02-09 21:36:14 +00:00
|
|
|
* @return string
|
2008-08-23 20:32:46 +00:00
|
|
|
*/
|
2012-03-28 20:28:31 +00:00
|
|
|
function namespaceForm( $namespace = NS_MAIN, $from = '', $to = '', $hideredirects = false ) {
|
2013-12-24 08:07:04 +00:00
|
|
|
$t = $this->getPageTitle();
|
2011-03-18 20:37:11 +00:00
|
|
|
|
2013-03-07 16:50:43 +00:00
|
|
|
$out = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) );
|
2014-06-16 17:39:07 +00:00
|
|
|
$out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $this->getConfig()->get( 'Script' ) ) );
|
2010-10-31 16:20:48 +00:00
|
|
|
$out .= Html::hidden( 'title', $t->getPrefixedText() );
|
2009-06-07 18:45:52 +00:00
|
|
|
$out .= Xml::openElement( 'fieldset' );
|
2011-11-08 16:04:25 +00:00
|
|
|
$out .= Xml::element( 'legend', null, $this->msg( 'allpages' )->text() );
|
2009-06-07 18:45:52 +00:00
|
|
|
$out .= Xml::openElement( 'table', array( 'id' => 'nsselect', 'class' => 'allpages' ) );
|
|
|
|
|
$out .= "<tr>
|
|
|
|
|
<td class='mw-label'>" .
|
2011-11-08 16:04:25 +00:00
|
|
|
Xml::label( $this->msg( 'allpagesfrom' )->text(), 'nsfrom' ) .
|
2009-06-07 18:45:52 +00:00
|
|
|
" </td>
|
|
|
|
|
<td class='mw-input'>" .
|
2013-01-26 18:15:35 +00:00
|
|
|
Xml::input( 'from', 30, str_replace( '_', ' ', $from ), array( 'id' => 'nsfrom' ) ) .
|
2009-06-07 18:45:52 +00:00
|
|
|
" </td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td class='mw-label'>" .
|
2011-11-08 16:04:25 +00:00
|
|
|
Xml::label( $this->msg( 'allpagesto' )->text(), 'nsto' ) .
|
2009-06-07 18:45:52 +00:00
|
|
|
" </td>
|
|
|
|
|
<td class='mw-input'>" .
|
2013-01-26 18:15:35 +00:00
|
|
|
Xml::input( 'to', 30, str_replace( '_', ' ', $to ), array( 'id' => 'nsto' ) ) .
|
2009-06-07 18:45:52 +00:00
|
|
|
" </td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td class='mw-label'>" .
|
2011-11-08 16:04:25 +00:00
|
|
|
Xml::label( $this->msg( 'namespace' )->text(), 'namespace' ) .
|
2009-06-07 18:45:52 +00:00
|
|
|
" </td>
|
|
|
|
|
<td class='mw-input'>" .
|
2012-01-29 19:05:25 +00:00
|
|
|
Html::namespaceSelector(
|
2012-02-02 22:57:39 +00:00
|
|
|
array( 'selected' => $namespace ),
|
|
|
|
|
array( 'name' => 'namespace', 'id' => 'namespace' )
|
2012-01-29 19:05:25 +00:00
|
|
|
) . ' ' .
|
2012-03-28 20:28:31 +00:00
|
|
|
Xml::checkLabel(
|
2012-04-12 20:43:08 +00:00
|
|
|
$this->msg( 'allpages-hide-redirects' )->text(),
|
2012-03-28 20:28:31 +00:00
|
|
|
'hideredirects',
|
|
|
|
|
'hideredirects',
|
|
|
|
|
$hideredirects
|
|
|
|
|
) . ' ' .
|
2011-11-08 16:04:25 +00:00
|
|
|
Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) .
|
2009-06-07 18:45:52 +00:00
|
|
|
" </td>
|
|
|
|
|
</tr>";
|
|
|
|
|
$out .= Xml::closeElement( 'table' );
|
|
|
|
|
$out .= Xml::closeElement( 'fieldset' );
|
|
|
|
|
$out .= Xml::closeElement( 'form' );
|
|
|
|
|
$out .= Xml::closeElement( 'div' );
|
2013-04-14 17:27:14 +00:00
|
|
|
|
2009-06-07 18:45:52 +00:00
|
|
|
return $out;
|
2008-08-23 20:32:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param int $namespace (default NS_MAIN)
|
|
|
|
|
* @param string $from List all pages from this name
|
|
|
|
|
* @param string $to List all pages to this name
|
|
|
|
|
* @param bool $hideredirects Dont show redirects (default false)
|
2008-08-23 20:32:46 +00:00
|
|
|
*/
|
2012-03-28 20:28:31 +00:00
|
|
|
function showToplevel( $namespace = NS_MAIN, $from = '', $to = '', $hideredirects = false ) {
|
2008-08-23 20:32:46 +00:00
|
|
|
$from = Title::makeTitleSafe( $namespace, $from );
|
|
|
|
|
$to = Title::makeTitleSafe( $namespace, $to );
|
2009-05-24 08:29:10 +00:00
|
|
|
$from = ( $from && $from->isLocal() ) ? $from->getDBkey() : null;
|
|
|
|
|
$to = ( $to && $to->isLocal() ) ? $to->getDBkey() : null;
|
2008-08-23 20:32:46 +00:00
|
|
|
|
2014-05-11 19:41:10 +00:00
|
|
|
$this->showChunk( $namespace, $from, $to, $hideredirects );
|
2008-08-23 20:32:46 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2008-08-23 20:32:46 +00:00
|
|
|
/**
|
2013-04-01 18:24:26 +00:00
|
|
|
* @param int $namespace Namespace (Default NS_MAIN)
|
2014-04-23 11:39:49 +00:00
|
|
|
* @param string $from List all pages from this name (default false)
|
|
|
|
|
* @param string $to List all pages to this name (default false)
|
|
|
|
|
* @param bool $hideredirects Dont show redirects (default false)
|
2008-08-23 20:32:46 +00:00
|
|
|
*/
|
2012-03-28 20:28:31 +00:00
|
|
|
function showChunk( $namespace = NS_MAIN, $from = false, $to = false, $hideredirects = false ) {
|
2011-04-03 04:37:13 +00:00
|
|
|
$output = $this->getOutput();
|
2006-11-08 07:12:03 +00:00
|
|
|
|
2013-01-28 21:11:10 +00:00
|
|
|
$fromList = $this->getNamespaceKeyAndText( $namespace, $from );
|
2008-08-23 20:32:46 +00:00
|
|
|
$toList = $this->getNamespaceKeyAndText( $namespace, $to );
|
2013-03-14 17:02:17 +00:00
|
|
|
$namespaces = $this->getContext()->getLanguage()->getNamespaces();
|
2008-08-23 20:32:46 +00:00
|
|
|
$n = 0;
|
2007-06-26 07:21:28 +00:00
|
|
|
|
2008-08-23 20:32:46 +00:00
|
|
|
if ( !$fromList || !$toList ) {
|
2011-11-08 16:04:25 +00:00
|
|
|
$out = $this->msg( 'allpagesbadtitle' )->parseAsBlock();
|
2014-04-01 21:44:03 +00:00
|
|
|
} elseif ( !array_key_exists( $namespace, $namespaces ) ) {
|
2008-08-23 20:32:46 +00:00
|
|
|
// Show errormessage and reset to NS_MAIN
|
2011-11-08 16:04:25 +00:00
|
|
|
$out = $this->msg( 'allpages-bad-ns', $namespace )->parse();
|
2008-08-23 20:32:46 +00:00
|
|
|
$namespace = NS_MAIN;
|
|
|
|
|
} else {
|
|
|
|
|
list( $namespace, $fromKey, $from ) = $fromList;
|
2010-11-30 18:44:50 +00:00
|
|
|
list( , $toKey, $to ) = $toList;
|
2006-07-02 14:39:47 +00:00
|
|
|
|
2008-08-23 20:32:46 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
|
$conds = array(
|
|
|
|
|
'page_namespace' => $namespace,
|
|
|
|
|
'page_title >= ' . $dbr->addQuotes( $fromKey )
|
|
|
|
|
);
|
2012-03-28 20:28:31 +00:00
|
|
|
|
|
|
|
|
if ( $hideredirects ) {
|
2013-02-03 19:28:43 +00:00
|
|
|
$conds['page_is_redirect'] = 0;
|
2012-03-28 20:28:31 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-25 22:52:41 +00:00
|
|
|
if ( $toKey !== "" ) {
|
2008-08-23 20:32:46 +00:00
|
|
|
$conds[] = 'page_title <= ' . $dbr->addQuotes( $toKey );
|
|
|
|
|
}
|
2008-08-20 17:50:13 +00:00
|
|
|
|
2008-08-23 20:32:46 +00:00
|
|
|
$res = $dbr->select( 'page',
|
2011-01-15 13:13:29 +00:00
|
|
|
array( 'page_namespace', 'page_title', 'page_is_redirect', 'page_id' ),
|
2008-08-23 20:32:46 +00:00
|
|
|
$conds,
|
|
|
|
|
__METHOD__,
|
|
|
|
|
array(
|
2013-03-25 22:52:41 +00:00
|
|
|
'ORDER BY' => 'page_title',
|
|
|
|
|
'LIMIT' => $this->maxPerPage + 1,
|
2008-08-23 20:32:46 +00:00
|
|
|
'USE INDEX' => 'name_title',
|
|
|
|
|
)
|
|
|
|
|
);
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2013-03-25 22:52:41 +00:00
|
|
|
if ( $res->numRows() > 0 ) {
|
2009-04-15 09:36:53 +00:00
|
|
|
$out = Xml::openElement( 'table', array( 'class' => 'mw-allpages-table-chunk' ) );
|
2013-03-25 22:52:41 +00:00
|
|
|
while ( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
|
2011-01-15 13:13:29 +00:00
|
|
|
$t = Title::newFromRow( $s );
|
2013-03-25 22:52:41 +00:00
|
|
|
if ( $t ) {
|
2008-08-23 20:32:46 +00:00
|
|
|
$link = ( $s->page_is_redirect ? '<div class="allpagesredirect">' : '' ) .
|
2011-08-04 15:48:36 +00:00
|
|
|
Linker::link( $t ) .
|
2013-03-25 22:52:41 +00:00
|
|
|
( $s->page_is_redirect ? '</div>' : '' );
|
2008-08-23 20:32:46 +00:00
|
|
|
} else {
|
|
|
|
|
$link = '[[' . htmlspecialchars( $s->page_title ) . ']]';
|
|
|
|
|
}
|
2013-03-25 22:52:41 +00:00
|
|
|
|
|
|
|
|
if ( $n % 3 == 0 ) {
|
2008-08-23 20:32:46 +00:00
|
|
|
$out .= '<tr>';
|
|
|
|
|
}
|
2013-03-25 22:52:41 +00:00
|
|
|
|
2010-07-18 12:55:11 +00:00
|
|
|
$out .= "<td style=\"width:33%\">$link</td>";
|
2008-08-23 20:32:46 +00:00
|
|
|
$n++;
|
2013-03-25 22:52:41 +00:00
|
|
|
if ( $n % 3 == 0 ) {
|
2009-04-15 09:36:53 +00:00
|
|
|
$out .= "</tr>\n";
|
2008-08-23 20:32:46 +00:00
|
|
|
}
|
2008-05-01 22:07:24 +00:00
|
|
|
}
|
2013-03-25 22:52:41 +00:00
|
|
|
|
|
|
|
|
if ( ( $n % 3 ) != 0 ) {
|
2009-04-15 09:36:53 +00:00
|
|
|
$out .= "</tr>\n";
|
2008-05-01 22:07:24 +00:00
|
|
|
}
|
2009-04-15 09:36:53 +00:00
|
|
|
$out .= Xml::closeElement( 'table' );
|
2008-08-23 20:32:46 +00:00
|
|
|
} else {
|
|
|
|
|
$out = '';
|
2006-07-02 14:39:47 +00:00
|
|
|
}
|
2004-04-09 08:27:00 +00:00
|
|
|
}
|
2005-09-25 12:19:51 +00:00
|
|
|
|
2008-08-23 20:32:46 +00:00
|
|
|
if ( $this->including() ) {
|
2014-05-13 18:33:55 +00:00
|
|
|
$output->addHTML( $out );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $from == '' ) {
|
|
|
|
|
// First chunk; no previous link.
|
|
|
|
|
$prevTitle = null;
|
2008-08-20 16:13:49 +00:00
|
|
|
} else {
|
2014-05-13 18:33:55 +00:00
|
|
|
# Get the last title from previous chunk
|
|
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
|
$res_prev = $dbr->select(
|
|
|
|
|
'page',
|
|
|
|
|
'page_title',
|
|
|
|
|
array( 'page_namespace' => $namespace, 'page_title < ' . $dbr->addQuotes( $from ) ),
|
|
|
|
|
__METHOD__,
|
|
|
|
|
array( 'ORDER BY' => 'page_title DESC',
|
|
|
|
|
'LIMIT' => $this->maxPerPage, 'OFFSET' => ( $this->maxPerPage - 1 )
|
|
|
|
|
)
|
|
|
|
|
);
|
2008-08-23 20:32:46 +00:00
|
|
|
|
2014-05-13 18:33:55 +00:00
|
|
|
# Get first title of previous complete chunk
|
|
|
|
|
if ( $dbr->numrows( $res_prev ) >= $this->maxPerPage ) {
|
|
|
|
|
$pt = $dbr->fetchObject( $res_prev );
|
|
|
|
|
$prevTitle = Title::makeTitle( $namespace, $pt->page_title );
|
|
|
|
|
} else {
|
|
|
|
|
# The previous chunk is not complete, need to link to the very first title
|
|
|
|
|
# available in the database
|
|
|
|
|
$options = array( 'LIMIT' => 1 );
|
|
|
|
|
if ( !$dbr->implicitOrderby() ) {
|
|
|
|
|
$options['ORDER BY'] = 'page_title';
|
|
|
|
|
}
|
|
|
|
|
$reallyFirstPage_title = $dbr->selectField( 'page', 'page_title',
|
|
|
|
|
array( 'page_namespace' => $namespace ), __METHOD__, $options );
|
|
|
|
|
# Show the previous link if it s not the current requested chunk
|
|
|
|
|
if ( $from != $reallyFirstPage_title ) {
|
|
|
|
|
$prevTitle = Title::makeTitle( $namespace, $reallyFirstPage_title );
|
2008-08-20 16:13:49 +00:00
|
|
|
} else {
|
2014-05-13 18:33:55 +00:00
|
|
|
$prevTitle = null;
|
2008-08-20 16:13:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
2014-05-13 18:33:55 +00:00
|
|
|
}
|
2008-08-20 16:13:49 +00:00
|
|
|
|
2014-05-13 18:33:55 +00:00
|
|
|
$self = $this->getPageTitle();
|
2009-06-07 18:45:52 +00:00
|
|
|
|
2014-05-13 18:33:55 +00:00
|
|
|
$topLinks = array(
|
|
|
|
|
Linker::link( $self, $this->msg( 'allpages' )->escaped() )
|
|
|
|
|
);
|
|
|
|
|
$bottomLinks = array();
|
2009-06-07 18:45:52 +00:00
|
|
|
|
2014-05-13 18:33:55 +00:00
|
|
|
# Do we put a previous link ?
|
2014-05-24 05:45:33 +00:00
|
|
|
if ( $prevTitle && $pt = $prevTitle->getText() ) {
|
2014-05-13 18:33:55 +00:00
|
|
|
$query = array( 'from' => $prevTitle->getText() );
|
2012-03-28 20:28:31 +00:00
|
|
|
|
2014-05-13 18:33:55 +00:00
|
|
|
if ( $namespace ) {
|
|
|
|
|
$query['namespace'] = $namespace;
|
2008-08-23 20:32:46 +00:00
|
|
|
}
|
2004-07-08 16:50:22 +00:00
|
|
|
|
2014-05-13 18:33:55 +00:00
|
|
|
if ( $hideredirects ) {
|
|
|
|
|
$query['hideredirects'] = $hideredirects;
|
|
|
|
|
}
|
2009-06-07 18:45:52 +00:00
|
|
|
|
2014-05-13 18:33:55 +00:00
|
|
|
$prevLink = Linker::linkKnown(
|
|
|
|
|
$self,
|
|
|
|
|
$this->msg( 'prevpage', $pt )->escaped(),
|
|
|
|
|
array(),
|
|
|
|
|
$query
|
|
|
|
|
);
|
|
|
|
|
$topLinks[] = $prevLink;
|
|
|
|
|
$bottomLinks[] = $prevLink;
|
|
|
|
|
}
|
2009-06-07 18:45:52 +00:00
|
|
|
|
2014-05-13 18:33:55 +00:00
|
|
|
if ( $n == $this->maxPerPage && $s = $res->fetchObject() ) {
|
|
|
|
|
# $s is the first link of the next chunk
|
|
|
|
|
$t = Title::makeTitle( $namespace, $s->page_title );
|
|
|
|
|
$query = array( 'from' => $t->getText() );
|
2012-03-28 20:28:31 +00:00
|
|
|
|
2014-05-13 18:33:55 +00:00
|
|
|
if ( $namespace ) {
|
|
|
|
|
$query['namespace'] = $namespace;
|
2008-08-23 20:32:46 +00:00
|
|
|
}
|
2008-08-20 16:13:49 +00:00
|
|
|
|
2014-05-13 18:33:55 +00:00
|
|
|
if ( $hideredirects ) {
|
|
|
|
|
$query['hideredirects'] = $hideredirects;
|
|
|
|
|
}
|
2008-08-20 16:13:49 +00:00
|
|
|
|
2014-05-13 18:33:55 +00:00
|
|
|
$nextLink = Linker::linkKnown(
|
|
|
|
|
$self,
|
|
|
|
|
$this->msg( 'nextpage', $t->getText() )->escaped(),
|
|
|
|
|
array(),
|
|
|
|
|
$query
|
|
|
|
|
);
|
|
|
|
|
$topLinks[] = $nextLink;
|
|
|
|
|
$bottomLinks[] = $nextLink;
|
2013-03-25 22:52:41 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-13 18:33:55 +00:00
|
|
|
$nsForm = $this->namespaceForm( $namespace, $from, $to, $hideredirects );
|
|
|
|
|
$out2 = Xml::openElement( 'table', array( 'class' => 'mw-allpages-table-form' ) ) .
|
|
|
|
|
'<tr>
|
|
|
|
|
<td>' .
|
|
|
|
|
$nsForm .
|
|
|
|
|
'</td>
|
|
|
|
|
<td class="mw-allpages-nav">' .
|
|
|
|
|
$this->getLanguage()->pipeList( $topLinks ) .
|
|
|
|
|
'</td></tr></table>';
|
|
|
|
|
|
|
|
|
|
$output->addHTML( $out2 . $out );
|
2011-01-15 14:45:40 +00:00
|
|
|
|
2014-05-13 18:33:55 +00:00
|
|
|
if ( count( $bottomLinks ) ) {
|
2011-04-03 04:37:13 +00:00
|
|
|
$output->addHTML(
|
2011-01-15 14:45:40 +00:00
|
|
|
Html::element( 'hr' ) .
|
2013-03-25 22:52:41 +00:00
|
|
|
Html::rawElement( 'div', array( 'class' => 'mw-allpages-nav' ),
|
2014-05-13 18:33:55 +00:00
|
|
|
$this->getLanguage()->pipeList( $bottomLinks )
|
2013-03-25 22:52:41 +00:00
|
|
|
)
|
|
|
|
|
);
|
2008-08-23 20:32:46 +00:00
|
|
|
}
|
2006-11-23 08:25:56 +00:00
|
|
|
}
|
2006-07-02 14:39:47 +00:00
|
|
|
|
2008-08-23 20:32:46 +00:00
|
|
|
/**
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param int $ns The namespace of the article
|
|
|
|
|
* @param string $text The name of the article
|
2014-04-23 11:39:49 +00:00
|
|
|
* @return array( int namespace, string dbkey, string pagename ) or null on error
|
2008-08-23 20:32:46 +00:00
|
|
|
*/
|
2013-01-28 21:11:10 +00:00
|
|
|
protected function getNamespaceKeyAndText( $ns, $text ) {
|
2013-03-25 22:52:41 +00:00
|
|
|
if ( $text == '' ) {
|
|
|
|
|
# shortcut for common case
|
|
|
|
|
return array( $ns, '', '' );
|
|
|
|
|
}
|
2008-08-23 20:32:46 +00:00
|
|
|
|
2013-01-28 21:11:10 +00:00
|
|
|
$t = Title::makeTitleSafe( $ns, $text );
|
2008-08-23 20:32:46 +00:00
|
|
|
if ( $t && $t->isLocal() ) {
|
|
|
|
|
return array( $t->getNamespace(), $t->getDBkey(), $t->getText() );
|
2011-06-17 16:05:05 +00:00
|
|
|
} elseif ( $t ) {
|
2009-12-11 21:07:27 +00:00
|
|
|
return null;
|
2008-08-23 20:32:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# try again, in case the problem was an empty pagename
|
2013-01-28 21:11:10 +00:00
|
|
|
$text = preg_replace( '/(#|$)/', 'X$1', $text );
|
|
|
|
|
$t = Title::makeTitleSafe( $ns, $text );
|
2008-08-23 20:32:46 +00:00
|
|
|
if ( $t && $t->isLocal() ) {
|
|
|
|
|
return array( $t->getNamespace(), '', '' );
|
|
|
|
|
} else {
|
2009-12-11 21:07:27 +00:00
|
|
|
return null;
|
2008-08-23 20:32:46 +00:00
|
|
|
}
|
2006-11-23 08:25:56 +00:00
|
|
|
}
|
2013-03-07 20:15:54 +00:00
|
|
|
|
|
|
|
|
protected function getGroupName() {
|
|
|
|
|
return 'pages';
|
|
|
|
|
}
|
2006-07-02 14:39:47 +00:00
|
|
|
}
|