Resolves #45809: Refactor code and introduce namespacing
[TYPO3CMS/Extensions/static_info_tables.git] / Classes / Utility / TcaUtility.php
1 <?php
2 namespace SJBR\StaticInfoTables\Utility;
3 /***************************************************************
4 * Copyright notice
5 *
6 * (c) 2013 StanislasRolland <typo3@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 * TCA-related functions
27 */
28 class TcaUtility {
29
30 /**
31 * Load the configuration of a table and additional configuration by language packs
32 *
33 * @param string $tableName: the name of the table
34 * @return void
35 */
36 static public function loadTca ($tableName) {
37 \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($tableName);
38 // Get all extending TCA's
39 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['static_info_tables']['extendingTCA'])) {
40 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['static_info_tables']['extendingTCA'] as $extensionKey) {
41 if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($extensionKey)) {
42 include(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extensionKey) . 'ext_tables.php');
43 }
44 }
45 }
46 }
47
48 /**
49 * Get the enable fields clause based on the table configuration
50 *
51 * @param string $tableName: the name of the table
52 * @return string enable fileds clause
53 */
54 static public function getEnableFields ($tableName) {
55 if (TYPO3_MODE === 'FE') {
56 $enableFields = $GLOBALS['TSFE']->sys_page->enableFields($tableName);
57 } else {
58 $enableFields = \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($tableName);
59 }
60 }
61 }
62 ?>