‪TYPO3CMS  10.4
ShortcutToolbarItem.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
23 
30 {
34  protected ‪$shortcutRepository;
35 
39  public function ‪__construct()
40  {
41  $this->shortcutRepository = GeneralUtility::makeInstance(ShortcutRepository::class);
42 
43  $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
44  $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Toolbar/ShortcutMenu');
45  $languageService = $this->‪getLanguageService();
46  $languageFile = 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf';
47  $pageRenderer->addInlineLanguageLabelArray([
48  'bookmark.delete' => $languageService->sL($languageFile . ':toolbarItems.bookmarksDelete'),
49  'bookmark.confirmDelete' => $languageService->sL($languageFile . ':toolbarItems.confirmBookmarksDelete'),
50  'bookmark.create' => $languageService->sL($languageFile . ':toolbarItems.createBookmark'),
51  'bookmark.savedTitle' => $languageService->sL($languageFile . ':toolbarItems.bookmarkSavedTitle'),
52  'bookmark.savedMessage' => $languageService->sL($languageFile . ':toolbarItems.bookmarkSavedMessage'),
53  ]);
54  }
55 
61  public function ‪checkAccess()
62  {
63  return (bool)($this->‪getBackendUser()->‪getTSConfig()['options.']['enableBookmarks'] ?? false);
64  }
65 
73  public function ‪getItem()
74  {
75  return $this->‪getFluidTemplateObject('Item.html')->‪render();
76  }
77 
83  public function ‪hasDropDown()
84  {
85  return true;
86  }
87 
93  public function ‪getDropDown()
94  {
95  $shortcutMenu = [];
96  $groups = $this->shortcutRepository->getGroupsFromShortcuts();
97  arsort($groups, SORT_NUMERIC);
98 
99  foreach ($groups as $groupId => $groupLabel) {
100  $shortcutMenu[] = [
101  'id' => (int)$groupId,
102  'title' => $groupLabel,
103  'shortcuts' => $this->shortcutRepository->getShortcutsByGroup($groupId),
104  ];
105  }
106 
107  $dropDownView = $this->‪getFluidTemplateObject('DropDown.html');
108  $dropDownView->assign('shortcutMenu', $shortcutMenu);
109 
110  return $dropDownView->render();
111  }
112 
118  public function ‪getAdditionalAttributes()
119  {
120  return [];
121  }
122 
128  public function ‪getIndex()
129  {
130  return 20;
131  }
132 
142  protected function ‪getFluidTemplateObject(string $templateFilename): ‪StandaloneView
143  {
144  $view = GeneralUtility::makeInstance(StandaloneView::class);
145  $view->setLayoutRootPaths(['EXT:backend/Resources/Private/Layouts']);
146  $view->setPartialRootPaths(['EXT:backend/Resources/Private/Partials']);
147  $view->setTemplateRootPaths(['EXT:backend/Resources/Private/Templates/ShortcutToolbarItem']);
148  $view->setTemplate($templateFilename);
149  $view->getRequest()->setControllerExtensionName('Backend');
150 
151  return $view;
152  }
153 
159  protected function ‪getBackendUser()
160  {
161  return ‪$GLOBALS['BE_USER'];
162  }
163 
167  protected function ‪getLanguageService()
168  {
169  return ‪$GLOBALS['LANG'];
170  }
171 }
‪TYPO3\CMS\Backend\Backend\Shortcut\ShortcutRepository
Definition: ShortcutRepository.php:44
‪TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface
Definition: ToolbarItemInterface.php:25
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\getAdditionalAttributes
‪array getAdditionalAttributes()
Definition: ShortcutToolbarItem.php:117
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication\getTSConfig
‪array getTSConfig()
Definition: BackendUserAuthentication.php:1217
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\getDropDown
‪string getDropDown()
Definition: ShortcutToolbarItem.php:92
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\getItem
‪string getItem()
Definition: ShortcutToolbarItem.php:72
‪TYPO3\CMS\Core\Page\PageRenderer
Definition: PageRenderer.php:42
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\getLanguageService
‪TYPO3 CMS Core Localization LanguageService getLanguageService()
Definition: ShortcutToolbarItem.php:166
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\checkAccess
‪bool checkAccess()
Definition: ShortcutToolbarItem.php:60
‪TYPO3\CMS\Backend\Backend\ToolbarItems
Definition: ClearCacheToolbarItem.php:16
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\getBackendUser
‪TYPO3 CMS Core Authentication BackendUserAuthentication getBackendUser()
Definition: ShortcutToolbarItem.php:158
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem
Definition: ShortcutToolbarItem.php:30
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\hasDropDown
‪bool hasDropDown()
Definition: ShortcutToolbarItem.php:82
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\$shortcutRepository
‪ShortcutRepository $shortcutRepository
Definition: ShortcutToolbarItem.php:33
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:34
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\__construct
‪__construct()
Definition: ShortcutToolbarItem.php:38
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Extbase\Mvc\View\ViewInterface\render
‪string render()
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\getFluidTemplateObject
‪StandaloneView getFluidTemplateObject(string $templateFilename)
Definition: ShortcutToolbarItem.php:141
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\getIndex
‪int getIndex()
Definition: ShortcutToolbarItem.php:127