TYPO3 CMS  TYPO3_6-2
ActionToolbarMenu.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\SysAction;
3 
17 
24 
30  protected $backendReference;
31 
35  protected $extensionKey = 'sys_action';
36 
40  public function __construct(\TYPO3\CMS\Backend\Controller\BackendController &$backendReference = NULL) {
41  $GLOBALS['LANG']->includeLLFile('EXT:sys_action/locallang.xlf');
42  $this->backendReference = $backendReference;
43  }
44 
51  public function setBackend(\TYPO3\CMS\Backend\Controller\BackendController &$backendReference) {
52  $this->backendReference = $backendReference;
53  }
54 
61  public function render() {
62  $actionMenu = array();
63  $actionEntries = $this->getActionEntries();
64  if ($actionEntries) {
65  $this->addJavascriptToBackend();
66  $this->addCssToBackend();
67  $title = $GLOBALS['LANG']->getLL('action_toolbaritem', TRUE);
68  $actionMenu[] = '<a href="#" class="toolbar-item">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('apps-toolbar-menu-actions', array('title' => $title)) . '</a>';
69  $actionMenu[] = '<ul class="toolbar-item-menu" style="display: none;">';
70  foreach ($actionEntries as $linkConf) {
71  $actionMenu[] = '<li><a href="' . htmlspecialchars($linkConf[1]) . '" target="content">' . $linkConf[2] . htmlspecialchars($linkConf[0]) . '</a></li>';
72  }
73  $actionMenu[] = '</ul>';
74  return implode(LF, $actionMenu);
75  } else {
76  return '';
77  }
78  }
79 
87  protected function getActionEntries() {
88  $actions = array();
89  if ($GLOBALS['BE_USER']->isAdmin()) {
90  $queryResource = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_action', 'pid = 0 AND hidden=0', '', 'sys_action.sorting');
91  } else {
92  $groupList = 0;
93  if ($GLOBALS['BE_USER']->groupList) {
94  $groupList = $GLOBALS['BE_USER']->groupList;
95  }
96  $queryResource = $GLOBALS['TYPO3_DB']->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 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($queryResource)) {
109  $actions[] = array(
110  $actionRow['title'],
111  BackendUtility::getModuleUrl('user_task') . '&SET[mode]=tasks&SET[function]=sys_action.TYPO3\\CMS\\SysAction\\ActionTask&show=' . $actionRow['uid'],
112  \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('sys_action', $actionRow)
113  );
114  }
115  $GLOBALS['TYPO3_DB']->sql_free_result($queryResource);
116  }
117  return $actions;
118  }
119 
125  public function getAdditionalAttributes() {
126  return 'id="tx-sys-action-menu"';
127  }
128 
134  protected function addJavascriptToBackend() {
135  $this->backendReference->addJavascriptFile(
136  \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($this->extensionKey) . 'toolbarmenu/tx_sysactions.js'
137  );
138  }
139 
145  protected function addCssToBackend() {
146  $this->backendReference->addCssFile(
147  'sysaction',
148  \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($this->extensionKey) . 'toolbarmenu/tx_sysactions.css'
149  );
150  }
151 
157  public function checkAccess() {
158  // Taskcenter is enabled for everybody
159  return TRUE;
160  }
161 
162 }
setBackend(\TYPO3\CMS\Backend\Controller\BackendController &$backendReference)
static getModuleUrl($moduleName, $urlParameters=array(), $backPathOverride=FALSE, $returnAbsoluteUrl=FALSE)
static getSpriteIcon($iconName, array $options=array(), array $overlays=array())
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
__construct(\TYPO3\CMS\Backend\Controller\BackendController &$backendReference=NULL)