Commit f1637b93 authored by Dainis Abols's avatar Dainis Abols
Browse files

Search results changes

parent 63ecdc8d
......@@ -70,6 +70,13 @@ class SearchController extends ActionController
*/
private $filter;
/**
* Mandatory fields
*
* @var array
*/
private $mandatory = [];
/**
* Define pagination limit
*
......@@ -83,12 +90,12 @@ class SearchController extends ActionController
* @var array
*/
private $sort = [
'default' => [],
'given_name' => [],
'maiden_name' => [],
'family_name' => [],
'mother' => [],
];
'default' => [],
'given_name' => [],
'maiden_name' => [],
'family_name' => [],
'mother' => [],
];
/**
* Set default sort
......@@ -118,7 +125,7 @@ class SearchController extends ActionController
{
// Set language data
$languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language');
$iso = $GLOBALS['TYPO3_REQUEST']->getAttribute('language')->getTwoLetterIsoCode();
$iso = $GLOBALS['TYPO3_REQUEST']->getAttribute('language')->getTwoLetterIsoCode();
$this->language = [
'id' => $languageAspect->getId(),
'iso' => $iso,
......@@ -164,7 +171,7 @@ class SearchController extends ActionController
$this->addLetterLinks($letters);
// Get current page @FIXME There has to be a better way!
$currentPage = $this->request->getArguments()['@widget_0']['currentPage'];
$currentPage = $this->request->getArguments()['@widget_0']['currentPage'];
$this->currentPage = !empty($currentPage) ? (int)$currentPage : 1;
$cleanQuery = strip_tags($request['query'] ?? ($_REQUEST['tx_lusearch_pi1']['query'] ?? ''));
......@@ -172,7 +179,6 @@ class SearchController extends ActionController
// Create sort
$this->createSortItem();
// Fetch data from SOLR
if (!empty($cleanQuery)) {
[$data, $facets] = $this->searchGeneral($cleanQuery, $request);
......@@ -245,7 +251,7 @@ class SearchController extends ActionController
$solr = new SolrNames();
$person = new Person();
$filterModel = new Filter($request, $this->frontendSession);
$facets = [];
$facets = [];
// Get current page
$currentPage = !empty($request['@widget_0']['currentPage']) ? (int)$request['@widget_0']['currentPage'] : 1;
......@@ -260,51 +266,58 @@ class SearchController extends ActionController
// Check facet call
if (!empty($request['filter'])) {
foreach($request['filter'] as $name=>$value)
$solr->setFacetFilter($name, $value);
foreach ($request['filter'] as $name => $value) {
$solr->setFacetFilter($name, $value);
}
}
// Set filters
$filters = [
'fate:'.$query,
'father:'.$query,
'spouse:'.$query,
'year_of_birth:'.$query,
'mother:'.$query,
'day_of_death:'.$query,
'maiden_name:'.$query,
'day_of_birth:'.$query,
'given_name:'.$query,
'other_name:'.$query,
'family_name:'.$query,
'year_of_death:'.$query,
'war_residence:'.$query,
'region:'.$query,
'prewar_residence:'.$query,
'fate:('.$query.')',
'father:('.$query.')',
'spouse:('.$query.')',
'year_of_birth:('.$query.')',
'mother:('.$query.')',
'day_of_death:('.$query.')',
'maiden_name:('.$query.')',
'day_of_birth:('.$query.')',
'given_name:('.$query.')',
'other_name:('.$query.')',
'family_name:('.$query.')',
'year_of_death:('.$query.')',
'war_residence:('.$query.')',
'region:('.$query.')',
'prewar_residence:('.$query.')',
];
// Assign filters
$solr->setFilters($filters);
// Set sort
foreach($this->sort as $sort=>$options) {
foreach ($this->sort as $sort => $options) {
if ($options['selected'] == 1) {
switch ($sort) {
case 'default':
$solr->sort('', '');
break;
case 'given_name':
$this->mandatory[] = 'given_name';
$solr->sort('given_name', 'asc');
$solr->sort('family_name', 'asc');
break;
case 'maiden_name':
$this->mandatory[] = 'maiden_name';
$solr->sort('maiden_name', 'asc');
$solr->sort('family_name', 'asc');
$solr->sort('given_name', 'asc');
break;
case 'family_name':
$this->mandatory[] = 'family_name';
$solr->sort('family_name', 'asc');
$solr->sort('given_name', 'asc');
break;
case 'mother':
$this->mandatory[] = 'mother';
$solr->sort('mother', 'asc');
$solr->sort('family_name', 'asc');
$solr->sort('given_name', 'asc');
......@@ -313,6 +326,9 @@ class SearchController extends ActionController
}
}
// Set mandatory fields
$solr->setMandatory($this->mandatory);
// Fetch data
$jsonData = $solr->fetch(true);
$result = $dataHelper->APIDecode($jsonData);
......@@ -344,8 +360,9 @@ class SearchController extends ActionController
$request = $this->getUrlRequest();
if (!empty($request['filter'])) {
foreach($request['filter'] as $name=>$value)
foreach ($request['filter'] as $name => $value) {
$solr->setFacetFilter($name, $value);
}
}
// Set filters
......@@ -355,7 +372,7 @@ class SearchController extends ActionController
$solr->setFilters($filters);
// Set sort
foreach($this->sort as $sort=>$options) {
foreach ($this->sort as $sort => $options) {
if ($options['selected'] == 1) {
switch ($sort) {
case 'default':
......@@ -533,10 +550,10 @@ class SearchController extends ActionController
if (!$path) {
parse_str($uri['query'], $request);
} else {
$request = explode('&', $uri['query']);
$request = explode('&', $uri['query']);
$newRequest = [];
foreach($request as $key=> $req) {
$req = explode('=', $req);
foreach ($request as $key => $req) {
$req = explode('=', $req);
$newRequest[$req[0]] = $req[1];
}
$request = $newRequest;
......@@ -561,12 +578,12 @@ class SearchController extends ActionController
$request = $this->getUrlRequest(true);
$thisSort = !empty($request['request']['sort']) ? $request['request']['sort'] : $this->default_sort;
foreach($this->sort as $sortKey => &$sortItem) {
foreach ($this->sort as $sortKey => &$sortItem) {
$request['request']['sort'] = $sortKey;
// Rebuild sort
$url = [];
foreach($request['request'] as $key=>$value) {
foreach ($request['request'] as $key => $value) {
if (!(strpos($key, 'currentPage') > 0 || strpos($key, 'cHash') === 0)) {
$url[] = $key.'='.$value;
}
......@@ -590,12 +607,12 @@ class SearchController extends ActionController
private function getVisualsFilter($filters)
{
// Preset
$visual = [];
$visual = [];
$myPerson = new Person();
// Fetch title and move value to key
foreach($filters as $field => $items){
foreach($items as $item) {
foreach ($filters as $field => $items) {
foreach ($items as $item) {
$visual[$field][$item] = $myPerson->getTitleByFacet($field, $item);
}
}
......
......@@ -140,10 +140,10 @@
<td>
<f:if condition="{person.gender} == 'f'">
<f:then>
<f:translate key="{language.file}:tx_lunames_domain_model_person.gender.female" default="Female"/>
Female
</f:then>
<f:else>
<f:translate key="{language.file}:tx_lunames_domain_model_person.gender.male" default="Male"/>
Male
</f:else>
</f:if>
</td>
......
{
"name": "luitd/lu-names",
"version": "1.2.4",
"version": "1.3.0",
"description": "Jews in Latvia names database extension for TYPO3",
"type": "typo3-cms-extension",
"keywords": [
......
......@@ -9,11 +9,11 @@ $EM_CONF[$_EXTKEY] = [
'author_email' => 'lauris.karklis@lu.lv, dainis.abols@lu.lv',
'state' => 'stable',
'clearCacheOnLoad' => true,
'version' => '1.2.4',
'version' => '1.3.0',
'constraints' => [
'depends' => [
'typo3' => '9.5.0-10.9.99',
'lu_api' => '2.6.0-2.9.99',
'lu_api' => '2.7.0-2.9.99',
],
],
'autoload' => [
......
......@@ -4,7 +4,7 @@ Jews in Latvia names database extension for TYPO3TYPO3 Extension for Regulations
## Version
1.2.4
1.3.0
## Dependecies
......
Supports Markdown
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