Glaisher has uploaded a new change for review.
https://gerrit.wikimedia.org/r/249386
Change subject: Use HTMLForm in Special:AllPages
......................................................................
Use HTMLForm in Special:AllPages
Also make HTMLSelectNamespace's work when 'all' is set to null.
Change-Id: Ia559b52464bceaf1202e3a6696728781bb62cdbc
---
M includes/htmlform/HTMLSelectNamespace.php
M includes/specials/SpecialAllPages.php
2 files changed, 53 insertions(+), 56 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/86/249386/1
diff --git a/includes/htmlform/HTMLSelectNamespace.php
b/includes/htmlform/HTMLSelectNamespace.php
index 4efdfbf..a7d532d 100644
--- a/includes/htmlform/HTMLSelectNamespace.php
+++ b/includes/htmlform/HTMLSelectNamespace.php
@@ -5,7 +5,15 @@
class HTMLSelectNamespace extends HTMLFormField {
public function __construct( $params ) {
parent::__construct( $params );
- $this->mAllValue = isset( $this->mParams['all'] ) ?
$this->mParams['all'] : 'all';
+
+ if ( isset( $params['all'] ) ) {
+ $this->mAllValue = $params['all'];
+ } elseif ( is_null( $params['all'] ) ) {
+ $this->mAllValue = null;
+ } else {
+ $this->mAllValue = 'all';
+ }
+
}
function getInputHTML( $value ) {
diff --git a/includes/specials/SpecialAllPages.php
b/includes/specials/SpecialAllPages.php
index 0c1a941..8fdf69e 100644
--- a/includes/specials/SpecialAllPages.php
+++ b/includes/specials/SpecialAllPages.php
@@ -71,7 +71,7 @@
$namespace = $request->getInt( 'namespace' );
$hideredirects = $request->getBool( 'hideredirects', false );
- $namespaces =
$this->getContext()->getLanguage()->getNamespaces();
+ $namespaces = $this->getLanguage()->getNamespaces();
$out->setPageTitle(
( $namespace > 0 && array_key_exists( $namespace,
$namespaces ) ) ?
@@ -95,59 +95,48 @@
* @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)
- * @return string
+ * @param bool $hideRedirects Dont show redirects (default false)
*/
- function namespaceForm( $namespace = NS_MAIN, $from = '', $to = '',
$hideredirects = false ) {
- $t = $this->getPageTitle();
- $out = Xml::openElement( 'div', array( 'class' =>
'namespaceoptions' ) );
- $out .= Xml::openElement(
- 'form',
- array( 'method' => 'get', 'action' =>
$this->getConfig()->get( 'Script' ) )
+ public function namespaceForm( $namespace = NS_MAIN, $from = '', $to =
'', $hideRedirects = false ) {
+ $fields = array(
+ 'from' => array(
+ 'type' => 'text',
+ 'name' => 'from',
+ 'id' => 'nsfrom',
+ 'size' => 30,
+ 'label-message' => 'allpagesfrom',
+ 'default' => str_replace( '_', ' ', $from ),
+ ),
+ 'to' => array(
+ 'type' => 'text',
+ 'name' => 'to',
+ 'id' => 'nsto',
+ 'size' => 30,
+ 'label-message' => 'allpagesto',
+ 'default' => str_replace( '_', ' ', $to ),
+ ),
+ 'namespace' => array(
+ 'type' => 'namespaceselect',
+ 'name' => 'namespace',
+ 'id' => 'namespace',
+ 'label-message' => 'namespace',
+ 'all' => null,
+ 'value' => $namespace,
+ ),
+ 'hideredirects' => array(
+ 'type' => 'check',
+ 'name' => 'hideredirects',
+ 'id' => 'hidredirects',
+ 'label-message' => 'allpages-hide-redirects',
+ 'value' => $hideRedirects,
+ ),
);
- $out .= Html::hidden( 'title', $t->getPrefixedText() );
- $out .= Xml::openElement( 'fieldset' );
- $out .= Xml::element( 'legend', null, $this->msg( 'allpages'
)->text() );
- $out .= Xml::openElement( 'table', array( 'id' => 'nsselect',
'class' => 'allpages' ) );
- $out .= "<tr>
- <td class='mw-label'>" .
- Xml::label( $this->msg( 'allpagesfrom' )->text(),
'nsfrom' ) .
- " </td>
- <td class='mw-input'>" .
- Xml::input( 'from', 30, str_replace( '_', ' ', $from ),
array( 'id' => 'nsfrom' ) ) .
- " </td>
-</tr>
-<tr>
- <td class='mw-label'>" .
- Xml::label( $this->msg( 'allpagesto' )->text(), 'nsto'
) .
- " </td>
- <td class='mw-input'>" .
- Xml::input( 'to', 30, str_replace( '_', ' ', $to ),
array( 'id' => 'nsto' ) ) .
- " </td>
-</tr>
-<tr>
- <td class='mw-label'>" .
- Xml::label( $this->msg( 'namespace' )->text(),
'namespace' ) .
- " </td>
- <td class='mw-input'>" .
- Html::namespaceSelector(
- array( 'selected' => $namespace ),
- array( 'name' => 'namespace', 'id' =>
'namespace' )
- ) . ' ' .
- Xml::checkLabel(
- $this->msg( 'allpages-hide-redirects' )->text(),
- 'hideredirects',
- 'hideredirects',
- $hideredirects
- ) . ' ' .
- Xml::submitButton( $this->msg( 'allpagessubmit'
)->text() ) .
- " </td>
-</tr>";
- $out .= Xml::closeElement( 'table' );
- $out .= Xml::closeElement( 'fieldset' );
- $out .= Xml::closeElement( 'form' );
- $out .= Xml::closeElement( 'div' );
- return $out;
+ $form = HTMLForm::factory( 'table', $fields,
$this->getContext() );
+ $form->setMethod( 'get' )
+ ->setWrapperLegendMsg( 'allpages' )
+ ->setSubmitTextMsg( 'allpagessubmit' )
+ ->prepareForm()
+ ->displayForm( false );
}
/**
@@ -317,7 +306,7 @@
);
}
- $topOut = $this->namespaceForm( $namespace, $from, $to,
$hideredirects );
+ $this->namespaceForm( $namespace, $from, $to, $hideredirects );
if ( count( $navLinks ) ) {
// Add pagination links
@@ -326,11 +315,11 @@
$this->getLanguage()->pipeList( $navLinks )
);
- $topOut .= $pagination;
+ $output->addHTML( $pagination );
$out .= Html::element( 'hr' ) . $pagination; // Footer
}
- $output->addHTML( $topOut . $out );
+ $output->addHTML( $out );
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/249386
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia559b52464bceaf1202e3a6696728781bb62cdbc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Glaisher <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits