[TASK] Separate ext:statictemplates code from core
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Utility / ExtensionManagementUtility.php
index 2522789..13262df 100644 (file)
@@ -4,7 +4,7 @@ namespace TYPO3\CMS\Core\Utility;
 /***************************************************************
  *  Copyright notice
  *
- *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
+ *  (c) 1999-2013 Kasper Skårhøj (kasperYYYY@typo3.com)
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -1288,7 +1288,6 @@ tt_content.' . $key . $prefix . ' {
 
        /**
         * Call this method to add an entry in the static template list found in sys_templates
-        * "static template files" are the modern equivalent (provided from extensions) to the traditional records in "static_templates"
         * FOR USE IN ext_localconf.php FILES
         *
         * @param string $extKey Is of course the extension key
@@ -1570,20 +1569,22 @@ tt_content.' . $key . $prefix . ' {
                $phpCodeToCache[] = '';
                // Iterate through loaded extensions and add ext_localconf content
                foreach ($extensionInformation as $extensionKey => $extensionDetails) {
-                       // Include a header per extension to make the cache file more readable
-                       $phpCodeToCache[] = '/**';
-                       $phpCodeToCache[] = ' * Extension: ' . $extensionKey;
-                       $phpCodeToCache[] = ' * File: ' . $extensionDetails['ext_localconf.php'];
-                       $phpCodeToCache[] = ' */';
-                       $phpCodeToCache[] = '';
-                       // Set $_EXTKEY and $_EXTCONF for this extension
-                       $phpCodeToCache[] = '$_EXTKEY = \'' . $extensionKey . '\';';
-                       $phpCodeToCache[] = '$_EXTCONF = $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXT\'][\'extConf\'][$_EXTKEY];';
-                       $phpCodeToCache[] = '';
-                       // Add ext_localconf.php content of extension
-                       $phpCodeToCache[] = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($extensionDetails['ext_localconf.php']));
-                       $phpCodeToCache[] = '';
-                       $phpCodeToCache[] = '';
+                       if (isset($extensionDetails['ext_localconf.php']) && $extensionDetails['ext_localconf.php']) {
+                               // Include a header per extension to make the cache file more readable
+                               $phpCodeToCache[] = '/**';
+                               $phpCodeToCache[] = ' * Extension: ' . $extensionKey;
+                               $phpCodeToCache[] = ' * File: ' . $extensionDetails['ext_localconf.php'];
+                               $phpCodeToCache[] = ' */';
+                               $phpCodeToCache[] = '';
+                               // Set $_EXTKEY and $_EXTCONF for this extension
+                               $phpCodeToCache[] = '$_EXTKEY = \'' . $extensionKey . '\';';
+                               $phpCodeToCache[] = '$_EXTCONF = $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXT\'][\'extConf\'][$_EXTKEY];';
+                               $phpCodeToCache[] = '';
+                               // Add ext_localconf.php content of extension
+                               $phpCodeToCache[] = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($extensionDetails['ext_localconf.php']));
+                               $phpCodeToCache[] = '';
+                               $phpCodeToCache[] = '';
+                       }
                }
                $phpCodeToCache = implode(LF, $phpCodeToCache);
                // Remove all start and ending php tags from content
@@ -1645,7 +1646,12 @@ tt_content.' . $key . $prefix . ' {
                        if (is_dir($tcaConfigurationDirectory)) {
                                $files = scandir($tcaConfigurationDirectory);
                                foreach ($files as $file) {
-                                       if (is_file($tcaConfigurationDirectory . '/' . $file) && ($file !== '.') && ($file !== '..')) {
+                                       if (
+                                               is_file($tcaConfigurationDirectory . '/' . $file)
+                                               && ($file !== '.')
+                                               && ($file !== '..')
+                                               && (substr($file, -4, 4) === '.php')
+                                       ) {
                                                $tcaOfTable = require($tcaConfigurationDirectory . '/' . $file);
                                                if (is_array($tcaOfTable)) {
                                                        // TCA table name is filename without .php suffix, eg 'sys_notes', not 'sys_notes.php'
@@ -1755,21 +1761,23 @@ tt_content.' . $key . $prefix . ' {
                $phpCodeToCache[] = '';
                // Iterate through loaded extensions and add ext_tables content
                foreach ($extensionInformation as $extensionKey => $extensionDetails) {
-                       // Include a header per extension to make the cache file more readable
-                       $phpCodeToCache[] = '/**';
-                       $phpCodeToCache[] = ' * Extension: ' . $extensionKey;
-                       $phpCodeToCache[] = ' * File: ' . $extensionDetails['ext_tables.php'];
-                       $phpCodeToCache[] = ' */';
-                       $phpCodeToCache[] = '';
-                       // Set $_EXTKEY and $_EXTCONF for this extension
-                       $phpCodeToCache[] = '$_EXTKEY = \'' . $extensionKey . '\';';
-                       $phpCodeToCache[] = '$_EXTCONF = $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXT\'][\'extConf\'][$_EXTKEY];';
-                       $phpCodeToCache[] = '';
-                       // Add ext_tables.php content of extension
-                       $phpCodeToCache[] = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($extensionDetails['ext_tables.php']));
-                       $phpCodeToCache[] = '';
-                       $phpCodeToCache[] = '\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadNewTcaColumnsConfigFiles();';
-                       $phpCodeToCache[] = '';
+                       if (isset($extensionDetails['ext_tables.php']) && $extensionDetails['ext_tables.php']) {
+                               // Include a header per extension to make the cache file more readable
+                               $phpCodeToCache[] = '/**';
+                               $phpCodeToCache[] = ' * Extension: ' . $extensionKey;
+                               $phpCodeToCache[] = ' * File: ' . $extensionDetails['ext_tables.php'];
+                               $phpCodeToCache[] = ' */';
+                               $phpCodeToCache[] = '';
+                               // Set $_EXTKEY and $_EXTCONF for this extension
+                               $phpCodeToCache[] = '$_EXTKEY = \'' . $extensionKey . '\';';
+                               $phpCodeToCache[] = '$_EXTCONF = $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXT\'][\'extConf\'][$_EXTKEY];';
+                               $phpCodeToCache[] = '';
+                               // Add ext_tables.php content of extension
+                               $phpCodeToCache[] = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($extensionDetails['ext_tables.php']));
+                               $phpCodeToCache[] = '';
+                               $phpCodeToCache[] = '\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadNewTcaColumnsConfigFiles();';
+                               $phpCodeToCache[] = '';
+                       }
                }
                $phpCodeToCache = implode(LF, $phpCodeToCache);
                // Remove all start and ending php tags from content
@@ -1786,8 +1794,12 @@ tt_content.' . $key . $prefix . ' {
         * $TCA[$tableName]['ctrl']['dynamicConfigFile'] must be the
         * absolute path to a file.
         *
+        * Be aware that 'dynamicConfigFile' is obsolete, and all TCA
+        * table definitions should be moved to Configuration/TCA/tablename.php
+        * to be fully loaded automatically.
+        *
         * Example:
-        * dynamicConfigFile = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Configuration/TCA/SysNote.php',
+        * dynamicConfigFile = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'SysNote.php',
         *
         * @return void
         * @throws \RuntimeException
@@ -1796,7 +1808,7 @@ tt_content.' . $key . $prefix . ' {
        static public function loadNewTcaColumnsConfigFiles() {
                global $TCA;
 
-               foreach ($TCA as $tableName => $configuration) {
+               foreach (array_keys($TCA) as $tableName) {
                        if (!isset($TCA[$tableName]['columns'])) {
                                $columnsConfigFile = $TCA[$tableName]['ctrl']['dynamicConfigFile'];
                                if ($columnsConfigFile) {