Skip to content
Snippets Groups Projects
Commit 69815882 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Adding static info tables options for countries & nationalities

parent e628f2e8
No related branches found
Tags 1.6.2
No related merge requests found
<?php
namespace SGalinski\SgJobs\Service;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use SJBR\StaticInfoTables\Domain\Model\Country;
use SJBR\StaticInfoTables\Domain\Repository\CountryRepository;
use SJBR\StaticInfoTables\Hook\Backend\Form\FormDataProvider\TcaSelectItemsProcessor;
use TYPO3\CMS\Backend\Form\FormDataProvider\TcaSelectItems;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
/**
* Class TcaItemsProcessor
*
* @package SGalinski\SgJobs\Service
*/
class TcaItemsProcessor extends TcaSelectItemsProcessor {
/**
* returns the country options from static info tables
*
* @param array $PA
* @param TcaSelectItems $fObj
* @throws \InvalidArgumentException
*/
public function getCountryOptions(array $PA, TcaSelectItems $fObj) {
$items = $PA['items'];
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
/** @var CountryRepository $countryRepository */
$countryRepository = $objectManager->get(CountryRepository::class);
$objects = $countryRepository->findAllOrderedBy('shortNameEn')->toArray();
if (!empty($objects)) {
// Index rows by uid
$uidIndexedObjects = [];
/** @var Country $object */
foreach ($objects as $object) {
$uidIndexedObjects[$object->getUid()] = $object;
$items[] = [$object->getShortNameEn(), $object->getUid()];
}
}
$items = $this->translateSelectorItems($items, 'static_countries');
if(count($items) > 1) {
foreach ($items as $key => $item) {
$object = NULL;
if ($item[1] && $object = $uidIndexedObjects[$item[1]]) {
$items[$key][1] = $object->getIsoCodeA3();
}
}
}
$PA['items'] = $items;
}
}
\ No newline at end of file
<?php
return [
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
$tx_sgjobs_domain_model_job_application = [
'ctrl' => [
'title' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application',
'label' => 'first_name, last_name',
......@@ -27,14 +29,14 @@ return [
],
'interface' => [
'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, pid, job_id, area, job_function, start_date, alternative_start_date,
company, task, qualification, description, contact',
company, task, qualification, description, contact',
],
'types' => [
'1' => [
'showitem' => '--palette--;;sysLanguageAndHidden,job_id, gender, first_name, last_name, street, city, zip,
country, nationality, education, birth_date, phone, mobile, email, message, cover_letter, cv, certificates,
div;;richtext[*]:rte_transform[mode=ts],
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access, starttime, endtime',
country, nationality, education, birth_date, phone, mobile, email, message, cover_letter, cv, certificates,
div;;richtext[*]:rte_transform[mode=ts],
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access, starttime, endtime',
],
],
'palettes' => [
......@@ -188,7 +190,7 @@ return [
],
],
'country' => [
'exclude' => 0,
'exclude' => TRUE,
'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.country',
'config' => [
'type' => 'input',
......@@ -305,4 +307,35 @@ return [
],
]
],
];
\ No newline at end of file
];
if (ExtensionManagementUtility::isLoaded('static_info_tables')) {
$tx_sgjobs_domain_model_job_application['columns']['country'] = [
'exclude' => TRUE,
'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.country',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [['', '']],
'itemsProcFunc' => 'SGalinski\SgJobs\Service\TcaItemsProcessor->getCountryOptions',
'size' => 1,
'minitems' => 0,
'maxitems' => 1,
],
];
$tx_sgjobs_domain_model_job_application['columns']['nationality'] = [
'exclude' => TRUE,
'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.nationality',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [['', '']],
'itemsProcFunc' => 'SGalinski\SgJobs\Service\TcaItemsProcessor->getCountryOptions',
'size' => 1,
'minitems' => 0,
'maxitems' => 1,
],
];
}
return $tx_sgjobs_domain_model_job_application;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment