28e4d811367deff11d0f797f07d74176fb9f590f
[TYPO3CMS/Extensions/static_info_tables.git] / ext_tables.php
1 <?php
2 if (!defined ('TYPO3_MODE')) {
3 die ('Access denied.');
4 }
5
6 // Configure extension static template
7 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'Configuration/TypoScript/Static', 'Static Info Tables');
8
9 $typo3Version = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version);
10 $extensionResourcesLanguagePath = 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_db.xlf:';
11 $extensionConfigurationTcaPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Configuration/Tca/';
12 $extensionResourcesIconsPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'Resources/Public/Images/Icons/';
13
14 // Country reference data from ISO 3166-1
15 $GLOBALS['TCA']['static_countries'] = array(
16 'ctrl' => array(
17 'label' => 'cn_short_en',
18 'label_alt' => 'cn_iso_2',
19 'label_alt_force' => 1,
20 'label_userFunc' => 'SJBR\\StaticInfoTables\\Hook\\Backend\\Form\\ElementRenderingHelper->addIsoCodeToLabel',
21 'adminOnly' => 1,
22 'rootLevel' => 1,
23 'is_static' => 1,
24 'readOnly' => 1,
25 'default_sortby' => 'ORDER BY cn_short_en',
26 'delete' => 'deleted',
27 'title' => $extensionResourcesLanguagePath . 'static_countries.title',
28 'dynamicConfigFile' => $extensionConfigurationTcaPath . 'Country.php',
29 'iconfile' => $extensionResourcesIconsPath . 'icon_static_countries.gif',
30 ),
31 'interface' => array(
32 'showRecordFieldList' => 'cn_iso_2,cn_iso_3,cn_iso_nr,cn_official_name_local,cn_official_name_en,cn_capital,cn_tldomain,cn_currency_iso_3,cn_currency_iso_nr,cn_phone,cn_uno_member,cn_eu_member,cn_address_format,cn_short_en'
33 )
34 );
35
36 // Country subdivision reference data from ISO 3166-2
37 $GLOBALS['TCA']['static_country_zones'] = array(
38 'ctrl' => array(
39 'label' => 'zn_name_local',
40 'label_alt' => 'zn_name_local,zn_code',
41 'adminOnly' => 1,
42 'rootLevel' => 1,
43 'is_static' => 1,
44 'readOnly' => 1,
45 'default_sortby' => 'ORDER BY zn_name_local',
46 'delete' => 'deleted',
47 'title' => $extensionResourcesLanguagePath . 'static_country_zones.title',
48 'dynamicConfigFile' => $extensionConfigurationTcaPath . 'CountryZone.php',
49 'iconfile' => $extensionResourcesIconsPath . 'icon_static_countries.gif',
50 ),
51 'interface' => array(
52 'showRecordFieldList' => 'zn_country_iso_nr,zn_country_iso_3,zn_code,zn_name_local,zn_name_en'
53 )
54 );
55
56 // Currency reference data from ISO 4217
57 $GLOBALS['TCA']['static_currencies'] = array(
58 'ctrl' => array(
59 'label' => 'cu_name_en',
60 'label_alt' => 'cu_iso_3',
61 'label_alt_force' => 1,
62 'label_userFunc' => 'SJBR\\StaticInfoTables\\Hook\\Backend\\Form\\ElementRenderingHelper->addIsoCodeToLabel',
63 'adminOnly' => 1,
64 'rootLevel' => 1,
65 'is_static' => 1,
66 'readOnly' => 1,
67 'default_sortby' => 'ORDER BY cu_name_en',
68 'delete' => 'deleted',
69 'title' => $extensionResourcesLanguagePath . 'static_currencies.title',
70 'dynamicConfigFile' => $extensionConfigurationTcaPath . 'Currency.php',
71 'iconfile' => $extensionResourcesIconsPath . 'icon_static_currencies.gif',
72 ),
73 'interface' => array(
74 'showRecordFieldList' => 'cu_iso_3,cu_iso_nr,cu_name_en,cu_symbol_left,cu_symbol_right,cu_thousands_point,cu_decimal_point,cu_decimal_digits,cu_sub_name_en,cu_sub_divisor,cu_sub_symbol_left,cu_sub_symbol_right'
75 )
76 );
77
78 // Language reference data from ISO 639-1
79 $GLOBALS['TCA']['static_languages'] = array(
80 'ctrl' => array(
81 'label' => 'lg_name_en',
82 'label_alt' => 'lg_iso_2',
83 'label_alt_force' => 1,
84 'label_userFunc' => 'SJBR\\StaticInfoTables\\Hook\\Backend\\Form\\ElementRenderingHelper->addIsoCodeToLabel',
85 'adminOnly' => 1,
86 'rootLevel' => 1,
87 'is_static' => 1,
88 'readOnly' => 1,
89 'default_sortby' => 'ORDER BY lg_name_en',
90 'delete' => 'deleted',
91 'title' => $extensionResourcesLanguagePath . 'static_languages.title',
92 'dynamicConfigFile' => $extensionConfigurationTcaPath . 'Language.php',
93 'iconfile' => $extensionResourcesIconsPath . 'icon_static_languages.gif',
94 ),
95 'interface' => array(
96 'showRecordFieldList' => 'lg_name_local,lg_name_en,lg_iso_2,lg_typo3,lg_country_iso_2,lg_collate_locale,lg_sacred,lg_constructed'
97 )
98 );
99
100 // UN Territory reference data
101 $GLOBALS['TCA']['static_territories'] = array(
102 'ctrl' => array(
103 'label' => 'tr_name_en',
104 'label_alt' => 'tr_iso_nr',
105 'label_alt_force' => 1,
106 'label_userFunc' => 'SJBR\\StaticInfoTables\\Hook\\Backend\\Form\\ElementRenderingHelper->addIsoCodeToLabel',
107 'adminOnly' => 1,
108 'rootLevel' => 1,
109 'is_static' => 1,
110 'readOnly' => 1,
111 'default_sortby' => 'ORDER BY tr_name_en',
112 'delete' => 'deleted',
113 'title' => $extensionResourcesLanguagePath . 'static_territories.title',
114 'dynamicConfigFile' => $extensionConfigurationTcaPath . 'Territory.php',
115 'iconfile' => $extensionResourcesIconsPath . 'icon_static_territories.gif',
116 ),
117 'interface' => array(
118 'showRecordFieldList' => 'tr_name_en,tr_iso_nr'
119 )
120 );
121
122 unset($extensionResourcesLanguagePath);
123 unset($extensionConfigurationTcaPath);
124 unset($extensionResourcesIconsPath);
125
126 // Configure static language field of sys_language table
127 if ($typo3Version < 6001000) {
128 \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('sys_language');
129 }
130 $GLOBALS['TCA']['sys_language']['columns']['static_lang_isocode']['config'] = array(
131 'type' => 'select',
132 'items' => array(
133 array('',0),
134 ),
135 'foreign_table' => 'static_languages',
136 'foreign_table_where' => 'AND static_languages.pid=0 ORDER BY static_languages.lg_name_en',
137 'itemsProcFunc' => 'SJBR\\StaticInfoTables\\Hook\\Backend\\Form\\ElementRenderingHelper->translateLanguagesSelector',
138 'size' => 1,
139 'minitems' => '0',
140 'maxitems' => 1,
141 'wizards' => array(
142 'suggest' => array(
143 'type' => 'suggest',
144 'default' => array(
145 'receiverClass' => 'SJBR\\StaticInfoTables\\Hook\\Backend\\Form\\SuggestReceiver'
146 )
147 )
148 )
149 );
150
151 // Add data handling hook to manage ISO codes redundancies on records
152 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'SJBR\\StaticInfoTables\\Hook\\Core\\DataHandling\\ProcessDataMap';
153
154 if (TYPO3_MODE == 'BE' && !(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_INSTALL)) {
155 /**
156 * Registers the Static Info Tables Manager backend module, if enabled
157 */
158 if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$_EXTKEY]['enableManager']) {
159 \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
160 $_EXTKEY,
161 // Make module a submodule of 'tools'
162 'tools',
163 // Submodule key
164 'Manager',
165 // Position
166 '',
167 // An array holding the controller-action combinations that are accessible
168 array(
169 'Manager' => 'information,newLanguagePack,createLanguagePack,testForm,testFormResult,sqlDumpNonLocalizedData'
170 ),
171 array(
172 'access' => 'user,group',
173 'icon' => 'EXT:' . $_EXTKEY . '/Resources/Public/Images/Icons/moduleicon.gif',
174 'labels' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_mod.xlf'
175 )
176 );
177 // Add module configuration setup
178 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScript($_EXTKEY, 'setup', '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:' . $_EXTKEY . '/Configuration/TypoScript/Manager/setup.txt">');
179
180 // Enable editing Static Info Tables
181 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['static_info_tables']['tables'])) {
182 $tableNames = array_keys($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['static_info_tables']['tables']);
183 foreach ($tableNames as $tableName) {
184 if ($typo3Version < 6001000) {
185 \SJBR\StaticInfoTables\Utility\TcaUtility::loadTCA($tableName);
186 }
187 $GLOBALS['TCA'][$tableName]['ctrl']['readOnly'] = 0;
188 }
189 }
190 }
191 }
192 ?>