Commit 17edd62b authored by Dainis Abols's avatar Dainis Abols
Browse files

Major search changed, additonal language selects. Needs migrations!

parent fb5ad638
......@@ -44,6 +44,18 @@ class FrontController extends ActionController
{
$this->sourceRepository = $sourceRepository;
}
/**
* SearchController constructor.
*
* Assign page ID
*/
public function __construct()
{
// Set language data
$this->language = [
'file' => 'LLL:EXT:lu_names/Resources/Private/Language/en_locallang.xlf',
];
}
/**
* Detail action
......@@ -63,7 +75,13 @@ class FrontController extends ActionController
$pageRenderer->addCssFile("EXT:lu_names/Resources/Public/Css/names_style.css");
// Change language file
if (!empty($this->settings['pluginLanguage'])) {
$this->language['file'] = 'LLL:EXT:lu_names/Resources/Private/Language/'.$this->settings['pluginLanguage'].'_locallang.xlf';
}
$this->view->assignMultiple($assign);
$this->view->assign('language', $this->language);
}
public function listSourcesAction()
......@@ -81,7 +99,13 @@ class FrontController extends ActionController
$sources = $this->sourceRepository->findAll();
// Change language file
if (!empty($this->settings['pluginLanguage'])) {
$this->language['file'] = 'LLL:EXT:lu_names/Resources/Private/Language/'.$this->settings['pluginLanguage'].'_locallang.xlf';
}
$this->view->assign('sources', $sources);
$this->view->assign('language', $this->language);
}
/**
......
......@@ -4,6 +4,7 @@ namespace Lu\LuNames\Controller;
use Lu\LuApi\DataSources\SolrNames;
use Lu\LuApi\Helpers\DataHelper;
use Lu\LuNames\Domain\Model\Location;
use Lu\LuNames\Domain\Model\Person;
use Lu\LuNames\Domain\Repository\PersonRepository;
use Lu\LuNames\Helpers\CacheHelper;
......@@ -109,7 +110,7 @@ class SearchController extends ActionController
private PersonRepository $personRepository;
/**
* MusicController constructor.
* SearchController constructor.
*
* Assign page ID
*/
......@@ -122,6 +123,7 @@ class SearchController extends ActionController
'id' => $languageAspect->getId(),
'iso' => $iso,
'code' => $iso == 'lv' ? 'lat' : 'eng',
'file' => 'LLL:EXT:lu_names/Resources/Private/Language/en_locallang.xlf',
];
// Set uri builder
......@@ -148,7 +150,7 @@ class SearchController extends ActionController
$cacheHelper = new CacheHelper();
if (empty($request['query'])) {
$request = $this->request->getArguments();
$request += $this->request->getArguments();
}
// Generate letter list
......@@ -207,6 +209,11 @@ class SearchController extends ActionController
// Add custom JS
$this->renderJs();
// Change language file
if (!empty($this->settings['pluginLanguage'])) {
$this->language['file'] = 'LLL:EXT:lu_names/Resources/Private/Language/'.$this->settings['pluginLanguage'].'_locallang.xlf';
}
// Assign variables
$this->view->assign('query', $cleanQuery);
$this->view->assign('letter', $request['letter'] ?? '');
......@@ -221,6 +228,7 @@ class SearchController extends ActionController
$this->view->assign('facets', $facets);
$this->view->assign('letters', $letters);
$this->view->assign('sort', $this->sort);
$this->view->assign('language', $this->language);
}
/**
......@@ -439,11 +447,11 @@ class SearchController extends ActionController
'maiden_name' => @$item['maiden_name'],
],
'birth' => [
'date' => ($item['year_of_birth'] ?? '').($item['month_of_birth'] ? '-'.sprintf("%02d", $item['month_of_birth']) : '').($item['day_of_birth'] ? '-'.sprintf("%02d", $item['day_of_birth']) : ''),
'date' => (new Person())->makeDater($item['year_of_birth'], $item['month_of_birth'], $item['day_of_birth']),
'day' => @$item['day_of_birth'],
'month' => @$item['month_of_birth'],
'year' => @$item['year_of_birth'],
'location' => @$item['place_of_birth'],
'location' => (new Location())->getTitleByIds(@$item['place_of_birth']),
],
'life' => [
'location' => trim(
......@@ -451,16 +459,16 @@ class SearchController extends ActionController
($item['prewar_residence'] ? "Pre-war residence: ".$item['prewar_residence'].". " : '').
($item['war_residence'] ? "War residence: ".$item['war_residence'].". " : ''), ". "
),
'region' => @$item['region'],
'prewar' => @$item['prewar_residence'],
'war' => @$item['war_residence'],
'region' => (new Location())->getTitleByIds(@$item['region']),
'prewar' => (new Location())->getTitleByIds(@$item['prewar_residence']),
'war' => (new Location())->getTitleByIds(@$item['war_residence']),
],
'death' => [
'date' => ($item['year_of_death'] ?? '').($item['month_of_death'] ? '-'.sprintf("%02d", $item['month_of_death']) : '').($item['day_of_death'] ? '-'.sprintf("%02d", $item['day_of_death']) : ''),
'date' => (new Person())->makeDater($item['year_of_death'], $item['month_of_death'], $item['day_of_death']),
'day' => @$item['day_of_death'],
'month' => @$item['month_of_death'],
'year' => @$item['year_of_death'],
'location' => @$item['place_of_death'],
'location' => (new Location())->getTitleByIds(@$item['place_of_death']),
],
'gender' => @$item['gender'],
'family' => [
......
......@@ -13,6 +13,13 @@ use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
*/
class FamilyStatus extends AbstractEntity
{
/**
* Table name
*
* @var string
*/
protected $table = 'tx_lunames_domain_model_familystatus';
/**
* The name of the person
*
......@@ -37,14 +44,52 @@ class FamilyStatus extends AbstractEntity
*/
public function getTitleById($uid)
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_lunames_domain_model_familystatus');
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->table);
$queryBuilder->getRestrictions()->removeAll();
$queryBuilder->select('title')
->from('tx_lunames_domain_model_familystatus')
->from($this->table)
->where('uid = '.$uid);
// Read and load data
$result = $queryBuilder->execute()->fetch();
return $result['title'] ?? '';
}
/**
* Fetch all titles title by ids
*
* @param $uid
*
* @return mixed|string
*/
public function getTitleByIds($uid = '')
{
// Return empty, if nothing provided
if (!$uid) {
return '';
}
// Fetch
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->table);
$queryBuilder->getRestrictions()->removeAll();
$queryBuilder->select('title')
->from($this->table)
->where($queryBuilder->expr()->in('uid',$uid));
// Read and load data
$statement = $queryBuilder->execute();
$titles = [];
while ($row = $statement->fetch()) {
$titles[] = $row['title'];
}
// Return back same value if nothing found in database
if (empty($titles)) {
return $uid;
}
// Return implided string version
return implode(', ', $titles);
}
}
......@@ -7,12 +7,19 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
/**
* Class Region
* Class Location
*
* @package Lu\LuNames\Domain\Model
*/
class Location extends AbstractEntity
{
/**
* Table name
*
* @var string
*/
protected $table = 'tx_lunames_domain_model_location';
/**
* @var string
*/
......@@ -43,14 +50,51 @@ class Location extends AbstractEntity
*/
public function getTitleById($uid)
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_lunames_domain_model_location');
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->table);
$queryBuilder->getRestrictions()->removeAll();
$queryBuilder->select('title')
->from('tx_lunames_domain_model_location')
->from($this->table)
->where('uid = '.$uid);
// Read and load data
$result = $queryBuilder->execute()->fetch();
return $result['title'] ?? '';
}
/**
* Fetch all titles title by ids
*
* @param $uid
*
* @return mixed|string
*/
public function getTitleByIds($uid = '')
{
// Return empty, if nothing provided
if (!$uid) {
return '';
}
// Fetch
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->table);
$queryBuilder->getRestrictions()->removeAll();
$queryBuilder->select('title')
->from($this->table)
->where($queryBuilder->expr()->in('uid', explode(',', $uid)));
// Read and load data
$statement = $queryBuilder->execute();
$titles = [];
while ($row = $statement->fetch()) {
$titles[] = $row['title'];
}
// Return back same value if nothing found in database
if (empty($titles)) {
return $uid;
}
// Return implided string version
return implode(', ', $titles);
}
}
......@@ -13,6 +13,13 @@ use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
*/
class Occupation extends AbstractEntity
{
/**
* Table name
*
* @var string
*/
protected $table = 'tx_lunames_domain_model_occupation';
/**
* The name of the person
*
......@@ -37,14 +44,51 @@ class Occupation extends AbstractEntity
*/
public function getTitleById($uid)
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_lunames_domain_model_occupation');
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->table);
$queryBuilder->getRestrictions()->removeAll();
$queryBuilder->select('title')
->from('tx_lunames_domain_model_location')
->from($this->table)
->where('uid = '.$uid);
// Read and load data
$result = $queryBuilder->execute()->fetch();
return $result['title'] ?? '';
}
/**
* Fetch all titles title by ids
*
* @param $uid
*
* @return mixed|string
*/
public function getTitleByIds($uid = '')
{
// Return empty, if nothing provided
if (!$uid) {
return '';
}
// Fetch
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->table);
$queryBuilder->getRestrictions()->removeAll();
$queryBuilder->select('title')
->from($this->table)
->where($queryBuilder->expr()->in('uid',$uid));
// Read and load data
$statement = $queryBuilder->execute();
$titles = [];
while ($row = $statement->fetch()) {
$titles[] = $row['title'];
}
// Return back same value if nothing found in database
if (empty($titles)) {
return $uid;
}
// Return implided string version
return implode(', ', $titles);
}
}
......@@ -439,9 +439,7 @@ class Person extends AbstractEntity
// Check if ID set
$name = $items[$k];
if (is_numeric($name)) {
$name = $this->getTitleByFacet($field, $name);
}
$name = $this->getTitleByFacet($field, $name);
$item[] = [
'uid' => $items[$k],
......@@ -487,16 +485,17 @@ class Person extends AbstractEntity
case 'place_of_death':
case 'prewar_residence':
case 'war_residence':
case 'region':
$myLocation = new Location();
$name = $myLocation->getTitleById($uid);
$name = $myLocation->getTitleByIds($uid);
break;
case 'occupation':
$myLocation = new Occupation();
$name = $myLocation->getTitleById($uid);
$myOccupation = new Occupation();
$name = $myOccupation->getTitleByIds($uid);
break;
case 'family_status':
$myLocation = new FamilyStatus();
$name = $myLocation->getTitleById($uid);
$myFamilyStatus = new FamilyStatus();
$name = $myFamilyStatus->getTitleByIds($uid);
break;
}
......@@ -549,4 +548,34 @@ class Person extends AbstractEntity
// Return finalized url
return $uri['path'].$uri['query'];
}
/**
* Create visual date output
*
* @param $year
* @param null $mopnth
* @param null $day
*
* @return string
*/
public function makeDater($year, $month = null, $day = null)
{
$date = [];
// Add day
if ($day) {
$date[0] = sprintf("%02d", $day);
}
// Add monthy
if ($day) {
$date[1] = sprintf("%02d", $month);
}
// Add year
$date[2] = $year;
// Return imploded version
return implode('.', $date);
}
}
......@@ -12,29 +12,28 @@
<el>
<switchableControllerActions>
<TCEforms>
<label>LLL:EXT:lu_names/Resources/Private/Language/locallang.xlf:plugin.mode.label</label>
<label>LLL:EXT:lu_names/Resources/Private/Language/en_locallang.xlf:plugin.mode.label</label>
<onChange>reload</onChange>
<config>
<type>select</type>
<renderType>selectSingle</renderType>
<items>
<numIndex index="1">
<numIndex index="0">LLL:EXT:lu_names/Resources/Private/Language/locallang.xlf:plugin.mode.searchResults</numIndex>
<numIndex index="0">LLL:EXT:lu_names/Resources/Private/Language/en_locallang.xlf:plugin.mode.searchResults</numIndex>
<numIndex index="1">Search->list</numIndex>
</numIndex>
<numIndex index="2">
<numIndex index="0">LLL:EXT:lu_names/Resources/Private/Language/locallang.xlf:plugin.mode.sources</numIndex>
<numIndex index="0">LLL:EXT:lu_names/Resources/Private/Language/en_locallang.xlf:plugin.mode.sources</numIndex>
<numIndex index="1">Front->listSources</numIndex>
</numIndex>
<numIndex index="3">
<numIndex index="0">LLL:EXT:lu_names/Resources/Private/Language/locallang.xlf:plugin.mode.detail</numIndex>
<numIndex index="0">LLL:EXT:lu_names/Resources/Private/Language/en_locallang.xlf:plugin.mode.detail</numIndex>
<numIndex index="1">Front->detail</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</switchableControllerActions>
<settings.detailPageId>
<TCEforms>
<label>Detail page id</label>
......@@ -48,6 +47,29 @@
</config>
</TCEforms>
</settings.detailPageId>
<settings.pluginLanguage>
<TCEforms>
<label>LLL:EXT:lu_names/Resources/Private/Language/en_locallang.xlf:plugin.language.label</label>
<config>
<type>select</type>
<renderType>selectSingle</renderType>
<items>
<numIndex index="1">
<numIndex index="0">English</numIndex>
<numIndex index="1">en</numIndex>
</numIndex>
<numIndex index="2">
<numIndex index="0">Latviešu</numIndex>
<numIndex index="1">lv</numIndex>
</numIndex>
<numIndex index="3">
<numIndex index="0">Русский</numIndex>
<numIndex index="1">ru</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</settings.pluginLanguage>
</el>
</ROOT>
</sDEF>
......
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2021-04-12T09:35:55Z">
<header>
<generator>LFEditor</generator>
</header>
<body>
<trans-unit id="administration.noRecordsFound">
<source><![CDATA[No records to display]]></source>
</trans-unit>
<trans-unit id="administration.title">
<source><![CDATA[Names Administration]]></source>
</trans-unit>
<trans-unit id="extension.description">
<source><![CDATA[Jews in Latvia names database extension for TYPO3]]></source>
</trans-unit>
<trans-unit id="extension.title">
<source><![CDATA[Names]]></source>
</trans-unit>
<trans-unit id="facet.family_status">
<source><![CDATA[Marital Status]]></source>
</trans-unit>
<trans-unit id="facet.gender">
<source><![CDATA[Gender]]></source>
</trans-unit>
<trans-unit id="facet.gender.f">
<source><![CDATA[Female]]></source>
</trans-unit>
<trans-unit id="facet.gender.m">
<source><![CDATA[Male]]></source>
</trans-unit>
<trans-unit id="facet.occupation">
<source><![CDATA[Occupation]]></source>
</trans-unit>
<trans-unit id="facet.region">
<source><![CDATA[Region]]></source>
</trans-unit>
<trans-unit id="facet.place_of_birth">
<source><![CDATA[Place of Birth]]></source>
</trans-unit>
<trans-unit id="facet.place_of_death">
<source><![CDATA[Place of Death]]></source>
</trans-unit>
<trans-unit id="facet.prewar_residence">
<source><![CDATA[Place of Residence Before the War]]></source>
</trans-unit>
<trans-unit id="facet.war_residence">
<source><![CDATA[Place of Residence During the War]]></source>
</trans-unit>
<trans-unit id="filter.clearFilter">
<source><![CDATA[Clear result and remove filters]]></source>
</trans-unit>
<trans-unit id="filter.description">
<source><![CDATA[Gender, place of residence etc.]]></source>
</trans-unit>
<trans-unit id="filter.select">
<source><![CDATA[Select]]></source>
</trans-unit>
<trans-unit id="filter.selectedParams">
<source><![CDATA[Selected parameters]]></source>
</trans-unit>
<trans-unit id="filter.title">
<source><![CDATA[Filter]]></source>
</trans-unit>
<trans-unit id="found.entries.0">
<source><![CDATA[%s records found]]></source>
</trans-unit>
<trans-unit id="found.entries.1">
<source><![CDATA[%s record found]]></source>
</trans-unit>
<trans-unit id="module.createNewRecord">
<source><![CDATA[Add new]]></source>
</trans-unit>
<trans-unit id="search.results.0" xml:space="preserve">
<source><![CDATA[<h4>Suggestions:</h4>
<ul>
<li>Check spelling.</li>
<li>Try using fewer or broader keywords.</li>
<li>Change the filtering criteria in one or more filter fields.</li>
</ul>]]></source>
</trans-unit>
<trans-unit id="sort.default">
<source><![CDATA[Relevance]]></source>
</trans-unit>
<trans-unit id="sort.family_name">
<source><![CDATA[Family Name]]></source>
</trans-unit>
<trans-unit id="sort.given_name">
<source><![CDATA[Given Name]]></source>
</trans-unit>
<trans-unit id="sort.last_name">
<source><![CDATA[Family Name]]></source>
</trans-unit>
<trans-unit id="sort.maiden_name">
<source><![CDATA[Family Name]]></source>
</trans-unit>
<trans-unit id="sort.mother">
<source><![CDATA[Matriname]]></source>
</trans-unit>
<trans-unit id="sortBySelect.default">
<source><![CDATA[Relevance]]></source>
</trans-unit>
<trans-unit id="sortBySelect.family_name">
<source><![CDATA[Family Name]]></source>
</trans-unit>
<trans-unit id="sortBySelect.given_name">
<source><![CDATA[Given Name]]></source>
</trans-unit>
<trans-unit id="sortBySelect.maiden_name">
<source><![CDATA[Family Name]]></source>
</trans-unit>
<trans-unit id="sortBySelect.mother">
<source><![CDATA[Matriname]]></source>
</trans-unit>
<trans-unit id="sortBySelect.title">
<source><![CDATA[Sort by]]></source>
</trans-unit>
<trans-unit id="tx_lunames_domain_model_familystatus.add">
<source><![CDATA[Add new]]></source>
</trans-unit>
<trans-unit id="tx_lunames_domain_model_familystatus.label">
<source><![CDATA[Marital Status]]></source>
</trans-unit>
<trans-unit id="tx_lunames_domain_model_location.add">
<source><![CDATA[Add new]]></source>