mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 11:05:56 +02:00
BUG Fixing search not working when no specific versions of docs
This commit is contained in:
parent
6eca5af929
commit
4a1e5436eb
@ -198,7 +198,7 @@ class DocumentationSearch {
|
||||
public function performSearch() {
|
||||
try {
|
||||
$index = Zend_Search_Lucene::open(self::get_index_location());
|
||||
|
||||
|
||||
Zend_Search_Lucene::setResultSetLimit(100);
|
||||
|
||||
$query = new Zend_Search_Lucene_Search_Query_Boolean();
|
||||
@ -214,7 +214,7 @@ class DocumentationSearch {
|
||||
|
||||
$query->addSubquery($moduleQuery, true);
|
||||
}
|
||||
|
||||
|
||||
if($this->versions) {
|
||||
$versionQuery = new Zend_Search_Lucene_Search_Query_MultiTerm();
|
||||
|
||||
@ -229,7 +229,6 @@ class DocumentationSearch {
|
||||
error_reporting('E_ALL ^ E_NOTICE');
|
||||
$this->results = $index->find($query);
|
||||
error_reporting($er);
|
||||
|
||||
$this->totalResults = $index->numDocs();
|
||||
}
|
||||
catch(Zend_Search_Lucene_Exception $e) {
|
||||
|
@ -821,14 +821,14 @@ class DocumentationViewer extends Controller {
|
||||
new HiddenField('Entities', '', implode(',', array_keys($this->getSearchedEntities()))),
|
||||
new HiddenField('Versions', '', implode(',', $this->getSearchedVersions()))
|
||||
);
|
||||
|
||||
|
||||
$actions = new FieldList(
|
||||
new FormAction('results', 'Search')
|
||||
);
|
||||
|
||||
|
||||
$form = new Form($this, 'DocumentationSearchForm', $fields, $actions);
|
||||
$form->disableSecurityToken();
|
||||
$form->setFormMethod('get');
|
||||
$form->setFormMethod('GET');
|
||||
$form->setFormAction(self::$link_base . 'DocumentationSearchForm');
|
||||
|
||||
return $form;
|
||||
@ -842,7 +842,7 @@ class DocumentationViewer extends Controller {
|
||||
function getSearchedEntities() {
|
||||
$entities = array();
|
||||
|
||||
if(isset($_REQUEST['Entities'])) {
|
||||
if(!empty($_REQUEST['Entities'])) {
|
||||
if(is_array($_REQUEST['Entities'])) {
|
||||
$entities = Convert::raw2att($_REQUEST['Entities']);
|
||||
}
|
||||
@ -866,7 +866,7 @@ class DocumentationViewer extends Controller {
|
||||
function getSearchedVersions() {
|
||||
$versions = array();
|
||||
|
||||
if(isset($_REQUEST['Versions'])) {
|
||||
if(!empty($_REQUEST['Versions'])) {
|
||||
if(is_array($_REQUEST['Versions'])) {
|
||||
$versions = Convert::raw2att($_REQUEST['Versions']);
|
||||
$versions = array_combine($versions, $versions);
|
||||
@ -900,7 +900,7 @@ class DocumentationViewer extends Controller {
|
||||
*/
|
||||
function results($data, $form = false) {
|
||||
$query = (isset($_REQUEST['Search'])) ? $_REQUEST['Search'] : false;
|
||||
|
||||
|
||||
$search = new DocumentationSearch();
|
||||
$search->setQuery($query);
|
||||
$search->setVersions($this->getSearchedVersions());
|
||||
@ -959,7 +959,7 @@ class DocumentationViewer extends Controller {
|
||||
|
||||
$form = new Form($this, 'AdvancedSearchForm', $fields, $actions, $required);
|
||||
$form->disableSecurityToken();
|
||||
$form->setFormMethod('get');
|
||||
$form->setFormMethod('GET');
|
||||
$form->setFormAction(self::$link_base . 'DocumentationSearchForm');
|
||||
|
||||
return $form;
|
||||
|
Loading…
Reference in New Issue
Block a user