[FEATURE] Make new content element wizard tab sort order configurable 76/44976/9
authorChristian Weiske <weiske@mogic.com>
Fri, 27 Nov 2015 10:41:36 +0000 (11:41 +0100)
committerMarkus Klein <markus.klein@typo3.org>
Sat, 16 Jan 2016 00:12:01 +0000 (01:12 +0100)
It is possible to influence the order of the tabs in the new
content element wizard by setting "before" and "after" values in
Page TSconfig:

    mod.wizards.newContentElement.wizardItems.special.before = common
    mod.wizards.newContentElement.wizardItems.forms.after = common,special

Releases: master
Resolves: #71876
Change-Id: I67ed31535394f16d0437563aa405c6e92a56e0fe
Reviewed-on: https://review.typo3.org/44976
Reviewed-by: Alexander Stehlik <alexander.stehlik@gmail.com>
Tested-by: Alexander Stehlik <alexander.stehlik@gmail.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/backend/Classes/Controller/ContentElement/NewContentElementController.php
typo3/sysext/core/Documentation/Changelog/master/Feature-71876-MakeNewContentElementWizardTabSortOrderConfigurable.rst [new file with mode: 0644]

index d1f720e..fd04f1e 100644 (file)
@@ -24,6 +24,7 @@ use TYPO3\CMS\Backend\Wizard\NewContentElementWizardHookInterface;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider;
 use TYPO3\CMS\Core\Imaging\IconRegistry;
+use TYPO3\CMS\Core\Service\DependencyOrderingService;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\StringUtility;
@@ -371,6 +372,12 @@ class NewContentElementController extends AbstractModule
             $appendWizards = $this->wizard_appendWizards($wizards['elements.']);
             if (is_array($wizards)) {
                 foreach ($wizards as $groupKey => $wizardGroup) {
+                    $this->prepareDependencyOrdering($wizards[$groupKey], 'before');
+                    $this->prepareDependencyOrdering($wizards[$groupKey], 'after');
+                }
+                $wizards = GeneralUtility::makeInstance(DependencyOrderingService::class)->orderByDependencies($wizards);
+
+                foreach ($wizards as $groupKey => $wizardGroup) {
                     $groupKey = rtrim($groupKey, '.');
                     $showItems = GeneralUtility::trimExplode(',', $wizardGroup['show'], true);
                     $showAll = $wizardGroup['show'] === '*';
@@ -538,6 +545,22 @@ class NewContentElementController extends AbstractModule
     }
 
     /**
+     * Prepare a wizard tab configuration for sorting.
+     *
+     * @param array  $wizardGroup TypoScript wizard tab configuration
+     * @param string $key         Which array key should be prepared
+     *
+     * @return void
+     */
+    protected function prepareDependencyOrdering(&$wizardGroup, $key)
+    {
+        if (isset($wizardGroup[$key])) {
+            $wizardGroup[$key] = GeneralUtility::trimExplode(',', $wizardGroup[$key]);
+            $wizardGroup[$key] = array_map(function ($s) {return $s . '.';}, $wizardGroup[$key]);
+        }
+    }
+
+    /**
      * Returns LanguageService
      *
      * @return \TYPO3\CMS\Lang\LanguageService
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-71876-MakeNewContentElementWizardTabSortOrderConfigurable.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-71876-MakeNewContentElementWizardTabSortOrderConfigurable.rst
new file mode 100644 (file)
index 0000000..a9c0aed
--- /dev/null
@@ -0,0 +1,14 @@
+=============================================================================
+Feature: #71876 - Make new content element wizard tab sort order configurable
+=============================================================================
+
+Description
+===========
+
+It is possible to influence the order of the tabs in the new content element
+wizard by setting ``before`` and ``after`` values in Page TSconfig:
+
+.. code-block:: typoscript
+
+    mod.wizards.newContentElement.wizardItems.special.before = common
+    mod.wizards.newContentElement.wizardItems.forms.after = common,special