Resolves #59896: TCA Selection of countries with different key
[TYPO3CMS/Extensions/static_info_tables.git] / class.tx_staticinfotables_div.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2004-2010 René Fritz (r.fritz@colorcube.de)
6 * (c) 2013 Stanislas Rolland <typo3(arobas)sjbr.ca>
7 * All rights reserved
8 *
9 * This script is part of the Typo3 project. The Typo3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 *
18 * This script is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * This copyright notice MUST APPEAR in all copies of the script!
24 ***************************************************************/
25 /**
26 * Misc functions to access the static info tables
27 * This class is deprecated since 6.0 and will be removed in version 6.2
28 */
29 class tx_staticinfotables_div extends \SJBR\StaticInfoTables\Utility\LocalizationUtility {
30
31 /**
32 * @deprecated since 6.0, will be removed two versions later - Use \SJBR\StaticInfoTables\Utility\LocalizationUtility::getLabelFields instead
33 */
34 public static function getTCAlabelField ($tableName, $loadTCA = TRUE, $lang = '', $local = FALSE) {
35 \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
36 return parent::getLabelFields($tableName, $lang, $local);
37 }
38
39 /**
40 * Fetches short title from an iso code
41 *
42 * @deprecated since 6.0, will be removed two versions later - Use \SJBR\StaticInfoTables\Utility\LocalizationUtility::getLabelFieldValue or, better, \SJBR\StaticInfoTables\Utility\LocalizationUtility::translate instead
43 * @param string $tableName: table name
44 * @param string $isoCode: iso code
45 * @param string $language: language code - if not set current default language is used
46 * @param boolean $local: local name only - if set local title is returned
47 * @return string short title
48 */
49 public static function getTitleFromIsoCode ($tableName, $isoCode, $language = '', $local = FALSE) {
50 \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
51 $indentifiers = array();
52 $indentifiers['iso'] = $isoCode;
53 return parent::getLabelFieldValue($identifiers, $tableName, $language, $local);
54 }
55
56 /**
57 * Get a list of countries by specific parameters or parts of names of countries
58 * in different languages. Parameters might be left empty.
59 *
60 * @deprecated since 6.0, will be removed two versions later - Use methods of \SJBR\StaticInfoTables\Domain\Repository\CountryRepository directly
61 *
62 * @param string a name of the country or a part of it in any language
63 * @param string ISO alpha-2 code of the country
64 * @param string ISO alpha-3 code of the country
65 * @param array Database row.
66 * @return array Array of rows of country records
67 */
68 public static function fetchCountries ($country, $iso2='', $iso3='', $isonr='') {
69 \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
70 $rcArray = array();
71 $where = '';
72
73 $table = 'static_countries';
74 if ($country != '') {
75 $value = $GLOBALS['TYPO3_DB']->fullQuoteStr(trim('%'.$country.'%'),$table);
76 $where = 'cn_official_name_local LIKE '.$value.' OR cn_official_name_en LIKE '.$value.' OR cn_short_local LIKE '.$value;
77 }
78
79 if ($isonr != '') {
80 $where = 'cn_iso_nr='.$GLOBALS['TYPO3_DB']->fullQuoteStr(trim($isonr),$table);
81 }
82
83 if ($iso2 != '') {
84 $where = 'cn_iso_2='.$GLOBALS['TYPO3_DB']->fullQuoteStr(trim($iso2),$table);
85 }
86
87 if ($iso3 !='') {
88 $where = 'cn_iso_3='.$GLOBALS['TYPO3_DB']->fullQuoteStr(trim($iso3),$table);
89 }
90
91 if ($where != '') {
92 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, $where);
93
94 if ($res) {
95 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
96 $rcArray[] = $row;
97 }
98 }
99 $GLOBALS['TYPO3_DB']->sql_free_result($res);
100 }
101 return $rcArray;
102 }
103
104 /**
105 * Function to add additional select items in the form of a hotlist
106 *
107 * @deprecated since 6.0, will be removed two versions later - Use suggest wizard instead
108 *
109 * @param array itemsProcFunc data array:
110 * @return void The $items array may have been modified
111 */
112 public function selectItemsTCA ($params) {
113 \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
114 }
115 }
116 ?>