[TASK] Add human readable sections names in Install Tool 73/39273/6
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Tue, 5 May 2015 06:24:59 +0000 (08:24 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Tue, 5 May 2015 19:39:50 +0000 (21:39 +0200)
For usability reasons, prepend human readable sections names
in the "All Configuration" site of the Install Tool.

Resolves: #22539
Releases: master
Change-Id: I06002f620b300b7431e87f7c70a18ebcf840bcd8
Reviewed-on: http://review.typo3.org/39273
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/install/Classes/Controller/Action/Tool/AllConfiguration.php
typo3/sysext/install/Classes/ViewHelpers/Object/ArrayValueByKeyViewHelper.php [new file with mode: 0644]
typo3/sysext/install/Resources/Private/Partials/Action/Tool/AllConfiguration/SubSection.html

index 3f976a8..88c63aa 100644 (file)
@@ -46,6 +46,7 @@ class AllConfiguration extends Action\AbstractAction {
                        $this->view->assign('configurationValuesSaved', TRUE);
                        $this->view->assign('savedConfigurationValueMessages', $this->updateLocalConfigurationValues());
                } else {
+                       $this->view->assign('sections', $this->getSpeakingSectionNames());
                        $this->view->assign('data', $this->setUpConfigurationData());
                }
 
@@ -53,6 +54,24 @@ class AllConfiguration extends Action\AbstractAction {
        }
 
        /**
+        * Returns an array of available sections and their description
+        *
+        * @return string[]
+        */
+       protected function getSpeakingSectionNames() {
+               return array(
+                       'BE' => 'Backend',
+                       'DB' => 'Database',
+                       'EXT' => 'Extension Installation',
+                       'FE' => 'Frontend',
+                       'GFX' => 'Image Processing',
+                       'HTTP' => 'Connection',
+                       'MAIL' => 'Mail',
+                       'SYS' => 'System'
+               );
+       }
+
+       /**
         * Set up configuration data
         *
         * @return array Configuration data
diff --git a/typo3/sysext/install/Classes/ViewHelpers/Object/ArrayValueByKeyViewHelper.php b/typo3/sysext/install/Classes/ViewHelpers/Object/ArrayValueByKeyViewHelper.php
new file mode 100644 (file)
index 0000000..4f9a82b
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+namespace TYPO3\CMS\Install\ViewHelpers\Object;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Install\ViewHelpers\Exception;
+use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
+use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
+use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
+
+/**
+ * View helper which allows you to access a key in an array.
+ *
+ * = Examples =
+ *
+ * <code title="Defaults">
+ * <i:object.key array="{array}" key="{key}" />
+ * </code>
+ * <output>
+ * The key in the array, if it exists, otherwise an empty string.
+ * </output>
+ *
+ * @internal
+ */
+class ArrayValueByKeyViewHelper extends AbstractViewHelper implements CompilableInterface {
+
+       /**
+        * Get the value of an key in an array.
+        *
+        * @param array $array The array being processed
+        * @param mixed $key The key being accessed
+        * @return string
+        */
+       public function render(array $array, $key) {
+               return self::renderStatic(
+                       array(
+                               'array' => $array,
+                               'key' => $key,
+                       ),
+                       $this->buildRenderChildrenClosure(),
+                       $this->renderingContext
+               );
+       }
+
+       /**
+        * @param array $arguments
+        * @param callable $renderChildrenClosure
+        * @param RenderingContextInterface $renderingContext
+        *
+        * @return string
+        * @throws Exception
+        */
+       static public function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) {
+               $array = $arguments['array'];
+               $key = $arguments['key'];
+               $result = '';
+               if (isset($array[$key])) {
+                       $result = $array[$key];
+               }
+               if (!is_scalar($result)) {
+                       throw new Exception(
+                               'Only scalar return values (string, int, float or double) are supported.',
+                               1430852128
+                       );
+               }
+               return (string)$result;
+       }
+
+}
index f47066e..c59fd39 100644 (file)
@@ -2,7 +2,7 @@
 
 <div class="toggleGroup">
        <div class="toggleButton">
-               <h4><strong>$TYPO3_CONF_VARS['{sectionName}']</strong></h4>
+               <h4><strong><i:object.arrayValueByKey array="{sections}" key="{sectionName}" /></strong> [{sectionName}]</h4>
        </div>
 
        <div class="toggleData" style="display:none">