jenkins-bot has submitted this change and it was merged.
Change subject: Make Special:IndexPages transcludable and with parameters
......................................................................
Make Special:IndexPages transcludable and with parameters
The Index page search results can now be transcluded, with three
optional parameters:
* key -- the search term
* order -- whether to order by 'quality', 'size', or 'alpha'
* sortascending -- to reverse the normal sort direction
Bug: T114346
Change-Id: I7636ee00929c4177745fb3dad6cf0d48cf0d88de
---
M SpecialProofreadPages.php
1 file changed, 38 insertions(+), 23 deletions(-)
Approvals:
Tpt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/SpecialProofreadPages.php b/SpecialProofreadPages.php
index 2d27998..a457d61 100644
--- a/SpecialProofreadPages.php
+++ b/SpecialProofreadPages.php
@@ -24,10 +24,11 @@
public function __construct( $name = 'IndexPages' ) {
parent::__construct( $name );
+ $this->mIncludable = true;
}
public function execute( $parameters ) {
- global $wgDisableTextSearch, $wgScript;
+ global $wgDisableTextSearch;
$this->setHeaders();
if ( $this->limit == 0 && $this->offset == 0 ) {
@@ -45,29 +46,12 @@
$this->suppressSqlOffset = false;
if ( !$wgDisableTextSearch ) {
- $orderSelect = new XmlSelect( 'order', 'order',
$this->queryOrder );
- $orderSelect->addOption( $this->msg(
'proofreadpage_index_status' )->text(), 'quality' );
- $orderSelect->addOption( $this->msg(
'proofreadpage_index_size' )->text(), 'size' );
- $orderSelect->addOption( $this->msg(
'proofreadpage_alphabeticalorder' )->text(), 'alpha' );
- $output->addHTML(
- Html::openElement( 'form', [ 'action' =>
$wgScript ] ) .
- Html::hidden( 'title',
$this->getPageTitle()->getPrefixedText() ) .
- Html::input( 'limit', $this->limit, 'hidden',
[] ) .
- Html::openElement( 'fieldset', [] ) .
- Html::element( 'legend', null, $this->msg(
'proofreadpage_specialpage_legend' )->text() ) .
- Html::openElement( 'p' ) .
- Html::element( 'label', [ 'for' => 'key' ],
$this->msg( 'proofreadpage_specialpage_label_key' )->text() ) . ' ' .
- Html::input( 'key', $this->searchTerm,
'search', [ 'id' => 'key', 'size' => '50' ] ) .
- Html::closeElement( 'p' ) .
- Html::openElement( 'p' ) .
- Html::element( 'label', [ 'for' => 'order' ],
$this->msg( 'proofreadpage_specialpage_label_orderby' )->text() ) . ' ' .
$orderSelect->getHtml() . ' ' .
- Xml::checkLabel( $this->msg(
'proofreadpage_specialpage_label_sortascending' )->text(), 'sortascending',
'sortascending', $this->sortAscending ) . ' ' .
- Xml::submitButton( $this->msg( 'ilsubmit'
)->text() ) .
- Html::closeElement( 'p' ) .
- Html::closeElement( 'fieldset' ) .
- Html::closeElement( 'form' )
- );
+ if ( !$this->including() ) {
+ // Only show the search form when not including
in another page.
+ $output->addHTML( $this->getSearchForm() );
+ }
+
if ( $this->searchTerm ) {
$indexNamespaceId =
ProofreadPage::getIndexNamespaceId();
$searchEngine = SearchEngine::create();
@@ -145,6 +129,37 @@
];
}
+ /**
+ * Get the HTML of the search form.
+ * @return string The HTML, with the <form> as the outermost element.
+ */
+ protected function getSearchForm() {
+ $config = RequestContext::getMain()->getConfig();
+
+ $orderSelect = new XmlSelect( 'order', 'order',
$this->queryOrder );
+ $orderSelect->addOption( $this->msg(
'proofreadpage_index_status' )->text(), 'quality' );
+ $orderSelect->addOption( $this->msg( 'proofreadpage_index_size'
)->text(), 'size' );
+ $orderSelect->addOption( $this->msg(
'proofreadpage_alphabeticalorder' )->text(), 'alpha' );
+
+ $searchForm = Html::openElement( 'form', [ 'action' =>
$config->get( 'Script' ) ] ) .
+ Html::hidden( 'title',
$this->getPageTitle()->getPrefixedText() ) .
+ Html::input( 'limit', $this->limit, 'hidden', [] ) .
+ Html::openElement( 'fieldset', [] ) .
+ Html::element( 'legend', null, $this->msg(
'proofreadpage_specialpage_legend' )->text() ) .
+ Html::openElement( 'p' ) .
+ Html::element( 'label', [ 'for' => 'key' ], $this->msg(
'proofreadpage_specialpage_label_key' )->text() ) . ' ' .
+ Html::input( 'key', $this->searchTerm, 'search', [ 'id'
=> 'key', 'size' => '50' ] ) .
+ Html::closeElement( 'p' ) .
+ Html::openElement( 'p' ) .
+ Html::element( 'label', [ 'for' => 'order' ],
$this->msg( 'proofreadpage_specialpage_label_orderby' )->text() ) . ' ' .
$orderSelect->getHtml() . ' ' .
+ Xml::checkLabel( $this->msg(
'proofreadpage_specialpage_label_sortascending' )->text(), 'sortascending',
'sortascending', $this->sortAscending ) . ' ' .
+ Xml::submitButton( $this->msg( 'ilsubmit' )->text() ) .
+ Html::closeElement( 'p' ) .
+ Html::closeElement( 'fieldset' ) .
+ Html::closeElement( 'form' );
+ return $searchForm;
+ }
+
public function getQueryInfo() {
$conds = [];
if ( $this->searchTerm ) {
--
To view, visit https://gerrit.wikimedia.org/r/323372
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7636ee00929c4177745fb3dad6cf0d48cf0d88de
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ProofreadPage
Gerrit-Branch: master
Gerrit-Owner: Samwilson <[email protected]>
Gerrit-Reviewer: Billinghurst <[email protected]>
Gerrit-Reviewer: Tpt <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits