[BUGFIX] Missing active state for shortcut button 77/42377/6
authorSascha Wilking <sascha.wilking@hmmh.de>
Fri, 7 Aug 2015 12:24:07 +0000 (14:24 +0200)
committerSusanne Moog <typo3@susannemoog.de>
Fri, 7 Aug 2015 13:02:26 +0000 (15:02 +0200)
After adding a page to bookmark list, the shortcut button gets an
active state now. The shortcut button is disabled then and can not
be clicked for a second time.

Resolves: #68296
Releases: master
Change-Id: I77d3e2b4a17131010442f5800f4733c243ef0146
Reviewed-on: http://review.typo3.org/42377
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Jan Runte <jan.runte@hmmh.de>
Tested-by: Jan Runte <jan.runte@hmmh.de>
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
Build/Resources/Public/Less/TYPO3/_element_docheader.less
typo3/sysext/backend/Classes/Backend/ToolbarItems/ShortcutToolbarItem.php
typo3/sysext/backend/Classes/Template/DocumentTemplate.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/backend/Resources/Public/JavaScript/Toolbar/ShortcutMenu.js
typo3/sysext/t3skin/Resources/Public/Css/backend.css

index 2a05044..39f4481 100644 (file)
                &:hover {
                        color: #000;
                }
+
+           &.active {
+                   color: @docheader-border;
+               }
+
+           &.active {
+                   span {
+                           cursor: default;
+                       }
+               }
        }
 
        .typo3-docheader-functions,
index 2425d4f..5125e9b 100644 (file)
@@ -562,7 +562,7 @@ class ShortcutToolbarItem implements ToolbarItemInterface {
                if (!empty($module) && !empty($url)) {
                        $shortcutCreated = 'alreadyExists';
 
-                       if (!$this->shortcutExists($url)) {
+                       if (!BackendUtility::shortcutExists($url)) {
                                $shortcutCreated = $this->addShortcut($url, $shortcutName, $module);
                        }
                }
index 17a972c..33770f9 100644 (file)
@@ -642,9 +642,22 @@ function jumpToUrl(URL) {
                        $motherModule = '\'\'';
                }
                $confirmationText = GeneralUtility::quoteJSvalue($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.makeBookmark'));
-               $url = GeneralUtility::quoteJSvalue(rawurlencode($pathInfo['path'] . '?' . $storeUrl));
-               $onClick = 'top.TYPO3.ShortcutMenu.createShortcut(' . GeneralUtility::quoteJSvalue(rawurlencode($modName)) . ', ' . $url . ', ' . $confirmationText . ', ' . $motherModule . ');return false;';
-               return '<a href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.makeBookmark', TRUE) . '">' . IconUtility::getSpriteIcon('actions-system-shortcut-new') . '</a>';
+
+               $shortcutUrl = $pathInfo['path'] . '?' . $storeUrl;
+               $shortcutExist = BackendUtility::shortcutExists($shortcutUrl);
+
+               if ($shortcutExist) {
+                       return '<a class="active" title="">' .
+                               IconUtility::getSpriteIcon('actions-system-shortcut-new') . '</a>';
+               }
+
+               $url = GeneralUtility::quoteJSvalue(rawurlencode($shortcutUrl));
+               $onClick = 'top.TYPO3.ShortcutMenu.createShortcut(' . GeneralUtility::quoteJSvalue(rawurlencode($modName)) .
+                       ', ' . $url . ', ' . $confirmationText . ', ' . $motherModule . ', this);return false;';
+
+               return '<a href="#" onclick="' . htmlspecialchars($onClick) . '" title="' .
+                       $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.makeBookmark', TRUE) . '">' .
+                       IconUtility::getSpriteIcon('actions-system-shortcut-new') . '</a>';
        }
 
        /**
index 23addd5..8a9c71d 100755 (executable)
@@ -21,6 +21,7 @@ use TYPO3\CMS\Backend\Routing\UriBuilder;
 use TYPO3\CMS\Backend\Template\DocumentTemplate;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Database\PreparedStatement;
 use TYPO3\CMS\Core\Database\RelationHandler;
 use TYPO3\CMS\Core\FormProtection\FormProtectionFactory;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
@@ -4528,6 +4529,33 @@ class BackendUtility {
        }
 
        /**
+        * Exists already a shortcut entry for this TYPO3 url?
+        *
+        * @param string $url
+        *
+        * @return bool
+        */
+       static public function shortcutExists($url) {
+               $statement = self::getDatabaseConnection()->prepare_SELECTquery(
+                       'uid',
+                       'sys_be_shortcuts',
+                       'userid = :userid AND url = :url'
+               );
+
+               $statement->bindValues([
+                       ':userid' => self::getBackendUserAuthentication()->user['uid'],
+                       ':url' => $url
+               ]
+               );
+
+               $statement->execute();
+               $rows = $statement->fetch(PreparedStatement::FETCH_ASSOC);
+               $statement->free();
+
+               return !empty($rows);
+       }
+
+       /**
         * Get the SignalSlot dispatcher
         *
         * @return \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
index d2e8cd8..a655de7 100644 (file)
@@ -102,12 +102,12 @@ define('TYPO3/CMS/Backend/Toolbar/ShortcutMenu', ['jquery'], function($) {
         * makes a call to the backend class to create a new shortcut,
         * when finished it reloads the menu
         */
-       ShortcutMenu.createShortcut = function(moduleName, url, confirmationText, motherModule) {
+       ShortcutMenu.createShortcut = function(moduleName, url, confirmationText, motherModule, shortcutButton) {
                if (typeof confirmationText !== 'undefined') {
                        // @todo: translations
                        top.TYPO3.Modal.confirm('Create bookmark', confirmationText)
                                .on('confirm.button.ok', function() {
-                                       var $toolbarItemIcon = $(ShortcutMenu.options.toolbarIconSelector, ShortcutMenu.options.containerSelector);
+                                       var $toolbarItemIcon = $(ShortcutMenu.options.toolbarIconSelector, ShortcutMenu.options.containerSelector);
                                        var $spinner = ShortcutMenu.$spinnerElement.clone();
                                        var $existingItem = $toolbarItemIcon.replaceWith($spinner);
 
@@ -123,6 +123,11 @@ define('TYPO3/CMS/Backend/Toolbar/ShortcutMenu', ['jquery'], function($) {
                                        }).done(function() {
                                                ShortcutMenu.refreshMenu();
                                                $spinner.replaceWith($existingItem);
+                                               if (typeof shortcutButton === 'object') {
+                                                       $(shortcutButton).addClass('active');
+                                                       $(shortcutButton).attr('title', null);
+                                                       $(shortcutButton).attr('onclick', null);
+                                               }
                                        });
                                        $(this).trigger('modal-dismiss');
                                })
index 68e37de..8a8d395 100644 (file)
@@ -1,14 +1,14 @@
-/*!
- * 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!
+/*!\r
+ * This file is part of the TYPO3 CMS project.\r
+ *\r
+ * It is free software; you can redistribute it and/or modify it under\r
+ * the terms of the GNU General Public License, either version 2\r
+ * of the License, or any later version.\r
+ *\r
+ * For the full copyright and license information, please read the\r
+ * LICENSE.txt file that was distributed with this source code.\r
+ *\r
+ * The TYPO3 project - inspiring people to share!\r
  */
 /*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
 html {
@@ -9157,6 +9157,12 @@ div#contentMenu1 {
 #typo3-docheader a:hover {
   color: #000;
 }
+#typo3-docheader a.active {
+  color: #c3c3c3;
+}
+#typo3-docheader a.active span {
+  cursor: default;
+}
 #typo3-docheader .typo3-docheader-functions,
 #typo3-docheader .typo3-docheader-buttons {
   color: #2d2d2d;