Skip to content
Snippets Groups Projects
Commit 8a765c82 authored by Demian Katz's avatar Demian Katz
Browse files

CollectionsController now uses search service.

parent 8d7f878f
No related merge requests found
......@@ -26,6 +26,7 @@
* @link http://vufind.org Main Site
*/
namespace VuFind\Controller;
use VuFindSearch\Query\Query;
/**
* Collections Controller
......@@ -65,13 +66,11 @@ class CollectionsController extends AbstractBase
$collections = $this->getCollectionsFromTitle(
$this->params()->fromQuery('title')
);
if (is_array($collections) && count($collections) != 1) {
$view = $this->createViewModel();
$view->collections = $collections;
return $view;
if (count($collections) != 1) {
return $this->createViewModel(array('collections' => $collections));
}
return $this->redirect()
->toRoute('collection', array('id' => $collections[0]['id']));
->toRoute('collection', array('id' => $collections[0]->getUniqueId()));
}
/**
......@@ -331,17 +330,10 @@ class CollectionsController extends AbstractBase
*/
protected function getCollectionsFromTitle($title)
{
$db = \VuFind\Connection\Manager::connectToIndex();
$title = addcslashes($title, '"');
$result = $db->search(
array(
'query' => "is_hierarchy_title:\"$title\"",
'handler' => 'AllFields',
'limit' => $this->getBrowseLimit()
)
);
return isset($result['response']['docs'])
? $result['response']['docs'] : array();
$query = new Query("is_hierarchy_title:\"$title\"", 'AllFields');
$searchService = $this->getServiceLocator()->get('VuFind\Search');
$result = $searchService->search('Solr', $query, 0, $this->getBrowseLimit());
return $result->getRecords();
}
}
......@@ -11,8 +11,8 @@
<div id="disambiguationItemsDiv">
<? foreach ($collections as $i => $collection): ?>
<div class="disambiguationItem <?=$i % 2 ? 'alt ' : ''?>record<?=$i?>">
<a href="<?=$this->url('collection', array('id' => $collection['id']))?>"><?=$this->escapeHtml($collection['title'])?></a>
<p><?=$this->escapeHtml($collection['description'])?></p>
<a href="<?=$this->url('collection', array('id' => $collection->getUniqueId()))?>"><?=$this->escapeHtml($collection->getTitle())?></a>
<p><?=$this->escapeHtml(implode(' ', $collection->getSummary()))?></p>
</div>
<? endforeach; ?>
</div>
......
......@@ -6,8 +6,8 @@
<ul class="results" data-role="listview" data-split-icon="plus" data-split-theme="c">
<? foreach ($collections as $i => $collection): ?>
<li>
<a rel="external" href="<?=$this->url('collection', array('id' => $collection['id']))?>"><h3><?=$this->escapeHtml($collection['title'])?></h3>
<p><?=$this->escapeHtml($collection['description'])?></p>
<a rel="external" href="<?=$this->url('collection', array('id' => $collection->getUniqueId()))?>"><h3><?=$this->escapeHtml($collection->getTitle())?></h3>
<p><?=$this->escapeHtml(implode(' ', $collection->getSummary()))?></p>
</a>
</li>
<? endforeach; ?>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment