2 namespace TYPO3\CMS\Backend\Toolbar
;
5 * This file is part of the TYPO3 CMS project.
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.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
17 use TYPO3\CMS\Backend\Utility\BackendUtility
;
18 use TYPO3\CMS\Backend\Utility\IconUtility
;
19 use TYPO3\CMS\Core\Utility\GeneralUtility
;
20 use TYPO3\CMS\Core\Utility\MathUtility
;
23 * Class to render the shortcut menu
25 * @author Ingo Renner <ingo@typo3.org>
27 class ShortcutToolbarItem
implements \TYPO3\CMS\Backend\Toolbar\ToolbarItemHookInterface
{
29 const SUPERGLOBAL_GROUP
= -100;
33 * @todo define visibility
39 * @todo define visibility
45 * @todo define visibility
50 * All available shortcuts
59 protected $shortcutGroups;
62 * Labels of all groups.
63 * If value is 1, the system will try to find a label in the locallang array.
67 protected $groupLabels;
70 * Reference back to the backend object
72 * @var \TYPO3\CMS\Backend\Controller\BackendController
74 protected $backendReference;
79 * @param \TYPO3\CMS\Backend\Controller\BackendController $backendReference TYPO3 backend object reference
81 public function __construct(\TYPO3\CMS\Backend\Controller\BackendController
&$backendReference = NULL) {
82 if (TYPO3_REQUESTTYPE
& TYPO3_REQUESTTYPE_AJAX
) {
83 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_misc.xlf');
84 // Needed to get the correct icons when reloading the menu after saving it
85 $loadModules = GeneralUtility
::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleLoader');
86 $loadModules->load($GLOBALS['TBE_MODULES']);
88 $this->backendReference
= $backendReference;
89 $this->shortcuts
= array();
90 // By default, 5 groups are set
91 $this->shortcutGroups
= array(
98 $this->shortcutGroups
= $this->initShortcutGroups();
99 $this->shortcuts
= $this->initShortcuts();
103 * Checks whether the user has access to this toolbar item
105 * @return boolean TRUE if user has access, FALSE if not
107 public function checkAccess() {
108 return (bool) $GLOBALS['BE_USER']->getTSConfigVal('options.enableBookmarks');
112 * Creates the shortcut menu (default renderer)
114 * @return string Workspace selector as HTML select
116 public function render() {
117 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.bookmarks', TRUE);
118 $this->addJavascriptToBackend();
119 $shortcutMenu = array();
120 $shortcutMenu[] = '<a href="#" class="toolbar-item">' . IconUtility
::getSpriteIcon('apps-toolbar-menu-shortcut', array('title' => $title)) . '</a>';
121 $shortcutMenu[] = '<div class="toolbar-item-menu" style="display: none;">';
122 $shortcutMenu[] = $this->renderMenu();
123 $shortcutMenu[] = '</div>';
124 return implode(LF
, $shortcutMenu);
128 * Renders the pure contents of the menu
130 * @return string The menu's content
132 public function renderMenu() {
133 $shortcutGroup = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.bookmarksGroup', TRUE);
134 $shortcutEdit = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.bookmarksEdit', TRUE);
135 $shortcutDelete = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.bookmarksDelete', TRUE);
136 $groupIcon = '<img' . IconUtility
::skinImg($this->backPath
, 'gfx/i/sysf.gif', 'width="18" height="16"') . ' title="' . $shortcutGroup . '" alt="' . $shortcutGroup . '" />';
137 $editIcon = '<img' . IconUtility
::skinImg($this->backPath
, 'gfx/edit2.gif', 'width="11" height="12"') . ' title="' . $shortcutEdit . '" alt="' . $shortcutEdit . '"';
138 $deleteIcon = '<img' . IconUtility
::skinImg($this->backPath
, 'gfx/garbage.gif', 'width="11" height="12"') . ' title="' . $shortcutDelete . '" alt="' . $shortcutDelete . '" />';
139 $shortcutMenu[] = '<table border="0" cellspacing="0" cellpadding="0" class="shortcut-list">';
140 // Render shortcuts with no group (group id = 0) first
141 $noGroupShortcuts = $this->getShortcutsByGroup(0);
142 foreach ($noGroupShortcuts as $shortcut) {
144 <tr id="shortcut-' . $shortcut['raw']['uid'] . '" class="shortcut">
145 <td class="shortcut-icon">' . $shortcut['icon'] . '</td>
146 <td class="shortcut-label">
147 <a id="shortcut-label-' . $shortcut['raw']['uid'] . '" href="#" onclick="' . $shortcut['action'] . '; return false;">' . htmlspecialchars($shortcut['label']) . '</a>
149 <td class="shortcut-edit">' . $editIcon . ' id="shortcut-edit-' . $shortcut['raw']['uid'] . '" /></td>
150 <td class="shortcut-delete">' . $deleteIcon . '</td>
153 // Now render groups and the contained shortcuts
154 $groups = $this->getGroupsFromShortcuts();
155 krsort($groups, SORT_NUMERIC
);
156 foreach ($groups as $groupId => $groupLabel) {
159 <tr class="shortcut-group" id="shortcut-group-' . $groupId . '">
160 <td class="shortcut-group-icon">' . $groupIcon . '</td>
161 <td class="shortcut-group-label">' . $groupLabel . '</td>
162 <td colspan="2"> </td>
164 $shortcuts = $this->getShortcutsByGroup($groupId);
166 foreach ($shortcuts as $shortcut) {
170 $firstRow = ' first-row';
173 <tr id="shortcut-' . $shortcut['raw']['uid'] . '" class="shortcut' . $firstRow . '">
174 <td class="shortcut-icon">' . $shortcut['icon'] . '</td>
175 <td class="shortcut-label">
176 <a id="shortcut-label-' . $shortcut['raw']['uid'] . '" href="#" onclick="' . $shortcut['action'] . '; return false;">' . htmlspecialchars($shortcut['label']) . '</a>
178 <td class="shortcut-edit">' . $editIcon . ' id="shortcut-edit-' . $shortcut['raw']['uid'] . '" /></td>
179 <td class="shortcut-delete">' . $deleteIcon . '</td>
182 $shortcutMenu[] = $shortcutGroup;
185 if (count($shortcutMenu) == 1) {
186 // No shortcuts added yet, show a small help message how to add shortcuts
187 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.bookmarks', TRUE);
188 $icon = IconUtility
::getSpriteIcon('actions-system-shortcut-new', array(
191 $label = str_replace('%icon%', $icon, $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xlf:bookmarkDescription'));
192 $shortcutMenu[] = '<tr><td style="padding:1px 2px; color: #838383;">' . $label . '</td></tr>';
194 $shortcutMenu[] = '</table>';
195 $compiledShortcutMenu = implode(LF
, $shortcutMenu);
196 return $compiledShortcutMenu;
200 * Renders the menu so that it can be returned as response to an AJAX call
202 * @param array $params Array of parameters from the AJAX interface, currently unused
203 * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj Object of type AjaxRequestHandler
206 public function renderAjax($params = array(), \TYPO3\CMS\Core\Http\AjaxRequestHandler
&$ajaxObj = NULL) {
207 $menuContent = $this->renderMenu();
208 $ajaxObj->addContent('shortcutMenu', $menuContent);
212 * Adds the necessary JavaScript to the backend
216 protected function addJavascriptToBackend() {
217 $this->backendReference
->addJavascriptFile('sysext/backend/Resources/Public/JavaScript/shortcutmenu.js');
221 * Returns additional attributes for the list item in the toolbar
223 * @return string List item HTML attibutes
225 public function getAdditionalAttributes() {
226 return 'id="shortcut-menu"';
230 * Retrieves the shortcuts for the current user
232 * @return array Array of shortcuts
234 protected function initShortcuts() {
235 $globalGroupIdList = implode(',', array_keys($this->getGlobalShortcutGroups()));
236 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
239 '(userid = ' . (int)$GLOBALS['BE_USER']->user
['uid'] . ' AND sc_group>=0) OR sc_group IN (' . $globalGroupIdList . ')',
243 // Traverse shortcuts
245 $shortcuts = array();
246 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
247 $shortcut = array('raw' => $row);
249 list($row['module_name'], $row['M_module_name']) = explode('|', $row['module_name']);
251 $queryParts = parse_url($row['url']);
252 $queryParameters = GeneralUtility
::explodeUrl2Array($queryParts['query'], 1);
253 if ($row['module_name'] === 'xMOD_alt_doc.php' && is_array($queryParameters['edit'])) {
254 $shortcut['table'] = key($queryParameters['edit']);
255 $shortcut['recordid'] = key($queryParameters['edit'][$shortcut['table']]);
256 if ($queryParameters['edit'][$shortcut['table']][$shortcut['recordid']] === 'edit') {
257 $shortcut['type'] = 'edit';
258 } elseif ($queryParameters['edit'][$shortcut['table']][$shortcut['recordid']] === 'new') {
259 $shortcut['type'] = 'new';
261 if (substr($shortcut['recordid'], -1) === ',') {
262 $shortcut['recordid'] = substr($shortcut['recordid'], 0, -1);
265 $shortcut['type'] = 'other';
267 // Check for module access
268 $moduleName = $row['M_module_name'] ?
: $row['module_name'];
269 $pageId = $this->getLinkedPageId($row['url']);
270 if (!$GLOBALS['BE_USER']->isAdmin()) {
271 if (!isset($GLOBALS['LANG']->moduleLabels
['tabs_images'][$moduleName . '_tab'])) {
272 // Nice hack to check if the user has access to this module
273 // - otherwise the translation label would not have been loaded :-)
276 if (MathUtility
::canBeInterpretedAsInteger($pageId)) {
277 // Check for webmount access
278 if (!$GLOBALS['BE_USER']->isInWebMount($pageId)) {
281 // Check for record access
282 $pageRow = BackendUtility
::getRecord('pages', $pageId);
283 if (!$GLOBALS['BE_USER']->doesUserHaveAccess($pageRow, ($perms = 1))) {
288 $moduleParts = explode('_', $moduleName);
289 $shortcutGroup = (int)$row['sc_group'];
290 if ($shortcutGroup && $lastGroup !== $shortcutGroup && $shortcutGroup !== self
::SUPERGLOBAL_GROUP
) {
291 $shortcut['groupLabel'] = $this->getShortcutGroupLabel($shortcutGroup);
293 $lastGroup = $shortcutGroup;
295 if ($row['description']) {
296 $shortcut['label'] = $row['description'];
298 $shortcut['label'] = GeneralUtility
::fixed_lgd_cs(rawurldecode($queryParts['query']), 150);
300 $shortcut['group'] = $shortcutGroup;
301 $shortcut['icon'] = $this->getShortcutIcon($row, $shortcut);
302 $shortcut['iconTitle'] = $this->getShortcutIconTitle($shortcut['label'], $row['module_name'], $row['M_module_name']);
303 $shortcut['action'] = 'jump(unescape(\'' . rawurlencode($this->getTokenUrl($row['url'])) . '\'),\'' . $moduleName . '\',\'' . $moduleParts[0] . '\', ' . (int)$pageId . ');';
305 $shortcuts[] = $shortcut;
311 * Adds the correct token, if the url is a mod.php script
316 protected function getTokenUrl($url) {
317 $parsedUrl = parse_url($url);
318 parse_str($parsedUrl['query'], $parameters);
319 if (strpos($parsedUrl['path'], 'mod.php') !== FALSE && isset($parameters['M'])) {
320 $module = $parameters['M'];
321 unset($parameters['M']);
322 $url = str_replace('mod.php', '', $parsedUrl['path']) . BackendUtility
::getModuleUrl($module, $parameters);
328 * Gets shortcuts for a specific group
330 * @param integer $groupId Group Id
331 * @return array Array of shortcuts that matched the group
333 protected function getShortcutsByGroup($groupId) {
334 $shortcuts = array();
335 foreach ($this->shortcuts
as $shortcut) {
336 if ($shortcut['group'] == $groupId) {
337 $shortcuts[] = $shortcut;
344 * Gets a shortcut by its uid
346 * @param integer $shortcutId Shortcut id to get the complete shortcut for
347 * @return mixed An array containing the shortcut's data on success or FALSE on failure
349 protected function getShortcutById($shortcutId) {
350 $returnShortcut = FALSE;
351 foreach ($this->shortcuts
as $shortcut) {
352 if ($shortcut['raw']['uid'] == (int)$shortcutId) {
353 $returnShortcut = $shortcut;
357 return $returnShortcut;
361 * Gets the available shortcut groups from default groups, user TSConfig, and global groups
365 protected function initShortcutGroups() {
366 // Groups from TSConfig
367 $bookmarkGroups = $GLOBALS['BE_USER']->getTSConfigProp('options.bookmarkGroups');
368 if (is_array($bookmarkGroups) && count($bookmarkGroups)) {
369 foreach ($bookmarkGroups as $groupId => $label) {
370 if (!empty($label)) {
371 $this->shortcutGroups
[$groupId] = (string)$label;
372 } elseif ($GLOBALS['BE_USER']->isAdmin()) {
373 unset($this->shortcutGroups
[$groupId]);
377 // Generate global groups, all global groups have negative IDs.
378 if (count($this->shortcutGroups
)) {
379 $groups = $this->shortcutGroups
;
380 foreach ($groups as $groupId => $groupLabel) {
381 $this->shortcutGroups
[$groupId * -1] = $groupLabel;
384 // Group -100 is kind of superglobal and can't be changed.
385 $this->shortcutGroups
[self
::SUPERGLOBAL_GROUP
] = 1;
387 foreach ($this->shortcutGroups
as $groupId => $groupLabel) {
388 $groupId = (int)$groupId;
389 $label = $groupLabel;
390 if ($groupLabel == '1') {
391 $label = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xlf:bookmark_group_' . abs($groupId), TRUE);
394 $label = $GLOBALS['LANG']->getLL('bookmark_group', 1) . ' ' . abs($groupId);
399 $label = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xlf:bookmark_global', TRUE) . ': ' . (!empty($label) ?
$label : abs($groupId));
400 if ($groupId === self
::SUPERGLOBAL_GROUP
) {
401 $label = $GLOBALS['LANG']->getLL('bookmark_global', 1) . ': ' . $GLOBALS['LANG']->getLL('bookmark_all', 1);
404 $this->shortcutGroups
[$groupId] = $label;
406 return $this->shortcutGroups
;
410 * gets the available shortcut groups
412 * @param array $params Array of parameters from the AJAX interface, currently unused
413 * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj Object of type AjaxRequestHandler
416 public function getAjaxShortcutGroups($params = array(), \TYPO3\CMS\Core\Http\AjaxRequestHandler
&$ajaxObj = NULL) {
417 $shortcutGroups = $this->shortcutGroups
;
418 if (!$GLOBALS['BE_USER']->isAdmin()) {
419 foreach ($shortcutGroups as $groupId => $groupName) {
420 if ((int)$groupId < 0) {
421 unset($shortcutGroups[$groupId]);
425 $ajaxObj->addContent('shortcutGroups', $shortcutGroups);
426 $ajaxObj->setContentFormat('json');
430 * Deletes a shortcut through an AJAX call
432 * @param array $params Array of parameters from the AJAX interface, currently unused
433 * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj Object of type AjaxRequestHandler
436 public function deleteAjaxShortcut($params = array(), \TYPO3\CMS\Core\Http\AjaxRequestHandler
&$ajaxObj = NULL) {
437 $shortcutId = (int)GeneralUtility
::_POST('shortcutId');
438 $fullShortcut = $this->getShortcutById($shortcutId);
439 $ajaxReturn = 'failed';
440 if ($fullShortcut['raw']['userid'] == $GLOBALS['BE_USER']->user
['uid']) {
441 $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_be_shortcuts', 'uid = ' . $shortcutId);
442 if ($GLOBALS['TYPO3_DB']->sql_affected_rows() == 1) {
443 $ajaxReturn = 'deleted';
446 $ajaxObj->addContent('delete', $ajaxReturn);
450 * Creates a shortcut through an AJAX call
452 * @param array $params Array of parameters from the AJAX interface, currently unused
453 * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj Oject of type AjaxRequestHandler
456 public function createAjaxShortcut($params = array(), \TYPO3\CMS\Core\Http\AjaxRequestHandler
&$ajaxObj = NULL) {
457 $shortcutCreated = 'failed';
459 $shortcutName = 'Shortcut';
460 $shortcutNamePrepend = '';
461 $url = GeneralUtility
::_POST('url');
462 $module = GeneralUtility
::_POST('module');
463 $motherModule = GeneralUtility
::_POST('motherModName');
464 // Determine shortcut type
465 $queryParts = parse_url($url);
466 $queryParameters = GeneralUtility
::explodeUrl2Array($queryParts['query'], 1);
467 // Proceed only if no scheme is defined, as URL is expected to be relative
468 if (empty($queryParts['scheme'])) {
469 if (is_array($queryParameters['edit'])) {
470 $shortcut['table'] = key($queryParameters['edit']);
471 $shortcut['recordid'] = key($queryParameters['edit'][$shortcut['table']]);
472 if ($queryParameters['edit'][$shortcut['table']][$shortcut['recordid']] == 'edit') {
473 $shortcut['type'] = 'edit';
474 $shortcutNamePrepend = $GLOBALS['LANG']->getLL('shortcut_edit', 1);
475 } elseif ($queryParameters['edit'][$shortcut['table']][$shortcut['recordid']] == 'new') {
476 $shortcut['type'] = 'new';
477 $shortcutNamePrepend = $GLOBALS['LANG']->getLL('shortcut_create', 1);
480 $shortcut['type'] = 'other';
482 // Lookup the title of this page and use it as default description
483 $pageId = $shortcut['recordid'] ?
$shortcut['recordid'] : $this->getLinkedPageId($url);
484 if (MathUtility
::canBeInterpretedAsInteger($pageId)) {
485 $page = BackendUtility
::getRecord('pages', $pageId);
487 // Set the name to the title of the page
488 if ($shortcut['type'] == 'other') {
489 $shortcutName = $page['title'];
491 $shortcutName = $shortcutNamePrepend . ' ' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$shortcut['table']]['ctrl']['title']) . ' (' . $page['title'] . ')';
495 $dirName = urldecode($pageId);
496 if (preg_match('/\\/$/', $dirName)) {
497 // If $pageId is a string and ends with a slash,
498 // assume it is a fileadmin reference and set
499 // the description to the basename of that path
500 $shortcutName .= ' ' . basename($dirName);
503 // adding the shortcut
504 if ($module && $url) {
505 $fieldValues = array(
506 'userid' => $GLOBALS['BE_USER']->user
['uid'],
507 'module_name' => $module . '|' . $motherModule,
509 'description' => $shortcutName,
510 'sorting' => $GLOBALS['EXEC_TIME']
512 $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_be_shortcuts', $fieldValues);
513 if ($GLOBALS['TYPO3_DB']->sql_affected_rows() == 1) {
514 $shortcutCreated = 'success';
517 $ajaxObj->addContent('create', $shortcutCreated);
522 * Gets called when a shortcut is changed, checks whether the user has
523 * permissions to do so and saves the changes if everything is ok
525 * @param array $params Array of parameters from the AJAX interface, currently unused
526 * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj Object of type AjaxRequestHandler
529 public function setAjaxShortcut($params = array(), \TYPO3\CMS\Core\Http\AjaxRequestHandler
&$ajaxObj = NULL) {
530 $shortcutId = (int)GeneralUtility
::_POST('shortcutId');
531 $shortcutName = strip_tags(GeneralUtility
::_POST('value'));
532 $shortcutGroupId = (int)GeneralUtility
::_POST('shortcut-group');
533 if ($shortcutGroupId > 0 ||
$GLOBALS['BE_USER']->isAdmin()) {
534 // Users can delete only their own shortcuts (except admins)
535 $addUserWhere = !$GLOBALS['BE_USER']->isAdmin() ?
' AND userid=' . (int)$GLOBALS['BE_USER']->user
['uid'] : '';
536 $fieldValues = array(
537 'description' => $shortcutName,
538 'sc_group' => $shortcutGroupId
540 if ($fieldValues['sc_group'] < 0 && !$GLOBALS['BE_USER']->isAdmin()) {
541 $fieldValues['sc_group'] = 0;
543 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_be_shortcuts', 'uid=' . $shortcutId . $addUserWhere, $fieldValues);
544 $affectedRows = $GLOBALS['TYPO3_DB']->sql_affected_rows();
545 if ($affectedRows == 1) {
546 $ajaxObj->addContent('shortcut', $shortcutName);
548 $ajaxObj->addContent('shortcut', 'failed');
551 $ajaxObj->setContentFormat('plain');
555 * Gets the label for a shortcut group
557 * @param integer $groupId A shortcut group id
558 * @return string The shortcut group label, can be an empty string if no group was found for the id
560 protected function getShortcutGroupLabel($groupId) {
561 return isset($this->shortcutGroups
[$groupId]) ?
$this->shortcutGroups
[$groupId] : '';
565 * Gets a list of global groups, shortcuts in these groups are available to all users
567 * @return array Array of global groups
569 protected function getGlobalShortcutGroups() {
570 $globalGroups = array();
571 foreach ($this->shortcutGroups
as $groupId => $groupLabel) {
573 $globalGroups[$groupId] = $groupLabel;
576 return $globalGroups;
580 * runs through the available shortcuts an collects their groups
582 * @return array Array of groups which have shortcuts
584 protected function getGroupsFromShortcuts() {
586 foreach ($this->shortcuts
as $shortcut) {
587 $groups[$shortcut['group']] = $this->shortcutGroups
[$shortcut['group']];
589 return array_unique($groups);
593 * Gets the icon for the shortcut
596 * @param array $shortcut
597 * @return string Shortcut icon as img tag
599 protected function getShortcutIcon($row, $shortcut) {
600 switch ($row['module_name']) {
601 case 'xMOD_alt_doc.php':
602 $table = $shortcut['table'];
603 $recordid = $shortcut['recordid'];
605 if ($shortcut['type'] == 'edit') {
606 // Creating the list of fields to include in the SQL query:
607 $selectFields = $this->fieldArray
;
608 $selectFields[] = 'uid';
609 $selectFields[] = 'pid';
610 if ($table == 'pages') {
611 $selectFields[] = 'module';
612 $selectFields[] = 'extendToSubpages';
613 $selectFields[] = 'doktype';
615 if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
616 $selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']);
618 if ($GLOBALS['TCA'][$table]['ctrl']['type']) {
619 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['type'];
621 if ($GLOBALS['TCA'][$table]['ctrl']['typeicon_column']) {
622 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_column'];
624 if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
625 $selectFields[] = 't3ver_state';
628 $selectFields = array_unique($selectFields);
629 $permissionClause = $table === 'pages' && $this->perms_clause ?
' AND ' . $this->perms_clause
: '';
630 $sqlQueryParts = array(
631 'SELECT' => implode(',', $selectFields),
633 'WHERE' => 'uid IN (' . $recordid . ') ' . $permissionClause . BackendUtility
::deleteClause($table) . BackendUtility
::versioningPlaceholderClause($table)
635 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($sqlQueryParts);
636 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
637 $icon = IconUtility
::getIcon($table, $row, $this->backPath
);
638 } elseif ($shortcut['type'] == 'new') {
639 $icon = IconUtility
::getIcon($table, array(), $this->backPath
);
641 $icon = IconUtility
::skinImg($this->backPath
, $icon, '', 1);
643 case 'xMOD_file_edit.php':
644 $icon = 'gfx/edit_file.gif';
647 $icon = 'gfx/edit_rtewiz.gif';
650 if ($GLOBALS['LANG']->moduleLabels
['tabs_images'][$row['module_name'] . '_tab']) {
651 $icon = $GLOBALS['LANG']->moduleLabels
['tabs_images'][$row['module_name'] . '_tab'];
652 // Change icon of fileadmin references - otherwise it doesn't differ with Web->List
653 $icon = str_replace('mod/file/list/list.gif', 'mod/file/file.gif', $icon);
654 if (GeneralUtility
::isAbsPath($icon)) {
655 $icon = '../' . \TYPO3\CMS\Core\Utility\PathUtility
::stripPathSitePrefix($icon);
658 $icon = 'gfx/dummy_module.gif';
661 return '<img src="' . $icon . '" alt="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.shortcut', TRUE) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.shortcut', TRUE) . '" />';
665 * Returns title for the shortcut icon
667 * @param string $shortcutLabel Shortcut label
668 * @param string $moduleName Backend module name (key)
669 * @param string $parentModuleName Parent module label
670 * @return string Title for the shortcut icon
672 protected function getShortcutIconTitle($shortcutLabel, $moduleName, $parentModuleName = '') {
674 if (substr($moduleName, 0, 5) == 'xMOD_') {
675 $title = substr($moduleName, 5);
677 $splitModuleName = explode('_', $moduleName);
678 $title = $GLOBALS['LANG']->moduleLabels
['tabs'][$splitModuleName[0] . '_tab'];
679 if (count($splitModuleName) > 1) {
680 $title .= '>' . $GLOBALS['LANG']->moduleLabels
['tabs'][($moduleName . '_tab')];
683 if ($parentModuleName) {
684 $title .= ' (' . $parentModuleName . ')';
686 $title .= ': ' . $shortcutLabel;
691 * Return the ID of the page in the URL if found.
693 * @param string $url The URL of the current shortcut link
694 * @return string If a page ID was found, it is returned. Otherwise: 0
696 protected function getLinkedPageId($url) {
697 return preg_replace('/.*[\\?&]id=([^&]+).*/', '$1', $url);