TYPO3 CMS  TYPO3_7-6
ActionToolbarItem.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 
27 {
31  protected $actionEntries = [];
32 
36  protected $iconFactory;
37 
41  public function __construct()
42  {
43  $this->getLanguageService()->includeLLFile('EXT:sys_action/Resources/Private/Language/locallang.xlf');
44  $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
45  $this->initializeActionEntries();
46  }
47 
53  public function getItem()
54  {
55  $title = $this->getLanguageService()->getLL('action_toolbaritem', true);
56  return '<span title="' . $title . '">' . $this->iconFactory->getIcon('apps-toolbar-menu-actions', Icon::SIZE_SMALL)->render('inline') . '</span>';
57  }
58 
64  public function getDropDown()
65  {
66  $actionMenu = [];
67  $actionMenu[] = '<ul class="dropdown-list">';
68  foreach ($this->actionEntries as $linkConf) {
69  $actionMenu[] = '<li>';
70  $actionMenu[] = '<a href="' . htmlspecialchars($linkConf[1]) . '" target="content" class="dropdown-list-link">';
71  $actionMenu[] = $linkConf[2] . ' ' . htmlspecialchars($linkConf[0]);
72  $actionMenu[] = '</a>';
73  $actionMenu[] = '</li>';
74  }
75  $actionMenu[] = '</ul>';
76  return implode(LF, $actionMenu);
77  }
78 
84  protected function initializeActionEntries()
85  {
86  $backendUser = $this->getBackendUser();
87  $databaseConnection = $this->getDatabaseConnection();
88  $actions = [];
89  if ($backendUser->isAdmin()) {
90  $queryResource = $databaseConnection->exec_SELECTquery('*', 'sys_action', 'pid = 0 AND hidden=0', '', 'sys_action.sorting');
91  } else {
92  $groupList = 0;
93  if ($backendUser->groupList) {
94  $groupList = $backendUser->groupList;
95  }
96  $queryResource = $databaseConnection->exec_SELECT_mm_query(
97  'sys_action.*',
98  'sys_action',
99  'sys_action_asgr_mm',
100  'be_groups',
101  ' AND be_groups.uid IN (' . $groupList . ') AND sys_action.pid = 0 AND sys_action.hidden = 0',
102  'sys_action.uid',
103  'sys_action.sorting'
104  );
105  }
106 
107  if ($queryResource) {
108  while ($actionRow = $databaseConnection->sql_fetch_assoc($queryResource)) {
109  $actions[] = [
110  $actionRow['title'],
111  BackendUtility::getModuleUrl('user_task') . '&SET[mode]=tasks&SET[function]=sys_action.TYPO3\\CMS\\SysAction\\ActionTask&show=' . $actionRow['uid'],
112  $this->iconFactory->getIconForRecord('sys_action', $actionRow, Icon::SIZE_SMALL)->render()
113  ];
114  }
115  $databaseConnection->sql_free_result($queryResource);
116  }
117  $this->actionEntries = $actions;
118  }
119 
125  public function getAdditionalAttributes()
126  {
127  return [];
128  }
129 
135  public function hasDropDown()
136  {
137  return true;
138  }
139 
145  public function checkAccess()
146  {
147  $result = false;
148  if (!empty($this->actionEntries)) {
149  $result = true;
150  }
151  return $result;
152  }
153 
159  public function getIndex()
160  {
161  return 35;
162  }
163 
169  protected function getBackendUser()
170  {
171  return $GLOBALS['BE_USER'];
172  }
173 
179  protected function getLanguageService()
180  {
181  return $GLOBALS['LANG'];
182  }
183 
189  protected function getDatabaseConnection()
190  {
191  return $GLOBALS['TYPO3_DB'];
192  }
193 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']