/**
* Maximum number of pages to show on single subpage.
+ *
+ * @var int $maxPerPage
*/
protected $maxPerPage = 345;
/**
* Maximum number of pages to show on single index subpage.
+ *
+ * @var int $maxLineCount
*/
protected $maxLineCount = 100;
/**
* Maximum number of chars to show for an entry.
+ *
+ * @var int $maxPageLength
*/
protected $maxPageLength = 70;
/**
* Determines, which message describes the input field 'nsfrom'.
+ *
+ * @var string $nsfromMsg
*/
protected $nsfromMsg = 'allpagesfrom';
+ /**
+ * Constructor
+ *
+ * @param $name string: name of the special page, as seen in links and URLs (default: 'Allpages')
+ */
function __construct( $name = 'Allpages' ){
parent::__construct( $name );
}
$from = $request->getVal( 'from', null );
$to = $request->getVal( 'to', null );
$namespace = $request->getInt( 'namespace' );
+ $hideredirects = $request->getBool( 'hideredirects', false );
$namespaces = $wgContLang->getNamespaces();
$out->addModuleStyles( 'mediawiki.special' );
if( $par !== null ) {
- $this->showChunk( $namespace, $par, $to );
+ $this->showChunk( $namespace, $par, $to, $hideredirects );
} elseif( $from !== null && $to === null ) {
- $this->showChunk( $namespace, $from, $to );
+ $this->showChunk( $namespace, $from, $to, $hideredirects );
} else {
- $this->showToplevel( $namespace, $from, $to );
+ $this->showToplevel( $namespace, $from, $to, $hideredirects );
}
}
* @param $namespace Integer: a namespace constant (default NS_MAIN).
* @param $from String: dbKey we are starting listing at.
* @param $to String: dbKey we are ending listing at.
+ * @param $hideredirects Bool: dont show redirects (default FALSE)
* @return string
*/
- function namespaceForm( $namespace = NS_MAIN, $from = '', $to = '' ) {
+ function namespaceForm( $namespace = NS_MAIN, $from = '', $to = '', $hideredirects = false ) {
global $wgScript;
$t = $this->getTitle();
array( 'selected' => $namespace ),
array( 'name' => 'namespace', 'id' => 'namespace' )
) . ' ' .
+ Xml::checkLabel(
+ wfMsg( 'allpages-hide-redirects' ),
+ 'hideredirects',
+ 'hideredirects',
+ $hideredirects
+ ) . ' ' .
Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) .
" </td>
</tr>";
* @param $namespace Integer (default NS_MAIN)
* @param $from String: list all pages from this name
* @param $to String: list all pages to this name
+ * @param $hideredirects Bool: dont show redirects (default FALSE)
*/
- function showToplevel( $namespace = NS_MAIN, $from = '', $to = '' ) {
+ function showToplevel( $namespace = NS_MAIN, $from = '', $to = '', $hideredirects = false ) {
$output = $this->getOutput();
# TODO: Either make this *much* faster or cache the title index points
$out = "";
$where = array( 'page_namespace' => $namespace );
+ if ( $hideredirects ) {
+ $where[ 'page_is_redirect' ] = 0;
+ }
+
$from = Title::makeTitleSafe( $namespace, $from );
$to = Title::makeTitleSafe( $namespace, $to );
$from = ( $from && $from->isLocal() ) ? $from->getDBkey() : null;
// Instead, display the first section directly.
if( count( $lines ) <= 2 ) {
if( !empty($lines) ) {
- $this->showChunk( $namespace, $from, $to );
+ $this->showChunk( $namespace, $from, $to, $hideredirects );
} else {
- $output->addHTML( $this->namespaceForm( $namespace, $from, $to ) );
+ $output->addHTML( $this->namespaceForm( $namespace, $from, $to, $hideredirects ) );
}
return;
}
while( count ( $lines ) > 0 ) {
$inpoint = array_shift( $lines );
$outpoint = array_shift( $lines );
- $out .= $this->showline( $inpoint, $outpoint, $namespace );
+ $out .= $this->showline( $inpoint, $outpoint, $namespace, $hideredirects );
}
$out .= Xml::closeElement( 'table' );
- $nsForm = $this->namespaceForm( $namespace, $from, $to );
+ $nsForm = $this->namespaceForm( $namespace, $from, $to, $hideredirects );
# Is there more?
if( $this->including() ) {
* @param $inpoint String: lower limit of pagenames
* @param $outpoint String: upper limit of pagenames
* @param $namespace Integer (Default NS_MAIN)
+ * @param $hideredirects Bool: dont show redirects (default FALSE)
* @return string
*/
- function showline( $inpoint, $outpoint, $namespace = NS_MAIN ) {
+ function showline( $inpoint, $outpoint, $namespace = NS_MAIN, $hideredirects ) {
global $wgContLang;
$inpointf = htmlspecialchars( str_replace( '_', ' ', $inpoint ) );
$outpointf = htmlspecialchars( str_replace( '_', ' ', $outpoint ) );
$outpointf = $wgContLang->truncate( $outpointf, $this->maxPageLength );
$queryparams = $namespace ? "namespace=$namespace&" : '';
+
+ $queryhideredirects = array();
+ if ($hideredirects) {
+ $queryhideredirects[ 'hideredirects' ] = 1;
+ }
+
$special = $this->getTitle();
- $link = htmlspecialchars( $special->getLocalUrl( $queryparams . 'from=' . urlencode($inpoint) . '&to=' . urlencode($outpoint) ) );
+ $link = htmlspecialchars( $special->getLocalUrl( $queryparams . 'from=' . urlencode($inpoint) . '&to=' . urlencode($outpoint), $queryhideredirects ) );
$out = $this->msg( 'alphaindexline' )->rawParams(
"<a href=\"$link\">$inpointf</a></td><td>",
* @param $namespace Integer (Default NS_MAIN)
* @param $from String: list all pages from this name (default FALSE)
* @param $to String: list all pages to this name (default FALSE)
+ * @param $hideredirects Bool: dont show redirects (default FALSE)
*/
- function showChunk( $namespace = NS_MAIN, $from = false, $to = false ) {
+ function showChunk( $namespace = NS_MAIN, $from = false, $to = false, $hideredirects = false ) {
global $wgContLang;
$output = $this->getOutput();
'page_namespace' => $namespace,
'page_title >= ' . $dbr->addQuotes( $fromKey )
);
+
+ if ( $hideredirects ) {
+ $conds[ 'page_is_redirect' ] = 0;
+ }
+
if( $toKey !== "" ) {
$conds[] = 'page_title <= ' . $dbr->addQuotes( $toKey );
}
$self = $this->getTitle();
- $nsForm = $this->namespaceForm( $namespace, $from, $to );
+ $nsForm = $this->namespaceForm( $namespace, $from, $to, $hideredirects );
$out2 = Xml::openElement( 'table', array( 'class' => 'mw-allpages-table-form' ) ).
'<tr>
<td>' .
if( $namespace )
$query['namespace'] = $namespace;
+ if( $hideredirects )
+ $query['hideredirects'] = $hideredirects;
+
$prevLink = Linker::linkKnown(
$self,
$this->msg( 'prevpage', $pt )->escaped(),
if( $namespace )
$query['namespace'] = $namespace;
+ if( $hideredirects )
+ $query['hideredirects'] = $hideredirects;
+
$nextLink = Linker::linkKnown(
$self,
$this->msg( 'nextpage', $t->getText() )->escaped(),
$prefix = $request->getVal( 'prefix', '' );
$ns = $request->getIntOrNull( 'namespace' );
$namespace = (int)$ns; // if no namespace given, use 0 (NS_MAIN).
+ $hideredirects = $request->getBool( 'hideredirects', false );
$namespaces = $wgContLang->getNamespaces();
$out->setPageTitle(
// Bug 27864: if transcluded, show all pages instead of the form.
if ( $this->including() || $showme != '' || $ns !== null ) {
- $this->showPrefixChunk( $namespace, $showme, $from );
+ $this->showPrefixChunk( $namespace, $showme, $from, $hideredirects );
} else {
- $out->addHTML( $this->namespacePrefixForm( $namespace, null ) );
+ $out->addHTML( $this->namespacePrefixForm( $namespace, null, $hideredirects ) );
}
}
/**
- * HTML for the top form
- * @param $namespace Integer: a namespace constant (default NS_MAIN).
- * @param $from String: dbKey we are starting listing at.
+ * HTML for the top form
+ * @param $namespace Integer: a namespace constant (default NS_MAIN).
+ * @param $from String: dbKey we are starting listing at.
+ * @param $hideredirects Bool: hide redirects (default FALSE)
* @return string
*/
- function namespacePrefixForm( $namespace = NS_MAIN, $from = '' ) {
+ function namespacePrefixForm( $namespace = NS_MAIN, $from = '', $hideredirects = false ) {
global $wgScript;
$out = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) );
Xml::label( wfMsg( 'namespace' ), 'namespace' ) .
"</td>
<td class='mw-input'>" .
- Html::namespaceSelector( array(
+ Html::namespaceSelector( array(
'selected' => $namespace,
), array(
'name' => 'namespace',
'id' => 'namespace',
'class' => 'namespaceselector',
- ) ) .
- Xml::submitButton( wfMsg( 'allpagessubmit' ) ) .
+ ) ) .
+ Xml::checkLabel(
+ wfMsg( 'allpages-hide-redirects' ),
+ 'hideredirects',
+ 'hideredirects',
+ $hideredirects
+ ) . ' ' .
+ Xml::submitButton( wfMsg( 'allpagessubmit' ) ) .
"</td>
- </tr>";
+ </tr>";
$out .= Xml::closeElement( 'table' );
$out .= Xml::closeElement( 'fieldset' );
$out .= Xml::closeElement( 'form' );
* @param $namespace Integer, default NS_MAIN
* @param $prefix String
* @param $from String: list all pages from this name (default FALSE)
+ * @param $hideredirects Bool: hide redirects (default FALSE)
*/
- function showPrefixChunk( $namespace = NS_MAIN, $prefix, $from = null ) {
+ function showPrefixChunk( $namespace = NS_MAIN, $prefix, $from = null, $hideredirects = false ) {
global $wgContLang;
if ( $from === null ) {
$dbr = wfGetDB( DB_SLAVE );
+ $conds = array(
+ 'page_namespace' => $namespace,
+ 'page_title' . $dbr->buildLike( $prefixKey, $dbr->anyString() ),
+ 'page_title >= ' . $dbr->addQuotes( $fromKey ),
+ );
+
+ if ( $hideredirects ) {
+ $conds['page_is_redirect'] = 0;
+ }
+
$res = $dbr->select( 'page',
array( 'page_namespace', 'page_title', 'page_is_redirect' ),
- array(
- 'page_namespace' => $namespace,
- 'page_title' . $dbr->buildLike( $prefixKey, $dbr->anyString() ),
- 'page_title >= ' . $dbr->addQuotes( $fromKey ),
- ),
+ $conds,
__METHOD__,
array(
'ORDER BY' => 'page_title',
if ( $this->including() ) {
$out2 = '';
} else {
- $nsForm = $this->namespacePrefixForm( $namespace, $prefix );
+ $nsForm = $this->namespacePrefixForm( $namespace, $prefix, $hideredirects );
$self = $this->getTitle();
$out2 = Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-prefixindex-nav-table' ) ) .
'<tr>
if( isset( $res ) && $res && ( $n == $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
$query = array(
'from' => $s->page_title,
- 'prefix' => $prefix
+ 'prefix' => $prefix,
+ 'hideredirects' => $hideredirects,
);
if( $namespace || ($prefix == '')) {