ItSpiderman has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/403927 )
Change subject: [WIP] Add export results to wiki-list functionality
......................................................................
[WIP] Add export results to wiki-list functionality
Change-Id: Ic068ecb7e5b8656c34c0c85149982ac42d4ee038
ERM: #8210
---
M ExtendedSearch/extension.json
M ExtendedSearch/includes/ExtendedSearchBase.class.php
M ExtendedSearch/includes/SearchIndex/SearchResult.class.php
A ExtendedSearch/views/view.ExportSearchForm.php
4 files changed, 84 insertions(+), 4 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions
refs/changes/27/403927/1
diff --git a/ExtendedSearch/extension.json b/ExtendedSearch/extension.json
index 725e11a..bdd03ad 100644
--- a/ExtendedSearch/extension.json
+++ b/ExtendedSearch/extension.json
@@ -68,7 +68,8 @@
"ViewMoreLikeThis": "views/view.MoreLikeThis.php",
"ViewExtendedSearchResultEntry":
"views/view.ExtendedSearchResultEntry.php",
"SpecialExtendedSearch":
"includes/specials/SpecialExtendedSearch.class.php",
- "TagCloudSearchStatsHandler":
"includes/Handler/TagCloudSearchStatsHandler.class.php"
+ "TagCloudSearchStatsHandler":
"includes/Handler/TagCloudSearchStatsHandler.class.php",
+ "ViewExportSearchForm": "views/view.ExportSearchForm.php"
},
"ResourceModules": {
"ext.bluespice.extendedsearch.focus": {
diff --git a/ExtendedSearch/includes/ExtendedSearchBase.class.php
b/ExtendedSearch/includes/ExtendedSearchBase.class.php
index df49bd6..4718988 100644
--- a/ExtendedSearch/includes/ExtendedSearchBase.class.php
+++ b/ExtendedSearch/includes/ExtendedSearchBase.class.php
@@ -172,7 +172,14 @@
$vNoOfResultsFound = new ViewNoOfResultsFound();
$vNoOfResultsFound->setOptions( $aMonitor );
+ $vExportSearchForm = new ViewExportSearchForm();
+ if( !empty( $aMonitor['exportHits'] ) ) {
+ $this->parseExportHits( $aMonitor );
+ }
+ $vExportSearchForm->setOptions( $aMonitor );
+
$oView->addItem( $vNoOfResultsFound );
+ $oView->addItem( $vExportSearchForm );
$oView->addItem( $oResultView );
return $oView;
@@ -767,4 +774,14 @@
return $oResponse;
}
+ protected function parseExportHits ( &$aMonitor ) {
+ $aHitTitles = [];
+ foreach( $aMonitor['exportHits'] as $oTitle ) {
+ if( $oTitle->exists() ) {
+ $aHitTitles[] = $oTitle->getFullText();
+ }
+ }
+ $aMonitor['exportHits'] = implode( ';', $aHitTitles );
+ }
+
}
\ No newline at end of file
diff --git a/ExtendedSearch/includes/SearchIndex/SearchResult.class.php
b/ExtendedSearch/includes/SearchIndex/SearchResult.class.php
index 210bcf0..a45ab9b 100644
--- a/ExtendedSearch/includes/SearchIndex/SearchResult.class.php
+++ b/ExtendedSearch/includes/SearchIndex/SearchResult.class.php
@@ -116,7 +116,7 @@
$this->createFacets();
}
- $this->createResults();
+ $this->createResults( $aMonitor );
return $this->vSearchResult;
}
@@ -340,9 +340,9 @@
/**
* Creates the results
*/
- private function createResults() {
+ private function createResults( &$aMonitor ) {
$oParser = new Parser();
-
+ $aMonitor['exportHits'] = [];
foreach ( $this->oResponse->response->docs as $oDocument ) {
//If pseudo namespace '999' we need tu use NS_FILE to
have a
//valid title object
@@ -371,6 +371,7 @@
if ( empty( $sSearchLink ) ) {
if ( $oDocument->type == 'wiki' ) {
if ( !$oTitle->userCan( 'read' ) )
continue;
+ $aMonitor['exportHits'][] = $oTitle;
$sSearchLink = $this->getWikiLink(
$oDocument, $oTitle, $oParser );
} elseif (
$this->oContext->getUser()->isAllowed( 'searchfiles' ) ) {
$sSearchLink = $this->getFileLink(
$oDocument, $oTitle );
diff --git a/ExtendedSearch/views/view.ExportSearchForm.php
b/ExtendedSearch/views/view.ExportSearchForm.php
new file mode 100644
index 0000000..29e367c
--- /dev/null
+++ b/ExtendedSearch/views/view.ExportSearchForm.php
@@ -0,0 +1,61 @@
+<?php
+
+class ViewExportSearchForm extends ViewBaseElement {
+ public function __construct () {
+ parent::__construct ();
+ }
+
+ public function execute ( $params = false ) {
+ $sInputFields[] = Xml::input(
+ 'title',
+ false,
+ $this->getOption ( 'exportHits' ),
+ array(
+ 'type' => 'hidden'
+ )
+ );
+
+ $sInputFields[] = Xml::input(
+ 'hits',
+ false,
+ SpecialPage::getTitleFor( 'SpecialExtendedSearch'
)->getFullText(),
+ array(
+ 'type' => 'hidden'
+ )
+ );
+
+ $sInputFields[] = Xml::input(
+ 'list_name',
+ false,
+ '',
+ array(
+ 'type' => 'text'
+ )
+ );
+
+ $sInputFields[] = Xml::openElement(
+ 'button',
+ array(
+ 'title' => "Export search",
+ 'id' => 'bs-export-search'
+ )
+ );
+ $sInputFields[] = "Export";
+ $sInputFields[] = Xml::closeElement( 'button' );
+
+
+ global $wgScript;
+ $aFormAttributes = array(
+ 'id' => 'bs-extendedsearch-form-export',
+ 'action' => $wgScript,
+ 'method' => 'post'
+ );
+
+ $aForm = array();
+ $aForm[] = Html::openElement( 'form', $aFormAttributes );
+ $aForm[] = implode( "\n", $sInputFields );
+ $aForm[] = Xml::closeElement( 'form' );
+
+ return implode( "\n", $aForm );
+ }
+}
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/403927
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic068ecb7e5b8656c34c0c85149982ac42d4ee038
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: REL1_27
Gerrit-Owner: ItSpiderman <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits