[FEATURE] Introduce .typoscript file extension 15/52815/3
authorAndreas Allacher <andreas@allacher.com>
Fri, 7 Oct 2016 05:37:33 +0000 (07:37 +0200)
committerBenni Mack <benni@typo3.org>
Wed, 17 May 2017 10:33:52 +0000 (12:33 +0200)
The new file extension .typoscript will be the default for TypoScript
configuration files and is the only recommended one from now on. This
effort is made to introduce a dedicated file extension for TypoScript
configuration files, and to avoid conflicts with already existing and
more spread file extensions like ".ts" for TypeScript or Video Transport
Stream Files.

Resolves: #78161
Resolves: #80689
Releases: master, 8.7
Change-Id: I44b41631f498e3ba39e0f1936329094a59859f4e
Reviewed-on: https://review.typo3.org/52815
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
.editorconfig
.gitattributes
_.htaccess
typo3/sysext/core/Classes/Compatibility/LoadedExtensionArrayElement.php
typo3/sysext/core/Classes/Imaging/IconRegistry.php
typo3/sysext/core/Classes/TypoScript/TemplateService.php
typo3/sysext/core/Documentation/Changelog/8.7/Feature-78161-IntroduceTypoScriptFileExtension.rst [new file with mode: 0644]
typo3/sysext/core/Resources/Public/Icons/T3Icons/mimetypes/mimetypes-text-typoscript.svg [new file with mode: 0644]
typo3/sysext/install/Classes/Controller/Action/Step/DefaultConfiguration.php
typo3/sysext/t3editor/Classes/T3editor.php

index 39ceb50..448a84a 100644 (file)
@@ -71,6 +71,9 @@ indent_size = 2
 [*.ts]
 indent_style = space
 indent_size = 2
+[*.typoscript]
+indent_style = space
+indent_size = 2
 
 # XLF-Files
 [*.xlf]
index d295442..26839f0 100644 (file)
@@ -20,7 +20,8 @@
 *.md text eol=lf
 *.yml text eol=lf
 *.ts text eol=lf
+*.typoscript text eol=lf
 *.xlf text eol=lf
 *.sql text eol=lf
 *.t3s text eol=lf
-*.txt text eol=lf
\ No newline at end of file
+*.txt text eol=lf
index 2890933..0275b1a 100644 (file)
@@ -310,7 +310,7 @@ AddDefaultCharset utf-8
 </IfModule>
 
 # Access block for files
-<FilesMatch "(?i:^\.|^#.*#|^(?:ChangeLog|ToDo|Readme|License)(?:\.md|\.txt)?|^composer\.(?:json|lock)|^ext_conf_template\.txt|^ext_typoscript_constants\.txt|^ext_typoscript_setup\.txt|flexform[^.]*\.xml|locallang[^.]*\.(?:xml|xlf)|\.(?:bak|co?nf|cfg|ya?ml|ts|dist|fla|in[ci]|log|sh|sql(?:\..*)?|sw[op]|git.*)|.*(?:~|rc))$">
+<FilesMatch "(?i:^\.|^#.*#|^(?:ChangeLog|ToDo|Readme|License)(?:\.md|\.txt)?|^composer\.(?:json|lock)|^ext_conf_template\.txt|^ext_typoscript_constants\.txt|^ext_typoscript_setup\.txt|flexform[^.]*\.xml|locallang[^.]*\.(?:xml|xlf)|\.(?:bak|co?nf|cfg|ya?ml|ts|typoscript|dist|fla|in[ci]|log|sh|sql(?:\..*)?|sw[op]|git.*)|.*(?:~|rc))$">
        # Apache < 2.3
        <IfModule !mod_authz_core.c>
                Order allow,deny
index df6ac6c..6920a96 100644 (file)
@@ -36,6 +36,8 @@ class LoadedExtensionArrayElement implements \IteratorAggregate, \ArrayAccess, \
         'ext_tables.php',
         'ext_tables.sql',
         'ext_tables_static+adt.sql',
+        'ext_typoscript_constants.typoscript',
+        'ext_typoscript_setup.typoscript',
         'ext_typoscript_constants.txt',
         'ext_typoscript_setup.txt'
     ];
index 45e54ae..04e1199 100644 (file)
@@ -2071,6 +2071,12 @@ class IconRegistry implements SingletonInterface
                 'source' => 'EXT:core/Resources/Public/Icons/T3Icons/mimetypes/mimetypes-text-ts.svg'
             ]
         ],
+        'mimetypes-text-typoscript' => [
+            'provider' => SvgIconProvider::class,
+            'options' => [
+                'source' => 'EXT:core/Resources/Public/Icons/T3Icons/mimetypes/mimetypes-text-typoscript.svg'
+            ]
+        ],
         'mimetypes-word' => [
             'provider' => SvgIconProvider::class,
             'options' => [
@@ -3056,6 +3062,7 @@ class IconRegistry implements SingletonInterface
         'php3' => 'mimetypes-text-php',
         'inc' => 'mimetypes-text-php',
         'ts' => 'mimetypes-text-ts',
+        'typoscript' => 'mimetypes-text-typoscript',
         'txt' => 'mimetypes-text-text',
         'class' => 'mimetypes-text-text',
         'tmpl' => 'mimetypes-text-text',
index c5be14b..3bea9b7 100644 (file)
@@ -922,7 +922,7 @@ class TemplateService
      */
     protected function getTypoScriptSourceFileContent($filePath, $baseName)
     {
-        $extensions = ['.ts', '.txt'];
+        $extensions = ['.typoscript', '.ts', '.txt'];
         foreach ($extensions as $extension) {
             $fileName = $filePath . $baseName . $extension;
             if (@file_exists($fileName)) {
@@ -948,17 +948,36 @@ class TemplateService
 
         // @todo Change to use new API
         foreach ($GLOBALS['TYPO3_LOADED_EXT'] as $extKey => $files) {
-            if ((is_array($files) || $files instanceof \ArrayAccess) && ($files['ext_typoscript_constants.txt'] || $files['ext_typoscript_setup.txt'])) {
+            if ((is_array($files) || $files instanceof \ArrayAccess) && ($files['ext_typoscript_constants.txt'] || $files['ext_typoscript_constants.typoscript'] || $files['ext_typoscript_setup.txt'] || $files['ext_typoscript_setup.typoscript'])) {
                 $mExtKey = str_replace('_', '', $extKey);
-                $subrow = [
-                    'constants' => $files['ext_typoscript_constants.txt'] ? @file_get_contents($files['ext_typoscript_constants.txt']) : '',
-                    'config' => $files['ext_typoscript_setup.txt'] ? @file_get_contents($files['ext_typoscript_setup.txt']) : '',
-                    'title' => $extKey,
-                    'uid' => $mExtKey
-                ];
-                $subrow = $this->prependStaticExtra($subrow);
-                $extPath = ExtensionManagementUtility::extPath($extKey);
-                $this->processTemplate($subrow, $idList . ',ext_' . $mExtKey, $pid, 'ext_' . $mExtKey, $templateID, $extPath);
+                $constants = '';
+                $config = '';
+
+                if ($files['ext_typoscript_constants.typoscript']) {
+                    $constants = @file_get_contents($files['ext_typoscript_constants.typoscript']);
+                } elseif ($files['ext_typoscript_constants.txt']) {
+                    $constants = @file_get_contents($files['ext_typoscript_constants.txt']);
+                }
+
+                if ($files['ext_typoscript_setup.typoscript']) {
+                    $config = @file_get_contents($files['ext_typoscript_setup.typoscript']);
+                } elseif ($files['ext_typoscript_setup.txt']) {
+                    $config = @file_get_contents($files['ext_typoscript_setup.txt']);
+                }
+
+                $this->processTemplate(
+                    $this->prependStaticExtra([
+                        'constants' => $constants,
+                        'config' => $config,
+                        'title' => $extKey,
+                        'uid' => $mExtKey
+                    ]),
+                    $idList . ',ext_' . $mExtKey,
+                    $pid,
+                    'ext_' . $mExtKey,
+                    $templateID,
+                    ExtensionManagementUtility::extPath($extKey)
+                );
             }
         }
     }
diff --git a/typo3/sysext/core/Documentation/Changelog/8.7/Feature-78161-IntroduceTypoScriptFileExtension.rst b/typo3/sysext/core/Documentation/Changelog/8.7/Feature-78161-IntroduceTypoScriptFileExtension.rst
new file mode 100644 (file)
index 0000000..b10d65a
--- /dev/null
@@ -0,0 +1,39 @@
+.. include:: ../../Includes.txt
+
+======================================================
+Feature: #78161 - Introduce .typoscript file extension
+======================================================
+
+See :issue:`78161`
+
+Description
+===========
+
+The new file extension .typoscript will be the default for TypoScript configuration
+files and is the only recommended one from now on. This effort is made to introduce
+a dedicated file extension for TypoScript configuration files, and to avoid conflicts
+with already existing and more spread file extensions like ".ts" for TypeScript or
+Video Transport Stream Files.
+
+New prioritised files for static templates:
+* constants.typoscript
+* setup.typoscript
+
+New prioritised files for extension statics:
+* ext_typoscript_constants.typoscript
+* ext_typoscript_setup.typoscript
+
+For more details please head over to the decision platform:
+* https://decisions.typo3.org/t/file-endings-for-typoscript-files-and-tsconfig-files/43
+* https://decisions.typo3.org/t/file-endings-for-typoscript-and-tsconfig-files-results/71
+
+
+Impact
+======
+
+The ".typoscript" file extension is prioritised over the legacy .txt and .ts file
+extensions, and the only recommended file extension for typoscript configuration
+files.
+
+
+.. index:: Frontend
diff --git a/typo3/sysext/core/Resources/Public/Icons/T3Icons/mimetypes/mimetypes-text-typoscript.svg b/typo3/sysext/core/Resources/Public/Icons/T3Icons/mimetypes/mimetypes-text-typoscript.svg
new file mode 100644 (file)
index 0000000..83b3e97
--- /dev/null
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M2 0v16h12V4l-4-4zm8 0z" fill="#ff8700" stroke="#b9b9b9" stroke-width="0" stroke-linejoin="round"/><path d="M10 3.98V0l4 4z" fill="#fff" stroke-width="0" stroke-linejoin="round" opacity=".65"/><path d="M14 4.024V9l-4-5z" opacity=".15" stroke-width="0" stroke-linejoin="round"/><g fill="#fff"><path d="M9.54 11.11a.835.835 0 0 1-.256.036c-.772 0-1.906-2.697-1.906-3.595 0-.33.079-.44.189-.535-.945.11-2.079.457-2.441.898-.079.11-.126.283-.126.503C5 9.82 6.496 13 7.551 13c.488 0 1.312-.803 1.989-1.89M9.047 6.921c.976 0 1.953.158 1.953.709 0 1.118-.709 2.473-1.07 2.473-.646 0-1.45-1.796-1.45-2.693 0-.41.158-.489.567-.489"/></g></svg>
\ No newline at end of file
index ff21342..7a986af 100644 (file)
@@ -102,7 +102,7 @@ page.10.value (
 page.100 =< styles.content.get',
                         'description' => 'This is an Empty Site Package TypoScript template.
 
-For each website you need a TypoScript template on the main page of your website (on the top level). For better maintenance all TypoScript should be extracted into external files via <INCLUDE_TYPOSCRIPT: source="FILE:EXT:site_myproject/Configuration/TypoScript/setup.ts">.'
+For each website you need a TypoScript template on the main page of your website (on the top level). For better maintenance all TypoScript should be extracted into external files via <INCLUDE_TYPOSCRIPT: source="FILE:EXT:site_myproject/Configuration/TypoScript/setup.typoscript">.'
                     ]
                 );
             break;
index 2fc078f..4507970 100644 (file)
@@ -133,6 +133,7 @@ class T3editor implements \TYPO3\CMS\Core\SingletonInterface
                 $mode = self::MODE_CSS;
                 break;
             case 'ts':
+            case 'typoscript':
                 $mode = self::MODE_TYPOSCRIPT;
                 break;
             case 'sparql':