[BUGFIX] Invalid HTML for the top toolbar in Backend 87/28587/6
authorXavier Perseguers <xavier@typo3.org>
Fri, 21 Mar 2014 10:39:59 +0000 (11:39 +0100)
committerXavier Perseguers <xavier@typo3.org>
Fri, 21 Mar 2014 15:03:46 +0000 (16:03 +0100)
Additional attributes must be concatenated with a leading blank
space in order to get valid HTML content.

Fixes: #57127
Releases: 6.2
Change-Id: Iac0cf3033af37efd8e1a8efeb777083503166c5c
Reviewed-on: https://review.typo3.org/28587
Reviewed-by: Andreas Fernandez
Tested-by: Andreas Fernandez
Reviewed-by: Eric Chavaillaz
Tested-by: Eric Chavaillaz
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
typo3/sysext/backend/Classes/Controller/BackendController.php
typo3/sysext/backend/Classes/Toolbar/ClearCacheToolbarItem.php
typo3/sysext/backend/Classes/Toolbar/LiveSearchToolbarItem.php
typo3/sysext/backend/Classes/Toolbar/ShortcutToolbarItem.php
typo3/sysext/opendocs/Classes/Controller/OpendocsController.php
typo3/sysext/sys_action/Classes/ActionToolbarMenu.php
typo3/sysext/workspaces/Classes/ExtDirect/WorkspaceSelectorToolbarItem.php

index 9333970..e97be59 100644 (file)
@@ -304,19 +304,23 @@ class BackendController {
                $toolbar .= '<li>' . $this->getLoggedInUserLabel() . '</li>';
                $toolbar .= '<li class="separator"><div id="logout-button" class="toolbar-item no-separator">' . $this->moduleMenu->renderLogoutButton() . '</div></li>';
                $i = 0;
+               $numberOfToolbarItems = count($this->toolbarItems);
                foreach ($this->toolbarItems as $key => $toolbarItem) {
                        $i++;
                        $menu = $toolbarItem->render();
                        if ($menu) {
-                               $additionalAttributes = $toolbarItem->getAdditionalAttributes();
-                               if (sizeof($this->toolbarItems) > 1 && $i == sizeof($this->toolbarItems) - 1) {
-                                       if (strpos($additionalAttributes, 'class="')) {
-                                               str_replace('class="', 'class="separator ', $additionalAttributes);
+                               $additionalAttributes = trim($toolbarItem->getAdditionalAttributes());
+                               if ($numberOfToolbarItems > 1 && $i == $numberOfToolbarItems - 1) {
+                                       if (strpos($additionalAttributes, 'class="') !== FALSE) {
+                                               $additionalAttributes = str_replace('class="', 'class="separator ', $additionalAttributes);
                                        } else {
-                                               $additionalAttributes .= 'class="separator"';
+                                               $additionalAttributes .= ' class="separator"';
                                        }
                                }
-                               $toolbar .= '<li ' . $additionalAttributes . '>' . $menu . '</li>';
+                               if ($additionalAttributes !== '') {
+                                       $additionalAttributes = ' ' . $additionalAttributes;
+                               }
+                               $toolbar .= '<li' . $additionalAttributes . '>' . $menu . '</li>';
                        }
                }
                return $toolbar . '</ul>';
index 816505f..3ea426e 100644 (file)
@@ -177,7 +177,7 @@ class ClearCacheToolbarItem implements ToolbarItemHookInterface {
         * @return string List item HTML attributes
         */
        public function getAdditionalAttributes() {
-               return ' id="clear-cache-actions-menu"';
+               return 'id="clear-cache-actions-menu"';
        }
 
        /**
index c407da1..7059e7b 100644 (file)
@@ -98,7 +98,7 @@ class LiveSearchToolbarItem implements \TYPO3\CMS\Backend\Toolbar\ToolbarItemHoo
         * @return string List item HTML attributes
         */
        public function getAdditionalAttributes() {
-               return ' id="live-search-menu"';
+               return 'id="live-search-menu"';
        }
 
 }
index ff81407..30f626f 100644 (file)
@@ -241,7 +241,7 @@ class ShortcutToolbarItem implements \TYPO3\CMS\Backend\Toolbar\ToolbarItemHookI
         * @return string List item HTML attibutes
         */
        public function getAdditionalAttributes() {
-               return ' id="shortcut-menu"';
+               return 'id="shortcut-menu"';
        }
 
        /**
index 0a4ccf1..1c877b5 100644 (file)
@@ -189,7 +189,7 @@ class OpendocsController implements \TYPO3\CMS\Backend\Toolbar\ToolbarItemHookIn
         * @return string List item HTML attibutes
         */
        public function getAdditionalAttributes() {
-               return ' id="tx-opendocs-menu"';
+               return 'id="tx-opendocs-menu"';
        }
 
        /**
index 833ab6f..bf7fda7 100644 (file)
@@ -133,7 +133,7 @@ class ActionToolbarMenu implements \TYPO3\CMS\Backend\Toolbar\ToolbarItemHookInt
         * @return string List item HTML attibutes
         */
        public function getAdditionalAttributes() {
-               return 'id="tx-sys-action-menu" ';
+               return 'id="tx-sys-action-menu"';
        }
 
        /**
index b188928..8ee913e 100644 (file)
@@ -162,7 +162,7 @@ class WorkspaceSelectorToolbarItem implements \TYPO3\CMS\Backend\Toolbar\Toolbar
         * @return      string          list item HTML attibutes
         */
        public function getAdditionalAttributes() {
-               return ' id="workspace-selector-menu"';
+               return 'id="workspace-selector-menu"';
        }
 
 }