Commit 3f8943b1 authored by Dainis Abols's avatar Dainis Abols
Browse files

Added url slug for clean names and missing language strings

1.0.3
parent 7d20f9e3
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
namespace Lu\LuNames\Command; namespace Lu\LuNames\Command;
use Lu\LuNames\Domain\Model\Person;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx; use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Core\Bootstrap; use TYPO3\CMS\Core\Core\Bootstrap;
...@@ -41,6 +41,7 @@ class ImportCommand extends Command ...@@ -41,6 +41,7 @@ class ImportCommand extends Command
$inputFile = $input->getArgument('xlsxFile'); $inputFile = $input->getArgument('xlsxFile');
$storagePid = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('lu_names')['storage_page_id']; $storagePid = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('lu_names')['storage_page_id'];
$personModel = GeneralUtility::makeInstance(Person::class);
$db = new \PDO('mysql:host='.$config['DB']['Connections']['Default']['host'].';dbname='.$config['DB']['Connections']['Default']['dbname'], $config['DB']['Connections']['Default']['user'], $config['DB']['Connections']['Default']['password']); $db = new \PDO('mysql:host='.$config['DB']['Connections']['Default']['host'].';dbname='.$config['DB']['Connections']['Default']['dbname'], $config['DB']['Connections']['Default']['user'], $config['DB']['Connections']['Default']['password']);
...@@ -192,9 +193,12 @@ class ImportCommand extends Command ...@@ -192,9 +193,12 @@ class ImportCommand extends Command
} }
} }
$slug = $personModel->generateSlug($personId, $row['B'], $row['E']);
$sourcesCount = empty($sources) ? '' : count(explode(' ', $sources));
$insert = '('.$personId.', '.$storagePid.', '.time().', '.time().', '.'0, '.'0, '; $insert = '('.$personId.', '.$storagePid.', '.time().', '.time().', '.'0, '.'0, ';
$insert .= "'".implode("','", $row)."',"; $insert .= "'".implode("','", $row)."',";
$insert .= $occupationId.",".$familyStatusId.")"; $insert .= $occupationId.",".$familyStatusId.","."'".$slug."'".",".$sourcesCount.")";
$values[] = ['sources' => $sources, 'insert' => $insert, 'personId' => $personId]; $values[] = ['sources' => $sources, 'insert' => $insert, 'personId' => $personId];
} }
...@@ -210,7 +214,7 @@ class ImportCommand extends Command ...@@ -210,7 +214,7 @@ class ImportCommand extends Command
'INSERT INTO tx_lunames_domain_model_person (uid, pid, tstamp, crdate, cruser_id, deleted, family_name, 'INSERT INTO tx_lunames_domain_model_person (uid, pid, tstamp, crdate, cruser_id, deleted, family_name,
maiden_name, other_name, given_name, father, mother, place_of_birth, year_of_birth, day_of_birth, month_of_birth, maiden_name, other_name, given_name, father, mother, place_of_birth, year_of_birth, day_of_birth, month_of_birth,
year_of_death, day_of_death, month_of_death, place_of_death, region, prewar_residence, war_residence, gender, spouse, fate, year_of_death, day_of_death, month_of_death, place_of_death, region, prewar_residence, war_residence, gender, spouse, fate,
comments, occupation,family_status) comments, occupation, family_status, slug, source_codes)
VALUES '.implode(',',$insertValues) VALUES '.implode(',',$insertValues)
); );
$statement->execute(); $statement->execute();
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
namespace Lu\LuNames\Domain\Model; namespace Lu\LuNames\Domain\Model;
use TYPO3\CMS\Core\DataHandling\SlugHelper;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage; use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
...@@ -350,4 +352,30 @@ class Person extends AbstractEntity ...@@ -350,4 +352,30 @@ class Person extends AbstractEntity
{ {
return $this->sourceCodes; return $this->sourceCodes;
} }
/**
* Generates slug field
*
* @param $uid
* @param $family_name
* @param $given_name
* @return string
*/
public function generateSlug($uid, $family_name, $given_name): string
{
$fieldConfig = $GLOBALS['TCA'][$this->tableName]['columns']['slug']['config'];
$slugHelper = GeneralUtility::makeInstance(SlugHelper::class,
$this->tableName,
'slug',
$fieldConfig
);
$data = [
'uid' => $uid,
'family_name' => $family_name,
'given_name' => $given_name
];
return $slugHelper->generate($data, $uid);
}
} }
...@@ -3,8 +3,11 @@ ...@@ -3,8 +3,11 @@
namespace Lu\LuNames\Hooks; namespace Lu\LuNames\Hooks;
use Lu\LuApi\DataSources\SolrSynchronize; use Lu\LuApi\DataSources\SolrSynchronize;
use Lu\LuNames\Domain\Model\Person;
use Lu\LuNames\Domain\Session\BackendSessionHandler; use Lu\LuNames\Domain\Session\BackendSessionHandler;
use Lu\LuNames\Helpers\DataHelper; use Lu\LuNames\Helpers\DataHelper;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/** /**
* Class TCEmainHook. Sync SOLR data on save, update, and delete events * Class TCEmainHook. Sync SOLR data on save, update, and delete events
...@@ -30,6 +33,22 @@ class TCEmainHook ...@@ -30,6 +33,22 @@ class TCEmainHook
public function processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, &$reference) public function processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, &$reference)
{ {
if ($table === 'tx_lunames_domain_model_person') { if ($table === 'tx_lunames_domain_model_person') {
// Prefix uid to slug field for newly created records
if ($status === 'new') {
$id = $reference->substNEWwithIDs[$id];
$personModel = GeneralUtility::makeInstance(Person::class);
$table = $personModel->getTableName();
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table);
$connection->update(
$table,
[
'slug' => $personModel->generateSlug($id, $fieldArray['family_name'], $fieldArray['given_name']),
],
['uid' => $id]
);
}
$this->syncAndStore(); $this->syncAndStore();
} }
} }
......
...@@ -6,15 +6,13 @@ routeEnhancers: ...@@ -6,15 +6,13 @@ routeEnhancers:
plugin: Pi1 plugin: Pi1
routes: routes:
- -
routePath: '/{uid}' routePath: '/{slug}'
_controller: 'Front::detail' _controller: 'Front::detail'
_arguments: _arguments:
uid: 'uid' slug: 'uid'
defaultController: 'Front::detail' defaultController: 'Front::detail'
requirements:
uid: \d+
aspects: aspects:
uid: slug:
type: PersistedAliasMapper type: PersistedAliasMapper
tableName: tx_lunames_domain_model_person tableName: 'tx_lunames_domain_model_person'
routeFieldName: uid routeFieldName: 'slug'
...@@ -333,19 +333,11 @@ return [ ...@@ -333,19 +333,11 @@ return [
'label' => $ll.'tx_lunames_domain_model_family_status.label', 'label' => $ll.'tx_lunames_domain_model_family_status.label',
'config' => [ 'config' => [
'type' => 'select', 'type' => 'select',
'minitems' => 0, 'renderType' => 'selectSingle',
'maxitems' => 1,
'foreign_table' => 'tx_lunames_domain_model_family_status', 'foreign_table' => 'tx_lunames_domain_model_family_status',
'foreign_table_where' => 'ORDER BY tx_lunames_domain_model_family_status.title ASC', 'foreign_table_where' => 'ORDER BY tx_lunames_domain_model_family_status.title ASC',
'items' => [['', '',]], 'items' => [['', 0]],
'fieldControl' => [ 'default' => 0,
'addRecord' => [
'disabled' => false,
'options' => [
'title' => $ll.'tx_lunames_domain_model_family_status.add',
],
],
],
], ],
], ],
'spouse' => [ 'spouse' => [
...@@ -397,9 +389,26 @@ return [ ...@@ -397,9 +389,26 @@ return [
], ],
], ],
], ],
'slug' => [
'label' => $ll.'tx_lunames_domain_model_person.slug',
'config' => [
'type' => 'slug',
'generatorOptions' => [
'fields' => ['uid', 'family_name', 'given_name'],
'fieldSeparator' => '-',
'prefixParentPageSlug' => false,
'replacements' => [
'/' => '',
],
],
'fallbackCharacter' => '-',
'eval' => 'uniqueInSite',
'default' => ''
],
],
], ],
'types' => [ 'types' => [
'0' => ['showitem' => 'photo, --palette--;;names, --palette--;;family_status, --palette--;;parents, --palette--;;birth, --palette--;;death, --palette--;;locations, occupation, --palette--;;fate, source_codes'], '0' => ['showitem' => 'photo, --palette--;;names, --palette--;;family_status, --palette--;;parents, --palette--;;birth, --palette--;;death, --palette--;;locations, occupation, --palette--;;fate, source_codes, slug'],
], ],
'palettes' => [ 'palettes' => [
'names' => [ 'names' => [
......
<?xml version="1.0" encoding="utf-8" standalone="yes" ?> <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0"> <xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2020-10-13T14:21:58Z"> <file source-language="en" datatype="plaintext" original="messages" date="2020-12-03T10:35:07Z">
<header> <header>
<generator>LFEditor</generator> <generator>LFEditor</generator>
</header> </header>
<body> <body>
<trans-unit id="found.entries.0" approved="yes">
<source><![CDATA[Found %s entries]]></source>
</trans-unit>
<trans-unit id="found.entries.1" approved="yes">
<source><![CDATA[Found %s entries]]></source>
</trans-unit>
<trans-unit id="administration.noRecordsFound"> <trans-unit id="administration.noRecordsFound">
<source><![CDATA[No records found on this page.]]></source> <source><![CDATA[No records found on this page.]]></source>
</trans-unit> </trans-unit>
...@@ -23,6 +17,12 @@ ...@@ -23,6 +17,12 @@
<trans-unit id="extension.title"> <trans-unit id="extension.title">
<source><![CDATA[Names]]></source> <source><![CDATA[Names]]></source>
</trans-unit> </trans-unit>
<trans-unit id="found.entries.0">
<source><![CDATA[Found %s entries]]></source>
</trans-unit>
<trans-unit id="found.entries.1">
<source><![CDATA[Found %s entries]]></source>
</trans-unit>
<trans-unit id="module.createNewRecord"> <trans-unit id="module.createNewRecord">
<source><![CDATA[Add new]]></source> <source><![CDATA[Add new]]></source>
</trans-unit> </trans-unit>
...@@ -56,6 +56,9 @@ ...@@ -56,6 +56,9 @@
<trans-unit id="tx_lunames_domain_model_person.august"> <trans-unit id="tx_lunames_domain_model_person.august">
<source><![CDATA[August]]></source> <source><![CDATA[August]]></source>
</trans-unit> </trans-unit>
<trans-unit id="tx_lunames_domain_model_person.comments">
<source><![CDATA[Comments]]></source>
</trans-unit>
<trans-unit id="tx_lunames_domain_model_person.day_of_birth"> <trans-unit id="tx_lunames_domain_model_person.day_of_birth">
<source><![CDATA[Day of birth]]></source> <source><![CDATA[Day of birth]]></source>
</trans-unit> </trans-unit>
...@@ -152,6 +155,9 @@ ...@@ -152,6 +155,9 @@
<trans-unit id="tx_lunames_domain_model_person.september"> <trans-unit id="tx_lunames_domain_model_person.september">
<source><![CDATA[September]]></source> <source><![CDATA[September]]></source>
</trans-unit> </trans-unit>
<trans-unit id="tx_lunames_domain_model_person.slug">
<source><![CDATA[URL path segment]]></source>
</trans-unit>
<trans-unit id="tx_lunames_domain_model_person.source_codes"> <trans-unit id="tx_lunames_domain_model_person.source_codes">
<source><![CDATA[Sources]]></source> <source><![CDATA[Sources]]></source>
</trans-unit> </trans-unit>
...@@ -170,9 +176,6 @@ ...@@ -170,9 +176,6 @@
<trans-unit id="tx_lunames_domain_model_source.label"> <trans-unit id="tx_lunames_domain_model_source.label">
<source><![CDATA[Source]]></source> <source><![CDATA[Source]]></source>
</trans-unit> </trans-unit>
<trans-unit id="tx_lunames_domain_model_person.comments">
<source><![CDATA[Comments]]></source>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="yes" ?> <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0"> <xliff version="1.0">
<file source-language="en" target-language="lv" datatype="plaintext" original="messages" date="2020-11-10T08:31:49Z"> <file source-language="en" target-language="lv" datatype="plaintext" original="messages" date="2020-12-03T10:35:07Z">
<header> <header>
<generator>LFEditor</generator> <generator>LFEditor</generator>
</header> </header>
...@@ -21,6 +21,14 @@ ...@@ -21,6 +21,14 @@
<source><![CDATA[Names]]></source> <source><![CDATA[Names]]></source>
<target><![CDATA[Names]]></target> <target><![CDATA[Names]]></target>
</trans-unit> </trans-unit>
<trans-unit id="found.entries.0" approved="yes">
<source><![CDATA[Found %s entries]]></source>
<target><![CDATA[Atrasti %s ieraksti]]></target>
</trans-unit>
<trans-unit id="found.entries.1" approved="yes">
<source><![CDATA[Found %s entries]]></source>
<target><![CDATA[Atrasts %s ieraksts]]></target>
</trans-unit>
<trans-unit id="module.createNewRecord" approved="yes"> <trans-unit id="module.createNewRecord" approved="yes">
<source><![CDATA[Add new]]></source> <source><![CDATA[Add new]]></source>
<target><![CDATA[Pievienot jaunu]]></target> <target><![CDATA[Pievienot jaunu]]></target>
...@@ -81,6 +89,10 @@ ...@@ -81,6 +89,10 @@
<source><![CDATA[December]]></source> <source><![CDATA[December]]></source>
<target><![CDATA[Decembris]]></target> <target><![CDATA[Decembris]]></target>
</trans-unit> </trans-unit>
<trans-unit id="tx_lunames_domain_model_person.fate" approved="yes">
<source><![CDATA[Fate in 1941-1945]]></source>
<target><![CDATA[Liktenis no 1941 līdz 1945]]></target>
</trans-unit>
<trans-unit id="tx_lunames_domain_model_person.father" approved="yes"> <trans-unit id="tx_lunames_domain_model_person.father" approved="yes">
<source><![CDATA[Father]]></source> <source><![CDATA[Father]]></source>
<target><![CDATA[Tēvs]]></target> <target><![CDATA[Tēvs]]></target>
...@@ -193,6 +205,10 @@ ...@@ -193,6 +205,10 @@
<source><![CDATA[September]]></source> <source><![CDATA[September]]></source>
<target><![CDATA[Septembris]]></target> <target><![CDATA[Septembris]]></target>
</trans-unit> </trans-unit>
<trans-unit id="tx_lunames_domain_model_person.slug" approved="yes">
<source><![CDATA[URL path segment]]></source>
<target><![CDATA[URL segments]]></target>
</trans-unit>
<trans-unit id="tx_lunames_domain_model_person.source_codes" approved="yes"> <trans-unit id="tx_lunames_domain_model_person.source_codes" approved="yes">
<source><![CDATA[Sources]]></source> <source><![CDATA[Sources]]></source>
<target><![CDATA[Avoti]]></target> <target><![CDATA[Avoti]]></target>
......
{ {
"name": "luitd/lu-names", "name": "luitd/lu-names",
"version": "1.0.1", "version": "1.0.3",
"description": "Jews in Latvia names database extension for TYPO3", "description": "Jews in Latvia names database extension for TYPO3",
"type": "typo3-cms-extension", "type": "typo3-cms-extension",
"keywords": [ "keywords": [
......
...@@ -9,7 +9,7 @@ $EM_CONF[$_EXTKEY] = [ ...@@ -9,7 +9,7 @@ $EM_CONF[$_EXTKEY] = [
'author_email' => 'lauris.karklis@lu.lv, dainis.abols@lu.lv', 'author_email' => 'lauris.karklis@lu.lv, dainis.abols@lu.lv',
'state' => 'stable', 'state' => 'stable',
'clearCacheOnLoad' => true, 'clearCacheOnLoad' => true,
'version' => '1.0.1', 'version' => '1.0.3',
'constraints' => [ 'constraints' => [
'depends' => [ 'depends' => [
'typo3' => '9.5.0-9.9.99', 'typo3' => '9.5.0-9.9.99',
......
...@@ -35,6 +35,7 @@ CREATE TABLE tx_lunames_domain_model_person ...@@ -35,6 +35,7 @@ CREATE TABLE tx_lunames_domain_model_person
`fate` text DEFAULT '' NOT NULL, `fate` text DEFAULT '' NOT NULL,
`comments` text DEFAULT '' NOT NULL, `comments` text DEFAULT '' NOT NULL,
`source_codes` varchar(255) DEFAULT '' NOT NULL, `source_codes` varchar(255) DEFAULT '' NOT NULL,
`slug` varchar(2048),
PRIMARY KEY (uid), PRIMARY KEY (uid),
KEY parent (pid) KEY parent (pid)
......
...@@ -4,7 +4,7 @@ Jews in Latvia names database extension for TYPO3TYPO3 Extension for Regulations ...@@ -4,7 +4,7 @@ Jews in Latvia names database extension for TYPO3TYPO3 Extension for Regulations
## Version ## Version
1.0.1 1.0.3
## Dependecies ## 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