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