[TASK] Remove references to TYPO3_DB object 05/58605/2
authorStanislas Rolland <typo3@sjbr.ca>
Tue, 9 Oct 2018 17:42:53 +0000 (13:42 -0400)
committerStanislas Rolland <typo3@sjbr.ca>
Tue, 9 Oct 2018 17:51:05 +0000 (19:51 +0200)
Change-Id: Iac40659bf07b31475293d03a28523bc7127f5179
Resolves: #86609
Reviewed-on: https://review.typo3.org/58605
Reviewed-by: Stanislas Rolland <typo3@sjbr.ca>
Tested-by: Stanislas Rolland <typo3@sjbr.ca>
ChangeLog
Classes/Domain/Repository/AbstractEntityRepository.php
Classes/Hook/Core/DataHandling/ProcessDataMap.php
Classes/PiBaseApi.php
Classes/Slot/Extensionmanager/AfterExtensionInstall.php
Classes/Utility/DatabaseUpdateUtility.php
Classes/Utility/LocalizationUtility.php
class.tx_staticinfotables_encoding.php [deleted file]

index 4cde5ae..7b3901e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-10-9  Stanislas Rolland  <typo3(arobas)sjbr.ca>
+
+       * Resolves #86608: Remove support for TYPO3 7 LTS - Thanks to Tomas Norre Mikkelsen
+       * Resolves #86609: Remove references to TYPO3_DB object - Thanks to Tomas Norre Mikkelsen
+
 2017-12-19  Stanislas Rolland  <typo3(arobas)sjbr.ca>
 
        * Resolves #83060: Wrong table name in Configuration/TCA/Overrides/static_countries.php - Thanks to Simon Schaufelberger
index dcdd02d..884d04f 100644 (file)
@@ -5,7 +5,7 @@ namespace SJBR\StaticInfoTables\Domain\Repository;
  *  Copyright notice
  *
  *  (c) 2011-2012 Armin Rüdiger Vieweg <info@professorweb.de>
- *  (c) 2013-2017 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  (c) 2013-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *
  *  All rights reserved
  *
@@ -32,6 +32,7 @@ use Doctrine\DBAL\Schema\Column;
 use Doctrine\DBAL\Schema\TableDiff;
 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;
@@ -222,11 +223,7 @@ abstract class AbstractEntityRepository extends Repository
                $dataMap = $this->dataMapper->getDataMap($this->objectType);
                $tableName = $dataMap->getTableName();
                $fieldsInfo = $this->getFieldsInfo();
-               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                       // TYPO3 CMS 8+ LTS
-                       $connectionPool = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class);
-               }
-
+               $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
                foreach ($fieldsInfo as $field => $fieldInfo) {
                        if ($field != 'cn_official_name_en') {
                                $matches = array();
@@ -240,20 +237,14 @@ abstract class AbstractEntityRepository extends Repository
                                                if (preg_match('#\(([0-9]+)\)#', $fieldInfo['Type'], $matches)) {
                                                        $localizationFieldLength = intval($matches[1]);
                                                        // Add the localization field
-                                                       if (is_object($connectionPool)) {
-                                                               // TYPO3 CMS 8+ LTS
-                                                               $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]);
-                                                       } else {
-                                                               $query = 'ALTER TABLE ' . $tableName . ' ADD ' . $localizationField . ' varchar(' . $localizationFieldLength . ') DEFAULT \'\' NOT NULL;';
-                                                               $res = $GLOBALS['TYPO3_DB']->admin_query($query);
-                                                       }
+                                                       $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]);
                                                }
                                        }
                                }
@@ -272,17 +263,12 @@ abstract class AbstractEntityRepository extends Repository
                $fieldsInfo = array();
                $dataMap = $this->dataMapper->getDataMap($this->objectType);
                $tableName = $dataMap->getTableName();
-               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                       // TYPO3 CMS 8+ LTS
-                       $connectionPool = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\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;
-                       }
-               } else {
-                       $fieldsInfo = $GLOBALS['TYPO3_DB']->admin_get_fields($tableName);
+               $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;
        }
@@ -298,14 +284,9 @@ abstract class AbstractEntityRepository extends Repository
                $dataMap = $this->dataMapper->getDataMap($this->objectType);
                $tableName = $dataMap->getTableName();
                $tableFields = array_keys($this->getFieldsInfo());
-               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                       // TYPO3 CMS 8+ LTS
-                       $connectionPool = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class);
-                       $connection = $connectionPool->getConnectionForTable($tableName);
-               }
-
+               $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
+               $connection = $connectionPool->getConnectionForTable($tableName);
                $updateQueries = array();
-
                // If the language pack is not yet created or not yet installed, the localization columns are not yet part of the domain model
                $exportFields = array();
                foreach ($tableFields as $field) {
@@ -317,40 +298,27 @@ abstract class AbstractEntityRepository extends Repository
                if (count($exportFields)) {
                        $updateQueries[] = '## ' . $tableName;
                        $exportFields = array_merge($exportFields, $this->isoKeys);
-                       if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                               // TYPO3 CMS 8+ LTS
-                               $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();
-                       } else {
-                               $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(implode(',', $exportFields), $tableName, '');
+                       $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 = array();
                                foreach ($row as $field => $value) {
                                        if (!in_array($field, $this->isoKeys)) {
-                                               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                                                       $set[] = $field . '=' . $connection->quote($value);
-                                               } else {
-                                                       $set[] = $field . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value, $tableName);
-                                               }
+                                               $set[] = $field . '=' . $connection->quote($value);
                                        }
                                }
                                $whereClause = '';
                                foreach ($this->isoKeys as $field) {
-                                       if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                                               $whereClause .= ($whereClause ? ' AND ' : ' WHERE ') . $field . '=' . $connection->quote($row[$field]);
-                                       } else {
-                                               $whereClause .= ($whereClause ? ' AND ' : ' WHERE ') . $field . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($row[$field], $tableName);
-                                       }
+                                       $whereClause .= ($whereClause ? ' AND ' : ' WHERE ') . $field . '=' . $connection->quote($row[$field]);
                                }
                                $updateQueries[] = 'UPDATE ' . $tableName . ' SET ' . implode(',', $set) . $whereClause . ';';
                        }
index 7696193..2870fad 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\StaticInfoTables\Hook\Core\DataHandling;
 /***************************************************************
  *  Copyright notice
  *
- *  (c) 2013-2017 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  (c) 2013-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the Typo3 project. The Typo3 project is
@@ -27,6 +27,7 @@ namespace SJBR\StaticInfoTables\Hook\Core\DataHandling;
 use SJBR\StaticInfoTables\Domain\Repository\CountryRepository;
 use SJBR\StaticInfoTables\Domain\Repository\CurrencyRepository;
 use SJBR\StaticInfoTables\Domain\Repository\TerritoryRepository;
+use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 
@@ -106,35 +107,18 @@ class ProcessDataMap
                                $country = $countryRepository->findOneByUid((int)$id);
                                // Get the country zones
                                $countryZones = $country->getCountryZones()->toArray();
-                               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                                       if (count($countryZones)) {
-                                               $connection = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)->getConnectionForTable('static_country_zones');
-                                               foreach ($countryZones as $countryZone) {
-                                                       $connection->update(
-                                                               'static_country_zones',
-                                                               [
-                                                                       'zn_country_iso_nr' => (int)$country->getIsoCodeNumber(),
-                                                                       'zn_country_iso_2' => $country->getIsoCodeA2(),
-                                                                       'zn_country_iso_3' => $country->getIsoCodeA3()
-                                                               ],
-                                                               ['uid' => (int)$countryZone->getUid()]
-                                                       );
-                                               }
-                                       }
-                               } else {
-                                       // TYPO3 CMS 7 LTS
-                                       if (count($countryZones)) {
-                                               foreach ($countryZones as $countryZone) {
-                                                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery(
-                                                               'static_country_zones',
-                                                               'uid = ' . (int)$countryZone->getUid(),
-                                                               [
-                                                                       'zn_country_iso_nr' => (int)$country->getIsoCodeNumber(),
-                                                                       'zn_country_iso_2' => $country->getIsoCodeA2(),
-                                                                       'zn_country_iso_3' => $country->getIsoCodeA3()
-                                                               ]
-                                                       );
-                                               }
+                               if (count($countryZones)) {
+                                       $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('static_country_zones');
+                                       foreach ($countryZones as $countryZone) {
+                                               $connection->update(
+                                                       'static_country_zones',
+                                                       [
+                                                               'zn_country_iso_nr' => (int)$country->getIsoCodeNumber(),
+                                                               'zn_country_iso_2' => $country->getIsoCodeA2(),
+                                                               'zn_country_iso_3' => $country->getIsoCodeA3()
+                                                       ],
+                                                       ['uid' => (int)$countryZone->getUid()]
+                                               );
                                        }
                                }
                                break;
index 8ea0bbf..8636706 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\StaticInfoTables;
 /***************************************************************
  *  Copyright notice
  *
- *  (c) 2004-2017 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  (c) 2004-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the Typo3 project. The Typo3 project is
@@ -27,10 +27,14 @@ namespace SJBR\StaticInfoTables;
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
 
+use SJBR\StaticInfoTables\Domain\Model\Currency;
 use SJBR\StaticInfoTables\Domain\Repository\CountryRepository;
 use SJBR\StaticInfoTables\Domain\Repository\CurrencyRepository;
 use SJBR\StaticInfoTables\Utility\HtmlElementUtility;
 use SJBR\StaticInfoTables\Utility\LocalizationUtility;
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Database\Query\QueryHelper;
+use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Frontend\Plugin\AbstractPlugin;
@@ -165,7 +169,7 @@ class PiBaseApi extends AbstractPlugin
        /**
         * Getting the name of a country, country subdivision, currency, language, tax
         *
-        * @param string Defines the type of entry of the requested name: 'TERRIRORIES', 'COUNTRIES', 'SUBDIVISIONS', 'CURRENCIES', 'LANGUAGES'
+        * @param string Defines the type of entry of the requested name: 'TERRITORIES', 'COUNTRIES', 'SUBDIVISIONS', 'CURRENCIES', 'LANGUAGES'
         * @param string The ISO alpha-3 code of a territory, country or currency, or the ISO alpha-2 code of a language or the code of a country subdivision, can be a comma ',' separated string, then all the single items are looked up and returned
         * @param string The value of the country code (cn_iso_3) for which a name of type 'SUBDIVISIONS' is requested (meaningful only in this case)
         * @param string Not used
@@ -308,66 +312,37 @@ class PiBaseApi extends AbstractPlugin
                }
                array_unique($prefixedTitleFields);
 
-               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                       $queryBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)
-                               ->getQueryBuilderForTable($table );
-                       $queryBuilder->setRestrictions(GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer::class));
-                       $queryBuilder
-                               ->select($prefixedTitleFields[0])
-                               ->from($table);
-                       array_shift($prefixedTitleFields);
-                       foreach ($prefixedTitleFields as $titleField) {
-                               $queryBuilder->addSelect($titleField);
-                       }
-                       if ($param === 'UN') {
-                               $queryBuilder->where($queryBuilder->expr()->eq('cn_uno_member', $queryBuilder->createNamedParameter(1, \PDO::PARAM_INT)));
-                       } else if ($param === 'EU') {
-                               $queryBuilder->where($queryBuilder->expr()->eq('cn_eu_member', $queryBuilder->createNamedParameter(1, \PDO::PARAM_INT)));
-                       }
-                       if ($addWhere) {
-                               $addWhere = \TYPO3\CMS\Core\Database\Query\QueryHelper::stripLogicalOperatorPrefix($addWhere);
-                               if (empty($queryBuilder->getQueryPart('where'))) {
-                                       $queryBuilder->where($addWhere);
-                               } else {
-                                       $queryBuilder->andWhere($addWhere);
-                               }
-                       }
-                       $query = $queryBuilder->execute();
-                       while ($row = $query->fetch()) {
-                               foreach ($titleFields as $titleField) {
-                                       if ($row[$titleField]) {
-                                               $nameArray[$row['cn_iso_3']] = $row[$titleField];
-                                               break;
-                                       }
-                               }
-                       }
-               } else {
-                       // TYPO3 CMS 7 LTS
-                       $labelFields = implode(',', $prefixedTitleFields);
-                       if ($param == 'UN') {
-                               $where = 'cn_uno_member=1';
-                       } elseif ($param == 'EU') {
-                               $where = 'cn_eu_member=1';
-                       } elseif ($param == 'ALL') {
-                               $where = '1=1';
+               $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+                       ->getQueryBuilderForTable($table );
+               $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
+               $queryBuilder
+                       ->select($prefixedTitleFields[0])
+                       ->from($table);
+               array_shift($prefixedTitleFields);
+               foreach ($prefixedTitleFields as $titleField) {
+                       $queryBuilder->addSelect($titleField);
+               }
+               if ($param === 'UN') {
+                       $queryBuilder->where($queryBuilder->expr()->eq('cn_uno_member', $queryBuilder->createNamedParameter(1, \PDO::PARAM_INT)));
+               } else if ($param === 'EU') {
+                       $queryBuilder->where($queryBuilder->expr()->eq('cn_eu_member', $queryBuilder->createNamedParameter(1, \PDO::PARAM_INT)));
+               }
+               if ($addWhere) {
+                       $addWhere = QueryHelper::stripLogicalOperatorPrefix($addWhere);
+                       if (empty($queryBuilder->getQueryPart('where'))) {
+                               $queryBuilder->where($addWhere);
                        } else {
-                               $where = '1=1';
+                               $queryBuilder->andWhere($addWhere);
                        }
-                       $where .= ($addWhere ? ' AND ' . $addWhere : '');
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                               $labelFields,
-                               $table,
-                               $where . \SJBR\StaticInfoTables\Utility\TcaUtility::getEnableFields($table)
-                       );
-                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                               foreach ($titleFields as $titleField) {
-                                       if ($row[$titleField]) {
-                                               $nameArray[$row['cn_iso_3']] = $row[$titleField];
-                                               break;
-                                       }
+               }
+               $query = $queryBuilder->execute();
+               while ($row = $query->fetch()) {
+                       foreach ($titleFields as $titleField) {
+                               if ($row[$titleField]) {
+                                       $nameArray[$row['cn_iso_3']] = $row[$titleField];
+                                       break;
                                }
                        }
-                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
                }
                if ($this->conf['countriesAllowed'] != '') {
                        $countriesAllowedArray = GeneralUtility::trimExplode(',', $this->conf['countriesAllowed']);
@@ -405,60 +380,34 @@ class PiBaseApi extends AbstractPlugin
                foreach ($titleFields as $titleField) {
                        $prefixedTitleFields[] = $table . '.' . $titleField;
                }
-               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                       $queryBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)
-                               ->getQueryBuilderForTable($table );
-                       $queryBuilder->setRestrictions(GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer::class));
-                       $queryBuilder
-                               ->select($table . '.zn_code')
-                               ->from($table);
-                       foreach ($prefixedTitleFields as $titleField) {
-                               $queryBuilder->addSelect($titleField);
-                       }
-                       if (strlen($param) == 3) {
-                               $queryBuilder->where($queryBuilder->expr()->eq('zn_country_iso_3', $queryBuilder->createNamedParameter($param, \PDO::PARAM_STR)));
-                       }
-                       if ($addWhere) {
-                               $addWhere = \TYPO3\CMS\Core\Database\Query\QueryHelper::stripLogicalOperatorPrefix($addWhere);
-                               if (empty($queryBuilder->getQueryPart('where'))) {
-                                       $queryBuilder->where($addWhere);
-                               } else {
-                                       $queryBuilder->andWhere($addWhere);
-                               }
-                       }
-                       $query = $queryBuilder->execute();
-                       while ($row = $query->fetch()) {
-                               foreach ($titleFields as $titleField) {
-                                       if ($row[$titleField]) {
-                                               $nameArray[$row['zn_code']] = $row[$titleField];
-                                               break;
-                                       }
-                               }
-                       }
-               } else {
-                       // TYPO3 CMS 7 LTS
-                       $labelFields = implode(',', $prefixedTitleFields);
-                       if (strlen($param) == 3) {
-                               $country = $param;
-                               $where = 'zn_country_iso_3=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($country,$table);
+               $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+                       ->getQueryBuilderForTable($table );
+               $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
+               $queryBuilder
+                       ->select($table . '.zn_code')
+                       ->from($table);
+               foreach ($prefixedTitleFields as $titleField) {
+                       $queryBuilder->addSelect($titleField);
+               }
+               if (strlen($param) == 3) {
+                       $queryBuilder->where($queryBuilder->expr()->eq('zn_country_iso_3', $queryBuilder->createNamedParameter($param, \PDO::PARAM_STR)));
+               }
+               if ($addWhere) {
+                       $addWhere = QueryHelper::stripLogicalOperatorPrefix($addWhere);
+                       if (empty($queryBuilder->getQueryPart('where'))) {
+                               $queryBuilder->where($addWhere);
                        } else {
-                               $where = '1=1';
+                               $queryBuilder->andWhere($addWhere);
                        }
-                       $where .= ($addWhere ? ' AND '. $addWhere : '');
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                               $table . '.zn_code,' . $labelFields,
-                               $table,
-                               $where . \SJBR\StaticInfoTables\Utility\TcaUtility::getEnableFields($table)
-                       );
-                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                               foreach ($titleFields as $titleField) {
-                                       if ($row[$titleField]) {
-                                               $nameArray[$row['zn_code']] = $row[$titleField];
-                                               break;
-                                       }
+               }
+               $query = $queryBuilder->execute();
+               while ($row = $query->fetch()) {
+                       foreach ($titleFields as $titleField) {
+                               if ($row[$titleField]) {
+                                       $nameArray[$row['zn_code']] = $row[$titleField];
+                                       break;
                                }
                        }
-                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
                }
                uasort($nameArray, 'strcoll');
                return $nameArray;
@@ -483,47 +432,27 @@ class PiBaseApi extends AbstractPlugin
                foreach ($titleFields as $titleField) {
                        $prefixedTitleFields[] = $table . '.' . $titleField;
                }
-               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                       $queryBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)
-                               ->getQueryBuilderForTable($table );
-                       $queryBuilder->setRestrictions(GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer::class));
-                       $queryBuilder
-                               ->select($table . '.cu_iso_3')
-                               ->from($table);
-                       foreach ($prefixedTitleFields as $titleField) {
-                               $queryBuilder->addSelect($titleField);
-                       }
-                       if ($addWhere) {
-                               $addWhere = \TYPO3\CMS\Core\Database\Query\QueryHelper::stripLogicalOperatorPrefix($addWhere);
-                               $queryBuilder->where($addWhere);
-                       }
-                       $query = $queryBuilder->execute();
-                       while ($row = $query->fetch()) {
-                               foreach ($titleFields as $titleField) {
-                                       if ($row[$titleField]) {
-                                               $nameArray[$row['cu_iso_3']] = $row[$titleField];
-                                               break;
-                                       }
-                               }
-                       }
-               } else {
-                       // TYPO3 CMS 7 LTS
-                       $labelFields = implode(',', $prefixedTitleFields);
-                       $where = '1=1' . ($addWhere ? ' AND ' . $addWhere : '');
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                               $table . '.cu_iso_3,' . $labelFields,
-                               $table,
-                               $where . \SJBR\StaticInfoTables\Utility\TcaUtility::getEnableFields($table)
-                       );
-                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                               foreach ($titleFields as $titleField) {
-                                       if ($row[$titleField]) {
-                                               $nameArray[$row['cu_iso_3']] = $row[$titleField];
-                                               break;
-                                       }
+               $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+                       ->getQueryBuilderForTable($table );
+               $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
+               $queryBuilder
+                       ->select($table . '.cu_iso_3')
+                       ->from($table);
+               foreach ($prefixedTitleFields as $titleField) {
+                       $queryBuilder->addSelect($titleField);
+               }
+               if ($addWhere) {
+                       $addWhere = QueryHelper::stripLogicalOperatorPrefix($addWhere);
+                       $queryBuilder->where($addWhere);
+               }
+               $query = $queryBuilder->execute();
+               while ($row = $query->fetch()) {
+                       foreach ($titleFields as $titleField) {
+                               if ($row[$titleField]) {
+                                       $nameArray[$row['cu_iso_3']] = $row[$titleField];
+                                       break;
                                }
                        }
-                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
                }
                uasort($nameArray, 'strcoll');
                return $nameArray;
@@ -549,51 +478,31 @@ class PiBaseApi extends AbstractPlugin
                foreach ($titleFields as $titleField) {
                        $prefixedTitleFields[] = $table . '.' . $titleField;
                }
-               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                       $queryBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)
-                               ->getQueryBuilderForTable($table );
-                       $queryBuilder->setRestrictions(GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer::class));
-                       $queryBuilder
-                               ->select($table . '.lg_iso_2')
-                               ->addSelect($table . '.lg_country_iso_2')
-                               ->from($table);
-                       foreach ($prefixedTitleFields as $titleField) {
-                               $queryBuilder->addSelect($titleField);
-                       }
-                       $queryBuilder->where(
-                               $queryBuilder->expr()->eq('lg_sacred', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)),
-                               $queryBuilder->expr()->eq('lg_constructed', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT))
-                       );
-                       if ($addWhere) {
-                               $addWhere = \TYPO3\CMS\Core\Database\Query\QueryHelper::stripLogicalOperatorPrefix($addWhere);
-                               $queryBuilder->andWhere($addWhere);
-                       }
-                       $query = $queryBuilder->execute();
-                       while ($row = $query->fetch()) {
-                               $code = $row['lg_iso_2'] . ($row['lg_country_iso_2'] ? '_' . $row['lg_country_iso_2'] : '');
-                               foreach ($titleFields as $titleField) {
-                                       if ($row[$titleField]) {
-                                               $nameArray[$code] = $row[$titleField];
-                                               break;
-                                       }
-                               }
-                       }
-               } else {
-                       // TYPO3 CMS 7 LTS
-                       $labelFields = implode(',', $prefixedTitleFields);
-                       $where = '1=1' . ($addWhere ? ' AND ' . $addWhere : '');
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                               $table . '.lg_iso_2,' . $table . '.lg_country_iso_2,' . $labelFields,
-                               $table,
-                               $where . ' AND lg_sacred = 0 AND lg_constructed = 0 ' . \SJBR\StaticInfoTables\Utility\TcaUtility::getEnableFields($table)
-                       );
-                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                               $code = $row['lg_iso_2'] . ($row['lg_country_iso_2'] ? '_' . $row['lg_country_iso_2'] : '');
-                               foreach ($titleFields as $titleField) {
-                                       if ($row[$titleField]) {
-                                               $nameArray[$code] = $row[$titleField];
-                                               break;
-                                       }
+               $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+                       ->getQueryBuilderForTable($table );
+               $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
+               $queryBuilder
+                       ->select($table . '.lg_iso_2')
+                       ->addSelect($table . '.lg_country_iso_2')
+                       ->from($table);
+               foreach ($prefixedTitleFields as $titleField) {
+                       $queryBuilder->addSelect($titleField);
+               }
+               $queryBuilder->where(
+                       $queryBuilder->expr()->eq('lg_sacred', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)),
+                       $queryBuilder->expr()->eq('lg_constructed', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT))
+               );
+               if ($addWhere) {
+                       $addWhere = QueryHelper::stripLogicalOperatorPrefix($addWhere);
+                       $queryBuilder->andWhere($addWhere);
+               }
+               $query = $queryBuilder->execute();
+               while ($row = $query->fetch()) {
+                       $code = $row['lg_iso_2'] . ($row['lg_country_iso_2'] ? '_' . $row['lg_country_iso_2'] : '');
+                       foreach ($titleFields as $titleField) {
+                               if ($row[$titleField]) {
+                                       $nameArray[$code] = $row[$titleField];
+                                       break;
                                }
                        }
                }
@@ -614,11 +523,11 @@ class PiBaseApi extends AbstractPlugin
                $this->currencyInfo['cu_iso_3'] = $this->currencyInfo['cu_iso_3'] ?: $this->currency;
                $currency = $this->currencyRepository->findOneByIsoCodeA3($this->currencyInfo['cu_iso_3']);
                // If not found we fetch the default currency!
-               if (!is_object($currency)) {
+               if (!($currency instanceof Currency)) {
                        $this->currencyInfo['cu_iso_3'] = $this->currency;
                        $currency = $this->currencyRepository->findOneByIsoCodeA3($this->currencyInfo['cu_iso_3']);
                }
-               if (is_object($currency)) {
+               if ($currency instanceof Currency) {
                        $this->currencyInfo['cu_name'] = $this->getStaticInfoName('CURRENCIES', $this->currencyInfo['cu_iso_3']);
                        $this->currencyInfo['cu_symbol_left'] = $currency->getSymbolLeft();
                        $this->currencyInfo['cu_symbol_right'] = $currency->getSymbolRight();
index 2f42666..6d0319c 100644 (file)
@@ -1,9 +1,10 @@
 <?php
 namespace SJBR\StaticInfoTables\Slot\Extensionmanager;
+
  /***************************************************************
  *  Copyright notice
  *
- *  (c) 2015 StanislasRolland <typo3(arobas)sjbr.ca>
+ *  (c) 2015-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the Typo3 project. The Typo3 project is
@@ -23,17 +24,22 @@ namespace SJBR\StaticInfoTables\Slot\Extensionmanager;
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
 
+use TYPO3\CMS\Core\Registry;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
+use TYPO3\CMS\Core\Utility\PathUtility;
+use TYPO3\CMS\Extbase\Object\ObjectManager;
+use TYPO3\CMS\Extensionmanager\Utility\InstallUtility;
+use TYPO3\CMS\Extensionmanager\Utility\UpdateScriptUtility;
 
 /**
  * AfterExtensionInstall slot
  *
  * Always run the extension update script except on first install of base extension
  */
-class AfterExtensionInstall {
-
+class AfterExtensionInstall
+{
        /**
-        * @var \TYPO3\CMS\Extbase\Object\ObjectManager
+        * @var ObjectManager
         */
        public $objectManager;
 
@@ -43,16 +49,18 @@ class AfterExtensionInstall {
        protected $registry;
 
        /**
-        * @param \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager
+        * @param ObjectManager $objectManager
         */
-       public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManager $objectManager) {
+       public function injectObjectManager(ObjectManager $objectManager)
+       {
                $this->objectManager = $objectManager;
        }
 
        /**
-        * @param \TYPO3\CMS\Core\Registry $registry
+        * @param Registry $registry
         */
-       public function injectRegistry(\TYPO3\CMS\Core\Registry $registry) {
+       public function injectRegistry(Registry $registry)
+       {
                $this->registry = $registry;
        }
 
@@ -60,14 +68,15 @@ class AfterExtensionInstall {
         * If the installed extension is static_info_tables or a language pack, execute the update script
         *
         * @param string $extensionKey: the key of the extension that was installed
-        * @param \TYPO3\CMS\Extensionmanager\Utility\InstallUtility $installUtility
+        * @param InstallUtility $installUtility
         * @return void
         */
-       public function executeUpdateScript($extensionKey, \TYPO3\CMS\Extensionmanager\Utility\InstallUtility $installUtility) {
+       public function executeUpdateScript($extensionKey, InstallUtility $installUtility)
+       {
                if (strpos($extensionKey, 'static_info_tables') === 0) {
                        $extensionKeyParts = explode('_', $extensionKey);
                        if (count($extensionKeyParts) === 3) {
-                               $extTablesStaticSqlRelFile = ExtensionManagementUtility::siteRelPath($extensionKey) . 'ext_tables_static+adt.sql';
+                               $extTablesStaticSqlRelFile = PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($extensionKey)) . 'ext_tables_static+adt.sql';
                        }
                        if (
                                // Base extension with data already imported once
@@ -76,8 +85,7 @@ class AfterExtensionInstall {
                                || (count($extensionKeyParts) === 4 && strlen($extensionKeyParts[3]) === 2)
                                || (count($extensionKeyParts) === 5 && strlen($extensionKeyParts[3]) === 2 && strlen($extensionKeyParts[4]) === 2)
                        ) {
-                               /** @var $updateScriptUtility \TYPO3\CMS\Extensionmanager\Utility\UpdateScriptUtility */
-                               $updateScriptUtility = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\UpdateScriptUtility');
+                               $updateScriptUtility = $this->objectManager->get(UpdateScriptUtility::class);
                                $updateScriptResult = $updateScriptUtility->executeUpdateIfNeeded($extensionKey);
                        }
                }
index e45b96c..912e93f 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\StaticInfoTables\Utility;
 /***************************************************************
  *  Copyright notice
  *
- *  (c) 2013-2017 StanislasRolland <typo3@sjbr.ca>
+ *  (c) 2013-2018 StanislasRolland <typo3@sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the Typo3 project. The Typo3 project is
@@ -25,6 +25,7 @@ namespace SJBR\StaticInfoTables\Utility;
  ***************************************************************/
 
 use SJBR\StaticInfoTables\Database\SqlParser;
+use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -53,39 +54,31 @@ class DatabaseUpdateUtility
                        $line = trim($line);
                        if ($line && preg_match('#^UPDATE#i', $line)) {
                                $parsedResult = $sqlParser->parseSQL($line);
-                               // WHERE clause
-                               $whereClause = $sqlParser->compileWhereClause($parsedResult['WHERE']);
                                // Fields
                                $fields = array();
                                foreach ($parsedResult['FIELDS'] as $fN => $fV) {
                                        $fields[$fN] = $fV[0];
                                }
                                if (count($fields)) {
-                                       if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                                               $queryBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)->getQueryBuilderForTable($parsedResult['TABLE']);
-                                               $queryBuilder->getRestrictions()->removeAll();
-                                               $queryBuilder->update($parsedResult['TABLE']);
-                                               // We expect only a few of conditions combined by AND
-                                               $whereExpressions = [];
-                                               foreach ($parsedResult['WHERE'] as $k => $v) {
-                                                       $whereExpressions[] = $queryBuilder->expr()->eq($v['field'], $queryBuilder->createNamedParameter($v['value'][0]));
+                                       $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($parsedResult['TABLE']);
+                                       $queryBuilder->getRestrictions()->removeAll();
+                                       $queryBuilder->update($parsedResult['TABLE']);
+                                       // We expect only a few of conditions combined by AND
+                                       $whereExpressions = [];
+                                       foreach ($parsedResult['WHERE'] as $k => $v) {
+                                               $whereExpressions[] = $queryBuilder->expr()->eq($v['field'], $queryBuilder->createNamedParameter($v['value'][0]));
+                                       }
+                                       if (count($whereExpressions)) {
+                                               $queryBuilder->where($whereExpressions[0]);
+                                               array_shift($whereExpressions);
+                                               foreach ($whereExpressions as $whereExpression) {
+                                                       $queryBuilder->andWhere($whereExpression);
                                                }
-                                               if (count($whereExpressions)) {
-                                                       $queryBuilder->where($whereExpressions[0]);
-                                                       array_shift($whereExpressions);
-                                                       foreach ($whereExpressions as $whereExpression) {
-                                                               $queryBuilder->andWhere($whereExpression);
-                                                       }
-                                               }
-                                               foreach ($fields as $fN => $fV) {
-                                                  $queryBuilder->set($fN, $fV);
-                                               }
-                                               $queryBuilder->execute();
-                                       } else {
-                                               // WHERE clause
-                                               $whereClause = $sqlParser->compileWhereClause($parsedResult['WHERE']);
-                                               $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($parsedResult['TABLE'], $whereClause, $fields);
-                                       }
+                                       }
+                                       foreach ($fields as $fN => $fV) {
+                                          $queryBuilder->set($fN, $fV);
+                                       }
+                                       $queryBuilder->execute();
                                }
                        }
                }
index 7d16e77..525efde 100644 (file)
@@ -5,7 +5,7 @@ namespace SJBR\StaticInfoTables\Utility;
  *  Copyright notice
  *
  *  (c) 2009 Sebastian Kurfürst <sebastian@typo3.org>
- *  (c) 2013-2017 Stanislas Rolland <typo3@sjbr.ca>
+ *  (c) 2013-2018 Stanislas Rolland <typo3@sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -28,6 +28,7 @@ namespace SJBR\StaticInfoTables\Utility;
 use SJBR\StaticInfoTables\Domain\Model\Language;
 use SJBR\StaticInfoTables\Domain\Repository\LanguageRepository;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
+use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Localization\Locales;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
@@ -87,110 +88,48 @@ class LocalizationUtility
         */
        public static function getLabelFieldValue($identifiers, $tableName, $language, $local = false)
        {
-               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                       $value = '';
-                       $labelFields = self::getLabelFields($tableName, $language, $local);
-                       if (count($labelFields)) {
-                               $queryBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)->getQueryBuilderForTable($tableName);
-                               $queryBuilder->from($tableName)->select('uid');
-                               foreach ($labelFields as $labelField) {
-                                       $queryBuilder->addSelect($labelField);
-                               }
-                               $whereCount = 0;
-                               if ($identifiers['uid']) {
-                                       $queryBuilder->where(
-                                               $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter((int)$identifiers['uid']), \PDO::PARAM_INT)
-                                       );
-                                       $whereCount++;
-                               } else if (!empty($identifiers['iso'])) {
-                                       $isoCode = is_array($identifiers['iso']) ? $identifiers['iso'] : [$identifiers['iso']];
-                                       foreach ($isoCode as $index => $code) {
-                                               if ($code) {
-                                                       $field = self::getIsoCodeField($tableName, $code, $index);
-                                                       if ($field) {
-                                                               if ($whereCount) {
-                                                                       $queryBuilder->andWhere(
-                                                                               $queryBuilder->expr()->eq($field, $queryBuilder->createNamedParameter($code))
-                                                                       );
-                                                                       $whereCount++;
-                                                               } else {
-                                                                       $queryBuilder->where(
-                                                                               $queryBuilder->expr()->eq($field, $queryBuilder->createNamedParameter($code))
-                                                                       );
-                                                                       $whereCount++;
-                                                               }
-                                                       }
-                                               }
-                                       }
-                               }
-                               // Get the entity
-                               if ($whereCount) {
-                                       $row = $queryBuilder->execute()->fetch();
-                                       if ($row) {
-                                               foreach ($labelFields as $labelField) {
-                                                       if ($row[$labelField]) {
-                                                               $value = $row[$labelField];
-                                                               break;
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-               } else {
-                       // TYPO3 CMS 7 LTS
-                       $value = self::getCompatibleLabelFieldValue($identifiers, $tableName, $language, $local);
-               }
-               return $value;
-       }
-
-       /**
-        * TYPO3 CMS 7 LTS
-        *
-        * Get the localized value for the label field
-        *
-        * @param array $identifiers An array with key 1- 'uid' containing a uid and/or 2- 'iso' containing one or two iso codes (i.e. country zone code and country code, or language code and country code)
-        * @param string $tableName The name of the table
-        * @param string language ISO code
-        * @param boolean local name only - if set local labels are returned
-        * @return string the value for the label field
-        */
-       protected static function getCompatibleLabelFieldValue($identifiers, $tableName, $language, $local = false)
-       {
                $value = '';
                $labelFields = self::getLabelFields($tableName, $language, $local);
                if (count($labelFields)) {
-                       // Build the list of fields
-                       $prefixedLabelFields = array();
+                       $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($tableName);
+                       $queryBuilder->from($tableName)->select('uid');
                        foreach ($labelFields as $labelField) {
-                               $prefixedLabelFields[] = $tableName . '.' . $labelField;
+                               $queryBuilder->addSelect($labelField);
                        }
-                       $fields = $tableName . '.uid,' . implode(',', $prefixedLabelFields);
-                       //Build the where clause
-                       $whereClause = '';
+                       $whereCount = 0;
                        if ($identifiers['uid']) {
-                               $whereClause .= $tableName . '.uid = ' . intval($identifiers['uid']);
+                               $queryBuilder->where(
+                                       $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter((int)$identifiers['uid']), \PDO::PARAM_INT)
+                               );
+                               $whereCount++;
                        } else if (!empty($identifiers['iso'])) {
-                               $isoCode = is_array($identifiers['iso']) ? $identifiers['iso'] : array($identifiers['iso']);
+                               $isoCode = is_array($identifiers['iso']) ? $identifiers['iso'] : [$identifiers['iso']];
                                foreach ($isoCode as $index => $code) {
                                        if ($code) {
                                                $field = self::getIsoCodeField($tableName, $code, $index);
                                                if ($field) {
-                                                       $whereClause .= ($whereClause ? ' AND ' : '') . $tableName . '.' . $field . ' = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($code, $tableName);
+                                                       if ($whereCount) {
+                                                               $queryBuilder->andWhere(
+                                                                       $queryBuilder->expr()->eq($field, $queryBuilder->createNamedParameter($code))
+                                                               );
+                                                               $whereCount++;
+                                                       } else {
+                                                               $queryBuilder->where(
+                                                                       $queryBuilder->expr()->eq($field, $queryBuilder->createNamedParameter($code))
+                                                               );
+                                                               $whereCount++;
+                                                       }
                                                }
                                        }
                                }
                        }
                        // Get the entity
-                       if ($whereClause) {
-                               $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                                       $fields,
-                                       $tableName,
-                                       $whereClause . \SJBR\StaticInfoTables\Utility\TcaUtility::getEnableFields($tableName)
-                               );
-                               if (is_array($rows) && count($rows)) {
+                       if ($whereCount) {
+                               $row = $queryBuilder->execute()->fetch();
+                               if ($row) {
                                        foreach ($labelFields as $labelField) {
-                                               if ($rows[0][$labelField]) {
-                                                       $value = $rows[0][$labelField];
+                                               if ($row[$labelField]) {
+                                                       $value = $row[$labelField];
                                                        break;
                                                }
                                        }
diff --git a/class.tx_staticinfotables_encoding.php b/class.tx_staticinfotables_encoding.php
deleted file mode 100644 (file)
index 2230d0e..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2004-2007 René Fritz (r.fritz@colorcube.de)
- *  (c) 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 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\Core\Utility\GeneralUtility;
-
-/**
- * Functions to convert the character encoding of the static info tables
- * * DEPRECATED * Used by language packs prior to Static Info Tables version 6
- *
- */
-class tx_staticinfotables_encoding
-{
-       /**
-        * Returns a selector box with charset encodings
-        *
-        * @deprecated since 6.0, will be removed two versions later - Language pack should be re-created
-        *
-        * @param string $elementName it the form elements name, probably something like "SET[...]"
-        * @param string $currentKey is the key to be selected currently.
-        * @param string $firstEntry is the key to be placed on top as first (default) entry.
-        * @param string $unsetEntries List of keys that should be removed (comma list).
-        * @return string HTML code for selector box
-        */
-       public function getEncodingSelect($elementName, $currentKey, $firstEntry='', $unsetEntries='')
-       {
-               GeneralUtility::logDeprecatedFunction();
-               $menuItems = array(
-                       'utf-8' => 'UTF-8',
-               );
-
-               if ($firstEntry && $menuItems[$firstEntry]) {
-                       $entry = array($firstEntry => $menuItems[$firstEntry]);
-                       unset($menuItems[$firstEntry]);
-                       $menuItems = array_merge($entry, $menuItems);
-               }
-
-               $unsetEntries = explode(',', $unsetEntries);
-               foreach($unsetEntries as $entry) {
-                       unset($menuItems[$entry]);
-               }
-
-               $options = array();
-               foreach ($menuItems as $value => $label)        {
-                       $options[] = '<option value="' . htmlspecialchars($value) . '"' . (!strcmp($currentKey,$value) ? ' selected="selected"' : '') . '>'
-                                                       . htmlspecialchars($label, ENT_COMPAT, 'UTF-8', false)
-                                                       . '</option>';
-               }
-               if (count($options)) {
-                       return '
-                                       <strong>This language pack is obsolete. It should be uninstalled and re-created using the Static Info Tables Manager.</strong><br />
-                                       <!-- charset encoding menu -->
-                                       <select name="'.$elementName.'">
-                                               '.implode('
-                                               ',$options).'
-                                       </select>
-                                               ';
-               } else {
-                       return '
-                                       <strong>This language pack is obsolete. It should be uninstalled and re-created using the Static Info Tables Manager.</strong><br />';
-               }
-       }
-}
\ No newline at end of file