Initial commit - Typo3 11.5.41

This commit is contained in:
Matteo Gallo
2026-07-03 17:53:31 +02:00
commit 5ca4743197
6811 changed files with 568848 additions and 0 deletions

View File

@@ -0,0 +1,106 @@
<?php
namespace SJBR\StaticInfoTables\Domain\Model;
/*
* Copyright notice
*
* (c) 2013-2022 Stanislas Rolland <typo3AAAA(arobas)sjbr.ca>
* 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 2 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\Utility\LocalizationUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMap;
use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper;
/**
* Abstract model for static entities
*/
class AbstractEntity extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* @var DataMapper
*/
protected $dataMapper;
/**
* Name of the table from persistence mapping of this model
*
* @var string
*/
protected $tableName = '';
/**
* On initialization, get the columns mapping configuration
*/
public function initializeObject()
{
$this->dataMapper = GeneralUtility::makeInstance(DataMapper::class);
}
/**
* Localized name of the entity
*
* @var string
*/
protected $nameLocalized = '';
/**
* Sets the localized name of the entity
*
* @param string $nameLocalized
*
* @return void
*/
public function setNameLocalized($nameLocalized)
{
$this->nameLocalized = $nameLocalized;
}
/**
* Gets the localized name of the entity
*
* @return string
*/
public function getNameLocalized()
{
$language = LocalizationUtility::getCurrentLanguage();
$labelFields = LocalizationUtility::getLabelFields($this->tableName, $language);
foreach ($labelFields as $labelField => $map) {
if ($this->_hasProperty($map['mapOnProperty'] ?? '')) {
$value = $this->_getProperty($map['mapOnProperty'] ?? '');
if ($value) {
$this->nameLocalized = $value;
break;
}
}
}
return $this->nameLocalized;
}
/**
* Gets the table name
*
* @return string
*/
public function getTableName()
{
return $this->tableName;
}
}

View File

@@ -0,0 +1,617 @@
<?php
namespace SJBR\StaticInfoTables\Domain\Model;
/*
* Copyright notice
*
* (c) 2011-2012 Armin Rüdiger Vieweg <info@professorweb.de>
* (c) 2013-2021 Stanislas Rolland <typo3AAAA(arobas)sjbr.ca>
* 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 2 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\CountryZone;
use TYPO3\CMS\Extbase\Annotation\ORM\Lazy;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
/**
* The Country model
*/
class Country extends AbstractEntity
{
/**
* @var string
*/
protected $addressFormat = '';
/**
* @var string
*/
protected $capitalCity = '';
/**
* Country zones of this country
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\SJBR\StaticInfoTables\Domain\Model\CountryZone>
* @Lazy
*/
protected $countryZones;
/**
* Currency code as number (i.e. 978)
* ISO 4217 Nr Currency code
*
* @var int
*/
protected $currencyIsoCodeNumber = 0;
/**
* Currency code as three digit string (i.e. EUR)
* ISO 4217 A3 Currency code
*
* @var string
*/
protected $currencyIsoCodeA3 = '';
/**
* Deletion status of the object
*
* @var bool
*/
protected $deleted = false;
/**
* Whether or not the country is a member of the European Union
*
* @var bool
*/
protected $euMember = false;
/**
* Country code as two digit string (i.e. AT)
* ISO 3166-1 A2 Country code
*
* @var string
*/
protected $isoCodeA2 = '';
/**
* Country code as three digit string (i.e. AUT)
* ISO 3166-1 A3 Country code
*
* @var string
*/
protected $isoCodeA3 = '';
/**
* Country code as number (i.e. 40)
* ISO 3166-1 Nr Country code
*
* @var int
*/
protected $isoCodeNumber = 0;
/**
* The official name of the country in English
*
* @var string
*/
protected $officialNameEn = '';
/**
* The official name of the country in local language and local script
*
* @var string
*/
protected $officialNameLocal = '';
/**
* UN number of territory in which the country is located
*
* @var int
*/
protected $parentTerritoryUnCodeNumber = 0;
/**
* The international phone prefix for the country
*
* @var int
*/
protected $phonePrefix = 0;
/**
* @var string
*/
protected $shortNameEn = '';
/**
* @var string
*/
protected $shortNameLocal = '';
/**
* Whether the country is a member of the UNO or not
*
* @var bool
*/
protected $unMember = false;
/**
* The Internet top level domain of the country
*
* @var string
*/
protected $topLevelDomain = '';
/**
* @var bool
*/
protected $zoneFlag = false;
/**
* On initialization, get the columns mapping configuration
*/
public function initializeObject()
{
parent::initializeObject();
$this->tableName = $this->dataMapper->getDataMap(self::class)->getTableName();
$this->countryZones = new ObjectStorage();
}
/**
* Sets the address format.
*
* @param string $addressFormat
*
* @return void
*/
public function setAddressFormat($addressFormat)
{
$this->addressFormat = $addressFormat;
}
/**
* Gets the address format.
*
* @return string
*/
public function getAddressFormat()
{
return $this->addressFormat;
}
/**
* Sets the name of the capital city
*
* @param string $capitalCity
*
* @return void
*/
public function setCapitalCity($capitalCity)
{
$this->capitalCity = $capitalCity;
}
/**
* Gets the name of the capital city
*
* @return string
*/
public function getCapitalCity()
{
return $this->capitalCity;
}
/**
* Sets the ISO A3 currency code.
*
* @param string $currencyIsoCodeA3
*
* @return void
*/
public function setCurrencyIsoCodeA3($currencyIsoCodeA3)
{
$this->currencyIsoCodeA3 = $currencyIsoCodeA3;
}
/**
* Gets the ISO A3 currency code.
*
* @return string
*/
public function getCurrencyIsoCodeA3()
{
return $this->currencyIsoCodeA3;
}
/**
* Sets the ISO numeric currency code
*
* @param int $currencyIsoCodeNumber
*
* @return void
*/
public function setCurrencyIsoCodeNumber($currencyIsoCodeNumber)
{
$this->currencyIsoCodeNumber = $currencyIsoCodeNumber;
}
/**
* Gets the ISO numeric currency code
*
* @return int
*/
public function getCurrencyIsoCodeNumber()
{
return $this->currencyIsoCodeNumber;
}
/**
* Sets whether this country is a member of the European Union.
*
* @param bool $euMember
*
* @return void
*/
public function setEuMember($euMember)
{
$this->euMember = $euMember;
}
/**
* Gets the deletion status of the entity
*
* @return bool
*/
public function getDeleted()
{
return $this->deleted;
}
/**
* Sets the deletion status of the entity
*
* @param bool $deleted
*
* @return void
*/
public function setDeleted($deleted)
{
$this->deleted = $deleted;
}
/**
* Gets whether this country is a member of the European Union.
*
* @return bool
*/
public function getEuMember()
{
return $this->euMember;
}
/**
* Gets whether this country is a member of the European Union.
*
* This method is a synonym for the getEuMember method.
*
* @return bool
*/
public function isEuMember()
{
return $this->getEuMember();
}
/**
* Sets the ISO alpha-2 code.
*
* @param string $isoCodeA2
*
* @return void
*/
public function setIsoCodeA2($isoCodeA2)
{
$this->isoCodeA2 = $isoCodeA2;
}
/**
* Gets the ISO alpha-2 code.
*
* @return string
*/
public function getIsoCodeA2()
{
return $this->isoCodeA2;
}
/**
* Sets the ISO alpha-3 code.
*
* @param string $isoCodeA3
*
* @return void
*/
public function setIsoCodeA3($isoCodeA3)
{
$this->isoCodeA3 = $isoCodeA3;
}
/**
* Gets the ISO alpha-3 code.
*
* @return string
*/
public function getIsoCodeA3()
{
return $this->isoCodeA3;
}
/**
* Sets the ISO code number.
*
* @param int $isoCodeNumber
*
* @return void
*/
public function setIsoCodeNumber($isoCodeNumber)
{
$this->isoCodeNumber = $isoCodeNumber;
}
/**
* Gets the ISO code number.
*
* @return int
*/
public function getIsoCodeNumber()
{
return $this->isoCodeNumber;
}
/**
* Sets the official name of the country in English
*
* @param string $officialNameEn
*
* @return void
*/
public function setOfficialNameEn($officialNameEn)
{
$this->officialNameEn = $officialNameEn;
}
/**
* Gets the official name of the country in English
*
* @return string
*/
public function getOfficialNameEn()
{
return $this->officialNameEn;
}
/**
* Sets the official name of the country in local language and script
*
* @param string $officialNameLocal
*
* @return void
*/
public function setOfficialNameLocal($officialNameLocal)
{
$this->officialNameLocal = $officialNameLocal;
}
/**
* Gets the official name of the country in local language and script
*
* @return string
*/
public function getOfficialNameLocal()
{
return $this->officialNameLocal;
}
/**
* Sets the parent territory UN numeric code.
*
* @param int $parentTerritoryUnCodeNumber
*
* @return void
*/
public function setParentTerritoryUnCodeNumber($parentTerritoryUnCodeNumber)
{
$this->parentTerritoryUnCodeNumber = $parentTerritoryUnCodeNumber;
}
/**
* Gets the parent territory UN numeric code.
*
* @return int
*/
public function getParentTerritoryUnCodeNumber()
{
return $this->parentTerritoryUnCodeNumber;
}
/**
* Sets the phone prefix.
*
* @param int $phonePrefix
*
* @return void
*/
public function setPhonePrefix($phonePrefix)
{
$this->phonePrefix = $phonePrefix;
}
/**
* Gets the phone prefix.
*
* @return int
*/
public function getPhonePrefix()
{
return $this->phonePrefix;
}
/**
* Sets the English short name.
*
* @param string $shortNameEn
*
* @return void
*/
public function setShortNameEn($shortNameEn)
{
$this->shortNameEn = $shortNameEn;
}
/**
* Gets the English short name.
*
* @return string
*/
public function getShortNameEn()
{
return $this->shortNameEn;
}
/**
* Sets the short local name.
*
* @param string $shortNameLocal
*
* @return void
*/
public function setShortNameLocal($shortNameLocal)
{
$this->shortNameLocal = $shortNameLocal;
}
/**
* Gets the short local name.
*
* @return string
*/
public function getShortNameLocal()
{
return $this->shortNameLocal;
}
/**
* Sets the top-level domain.
*
* @param string $topLevelDomain
*
* @return void
*/
public function setTopLevelDomain($topLevelDomain)
{
$this->topLevelDomain = $topLevelDomain;
}
/**
* Gets the top-level domain.
*
* @return string
*/
public function getTopLevelDomain()
{
return $this->topLevelDomain;
}
/**
* Sets whether this country is a member of the United Nations.
*
* @param bool $unMember
*
* @return void
*/
public function setUnMember($unMember)
{
$this->unMember = $unMember;
}
/**
* Gets whether this country is a member of the United Nations.
*
* @return bool
*/
public function getUnMember()
{
return $this->unMember;
}
/**
* Sets whether this country is a member of the United Nations.
*
* This method is a synonym for the getUnMember method.
*
* @return bool
*/
public function isUnMember()
{
return $this->getUnMember();
}
/**
* Sets the zone flag.
*
* @param bool $zoneFlag
*
* @return void
*/
public function setZoneFlag($zoneFlag)
{
$this->zoneFlag = $zoneFlag;
}
/**
* Gets the zone flag.
*
* @return bool
*/
public function getZoneFlag()
{
return $this->zoneFlag;
}
/**
* Sets the country zones
*
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\SJBR\StaticInfoTables\Domain\Model\CountryZone> $countryZones
*
* @return void
*/
public function setCountryZones($countryZones)
{
$this->countryZones = $countryZones;
}
/**
* Gets the country zones
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\SJBR\StaticInfoTables\Domain\Model\CountryZone> $countryZones
*/
public function getCountryZones()
{
return $this->countryZones;
}
}

View File

@@ -0,0 +1,255 @@
<?php
namespace SJBR\StaticInfoTables\Domain\Model;
/*
* Copyright notice
*
* (c) 2011-2012 Armin Rüdiger Vieweg <info@professorweb.de>
* (c) 2013-2021 Stanislas Rolland <typo3AAAA(arobas)sjbr.ca>
* 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 2 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!
*/
/**
* The Country Zone model
*
* @copyright Copyright belongs to the respective authors
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*/
class CountryZone extends AbstractEntity
{
/**
* Country code as two digit string (i.e. AT)
* ISO 3166-1 A2 Country code
*
* @var string
*/
protected $countryIsoCodeA2 = '';
/**
* Country code as three digit string (i.e. AUT)
* ISO 3166-1 A3 Country code
*
* @var string
*/
protected $countryIsoCodeA3 = '';
/**
* Country code as number (i.e. 40)
* ISO 3166-1 Nr Country code
*
* @var int
*/
protected $countryIsoCodeNumber = 0;
/**
* Deletion status of the object
*
* @var bool
*/
protected $deleted = false;
/**
* Country zone code as string
* ISO 3166-2 Country Zone code
*
* @var string
*/
protected $isoCode = '';
/**
* Local name of the country zone
*
* @var string
*/
protected $localName = '';
/**
* English name of the country zone
*
* @var string
*/
protected $nameEn = '';
/**
* On initialization, get the columns mapping configuration
*/
public function initializeObject()
{
parent::initializeObject();
$this->tableName = $this->dataMapper->getDataMap(self::class)->getTableName();
}
/**
* Sets the country ISO alpha-2 code.
*
* @param string $countryIsoCodeA2
*
* @return void
*/
public function setCountryIsoCodeA2($countryIsoCodeA2)
{
$this->countryIsoCodeA2 = $countryIsoCodeA2;
}
/**
* Gets the country ISO alpha-2 code.
*
* @return string
*/
public function getCountryIsoCodeA2()
{
return $this->countryIsoCodeA2;
}
/**
* Sets the country ISO alpha-3 code.
*
* @param string $countryIsoCodeA3
*
* @return void
*/
public function setCountryIsoCodeA3($countryIsoCodeA3)
{
$this->countryIsoCodeA3 = $countryIsoCodeA3;
}
/**
* Gets the country ISO alpha-3 code.
*
* @return string
*/
public function getCountryIsoCodeA3()
{
return $this->countryIsoCodeA3;
}
/**
* Sets the country numeric ISO code
*
* @param int $countryIsoCodeNumber
*
* @return void
*/
public function setCountryIsoCodeNumber($countryIsoCodeNumber)
{
$this->countryIsoCodeNumber = $countryIsoCodeNumber;
}
/**
* Gets the country numeric ISO code
*
* @return int
*/
public function getCountryIsoCodeNumber()
{
return $this->countryIsoCodeNumber;
}
/**
* Gets the deletion status of the entity
*
* @return bool
*/
public function getDeleted()
{
return $this->deleted;
}
/**
* Sets the deletion status of the entity
*
* @param bool $deleted
*
* @return void
*/
public function setDeleted($deleted)
{
return $this->deleted = $deleted;
}
/**
* Sets the country zone ISO code.
*
* @param string $isoCode
*
* @return void
*/
public function setIsoCode($isoCode)
{
$this->isoCode = $isoCode;
}
/**
* Gets the country zone ISO code.
*
* @return string
*/
public function getIsoCode()
{
return $this->isoCode;
}
/**
* Sets the local name.
*
* @param string $localName
*
* @return void
*/
public function setLocalName($localName)
{
$this->localName = $localName;
}
/**
* Gets the local name.
*
* @return string
*/
public function getLocalName()
{
return $this->localName;
}
/**
* Sets the English name.
*
* @param string $nameEn
*
* @return void
*/
public function setNameEn($nameEn)
{
$this->nameEn = $nameEn;
}
/**
* Returns English name. If empty returns the localName.
*
* @return string
*/
public function getNameEn()
{
if ($this->nameEn === '') {
return $this->getLocalName();
}
return $this->nameEn;
}
}

View File

@@ -0,0 +1,424 @@
<?php
namespace SJBR\StaticInfoTables\Domain\Model;
/*
* Copyright notice
*
* (c) 2011-2012 Armin Rüdiger Vieweg <info@professorweb.de>
* (c) 2013-2021 Stanislas Rolland <typo3AAAA(arobas)sjbr.ca>
* 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 2 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!
*/
/**
* The Currency model
*
* @copyright Copyright belongs to the respective authors
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*/
class Currency extends AbstractEntity
{
/**
* The number of decimals to be shown when an amount is presented in this currency
*
* @var int
*/
protected $decimalDigits = 0;
/**
* The character to be shown in front of the decimals when an amount is presented in this currency
*
* @var string
*/
protected $decimalPoint = '';
/**
* Deletion status of the object
*
* @var bool
*/
protected $deleted = false;
/**
* The divisor used to obtain the subdivision of the currency
*
* @var int
*/
protected $divisor = 0;
/**
* Currency code as three digit string (i.e. EUR)
* ISO 4217 alpha-3 currency code
*
* @var string
*/
protected $isoCodeA3 = '';
/**
* Currency code as number
* ISO 4217 numeric currency code
*
* @var int
*/
protected $isoCodeNumber = 0;
/**
* English name of the currency
*
* @var string
*/
protected $nameEn = '';
/**
* English name of the currency subdivision unit
*
* @var string
*/
protected $subdivisionNameEn = '';
/**
* The symbol to be shown to the left of an amount stated in units of the subdivision of the currency
*
* @var string
*/
protected $subdivisionSymbolLeft = '';
/**
* The symbol to be shown to the right of an amount stated in units of the subdivision of the currency
*
* @var string
*/
protected $subdivisionSymbolRight = '';
/**
* The symbol to be shown to the left of an amount stated in units of the currency
*
* @var string
*/
protected $symbolLeft = '';
/**
* The symbol to be shown to the right of an amount stated in units of the currency
*
* @var string
*/
protected $symbolRight = '';
/**
* Character to be used between every group of thousands of an amount stated in units of this currency
*
* @var string
*/
protected $thousandsPoint = '';
/**
* On initialization, get the columns mapping configuration
*/
public function initializeObject()
{
parent::initializeObject();
$this->tableName = $this->dataMapper->getDataMap(self::class)->getTableName();
}
/**
* Sets the number of decimal digits.
*
* @param int $decimalDigits
*
* @return void
*/
public function setDecimalDigits($decimalDigits)
{
$this->decimalDigits = $decimalDigits;
}
/**
* Gets the number of decimal digits.
*
* @return int
*/
public function getDecimalDigits()
{
return $this->decimalDigits;
}
/**
* Sets the decimal point character
*
* @param string $decimalPoint
*
* @return void
*/
public function setDecimalPoint($decimalPoint)
{
$this->decimalPoint = $decimalPoint;
}
/**
* Gets the decimal point character
*
* @return string
*/
public function getDecimalPoint()
{
return $this->decimalPoint;
}
/**
* Gets the deletion status of the entity
*
* @return bool
*/
public function getDeleted()
{
return $this->deleted;
}
/**
* Sets the deletion status of the entity
*
* @param bool $deleted
*
* @return void
*/
public function setDeleted($deleted)
{
return $this->deleted = $deleted;
}
/**
* Sets the divisor.
*
* @param int $divisor
*
* @return void
*/
public function setDivisor($divisor)
{
$this->divisor = $divisor;
}
/**
* Gets the divisor.
*
* @return int
*/
public function getDivisor()
{
return $this->divisor;
}
/**
* Sets the ISO alpha-3 code.
*
* @param string $isoCodeA3
*
* @return void
*/
public function setIsoCodeA3($isoCodeA3)
{
$this->isoCodeA3 = $isoCodeA3;
}
/**
* Gets the ISO alpha-3 code.
*
* @return string
*/
public function getIsoCodeA3()
{
return $this->isoCodeA3;
}
/**
* Sets the ISO code number.
*
* @param int $isoCodeNumber
*
* @return void
*/
public function setIsoCodeNumber($isoCodeNumber)
{
$this->isoCodeNumber = $isoCodeNumber;
}
/**
* Gets the ISO code number.
*
* @return int
*/
public function getIsoCodeNumber()
{
return $this->isoCodeNumber;
}
/**
* Sets the English name of the currency
*
* @param string $nameEn
*
* @return void
*/
public function setNameEn($nameEn)
{
$this->nameEn = $nameEn;
}
/**
* Gets the English name of the currency
*
* @return string
*/
public function getNameEn()
{
return $this->nameEn;
}
/**
* Sets the English name of the currency subdivision
*
* @param string $subdivisionNameEn
*
* @return void
*/
public function setSubdivisionNameEn($subdivisionNameEn)
{
$this->subdivisionNameEn = $subdivisionNameEn;
}
/**
* Gets the English name of the currency subdivision
*
* @return string
*/
public function getSubdivisionNameEn()
{
return $this->subdivisionNameEn;
}
/**
* Sets the left-hand side symbol for an amount stated in units of the subdivision of the currency
*
* @param string $subdivisionSymbolLeft
*
* @return void
*/
public function setSubdivisionSymbolLeft($subdivisionSymbolLeft)
{
$this->subdivisionSymbolLeft = $subdivisionSymbolLeft;
}
/**
* Gets the left-hand side symbol for an amount stated in units of the subdivision of the currency
*
* @return string
*/
public function getSubdivisionSymbolLeft()
{
return $this->subdivisionSymbolLeft;
}
/**
* Sets the right-hand side symbol for an amount stated in units of the subdivision of the currency
*
* @param string $subdivisionSymbolRight
*
* @return void
*/
public function setSubdivisionSymbolRight($subdivisionSymbolRight)
{
$this->subdivisionSymbolRight = $subdivisionSymbolRight;
}
/**
* Gets the right-hand side symbol for an amount stated in units of the subdivision of the currency
*
* @return string
*/
public function getSubdivisionSymbolRight()
{
return $this->subdivisionSymbolRight;
}
/**
* Sets the symbol to be shown to the left of an amount stated in units of the currency
*
* @param string $symbolLeft
*
* @return void
*/
public function setSymbolLeft($symbolLeft)
{
$this->symbolLeft = $symbolLeft;
}
/**
* Gets the symbol to be shown to the left of an amount stated in units of the currency
*
* @return string
*/
public function getSymbolLeft()
{
return $this->symbolLeft;
}
/**
* Sets the symbol to be shown to the right of an amount stated in units of the currency
*
* @param string $symbolRight
*
* @return void
*/
public function setSymbolRight($symbolRight)
{
$this->symbolRight = $symbolRight;
}
/**
* Gets the symbol to be shown to the right of an amount stated in units of the currency
*
* @return string
*/
public function getSymbolRight()
{
return $this->symbolRight;
}
/**
* Sets the thousands point/separator.
*
* @param string $thousandsPoint
*
* @return void
*/
public function setThousandsPoint($thousandsPoint)
{
$this->thousandsPoint = $thousandsPoint;
}
/**
* Gets the thousands point/separator.
*
* @return string
*/
public function getThousandsPoint()
{
return $this->thousandsPoint;
}
}

View File

@@ -0,0 +1,325 @@
<?php
namespace SJBR\StaticInfoTables\Domain\Model;
/***************************************************************
* Copyright notice
*
* (c) 2011-2012 Armin Rüdiger Vieweg <info@professorweb.de>
* (c) 2013-2021 Stanislas Rolland <typo3AAAA(arobas)sjbr.ca>
* 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 2 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!
*/
/**
* The Language model
*
* @copyright Copyright belongs to the respective authors
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*/
class Language extends AbstractEntity
{
/**
* @var string
*/
protected $collatingLocale = '';
/**
* Country code as two digit string (i.e. AT)
* Identifies this language as a variant of the language identified by the ISO 639-1 A2 Language code
* See also RFC 4646
* ISO 3166-1 A2 Country code
*
* @var string
*/
protected $countryIsoCodeA2 = '';
/**
* @var bool
*/
protected $constructedLanguage = false;
/**
* Deletion status of the object
*
* @var bool
*/
protected $deleted = false;
/**
* ISO 639-1 A2 Language code
*
* @var string
*/
protected $isoCodeA2 = '';
/**
* Local name: name of language in the language itself
*
* @var string
*/
protected $localName = '';
/**
* English name
*
* @var string
*/
protected $nameEn = '';
/**
* @var bool
*/
protected $sacredLanguage = false;
/**
* @var string
*/
protected $typo3Code = '';
/**
* On initialization, get the columns mapping configuration
*/
public function initializeObject()
{
parent::initializeObject();
$this->tableName = $this->dataMapper->getDataMap(self::class)->getTableName();
}
/**
* Sets the collating locale.
*
* @param string $collatingLocale
*
* @return void
*/
public function setCollatingLocale($collatingLocale)
{
$this->collatingLocale = $collatingLocale;
}
/**
* Gets the collating locale.
*
* @return string
*/
public function getCollatingLocale()
{
return $this->collatingLocale;
}
/**
* Sets the ISO 3166-1 A2 Country code
*
* @param string $countryIsoCodeA2
*
* @return void
*/
public function setCountryIsoCodeA2($countryIsoCodeA2)
{
$this->countryIsoCodeA2 = $countryIsoCodeA2;
}
/**
* Gets the ISO 3166-1 A2 Country code
*
* @return string
*/
public function getCountryIsoCodeA2()
{
return $this->countryIsoCodeA2;
}
/**
* Sets whether this is a constructed language.
*
* @param bool $constructedLanguage
*
* @return void
*/
public function setConstructedLanguage($constructedLanguage)
{
$this->constructedLanguage = $constructedLanguage;
}
/**
* Gets whether this is a constructed language.
*
* @return bool
*/
public function getConstructedLanguage()
{
return $this->constructedLanguage;
}
/**
* Gets whether this is a constructed language.
*
* This method is a synonym for the getConstructedLanguage method.
*
* @return bool
*/
public function isConstructedLanguage()
{
return $this->getConstructedLanguage();
}
/**
* Gets the deletion status of the entity
*
* @return bool
*/
public function getDeleted()
{
return $this->deleted;
}
/**
* Sets the deletion status of the entity
*
* @param bool $deleted
*
* @return void
*/
public function setDeleted($deleted)
{
return $this->deleted = $deleted;
}
/**
* Sets the ISO 639-1 A2 Language code
*
* @param string $isoCodeA2
*
* @return void
*/
public function setIsoCodeA2($isoCodeA2)
{
$this->isoCodeA2 = $isoCodeA2;
}
/**
* Gets the ISO 639-1 A2 Language code
*
* @return string
*/
public function getIsoCodeA2()
{
return $this->isoCodeA2;
}
/**
* Sets the local name.
*
* @param string $localName
*
* @return void
*/
public function setLocalName($localName)
{
$this->localName = $localName;
}
/**
* Gets the local name.
*
* @return string
*/
public function getLocalName()
{
return $this->localName;
}
/**
* Sets the English name
*
* @param string $nameEn
*
* @return void
*/
public function setNameEn($nameEn)
{
$this->nameEn = $nameEn;
}
/**
* Gets the English name
*
* @return string
*/
public function getNameEn()
{
return $this->nameEn;
}
/**
* Sets whether this is a sacred language.
*
* @param bool $sacredLanguage
*
* @return void
*/
public function setSacredLanguage($sacredLanguage)
{
$this->sacredLanguage = $sacredLanguage;
}
/**
* Gets whether this is a sacred language.
*
* @return bool
*/
public function getSacredLanguage()
{
return $this->sacredLanguage;
}
/**
* Sets whether this is a sacred language.
*
* This method is a synonym for the getSacredLanguage method.
*
* @return bool
*/
public function isSacredLanguage()
{
return $this->getSacredLanguage();
}
/**
* Sets the TYPO3 language code.
*
* @param string $typo3Code
*
* @return void
*/
public function setTypo3Code($typo3Code)
{
$this->typo3Code = $typo3Code;
}
/**
* Gets the TYPO3 language code.
*
* @return string
*/
public function getTypo3Code()
{
return $this->typo3Code;
}
}

View File

@@ -0,0 +1,268 @@
<?php
namespace SJBR\StaticInfoTables\Domain\Model;
/*
* Copyright notice
*
* (c) 2013-2021 Stanislas Rolland <typo3AAAA(arobas)sjbr.ca>
* 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 2 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.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* 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\Repository\CountryRepository;
use SJBR\StaticInfoTables\Domain\Repository\CountryZoneRepository;
use SJBR\StaticInfoTables\Domain\Repository\CurrencyRepository;
use SJBR\StaticInfoTables\Domain\Repository\LanguageRepository;
use SJBR\StaticInfoTables\Domain\Repository\TerritoryRepository;
use TYPO3\CMS\Core\Localization\Parser\XliffParser;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Annotation\Validate;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
/**
* Language Pack object
*/
class LanguagePack extends AbstractEntity
{
/**
* Name of the extension this class belongs to
*
* @var string
*/
protected $extensionName = 'StaticInfoTables';
/**
* @var string
* @Validate("TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator")
*/
protected $author;
/**
* @var string
*/
protected $authorCompany;
/**
* @var string
* @Validate("TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator")
*/
protected $vendorName;
/**
* @var string
* @Validate("EmailAddress")
*/
protected $authorEmail;
/**
* @var string
*/
protected $locale;
/**
* @var string
*/
protected $language;
/**
* @var string
*/
protected $typo3VersionRange;
/**
* @var string
* @Validate("TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator")
*/
protected $version;
/**
* @var CountryRepository
*/
protected $countryRepository;
/**
* @var CountryZoneRepository
*/
protected $countryZoneRepository;
/**
* @var CurrencyRepository
*/
protected $currencyRepository;
/**
* @var LanguageRepository
*/
protected $languageRepository;
/**
* @var TerritoryRepository
*/
protected $territoryRepository;
public function __construct(
$author = '',
$authorCompany = '',
$vendorName = '',
$authorEmail = '',
$locale = '',
$language = ''
) {
$this->countryRepository = GeneralUtility::makeInstance(CountryRepository::class);
$this->countryZoneRepository = GeneralUtility::makeInstance(CountryZoneRepository::class);
$this->currencyRepository = GeneralUtility::makeInstance(CurrencyRepository::class);
$this->languageRepository = GeneralUtility::makeInstance(LanguageRepository::class);
$this->territoryRepository = GeneralUtility::makeInstance(TerritoryRepository::class);
$this->setAuthor($author);
$this->setAuthorCompany($authorCompany);
$this->setVendorName($vendorName);
$this->setAuthorEmail($authorEmail);
$this->setLocale($locale);
$this->setLanguage($language);
}
public function setAuthor($author)
{
$this->author = $author;
}
public function getAuthor()
{
return $this->author;
}
public function setAuthorCompany($authorCompany)
{
$this->authorCompany = $authorCompany;
}
public function getAuthorCompany()
{
return $this->authorCompany;
}
public function setVendorName($vendorName)
{
$this->vendorName = $vendorName;
}
public function getVendorName()
{
return $this->vendorName;
}
public function setAuthorEmail($authorEmail)
{
$this->authorEmail = $authorEmail;
}
public function getAuthorEmail()
{
return $this->authorEmail;
}
public function setLocale($locale)
{
$this->locale = $locale;
}
public function getLocale()
{
return $this->locale;
}
public function setLanguage($language)
{
$this->language = $language;
}
public function getLanguage()
{
return $this->language;
}
public function setTypo3VersionRange($typo3VersionRange)
{
$this->typo3VersionRange = $typo3VersionRange;
}
public function getTypo3VersionRange()
{
return $this->typo3VersionRange;
}
public function setVersion($version)
{
$this->version = $version;
}
public function getVersion()
{
return $this->version;
}
/**
* Gets the localization labels for this language pack
*
* @return string localization labels in xliff format
*/
public function getLocalizationLabels()
{
// Build the localization labels of the language pack
$XliffParser = new XliffParser();
$extensionKey = GeneralUtility::camelCaseToLowerCaseUnderscored($this->extensionName);
$extensionPath = ExtensionManagementUtility::extPath($extensionKey);
$sourceXliffFilePath = $extensionPath . 'Resources/Private/Language/locallang_db.xlf';
$parsedData = $XliffParser->getParsedData($sourceXliffFilePath, 'default');
$localizationLabels = [];
$localeLowerCase = strtolower($this->getLocale());
$localeUpperCase = strtoupper($this->getLocale());
foreach ($parsedData['default'] as $translationElementId => $translationElement) {
if (substr($translationElementId, -3) == '_en') {
$localizationLabels[] = chr(9) . chr(9) . chr(9) . '<trans-unit id="' . substr($translationElementId, 0, -2) . $localeLowerCase . '" xml:space="preserve">';
$localizationLabels[] = chr(9) . chr(9) . chr(9) . chr(9) . '<source>' . str_replace('(EN)', '(' . $localeUpperCase . ')', $translationElement[0]['source']) . '</source>';
if ($translationElement[0]['target']) {
$localizationLabels[] = chr(9) . chr(9) . chr(9) . chr(9) . '<target>' . str_replace('(EN)', '(' . $localeUpperCase . ')', $translationElement[0]['target']) . '</target>';
}
$localizationLabels[] = chr(9) . chr(9) . chr(9) . '</trans-unit>';
}
}
return implode(LF, $localizationLabels);
}
/**
* Gets the update queries for this language pack
*
* @return string update queries in sql format
*/
public function getUpdateQueries()
{
$updateQueries = [];
$locale = $this->getLocale();
$updateQueries = array_merge($updateQueries, $this->countryRepository->getUpdateQueries($locale));
$updateQueries = array_merge($updateQueries, $this->countryZoneRepository->getUpdateQueries($locale));
$updateQueries = array_merge($updateQueries, $this->currencyRepository->getUpdateQueries($locale));
$updateQueries = array_merge($updateQueries, $this->languageRepository->getUpdateQueries($locale));
$updateQueries = array_merge($updateQueries, $this->territoryRepository->getUpdateQueries($locale));
return implode(LF, $updateQueries);
}
}

View File

@@ -0,0 +1,91 @@
<?php
namespace SJBR\StaticInfoTables\Domain\Model;
/***************************************************************
* Copyright notice
*
* (c) 2013-2017 Stanislas Rolland <typo3(arobas)sjbr.ca>
*
* 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 TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
/**
* The System Language model
*/
class SystemLanguage extends AbstractEntity
{
/**
* @var string System language name
*/
protected $title = '';
/**
* @var \SJBR\StaticInfoTables\Domain\Model\Language
*/
protected $isoLanguage = null;
/**
* Sets the language name
*
* @param string $title
*
* @return void
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* Gets the backend language name
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Sets the ISO language
*
* @param Language $isoLanguage
*
* @return void
*/
public function setIsoLanguage(Language $isoLanguage)
{
$this->isoLanguage = $isoLanguage;
}
/**
* Gets the ISO language
*
* @return Language
*/
public function getIsoLanguage()
{
if ($this->isoLanguage !== null) {
return clone $this->isoLanguage;
}
return $this->isoLanguage;
}
}

View File

@@ -0,0 +1,161 @@
<?php
namespace SJBR\StaticInfoTables\Domain\Model;
/***************************************************************
* Copyright notice
*
* (c) 2011-2012 Armin Rüdiger Vieweg <info@professorweb.de>
* (c) 2013-2022 Stanislas Rolland <typo3AAAA(arobas)sjbr.ca>
* 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 2 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!
*/
/**
* The Territory model
*
* @copyright Copyright belongs to the respective authors
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*/
class Territory extends AbstractEntity
{
/**
* Deletion status of the object
*
* @var bool
*/
protected $deleted = false;
/**
* UN numeric territory code
*
* @var int
*/
protected $unCodeNumber = 0;
/**
* English name
*
* @var string
*/
protected $nameEn = '';
/**
* UN numeric territory code of parent territory
*
* @var int
*/
protected $parentTerritoryUnCodeNumber = 0;
/**
* On initialization, get the columns mapping configuration
*/
public function initializeObject()
{
parent::initializeObject();
$this->tableName = $this->dataMapper->getDataMap(self::class)->getTableName();
}
/**
* Gets the deletion status of the entity
*
* @return bool
*/
public function getDeleted()
{
return $this->deleted;
}
/**
* Sets the deletion status of the entity
*
* @param bool $deleted
*
* @return void
*/
public function setDeleted($deleted)
{
$this->deleted = $deleted;
}
/**
* Sets the English name
*
* @param string $nameEn
*
* @return void
*/
public function setNameEn($nameEn)
{
$this->nameEn = $nameEn;
}
/**
* Returns the English name
*
* @return string
*/
public function getNameEn()
{
return $this->nameEn;
}
/**
* Sets the UN territory numeric code
*
* @param int $unCodeNumber
*
* @return void
*/
public function setUnCodeNumber($unCodeNumber)
{
$this->unCodeNumber = $unCodeNumber;
}
/**
* Returns the UN territory numeric code
*
* @return int
*/
public function getUnCodeNumber()
{
return $this->unCodeNumber;
}
/**
* Sets the UN numeric territory code of the parent territory
*
* @param int $parentTerritoryUnCodeNumber
*
* @return void
*/
public function setParentTerritoryUnCodeNumber($parentTerritoryUnCodeNumber)
{
$this->parentTerritoryUnCodeNumber = $parentTerritoryUnCodeNumber;
}
/**
* Returns the UN numeric territory code of the parent territory
*
* @return int
*/
public function getParentTerritoryUnCodeNumber()
{
return $this->parentTerritoryUnCodeNumber;
}
}

View File

@@ -0,0 +1,423 @@
<?php
namespace SJBR\StaticInfoTables\Domain\Repository;
/*
* Copyright notice
*
* (c) 2011-2012 Armin Rüdiger Vieweg <info@professorweb.de>
* (c) 2013-2022 Stanislas Rolland <typo3AAAA(arobas)sjbr.ca>
* 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 2 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 Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\Type;
use SJBR\StaticInfoTables\Service\SqlSchemaMigrationService;
use SJBR\StaticInfoTables\Utility\DatabaseUtility;
use SJBR\StaticInfoTables\Utility\LocalizationUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper;
use TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface;
use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
use TYPO3\CMS\Extbase\Persistence\Repository;
/**
* Abstract Repository for static entities
*
* @author Armin Rüdiger Vieweg <info@professorweb.de>
* @author Stanislas Rolland <typo3(arobas)sjbr.ca>
* @author Oliver Klee <typo3-coding@oliverklee.de>
*/
abstract class AbstractEntityRepository extends Repository
{
/**
* @var string Name of the extension this class belongs to
*/
protected $extensionName = 'StaticInfoTables';
/**
* @var DataMapper
*/
protected $dataMapper;
/**
* @var array ISO keys for this static table
*/
protected $isoKeys = [];
/**
* Injects the DataMapper to map nodes to objects
*
* @param DataMapper $dataMapper
*
* @return void
*/
public function injectDataMapper(DataMapper $dataMapper)
{
$this->dataMapper = $dataMapper;
}
/**
* Initializes the repository.
*
* @return void
*/
public function initializeObject()
{
$querySettings = GeneralUtility::makeInstance(Typo3QuerySettings::class);
$querySettings->setRespectStoragePage(false);
$this->setDefaultQuerySettings($querySettings);
}
/**
* Find all with deleted included
*
* @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface|array all entries
*/
public function findAllDeletedIncluded()
{
$querySettings = GeneralUtility::makeInstance(QuerySettingsInterface::class);
$querySettings->setStoragePageIds([0]);
$querySettings->setIncludeDeleted(true);
$this->setDefaultQuerySettings($querySettings);
return parent::findAll();
}
/**
* Find all objects with uid in list
*
* @param string $list: list of uid's
* @return QueryResultInterface|array all entries
*/
public function findAllByUidInList($list = '')
{
if (empty($list)) {
return [];
}
$query = $this->createQuery();
$list = GeneralUtility::trimExplode(',', $list, true);
$query->matching($query->in('uid', $list));
return $query->execute();
}
/**
* Find all ordered by the localized name
*
* @param string $orderDirection may be "asc" or "desc". Default is "asc".
* @return QueryResultInterface|array all entries ordered by localized name
*/
protected function findAllOrderedByLocalizedName($orderDirection = 'asc')
{
$entities = parent::findAll();
return $this->localizedSort($entities, $orderDirection);
}
/**
* Sort entities by the localized name
*
* @param QueryResultInterface $entities to be sorted
* @param string $orderDirection may be "asc" or "desc". Default is "asc".
*
* @return array entities ordered by localized name
*/
public function localizedSort(QueryResultInterface $entities, $orderDirection = 'asc')
{
$result = $entities->toArray();
$locale = LocalizationUtility::setCollatingLocale();
if ($locale !== false) {
if ($orderDirection === 'asc') {
uasort($result, [$this, 'strcollOnLocalizedName']);
} else {
uasort($result, [$this, 'strcollOnLocalizedNameDesc']);
}
}
return $result;
}
/**
* Using strcoll comparison on localized names
*
* @return int see strcoll
*
* @param mixed $entityA
* @param mixed $entityB
*/
protected function strcollOnLocalizedName($entityA, $entityB)
{
return strcoll($entityA->getNameLocalized(), $entityB->getNameLocalized());
}
/**
* Using strcoll comparison on localized names - descending order
*
* @return int see strcoll
*
* @param mixed $entityA
* @param mixed $entityB
*/
protected function strcollOnLocalizedNameDesc($entityA, $entityB)
{
return strcoll($entityB->getNameLocalized(), $entityA->getNameLocalized());
}
/**
* Find all ordered by given property name
*
* @param string $propertyName property name to order by
* @param string $orderDirection may be "asc" or "desc". Default is "asc".
* @return QueryResultInterface|array all entries ordered by $propertyName
*/
public function findAllOrderedBy($propertyName, $orderDirection = 'asc')
{
$queryResult = [];
if ($orderDirection !== 'asc' && $orderDirection !== 'desc') {
throw new \InvalidArgumentException('Order direction must be "asc" or "desc".', 1316607580);
}
if ($propertyName == 'nameLocalized') {
$queryResult = $this->findAllOrderedByLocalizedName($orderDirection);
} else {
$query = $this->createQuery();
$object = new $this->objectType();
if (!array_key_exists($propertyName, $object->_getProperties())) {
throw new \InvalidArgumentException('The model "' . $this->objectType . '" has no property "' . $propertyName . '" to order by.', 1316607579);
}
if ($orderDirection === 'asc') {
$orderDirection = QueryInterface::ORDER_ASCENDING;
} else {
$orderDirection = QueryInterface::ORDER_DESCENDING;
}
$query->setOrderings([$propertyName => $orderDirection]);
return $query->execute();
}
return $queryResult;
}
/**
* Adds localization columns, if needed
*
* @param string $locale: the locale for which localization columns should be added
* @return AbstractEntityRepository $this
*/
public function addLocalizationColumns($locale)
{
$dataMap = $this->dataMapper->getDataMap($this->objectType);
$tableName = $dataMap->getTableName();
$fieldsInfo = $this->getFieldsInfo();
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
foreach ($fieldsInfo as $field => $fieldInfo) {
if ($field != 'cn_official_name_en') {
$matches = [];
if (preg_match('#_en$#', $field, $matches)) {
// Make localization field name
$localizationField = preg_replace('#_en$#', '_' . $locale, $field);
// Add the field if it does not yet exist
if (!$fieldsInfo[$localizationField]) {
// Get field length
$matches = [];
if (preg_match('#\\(([0-9]+)\\)#', $fieldInfo['Type'] ?? '', $matches)) {
$localizationFieldLength = (int)($matches[1]);
// Add the localization field
$connection = $connectionPool->getConnectionForTable($tableName);
$column = new Column($localizationField, Type::getType(Type::STRING));
$column->setLength($localizationFieldLength)
->setNotnull(true)
->setDefault('');
$tableDiff = new TableDiff($tableName, [$column]);
$query = $connection->getDatabasePlatform()->getAlterTableSQL($tableDiff);
$connection->executeUpdate($query[0]);
}
}
}
}
}
return $this;
}
/**
* Get the information on the table fields
*
* @return array table fields information array
*/
protected function getFieldsInfo()
{
$fieldsInfo = [];
$dataMap = $this->dataMapper->getDataMap($this->objectType);
$tableName = $dataMap->getTableName();
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$connection = $connectionPool->getConnectionForTable($tableName);
$query = $connection->getDatabasePlatform()->getListTableColumnsSQL($tableName, $connection->getDatabase());
$columnsInfo = $connection->executeQuery($query);
foreach ($columnsInfo as $fieldRow) {
$fieldsInfo[$fieldRow['Field']] = $fieldRow;
}
return $fieldsInfo;
}
/**
* Get update queries for the localization columns for a given locale
*
* @return array Update queries
* @param mixed $locale
*/
public function getUpdateQueries($locale)
{
// Get the information of the table and its fields
$dataMap = $this->dataMapper->getDataMap($this->objectType);
$tableName = $dataMap->getTableName();
$tableFields = array_keys($this->getFieldsInfo());
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$connection = $connectionPool->getConnectionForTable($tableName);
$updateQueries = [];
// If the language pack is not yet created or not yet installed, the localization columns are not yet part of the domain model
$exportFields = [];
foreach ($tableFields as $field) {
$matches = [];
if (preg_match('#_' . strtolower($locale) . '$#', $field, $matches)) {
$exportFields[] = $field;
}
}
if (count($exportFields)) {
$updateQueries[] = '## ' . $tableName;
$exportFields = array_merge($exportFields, $this->isoKeys);
$queryBuilder = $connectionPool->getQueryBuilderForTable($tableName);
$queryBuilder->getRestrictions()->removeAll();
$queryBuilder->select($exportFields[0]);
array_shift($exportFields);
foreach ($exportFields as $exportField) {
$queryBuilder->addSelect($exportField);
}
$rows = $queryBuilder
->from($tableName)
->execute()
->fetchAll();
foreach ($rows as $row) {
$set = [];
foreach ($row as $field => $value) {
if (!in_array($field, $this->isoKeys)) {
$set[] = $field . '=' . $connection->quote($value);
}
}
$whereClause = '';
foreach ($this->isoKeys as $field) {
$whereClause .= ($whereClause ? ' AND ' : ' WHERE ') . $field . '=' . $connection->quote($row[$field]);
}
$updateQueries[] = 'UPDATE ' . $tableName . ' SET ' . implode(',', $set) . $whereClause . ';';
}
}
return $updateQueries;
}
/**
* Dump non-localized contents of the repository
*/
public function sqlDumpNonLocalizedData()
{
// Get the information of the table and its fields
$dataMap = $this->dataMapper->getDataMap($this->objectType);
$tableName = $dataMap->getTableName();
$sqlSchemaMigrationService = GeneralUtility::makeInstance(SqlSchemaMigrationService::class);
$dbFieldDefinitions = $sqlSchemaMigrationService->getFieldDefinitions_database();
$dbFields = [];
$dbFields[$tableName] = $dbFieldDefinitions[$tableName];
$extensionKey = GeneralUtility::camelCaseToLowerCaseUnderscored($this->extensionName);
$extensionPath = ExtensionManagementUtility::extPath($extensionKey);
$ext_tables = @file_get_contents($extensionPath . 'ext_tables.sql');
$tableFields = array_keys($dbFields[$tableName]['fields']);
foreach ($tableFields as $field) {
// This is a very simple check if the field is from static_info_tables and not from a language pack
$match = [];
if (!preg_match('#' . preg_quote($field, '#') . '#m', $ext_tables, $match)) {
unset($dbFields[$tableName]['fields'][$field]);
}
}
$databaseUtility = GeneralUtility::makeInstance(DatabaseUtility::class);
return $databaseUtility->dumpStaticTables($dbFields);
}
/**
* Adds an object to this repository.
*
* @param object $object The object to add
* @return void
* @throws \BadMethodCallException(
*/
public function add($object)
{
throw new \BadMethodCallException(
'This is a read-only repository in which the add method must not be called.',
1420485488
);
}
/**
* Removes an object from this repository.
*
* @param object $object The object to remove
* @return void
* @throws \BadMethodCallException(
*/
public function remove($object)
{
throw new \BadMethodCallException(
'This is a read-only repository in which the remove method must not be called.',
1420485646
);
}
/**
* Replaces an existing object with the same identifier by the given object.
*
* @return void
* @throws \BadMethodCallException(
*/
public function update($modifiedObject)
{
throw new \BadMethodCallException(
'This is a read-only repository in which the update method must not be called.',
1420485660
);
}
/**
* Removes all objects of this repository as if remove() was called for all of them.
*
* @return void
* @throws \BadMethodCallException(
*/
public function removeAll()
{
throw new \BadMethodCallException(
'This is a read-only repository in which the removeAll method must not be called.',
1420485668
);
}
}

View File

@@ -0,0 +1,119 @@
<?php
namespace SJBR\StaticInfoTables\Domain\Repository;
/*
* Copyright notice
*
* (c) 2011-2012 Armin Rädiger Vieweg <info@professorweb.de>
* (c) 2013-2016 Stanislas Rolland <typo3(arobas)sjbr.ca>
*
* 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 2 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\Territory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
/**
* Repository for \SJBR\StaticInfoTables\Domain\Model\Country
*/
class CountryRepository extends AbstractEntityRepository
{
/**
* ISO keys for this static table
*
* @var array
*/
protected $isoKeys = ['cn_iso_2'];
/**
* @var TerritoryRepository
*/
protected $territoryRepository;
/**
* Dependency injection of the Territory Repository
*
* @param TerritoryRepository $territoryRepository
* @return void
*/
public function injectTerritoryRepository(TerritoryRepository $territoryRepository)
{
$this->territoryRepository = $territoryRepository;
}
/**
* Finds countries by territory
*
* @param Territory $territory
* @return QueryResultInterface|array
*/
public function findByTerritory(Territory $territory)
{
$unCodeNumbers = [$territory->getUnCodeNumber()];
// Get UN code numbers of subterritories (recursively)
$subterritories = $this->territoryRepository->findWithinTerritory($territory);
foreach ($subterritories as $subterritory) {
$unCodeNumbers[] = $subterritory->getUnCodeNumber();
}
$query = $this->createQuery();
$query->matching(
$query->in('parentTerritoryUnCodeNumber', $unCodeNumbers)
);
return $query->execute();
}
/**
* Finds countries by territory ordered by localized name
*
* @param Territory $territory
* @return array Countries of the territory sorted by localized name
*/
public function findByTerritoryOrderedByLocalizedName(Territory $territory)
{
$entities = $this->findByTerritory($territory);
return $this->localizedSort($entities);
}
/**
* Finds a set of allowed countries
*
* @param string $allowedCountries: list of alpha-3 country codes
* @return array the selected countries
*/
public function findAllowedByIsoCodeA3($allowedCountries = '')
{
$query = $this->createQuery();
$countries = GeneralUtility::trimExplode(',', $allowedCountries, true);
$query->matching(
$query->in('isoCodeA3', $countries)
);
$entities = $query->execute();
$orderedCountries = [];
foreach ($countries as $isoCodeA3) {
foreach ($entities as $entity) {
if ($entity->getIsoCodeA3() === $isoCodeA3) {
$orderedCountries[] = $entity;
break;
}
}
}
return $orderedCountries;
}
}

View File

@@ -0,0 +1,68 @@
<?php
namespace SJBR\StaticInfoTables\Domain\Repository;
/*
* Copyright notice
*
* (c) 2011-2012 Armin Rüdiger Vieweg <info@professorweb.de>
* (c) 2013-2021 Stanislas Rolland <typo3AAAA(arobas)sjbr.ca>
*
* 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 2 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 TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
/**
* Repository for \SJBR\StaticInfoTables\Domain\Model\CountryZone
*/
class CountryZoneRepository extends AbstractEntityRepository
{
/**
* @var array ISO keys for this static table
*/
protected $isoKeys = ['zn_country_iso_2', 'zn_code'];
/**
* Finds country zones by country
*
* @param Country $country
* @return QueryResultInterface|array
*/
public function findByCountry(Country $country)
{
$query = $this->createQuery();
$query->matching(
$query->equals('countryIsoCodeNumber', $country->getIsoCodeNumber())
);
return $query->execute();
}
/**
* Finds country zones by country ordered by localized name
*
* @param Country $country
* @return array Country zones of the country sorted by localized name
*/
public function findByCountryOrderedByLocalizedName(Country $country)
{
$entities = $this->findByCountry($country);
return $this->localizedSort($entities);
}
}

View File

@@ -0,0 +1,56 @@
<?php
namespace SJBR\StaticInfoTables\Domain\Repository;
/*
* Copyright notice
*
* (c) 2011-2012 Armin Rüdiger Vieweg <info@professorweb.de>
* (c) 2013-2021 Stanislas Rolland <typo3AAAA(arobas)sjbr.ca>
*
* 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 2 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 TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
/**
* Repository for \SJBR\StaticInfoTables\Domain\Model\Currency
*/
class CurrencyRepository extends AbstractEntityRepository
{
/**
* @var array ISO keys for this static table
*/
protected $isoKeys = ['cu_iso_3'];
/**
* Finds currency by country
*
* @param Country $country
* @return QueryResultInterface|array
*/
public function findByCountry(Country $country)
{
$query = $this->createQuery();
$query->matching(
$query->equals('isoCodeNumber', $country->getCurrencyIsoCodeNumber())
);
return $query->execute();
}
}

View File

@@ -0,0 +1,159 @@
<?php
namespace SJBR\StaticInfoTables\Domain\Repository;
/*
* Copyright notice
*
* (c) 2013-2021 Stanislas Rolland <typo3AAAA(arobas)sjbr.ca>
* 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 2 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.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* 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\Cache\ClassCacheManager;
use SJBR\StaticInfoTables\Domain\Model\LanguagePack;
use SJBR\StaticInfoTables\Utility\VersionNumberUtility;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\Repository;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use TYPO3\CMS\Extensionmanager\Utility\InstallUtility;
class LanguagePackRepository extends Repository
{
/**
* @var string Name of the extension this class belongs to
*/
protected $extensionName = 'StaticInfoTables';
/**
* Writes the language pack files
*
* @param LanguagePack the object to be stored
* @return array localized messages
*/
public function writeLanguagePack(LanguagePack $languagePack)
{
$content = [];
$extensionKey = GeneralUtility::camelCaseToLowerCaseUnderscored($this->extensionName);
$extensionPath = ExtensionManagementUtility::extPath($extensionKey);
$content = [];
$locale = $languagePack->getLocale();
$localeLowerCase = strtolower($locale);
$localeUpperCase = strtoupper($locale);
$localeCamel = GeneralUtility::underscoredToUpperCamelCase(strtolower($locale));
$languagePackExtensionKey = $extensionKey . '_' . $localeLowerCase;
$languagePackExtensionPath = Environment::getPublicPath() . '/typo3conf/ext/' . $languagePackExtensionKey . '/';
// Cleanup any pre-existing language pack
if (is_dir($languagePackExtensionPath)) {
GeneralUtility::rmdir($languagePackExtensionPath, true);
}
// Create language pack directory structure
if (!is_dir($languagePackExtensionPath)) {
GeneralUtility::mkdir_deep($languagePackExtensionPath);
}
if (!is_dir($languagePackExtensionPath . 'Classes/Domain/Model/')) {
GeneralUtility::mkdir_deep($languagePackExtensionPath . 'Classes/Domain/Model/');
}
if (!is_dir($languagePackExtensionPath . 'Configuration/DomainModelExtension/')) {
GeneralUtility::mkdir_deep($languagePackExtensionPath . 'Configuration/DomainModelExtension/');
}
if (!is_dir($languagePackExtensionPath . 'Configuration/TCA/Overrides/')) {
GeneralUtility::mkdir_deep($languagePackExtensionPath . 'Configuration/TCA/Overrides/');
}
if (!is_dir($languagePackExtensionPath . 'Configuration/PageTSconfig/')) {
GeneralUtility::mkdir_deep($languagePackExtensionPath . 'Configuration/PageTSconfig/');
}
if (!is_dir($languagePackExtensionPath . 'Configuration/Extbase/Persistence/')) {
GeneralUtility::mkdir_deep($languagePackExtensionPath . 'Configuration/Extbase/Persistence/');
}
if (!is_dir($languagePackExtensionPath . 'Resources/Private/Language/')) {
GeneralUtility::mkdir_deep($languagePackExtensionPath . 'Resources/Private/Language/');
}
if (!is_dir($languagePackExtensionPath . 'Resources/Public/Icons/')) {
GeneralUtility::mkdir_deep($languagePackExtensionPath . 'Resources/Public/Icons/');
}
// Get the source files of the language pack template
$sourcePath = $extensionPath . 'Resources/Private/LanguagePackTemplate/';
$sourceFiles = [];
$sourceFiles = GeneralUtility::getAllFilesAndFoldersInPath($sourceFiles, $sourcePath);
$sourceFiles = GeneralUtility::removePrefixPathFromList($sourceFiles, $sourcePath);
$typo3VersionRange = VersionNumberUtility::splitVersionRange($languagePack->getTypo3VersionRange());
$typo3VersionMinArray = VersionNumberUtility::convertVersionStringToArray($typo3VersionRange[0]);
$typo3VersionMaxArray = VersionNumberUtility::convertVersionStringToArray(VersionNumberUtility::raiseVersionNumber('main', $typo3VersionRange[1]));
// Set markers replacement values
$replace = [
'###LANG_ISO_LOWER###' => $localeLowerCase,
'###LANG_ISO_UPPER###' => $localeUpperCase,
'###LANG_ISO_CAMEL###' => $localeCamel,
'###TYPO3_VERSION_RANGE###' => $languagePack->getTypo3VersionRange(),
'###TYPO3_VERSION_MIN###' => $typo3VersionMinArray['version_main'] . '.' . $typo3VersionMinArray['version_sub'],
'###TYPO3_VERSION_MAX###' => $typo3VersionMaxArray['version_main'] . '.0',
'###VERSION###' => $languagePack->getVersion(),
'###LANG_NAME###' => $languagePack->getLanguage(),
'###AUTHOR###' => $languagePack->getAuthor(),
'###AUTHOR_EMAIL###' => $languagePack->getAuthorEmail(),
'###AUTHOR_COMPANY###' => $languagePack->getAuthorCompany(),
'###VENDOR_NAME###' => $languagePack->getVendorName(),
'###VERSION_BASE###' => $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS'][$extensionKey]['version'],
'###LANG_TCA_LABELS###' => $languagePack->getLocalizationLabels(),
'###LANG_SQL_UPDATE###' => $languagePack->getUpdateQueries(),
];
// Create the language pack files
$success = true;
foreach ($sourceFiles as $hash => $file) {
$fileContent = @file_get_contents($sourcePath . $file);
foreach ($replace as $marker => $replacement) {
$fileContent = str_replace($marker, $replacement, $fileContent);
}
$success = GeneralUtility::writeFile($languagePackExtensionPath . str_replace('.code', '.php', $file), $fileContent);
if (!$success) {
$content[] = LocalizationUtility::translate('couldNotWriteFile', $this->extensionName) . ' ' . $languagePackExtensionPath . $file;
break;
}
}
if ($success) {
$cacheManager = GeneralUtility::makeInstance(CacheManager::class);
$classCacheManager = new ClassCacheManager($cacheManager);
$installUtility = GeneralUtility::makeInstance(InstallUtility::class);
$installed = ExtensionManagementUtility::isLoaded($languagePackExtensionKey);
if ($installed) {
$content[] = LocalizationUtility::translate('languagePack', $this->extensionName)
. ' ' . $languagePackExtensionKey
. ' ' . LocalizationUtility::translate('languagePackUpdated', $this->extensionName);
} else {
$content[] = LocalizationUtility::translate('languagePackCreated', $this->extensionName) . ' ' . $languagePack->getLanguage() . ' (' . $locale . ')';
$installUtility->install($languagePackExtensionKey);
$content[] = LocalizationUtility::translate('languagePack', $this->extensionName)
. ' ' . $languagePackExtensionKey
. ' ' . LocalizationUtility::translate('wasInstalled', $this->extensionName);
}
$classCacheManager->reBuild();
}
return $content;
}
}

View File

@@ -0,0 +1,65 @@
<?php
namespace SJBR\StaticInfoTables\Domain\Repository;
/*
* Copyright notice
*
* (c) 2013-2021 Stanislas Rolland <typo3AAAA(arobas)sjbr.ca>
*
* 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 2 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 TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
/**
* Repository for \SJBR\StaticInfoTables\Domain\Model\Language
*/
class LanguageRepository extends AbstractEntityRepository
{
/**
* @var array ISO keys for this static table
*/
protected $isoKeys = ['lg_iso_2', 'lg_country_iso_2'];
/**
* Find all neither constructed nor sacred languages
*
* @return QueryResultInterface|array all languages neither constructed nor sacred
*/
public function findAllNonConstructedNonSacred()
{
$query = $this->createQuery();
$query->matching($query->logicalAnd([$query->equals('constructedLanguage', false), $query->equals('sacredLanguage', false)]));
return $query->execute();
}
/**
* Find the language object with the specified iso codes
*
* @param string $languageIsoCodeA2
* @param string $countryIsoCodeA2
* @return QueryResultInterface|array all entries ordered by $propertyName
*/
public function findOneByIsoCodes($languageIsoCodeA2, $countryIsoCodeA2 = '')
{
$query = $this->createQuery();
$query->matching($query->logicalAnd([$query->equals('isoCodeA2', $languageIsoCodeA2), $query->equals('countryIsoCodeA2', $countryIsoCodeA2)]));
return $query->execute()->getFirst();
}
}

View File

@@ -0,0 +1,57 @@
<?php
namespace SJBR\StaticInfoTables\Domain\Repository;
/***************************************************************
* Copyright notice
*
* (c) 2013-2017 Stanislas Rolland <typo3@sjbr.ca>
* 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 2 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.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* 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 TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
use TYPO3\CMS\Extbase\Persistence\Repository;
/**
* System language repository
*/
class SystemLanguageRepository extends Repository
{
/**
* Find all system language objects with uid in list
* If no list is provided, find all system language objects
*
* @param string $list: list of uid's
*
* @return QueryResultInterface|array all entries
*/
public function findAllByUidInList($list = '')
{
if (empty($list)) {
return $this->findAll();
}
$query = $this->createQuery();
$list = GeneralUtility::trimExplode(',', $list, true);
$query->matching($query->in('uid', $list));
return $query->execute();
}
}

View File

@@ -0,0 +1,107 @@
<?php
namespace SJBR\StaticInfoTables\Domain\Repository;
/*
* Copyright notice
*
* (c) 2011-2012 Armin Rüdiger Vieweg <info@professorweb.de>
* (c) 2013-2021 Stanislas Rolland <typo3AAAA(arobas)sjbr.ca>
*
* 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 2 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\Model\Territory;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
/**
* Repository for \SJBR\StaticInfoTables\Domain\Model\Territory
*/
class TerritoryRepository extends AbstractEntityRepository
{
/**
* ISO keys for this static table
*
* @var array
*/
protected $isoKeys = ['tr_iso_nr'];
/**
* Finds the territory within which a country is located
*
* @param Country $country
* @return QueryResultInterface|array
*/
public function findByCountry(Country $country)
{
$query = $this->createQuery();
$query->matching(
$query->equals('unCodeNumber', $country->getParentTerritoryUnCodeNumber())
);
return $query->execute();
}
/**
* Finds territories that have a given territory as parent territory
*
* @param Territory $territory
* @return QueryResultInterface|array
*/
public function findByTerritory(Territory $territory)
{
$query = $this->createQuery();
$query->matching(
$query->equals('parentTerritoryUnCodeNumber', $territory->getUnCodeNumber())
);
return $query->execute();
}
/**
* Finds all territories within a territory recursively
*
* @param Territory $territory
* @param array $unCodeNumbers array of UN territory code numbers used for recursive retrieval of sub-territories
* @return QueryResultInterface|array
*/
public function findWithinTerritory(Territory $territory, &$unCodeNumbers = [])
{
if (empty($unCodeNumbers)) {
$unCodeNumbers = [$territory->getUnCodeNumber()];
}
$initialCount = count($unCodeNumbers);
$query = $this->createQuery();
$query->matching(
$query->in('parentTerritoryUnCodeNumber', $unCodeNumbers)
);
$territories = $query->execute();
// Get UN code numbers of new subterritories
foreach ($territories as $subterritory) {
$unCodeNumbers[] = $subterritory->getUnCodeNumber();
}
$unCodeNumbers = array_unique($unCodeNumbers);
// Call recursively until no additional subterritories are found
if (count($unCodeNumbers) > $initialCount) {
$territories = $this->findWithinTerritory($territory, $unCodeNumbers);
}
return $territories;
}
}