[FEATURE] Include a pageTSconfig file like TS static templates 76/41676/11
authorJigal van Hemert <jigal.van.hemert@typo3.org>
Sat, 18 Jul 2015 14:23:17 +0000 (16:23 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Wed, 22 Jul 2015 08:42:40 +0000 (10:42 +0200)
Adds a field in the page properties and includes all these files before
the TSConfig from the normal field in the page properties and after the
default TSconfig.

Resolves: #68315
Resolves: #68313
Releases: master
Change-Id: I6bbca330a85b815e1111f69149cbf1bee8447045
Reviewed-on: http://review.typo3.org/41676
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
typo3/sysext/core/Configuration/TCA/pages.php
typo3/sysext/core/Documentation/Changelog/master/Feature-68315-IncludeAPageTSconfigFileInPagePropertiesLikeTSStaticTemplates.rst [new file with mode: 0644]
typo3/sysext/core/ext_tables.sql
typo3/sysext/frontend/Resources/Private/Language/locallang_tca.xlf

index 8492747..c32272d 100755 (executable)
@@ -32,6 +32,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\HttpUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Core\Versioning\VersionState;
 use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Frontend\Page\PageRepository;
@@ -348,6 +349,7 @@ class BackendUtility {
                                        'pid' => $val['pid'],
                                        'title' => $val['title'],
                                        'doktype' => $val['doktype'],
+                                       'tsconfig_includes' => $val['tsconfig_includes'],
                                        'TSconfig' => $val['TSconfig'],
                                        'is_siteroot' => $val['is_siteroot'],
                                        't3ver_oid' => $val['t3ver_oid'],
@@ -381,7 +383,7 @@ class BackendUtility {
                        $row = $getPageForRootline_cache[$ident];
                } else {
                        $db = static::getDatabaseConnection();
-                       $res = $db->exec_SELECTquery('pid,uid,title,doktype,TSconfig,is_siteroot,t3ver_oid,t3ver_wsid,t3ver_state,t3ver_stage,backend_layout_next_level', 'pages', 'uid=' . (int)$uid . ' ' . self::deleteClause('pages') . ' ' . $clause);
+                       $res = $db->exec_SELECTquery('pid,uid,title,doktype,tsconfig_includes,TSconfig,is_siteroot,t3ver_oid,t3ver_wsid,t3ver_state,t3ver_stage,backend_layout_next_level', 'pages', 'uid=' . (int)$uid . ' ' . self::deleteClause('pages') . ' ' . $clause);
                        $row = $db->sql_fetch_assoc($res);
                        if ($row) {
                                $newLocation = FALSE;
@@ -1234,6 +1236,30 @@ class BackendUtility {
                        // Setting default configuration
                        $TSdataArray['defaultPageTSconfig'] = $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'];
                        foreach ($rootLine as $k => $v) {
+                               if (trim($v['tsconfig_includes'])) {
+                                       $includeTsConfigFileList = GeneralUtility::trimExplode(',', $v['tsconfig_includes'], TRUE);
+                                       // Traversing list
+                                       foreach ($includeTsConfigFileList as $key => $includeTsConfigFile) {
+                                               if (StringUtility::beginsWith($includeTsConfigFile, 'EXT:')) {
+                                                       list($includeTsConfigFileExtensionKey, $includeTsConfigFilename) = explode(
+                                                               '/',
+                                                               substr($includeTsConfigFile, 4),
+                                                               2
+                                                       );
+                                                       if (
+                                                               (string)$includeTsConfigFileExtensionKey !== ''
+                                                               && ExtensionManagementUtility::isLoaded($includeTsConfigFileExtensionKey)
+                                                               && (string)$includeTsConfigFilename !== ''
+                                                       ) {
+                                                               $includeTsConfigFileAndPath = ExtensionManagementUtility::extPath($includeTsConfigFileExtensionKey) .
+                                                                       $includeTsConfigFilename;
+                                                               if (file_exists($includeTsConfigFileAndPath)) {
+                                                                       $TSdataArray['uid_' . $v['uid'] . '_static_' . $key] = GeneralUtility::getUrl($includeTsConfigFileAndPath);
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
                                $TSdataArray['uid_' . $v['uid']] = $v['TSconfig'];
                        }
                        $TSdataArray = static::emitGetPagesTSconfigPreIncludeSignal($TSdataArray, $id, $rootLine, $returnPartArray);
index 16619ec..eca3b5e 100644 (file)
@@ -1432,6 +1432,23 @@ tt_content.' . $key . $suffix . ' {
        }
 
        /**
+        * Call this method to add an entry in the pageTSconfig list found in pages
+        * FOR USE in ext_tables.php FILES or files in Configuration/TCA/Overrides/*.php Use the latter to benefit from TCA caching!
+        *
+        * @param string $extKey The extension key
+        * @param string $file The path and title where the TSconfig file is located
+        * @param string $title The title in the selector box
+        * @return void
+        */
+       static public function registerPageTSConfigFile($extKey, $file, $title) {
+               if ($extKey && $file && is_array($GLOBALS['TCA']['pages']['columns'])) {
+                       $value = str_replace(',',  '', 'EXT:' . $extKey . '/' . $file);
+                       $itemArray = array(trim($title . ' (' . $extKey . ')'), $value);
+                       $GLOBALS['TCA']['pages']['columns']['tsconfig_includes']['config']['items'][] = $itemArray;
+               }
+       }
+
+       /**
         * Adds $content to the default TypoScript setup code as set in $GLOBALS['TYPO3_CONF_VARS'][FE]['defaultTypoScript_setup']
         * Prefixed with a [GLOBAL] line
         * FOR USE IN ext_localconf.php FILES
index 694acd3..d93403d 100644 (file)
@@ -801,7 +801,18 @@ return array(
                                'size' => 1,
                                'maxitems' => 1,
                        )
-               )
+               ),
+               'tsconfig_includes' => array(
+                       'label' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tsconfig_includes',
+                       'config' => array(
+                               'type' => 'select',
+                               'size' => 10,
+                               'maxitems' => 100,
+                               'items' => array(),
+                               'enableMultiSelectFilterTextfield' => TRUE,
+                               'softref' => 'ext_fileref'
+                       )
+               ),
        ),
        'types' => array(
                // normal
@@ -1029,7 +1040,7 @@ return array(
                        'showitem' => 'media;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.media_formlabel',
                ),
                'config' => array(
-                       'showitem' => 'TSconfig;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.TSconfig_formlabel',
+                       'showitem' => 'tsconfig_includes;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tsconfig_includes, --linebreak--, TSconfig;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.TSconfig_formlabel',
                )
        )
 );
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-68315-IncludeAPageTSconfigFileInPagePropertiesLikeTSStaticTemplates.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-68315-IncludeAPageTSconfigFileInPagePropertiesLikeTSStaticTemplates.rst
new file mode 100644 (file)
index 0000000..c42b2e4
--- /dev/null
@@ -0,0 +1,27 @@
+=========================================================================================
+Feature: #68315 - Include a pageTSconfig file in page properties like TS static templates
+=========================================================================================
+
+Description
+===========
+
+In the Page properties an option is added to include a page TSconfig file (the same way as TypoScript static templates are included).
+The included files from the pages in the rootline are included after the default page TSconfig and before the normal TSconfig
+from the pages in the rootline.
+To add files to the selector in the Page properties a new function ``registerPageTSConfigFile`` is added to
+``\TYPO3\CMS\Core\Utility\ExtensionManagementUtility`` to register a pageTSconfig file.
+
+
+Impact
+======
+
+No effect on existing installations.
+
+Usage
+=====
+
+In ``Configuration/TCA/Overrides/pages.php`` of any extension, register PageTS config files, which will be shown afterwards at the newly introduced field.
+
+.. code-block:: php
+
+       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerPageTSConfigFile('extension_name', 'Configuration/PageTS/myPageTSconfigFile.txt', 'My special config');
index 8932a75..b11399e 100644 (file)
@@ -162,6 +162,7 @@ CREATE TABLE pages (
        fe_login_mode tinyint(4) DEFAULT '0' NOT NULL,
        backend_layout varchar(64) DEFAULT '' NOT NULL,
        backend_layout_next_level varchar(64) DEFAULT '' NOT NULL,
+       tsconfig_includes text,
        PRIMARY KEY (uid),
        KEY t3ver_oid (t3ver_oid,t3ver_wsid),
        KEY parent (pid,deleted,sorting),
index cafff1d..8da535d 100644 (file)
                        <trans-unit id="pages.backend_layout.default">
                                <source>Default</source>
                        </trans-unit>
+                       <trans-unit id="pages.tsconfig_includes">
+                               <source>Include Page TSConfig (from extensions):</source>
+                       </trans-unit>
                        <trans-unit id="tt_content">
                                <source>Page Content</source>
                        </trans-unit>