summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialPrefixindex.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/specials/SpecialPrefixindex.php')
-rw-r--r--includes/specials/SpecialPrefixindex.php46
1 files changed, 24 insertions, 22 deletions
diff --git a/includes/specials/SpecialPrefixindex.php b/includes/specials/SpecialPrefixindex.php
index 0d065b09..2e67e2b5 100644
--- a/includes/specials/SpecialPrefixindex.php
+++ b/includes/specials/SpecialPrefixindex.php
@@ -26,7 +26,7 @@
*
* @ingroup SpecialPage
*/
-class SpecialPrefixindex extends SpecialAllpages {
+class SpecialPrefixindex extends SpecialAllPages {
/**
* Whether to remove the searched prefix from the displayed link. Useful
@@ -36,6 +36,9 @@ class SpecialPrefixindex extends SpecialAllpages {
protected $hideRedirects = false;
+ // number of columns in output table
+ protected $columns = 3;
+
// Inherit $maxPerPage
function __construct() {
@@ -44,7 +47,7 @@ class SpecialPrefixindex extends SpecialAllpages {
/**
* Entry point : initialise variables and call subfunctions.
- * @param string $par becomes "FOO" when called like Special:Prefixindex/FOO (default null)
+ * @param string $par Becomes "FOO" when called like Special:Prefixindex/FOO (default null)
*/
function execute( $par ) {
global $wgContLang;
@@ -63,16 +66,17 @@ class SpecialPrefixindex extends SpecialAllpages {
$namespace = (int)$ns; // if no namespace given, use 0 (NS_MAIN).
$this->hideRedirects = $request->getBool( 'hideredirects', $this->hideRedirects );
$this->stripPrefix = $request->getBool( 'stripprefix', $this->stripPrefix );
+ $this->columns = $request->getInt( 'columns', $this->columns );
$namespaces = $wgContLang->getNamespaces();
$out->setPageTitle(
- ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces ) ) )
+ ( $namespace > 0 && array_key_exists( $namespace, $namespaces ) )
? $this->msg( 'prefixindex-namespace', str_replace( '_', ' ', $namespaces[$namespace] ) )
: $this->msg( 'prefixindex' )
);
$showme = '';
- if ( isset( $par ) ) {
+ if ( $par !== null ) {
$showme = $par;
} elseif ( $prefix != '' ) {
$showme = $prefix;
@@ -92,16 +96,14 @@ class SpecialPrefixindex extends SpecialAllpages {
/**
* HTML for the top form
- * @param $namespace Integer: a namespace constant (default NS_MAIN).
- * @param string $from dbKey we are starting listing at.
+ * @param int $namespace A namespace constant (default NS_MAIN).
+ * @param string $from DbKey we are starting listing at.
* @return string
*/
protected function namespacePrefixForm( $namespace = NS_MAIN, $from = '' ) {
- global $wgScript;
-
$out = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) );
- $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
- $out .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() );
+ $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $this->getConfig()->get( 'Script' ) ) );
+ $out .= Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() );
$out .= Xml::openElement( 'fieldset' );
$out .= Xml::element( 'legend', null, $this->msg( 'allpages' )->text() );
$out .= Xml::openElement( 'table', array( 'id' => 'nsselect', 'class' => 'allpages' ) );
@@ -149,9 +151,9 @@ class SpecialPrefixindex extends SpecialAllpages {
}
/**
- * @param $namespace Integer, default NS_MAIN
- * @param $prefix String
- * @param string $from list all pages from this name (default FALSE)
+ * @param int $namespace Default NS_MAIN
+ * @param string $prefix
+ * @param string $from List all pages from this name (default false)
*/
protected function showPrefixChunk( $namespace = NS_MAIN, $prefix, $from = null ) {
global $wgContLang;
@@ -163,10 +165,11 @@ class SpecialPrefixindex extends SpecialAllpages {
$fromList = $this->getNamespaceKeyAndText( $namespace, $from );
$prefixList = $this->getNamespaceKeyAndText( $namespace, $prefix );
$namespaces = $wgContLang->getNamespaces();
+ $res = null;
if ( !$prefixList || !$fromList ) {
$out = $this->msg( 'allpagesbadtitle' )->parseAsBlock();
- } elseif ( !in_array( $namespace, array_keys( $namespaces ) ) ) {
+ } elseif ( !array_key_exists( $namespace, $namespaces ) ) {
// Show errormessage and reset to NS_MAIN
$out = $this->msg( 'allpages-bad-ns', $namespace )->parse();
$namespace = NS_MAIN;
@@ -203,7 +206,7 @@ class SpecialPrefixindex extends SpecialAllpages {
$n = 0;
if ( $res->numRows() > 0 ) {
- $out = Xml::openElement( 'table', array( 'id' => 'mw-prefixindex-list-table' ) );
+ $out = Xml::openElement( 'table', array( 'class' => 'mw-prefixindex-list-table' ) );
$prefixLength = strlen( $prefix );
while ( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
@@ -224,17 +227,17 @@ class SpecialPrefixindex extends SpecialAllpages {
} else {
$link = '[[' . htmlspecialchars( $s->page_title ) . ']]';
}
- if ( $n % 3 == 0 ) {
+ if ( $n % $this->columns == 0 ) {
$out .= '<tr>';
}
$out .= "<td>$link</td>";
$n++;
- if ( $n % 3 == 0 ) {
+ if ( $n % $this->columns == 0 ) {
$out .= '</tr>';
}
}
- if ( $n % 3 != 0 ) {
+ if ( $n % $this->columns != 0 ) {
$out .= '</tr>';
}
@@ -249,7 +252,7 @@ class SpecialPrefixindex extends SpecialAllpages {
$out2 = '';
} else {
$nsForm = $this->namespacePrefixForm( $namespace, $prefix );
- $self = $this->getTitle();
+ $self = $this->getPageTitle();
$out2 = Xml::openElement( 'table', array( 'id' => 'mw-prefixindex-nav-table' ) ) .
'<tr>
<td>' .
@@ -257,14 +260,13 @@ class SpecialPrefixindex extends SpecialAllpages {
'</td>
<td id="mw-prefixindex-nav-form" class="mw-prefixindex-nav">';
- if ( isset( $res ) && $res && ( $n == $this->maxPerPage ) &&
- ( $s = $res->fetchObject() )
- ) {
+ if ( $res && ( $n == $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
$query = array(
'from' => $s->page_title,
'prefix' => $prefix,
'hideredirects' => $this->hideRedirects,
'stripprefix' => $this->stripPrefix,
+ 'columns' => $this->columns,
);
if ( $namespace || $prefix == '' ) {