2 namespace TYPO3\CMS\Backend\ClickMenu
;
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\
Resource\ResourceFactory
;
20 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility
;
21 use TYPO3\CMS\Core\Utility\GeneralUtility
;
24 * Class for generating the click menu
26 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
31 // Internal, static: GPvar:
32 // Defines if the click menu is first level or second. Second means the click menu is triggered from another menu.
34 * @todo Define visibility
38 // Clipboard array (submitted by eg. pressing the paste button)
40 * @todo Define visibility
45 // Backpath for scripts/images.
47 * @todo Define visibility
49 public $backPath = '';
51 // BackPath place holder: We need different backPath set whether the clickmenu is written back to a frame which is not in typo3/ dir or if the clickmenu is shown in the top frame (no backpath)
53 * @todo Define visibility
55 public $PH_backPath = '###BACK_PATH###';
57 // If set, the calling document should be in the listframe of a frameset.
59 * @todo Define visibility
61 public $listFrame = 0;
63 // If set, the menu is about database records, not files. (set if part 2 [1] of the item-var is NOT blank)
65 * @todo Define visibility
69 // If TRUE, the "content" frame is always used for reference (when condensed mode is enabled)
71 * @todo Define visibility
73 public $alwaysContentFrame = 0;
75 // Stores the parts of the input $item string, splitted by "|":
76 // [0] = table/file, [1] = uid/blank, [2] = flag: If set, listFrame,
77 // If "2" then "content frame" is forced [3] = ("+" prefix = disable
78 // all by default, enable these. Default is to disable) Items key list
80 * @todo Define visibility
82 public $iParts = array();
84 // Contains list of keywords of items to disable in the menu
86 * @todo Define visibility
88 public $disabledItems = array();
90 // If TRUE, Show icons on the left.
92 * @todo Define visibility
94 public $leftIcons = 0;
96 // Array of classes to be used for user processing of the menu content. This is for the API of adding items to the menu from outside.
98 * @todo Define visibility
100 public $extClassArray = array();
102 // Enable/disable ajax behavior
104 * @todo Define visibility
108 // Internal, dynamic:
109 // Counter for elements in the menu. Used to number the name / id of the mouse-over icon.
111 * @todo Define visibility
115 // Set, when edit icon is drawn.
117 * @todo Define visibility
119 public $editPageIconSet = 0;
121 // Set to TRUE, if editing of the element is OK.
123 * @todo Define visibility
128 * @todo Define visibility
130 public $rec = array();
133 * Initialize click menu
135 * @return string The clickmenu HTML content
136 * @todo Define visibility
138 public function init() {
140 $this->cmLevel
= (int)GeneralUtility
::_GP('cmLevel');
141 $this->CB
= GeneralUtility
::_GP('CB');
142 if (GeneralUtility
::_GP('ajax')) {
144 // XML has to be parsed, no parse errors allowed
145 @ini_set
('display_errors', 0);
147 // Deal with Drag&Drop context menus
148 if ((string)GeneralUtility
::_GP('dragDrop') !== '') {
149 return $this->printDragDropClickMenu(GeneralUtility
::_GP('dragDrop'), GeneralUtility
::_GP('srcId'), GeneralUtility
::_GP('dstId'));
151 // Can be set differently as well
152 $this->iParts
[0] = GeneralUtility
::_GP('table');
153 $this->iParts
[1] = GeneralUtility
::_GP('uid');
154 $this->iParts
[2] = GeneralUtility
::_GP('listFr');
155 $this->iParts
[3] = GeneralUtility
::_GP('enDisItems');
157 if ($this->iParts
[2]) {
158 $this->listFrame
= 1;
160 if ($this->iParts
[2] == 2) {
161 $this->alwaysContentFrame
= 1;
163 if (isset($this->iParts
[1]) && $this->iParts
[1] !== '') {
166 $TSkey = ($this->isDBmenu ?
'page' : 'folder') . ($this->listFrame ?
'List' : 'Tree');
167 $this->disabledItems
= GeneralUtility
::trimExplode(',', $GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.' . $TSkey . '.disableItems'), TRUE);
168 $this->leftIcons
= $GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.options.leftIcons');
169 // &cmLevel flag detected (2nd level menu)
170 if (!$this->cmLevel
) {
171 // Make 1st level clickmenu:
172 if ($this->isDBmenu
) {
173 $CMcontent = $this->printDBClickMenu($this->iParts
[0], $this->iParts
[1]);
175 $CMcontent = $this->printFileClickMenu($this->iParts
[0]);
178 // Make 2nd level clickmenu (only for DBmenus)
179 if ($this->isDBmenu
) {
180 $CMcontent = $this->printNewDBLevel($this->iParts
[0], $this->iParts
[1]);
183 // Return clickmenu content:
187 /***************************************
191 ***************************************/
193 * Make 1st level clickmenu:
195 * @param string $table Table name
196 * @param integer $uid UID for the current record.
197 * @return string HTML content
198 * @todo Define visibility
200 public function printDBClickMenu($table, $uid) {
203 $this->rec
= BackendUtility
::getRecordWSOL($table, $uid);
204 $menuItems = array();
208 if ($table === 'pages' && $uid === 0) {
212 if ($table === 'pages' && in_array($uid, $GLOBALS['BE_USER']->returnWebmounts())) {
215 // Used to hide cut,copy icons for l10n-records
216 $l10nOverlay = FALSE;
217 // Should only be performed for overlay-records within the same table
218 if (BackendUtility
::isTableLocalizable($table) && !isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'])) {
219 $l10nOverlay = (int)$this->rec
[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0;
221 // If record found (or root), go ahead and fill the $menuItems array which will contain data for the elements to render.
222 if (is_array($this->rec
) ||
$root) {
224 $lCP = $GLOBALS['BE_USER']->calcPerms(BackendUtility
::getRecord('pages', $table == 'pages' ?
$this->rec
['uid'] : $this->rec
['pid']));
226 if (!in_array('view', $this->disabledItems
)) {
227 if ($table === 'pages') {
228 $menuItems['view'] = $this->DB_view($uid);
230 if ($table === 'tt_content') {
231 $ws_rec = BackendUtility
::getRecordWSOL($table, $this->rec
['uid']);
232 $menuItems['view'] = $this->DB_view($ws_rec['pid']);
236 if (!$root && ($GLOBALS['BE_USER']->isPSet($lCP, $table, 'edit') ||
$GLOBALS['BE_USER']->isPSet($lCP, $table, 'editcontent'))) {
237 if (!in_array('edit', $this->disabledItems
)) {
238 $menuItems['edit'] = $this->DB_edit($table, $uid);
243 if (!in_array('new', $this->disabledItems
) && $GLOBALS['BE_USER']->isPSet($lCP, $table, 'new')) {
244 $menuItems['new'] = $this->DB_new($table, $uid);
247 if (!in_array('info', $this->disabledItems
) && !$root) {
248 $menuItems['info'] = $this->DB_info($table, $uid);
250 $menuItems['spacer1'] = 'spacer';
252 if (!in_array('copy', $this->disabledItems
) && !$root && !$DBmount && !$l10nOverlay) {
253 $menuItems['copy'] = $this->DB_copycut($table, $uid, 'copy');
256 if (!in_array('cut', $this->disabledItems
) && !$root && !$DBmount && !$l10nOverlay) {
257 $menuItems['cut'] = $this->DB_copycut($table, $uid, 'cut');
260 $elFromAllTables = count($this->clipObj
->elFromTable(''));
261 if (!in_array('paste', $this->disabledItems
) && $elFromAllTables) {
262 $selItem = $this->clipObj
->getSelectedRecord();
264 GeneralUtility
::fixed_lgd_cs($selItem['_RECORD_TITLE'], $GLOBALS['BE_USER']->uc
['titleLen']),
265 $root ?
$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] : GeneralUtility
::fixed_lgd_cs(BackendUtility
::getRecordTitle($table, $this->rec
), $GLOBALS['BE_USER']->uc
['titleLen']),
266 $this->clipObj
->currentMode()
268 if ($table === 'pages' && $lCP & 8) {
269 if ($elFromAllTables) {
270 $menuItems['pasteinto'] = $this->DB_paste('', $uid, 'into', $elInfo);
273 $elFromTable = count($this->clipObj
->elFromTable($table));
274 if (!$root && !$DBmount && $elFromTable && $GLOBALS['TCA'][$table]['ctrl']['sortby']) {
275 $menuItems['pasteafter'] = $this->DB_paste($table, -$uid, 'after', $elInfo);
279 $elInfo = array(GeneralUtility
::fixed_lgd_cs(BackendUtility
::getRecordTitle($table, $this->rec
), $GLOBALS['BE_USER']->uc
['titleLen']));
280 if (!in_array('delete', $this->disabledItems
) && !$root && !$DBmount && $GLOBALS['BE_USER']->isPSet($lCP, $table, 'delete')) {
281 $menuItems['spacer2'] = 'spacer';
282 $menuItems['delete'] = $this->DB_delete($table, $uid, $elInfo);
284 if (!in_array('history', $this->disabledItems
)) {
285 $menuItems['history'] = $this->DB_history($table, $uid, $elInfo);
288 // Adding external elements to the menuItems array
289 $menuItems = $this->processingByExtClassArray($menuItems, $table, $uid);
290 // Processing by external functions?
291 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
292 if (!is_array($this->rec
)) {
293 $this->rec
= array();
295 // Return the printed elements:
296 return $this->printItems($menuItems, $root ? IconUtility
::getSpriteIcon('apps-pagetree-root') . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) : IconUtility
::getSpriteIconForRecord($table, $this->rec
, array('title' => htmlspecialchars(BackendUtility
::getRecordIconAltText($this->rec
, $table)))) . BackendUtility
::getRecordTitle($table, $this->rec
, TRUE));
300 * Make 2nd level clickmenu (only for DBmenus)
302 * @param string $table Table name
303 * @param integer $uid UID for the current record.
304 * @return string HTML content
305 * @todo Define visibility
307 public function printNewDBLevel($table, $uid) {
309 // Setting internal record to the table/uid :
310 $this->rec
= BackendUtility
::getRecordWSOL($table, $uid);
311 $menuItems = array();
314 if ($table === 'pages' && $uid === 0) {
317 // If record was found, check permissions and get menu items.
318 if (is_array($this->rec
) ||
$root) {
319 $lCP = $GLOBALS['BE_USER']->calcPerms(BackendUtility
::getRecord('pages', $table == 'pages' ?
$this->rec
['uid'] : $this->rec
['pid']));
321 if (!$root && ($GLOBALS['BE_USER']->isPSet($lCP, $table, 'edit') ||
$GLOBALS['BE_USER']->isPSet($lCP, $table, 'editcontent'))) {
324 $menuItems = $this->processingByExtClassArray($menuItems, $table, $uid);
326 // Return the printed elements:
327 if (!is_array($menuItems)) {
328 $menuItems = array();
330 return $this->printItems($menuItems, $root ? IconUtility
::getSpriteIcon('apps-pagetree-root') . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) : IconUtility
::getSpriteIconForRecord($table, $this->rec
, array('title' => htmlspecialchars(BackendUtility
::getRecordIconAltText($this->rec
, $table)))) . BackendUtility
::getRecordTitle($table, $this->rec
, TRUE));
334 * Processing the $menuItems array (for extension classes) (DATABASE RECORDS)
336 * @param array $menuItems Array for manipulation.
337 * @return array Processed $menuItems array
338 * @todo Define visibility
340 public function externalProcessingOfDBMenuItems($menuItems) {
345 * Processing the $menuItems array by external classes (typ. adding items)
347 * @param array $menuItems Array for manipulation.
348 * @param string $table Table name
349 * @param integer $uid UID for the current record.
350 * @return array Processed $menuItems array
351 * @todo Define visibility
353 public function processingByExtClassArray($menuItems, $table, $uid) {
354 if (is_array($this->extClassArray
)) {
355 foreach ($this->extClassArray
as $conf) {
356 $obj = GeneralUtility
::makeInstance($conf['name']);
357 $menuItems = $obj->main($this, $menuItems, $table, $uid);
364 * Returning JavaScript for the onClick event linking to the input URL.
366 * @param string $url The URL relative to TYPO3_mainDir
367 * @param string $retUrl The return_url-parameter
368 * @param boolean $hideCM If set, the "hideCM()" will be called
369 * @param string $overrideLoc If set, gives alternative location to load in (for example top frame or somewhere else)
370 * @return string JavaScript for an onClick event.
371 * @todo Define visibility
373 public function urlRefForCM($url, $retUrl = '', $hideCM = 1, $overrideLoc = '') {
374 $loc = 'top.content.list_frame';
375 $editOnClick = ($overrideLoc ?
'var docRef=' . $overrideLoc : 'var docRef=(top.content.list_frame)?top.content.list_frame:' . $loc) . '; docRef.location.href=top.TS.PATH_typo3+\'' . $url . '\'' . ($retUrl ?
'+\'&' . $retUrl . '=\'+top.rawurlencode(' . $this->frameLocation('docRef.document') . '.pathname+' . $this->frameLocation('docRef.document') . '.search)' : '') . ';' . ($hideCM ?
'return hideCM();' : '');
380 * Adding CM element for Clipboard "copy" and "cut"
382 * @param string $table Table name
383 * @param integer $uid UID for the current record.
384 * @param string $type Type: "copy" or "cut
385 * @return array Item array, element in $menuItems
387 * @todo Define visibility
389 public function DB_copycut($table, $uid, $type) {
390 if ($this->clipObj
->current
== 'normal') {
391 $isSel = $this->clipObj
->isSelected($table, $uid);
394 if ($this->listFrame
) {
395 $addParam['reloadListFrame'] = $this->alwaysContentFrame ?
2 : 1;
397 return $this->linkItem($this->label($type), $this->excludeIcon(IconUtility
::getSpriteIcon('actions-edit-' . $type . ($isSel === $type ?
'-release' : ''))), 'top.loadTopMenu(\'' . $this->clipObj
->selUrlDB($table, $uid, ($type == 'copy' ?
1 : 0), ($isSel == $type), $addParam) . '\');return false;');
401 * Adding CM element for Clipboard "paste into"/"paste after"
402 * NOTICE: $table and $uid should follow the special syntax for paste, see clipboard-class :: pasteUrl();
404 * @param string $table Table name
405 * @param integer $uid UID for the current record. NOTICE: Special syntax!
406 * @param string $type Type: "into" or "after
407 * @param array $elInfo Contains instructions about whether to copy or cut an element.
408 * @return array Item array, element in $menuItems
409 * @see \TYPO3\CMS\Backend\Clipboard\Clipboard::pasteUrl()
411 * @todo Define visibility
413 public function DB_paste($table, $uid, $type, $elInfo) {
415 $loc = 'top.content.list_frame';
416 if ($GLOBALS['BE_USER']->jsConfirmation(2)) {
417 $conf = $loc . ' && confirm(' . GeneralUtility
::quoteJSvalue(sprintf($GLOBALS['LANG']->sL(('LLL:EXT:lang/locallang_core.xlf:mess.' . ($elInfo[2] == 'copy' ?
'copy' : 'move') . '_' . $type)), $elInfo[0], $elInfo[1])) . ')';
421 $editOnClick = 'if(' . $conf . '){' . $loc . '.location.href=top.TS.PATH_typo3+\'' . $this->clipObj
->pasteUrl($table, $uid, 0) . '&redirect=\'+top.rawurlencode(' . $this->frameLocation(($loc . '.document')) . '.pathname+' . $this->frameLocation(($loc . '.document')) . '.search); hideCM();}';
422 return $this->linkItem($this->label('paste' . $type), $this->excludeIcon(IconUtility
::getSpriteIcon('actions-document-paste-' . $type)), $editOnClick . 'return false;');
426 * Adding CM element for Info
428 * @param string $table Table name
429 * @param integer $uid UID for the current record.
430 * @return array Item array, element in $menuItems
432 * @todo Define visibility
434 public function DB_info($table, $uid) {
435 return $this->linkItem($this->label('info'), $this->excludeIcon(IconUtility
::getSpriteIcon('actions-document-info')), 'top.launchView(\'' . $table . '\', \'' . $uid . '\'); return hideCM();');
439 * Adding CM element for History
441 * @param string $table Table name
442 * @param integer $uid UID for the current record.
443 * @return array Item array, element in $menuItems
445 * @todo Define visibility
447 public function DB_history($table, $uid) {
448 $url = BackendUtility
::getModuleUrl('record_history', array('element' => $table . ':' . $uid));
449 return $this->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_history')), $this->excludeIcon(IconUtility
::getSpriteIcon('actions-document-history-open')), $this->urlRefForCM($url, 'returnUrl'), 0);
453 * Adding CM element for Permission setting
455 * @param string $table Table name
456 * @param integer $uid UID for the current record.
457 * @param array $rec The "pages" record with "perms_*" fields inside.
458 * @return array Item array, element in $menuItems
460 * @todo Define visibility
462 public function DB_perms($table, $uid, $rec) {
463 if (!ExtensionManagementUtility
::isLoaded('perm')) {
466 $url = ExtensionManagementUtility
::extRelPath('perm') . 'mod1/index.php?id=' . $uid . ($rec['perms_userid'] == $GLOBALS['BE_USER']->user
['uid'] ||
$GLOBALS['BE_USER']->isAdmin() ?
'&return_id=' . $uid . '&edit=1' : '');
467 return $this->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_perms')), $this->excludeIcon(IconUtility
::getSpriteIcon('status-status-locked')), $this->urlRefForCM($url), 0);
471 * Adding CM element for DBlist
473 * @param string $table Table name
474 * @param integer $uid UID for the current record.
475 * @param array $rec Record of the element (needs "pid" field if not pages-record)
476 * @return array Item array, element in $menuItems
478 * @todo Define visibility
480 public function DB_db_list($table, $uid, $rec) {
481 $urlParams = array();
482 $urlParams['id'] = $table == 'pages' ?
$uid : $rec['pid'];
483 $urlParams['table'] = $table == 'pages' ?
'' : $table;
484 $url = BackendUtility
::getModuleUrl('web_list', $urlParams, '', TRUE);
485 return $this->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_db_list')), $this->excludeIcon(IconUtility
::getSpriteIcon('actions-system-list-open')), 'top.nextLoadModuleUrl=\'' . $url . '\';top.goToModule(\'web_list\', 1);', 0);
489 * Adding CM element for Moving wizard
491 * @param string $table Table name
492 * @param integer $uid UID for the current record.
493 * @param array $rec Record. Needed for tt-content elements which will have the sys_language_uid sent
494 * @return array Item array, element in $menuItems
496 * @todo Define visibility
498 public function DB_moveWizard($table, $uid, $rec) {
499 // Hardcoded field for tt_content elements.
500 $url = 'move_el.php?table=' . $table . '&uid=' . $uid . ($table == 'tt_content' ?
'&sys_language_uid=' . (int)$rec['sys_language_uid'] : '');
501 return $this->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_moveWizard' . ($table == 'pages' ?
'_page' : ''))), $this->excludeIcon(IconUtility
::getSpriteIcon('actions-' . ($table === 'pages' ?
'page' : 'document') . '-move')), $this->urlRefForCM($url, 'returnUrl'), 0);
505 * Adding CM element for Create new wizard (either db_new.php or sysext/cms/layout/db_new_content_el.php or custom wizard)
507 * @param string $table Table name
508 * @param integer $uid UID for the current record.
509 * @param array $rec Record.
510 * @return array Item array, element in $menuItems
512 * @todo Define visibility
514 public function DB_newWizard($table, $uid, $rec) {
515 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
516 $tmpTSc = BackendUtility
::getModTSconfig($this->pageinfo
['uid'], 'mod.web_list');
517 $tmpTSc = $tmpTSc['properties']['newContentWiz.']['overrideWithExtension'];
518 $newContentWizScriptPath = ExtensionManagementUtility
::isLoaded($tmpTSc) ? ExtensionManagementUtility
::extRelPath($tmpTSc) . 'mod1/db_new_content_el.php' : 'sysext/cms/layout/db_new_content_el.php';
519 $url = $table == 'pages' ?
'db_new.php?id=' . $uid . '&pagesOnly=1' : $newContentWizScriptPath . '?id=' . $rec['pid'] . '&sys_language_uid=' . (int)$rec['sys_language_uid'];
520 return $this->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_newWizard')), $this->excludeIcon(IconUtility
::getSpriteIcon('actions-' . ($table === 'pages' ?
'page' : 'document') . '-new')), $this->urlRefForCM($url, 'returnUrl'), 0);
524 * Adding CM element for Editing of the access related fields of a table (disable, starttime, endtime, fe_groups)
526 * @param string $table Table name
527 * @param integer $uid UID for the current record.
528 * @return array Item array, element in $menuItems
530 * @todo Define visibility
532 public function DB_editAccess($table, $uid) {
533 $addParam = '&columnsOnly=' . rawurlencode((implode(',', $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']) . ($table == 'pages' ?
',extendToSubpages' : '')));
534 $url = 'alt_doc.php?edit[' . $table . '][' . $uid . ']=edit' . $addParam;
535 return $this->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editAccess')), $this->excludeIcon(IconUtility
::getSpriteIcon('actions-document-edit-access')), $this->urlRefForCM($url, 'returnUrl'), 1);
539 * Adding CM element for edit page properties
541 * @param integer $uid page uid to edit (PID)
542 * @return array Item array, element in $menuItems
544 * @todo Define visibility
546 public function DB_editPageProperties($uid) {
547 $url = 'alt_doc.php?edit[pages][' . $uid . ']=edit';
548 return $this->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editPageProperties')), $this->excludeIcon(IconUtility
::getSpriteIcon('actions-page-open')), $this->urlRefForCM($url, 'returnUrl'), 1);
552 * Adding CM element for regular editing of the element!
554 * @param string $table Table name
555 * @param integer $uid UID for the current record.
556 * @return array Item array, element in $menuItems
558 * @todo Define visibility
560 public function DB_edit($table, $uid) {
561 // If another module was specified, replace the default Page module with the new one
562 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
563 $pageModule = BackendUtility
::isModuleSetInTBE_MODULES($newPageModule) ?
$newPageModule : 'web_layout';
565 $loc = 'top.content.list_frame';
567 $theIcon = 'actions-document-open';
568 if ($this->iParts
[0] == 'pages' && $this->iParts
[1] && $GLOBALS['BE_USER']->check('modules', $pageModule)) {
569 $theIcon = 'actions-page-open';
570 $this->editPageIconSet
= 1;
571 if ($GLOBALS['BE_USER']->uc
['classicPageEditMode']) {
572 $addParam = '&editRegularContentFromId=' . (int)$this->iParts
[1];
574 $editOnClick = 'if(' . $loc . '){' . $loc . '.location.href=top.TS.PATH_typo3+\'alt_doc.php?returnUrl=\'+top.rawurlencode(' . $this->frameLocation(($loc . '.document')) . '.pathname+' . $this->frameLocation(($loc . '.document')) . '.search)+\'&edit[' . $table . '][' . $uid . ']=edit' . $addParam . '\';}';
578 $editOnClick = 'if(' . $loc . '){' . $loc . '.location.href=top.TS.PATH_typo3+\'alt_doc.php?returnUrl=\'+top.rawurlencode(' . $this->frameLocation(($loc . '.document')) . '.pathname+' . $this->frameLocation(($loc . '.document')) . '.search)+\'&edit[' . $table . '][' . $uid . ']=edit' . $addParam . '\';}';
580 return $this->linkItem($this->label('edit'), $this->excludeIcon(IconUtility
::getSpriteIcon($theIcon)), $editOnClick . 'return hideCM();');
584 * Adding CM element for regular Create new element
586 * @param string $table Table name
587 * @param integer $uid UID for the current record.
588 * @return array Item array, element in $menuItems
590 * @todo Define visibility
592 public function DB_new($table, $uid) {
594 $loc = 'top.content.list_frame';
595 $editOnClick = 'if(' . $loc . '){' . $loc . '.location.href=top.TS.PATH_typo3+\'' . ($this->listFrame ?
'alt_doc.php?returnUrl=\'+top.rawurlencode(' . $this->frameLocation(($loc . '.document')) . '.pathname+' . $this->frameLocation(($loc . '.document')) . '.search)+\'&edit[' . $table . '][-' . $uid . ']=new\'' : 'db_new.php?id=' . (int)$uid . '\'') . ';}';
596 return $this->linkItem($this->label('new'), $this->excludeIcon(IconUtility
::getSpriteIcon('actions-' . ($table === 'pages' ?
'page' : 'document') . '-new')), $editOnClick . 'return hideCM();');
600 * Adding CM element for Delete
602 * @param string $table Table name
603 * @param integer $uid UID for the current record.
604 * @param array $elInfo Label for including in the confirmation message, EXT:lang/locallang_core.xlf:mess.delete
605 * @return array Item array, element in $menuItems
607 * @todo Define visibility
609 public function DB_delete($table, $uid, $elInfo) {
611 $loc = 'top.content.list_frame';
612 if ($GLOBALS['BE_USER']->jsConfirmation(4)) {
613 $conf = 'confirm(' . GeneralUtility
::quoteJSvalue((sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:mess.delete'), $elInfo[0]) . BackendUtility
::referenceCount($table, $uid, ' (There are %s reference(s) to this record!)') . BackendUtility
::translationCount($table, $uid, (' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.translationsOfRecord'))))) . ')';
617 $editOnClick = 'if(' . $loc . ' && ' . $conf . ' ){' . $loc . '.location.href=top.TS.PATH_typo3+\'tce_db.php?redirect=\'+top.rawurlencode(' . $this->frameLocation(($loc . '.document')) . '.pathname+' . $this->frameLocation(($loc . '.document')) . '.search)+\'' . '&cmd[' . $table . '][' . $uid . '][delete]=1&prErr=1&vC=' . $GLOBALS['BE_USER']->veriCode() . BackendUtility
::getUrlToken('tceAction') . '\';}hideCM();top.nav.refresh.defer(500, top.nav);';
618 return $this->linkItem($this->label('delete'), $this->excludeIcon(IconUtility
::getSpriteIcon('actions-edit-delete')), $editOnClick . 'return false;');
622 * Adding CM element for View Page
624 * @param integer $id Page uid (PID)
625 * @param string $anchor Anchor, if any
626 * @return array Item array, element in $menuItems
628 * @todo Define visibility
630 public function DB_view($id, $anchor = '') {
631 return $this->linkItem($this->label('view'), $this->excludeIcon(IconUtility
::getSpriteIcon('actions-document-view')), BackendUtility
::viewOnClick($id, $this->PH_backPath
, BackendUtility
::BEgetRootLine($id), $anchor) . 'return hideCM();');
635 * Adding element for setting temporary mount point.
637 * @param integer $page_id Page uid (PID)
638 * @return array Item array, element in $menuItems
640 * @todo Define visibility
642 public function DB_tempMountPoint($page_id) {
643 return $this->linkItem($this->label('tempMountPoint'), $this->excludeIcon(IconUtility
::getSpriteIcon('apps-pagetree-page-mountpoint')), 'if (top.content.nav_frame) {
644 var node = top.TYPO3.Backend.NavigationContainer.PageTree.getSelected();
652 id: ' . (int)$page_id . '
657 node.ownerTree.commandProvider.mountAsTreeRoot(useNode, node.ownerTree);
664 * Adding CM element for hide/unhide of the input record
666 * @param string $table Table name
667 * @param array $rec Record array
668 * @param string $hideField Name of the hide field
669 * @return array Item array, element in $menuItems
671 * @todo Define visibility
673 public function DB_hideUnhide($table, $rec, $hideField) {
674 return $this->DB_changeFlag($table, $rec, $hideField, $this->label(($rec[$hideField] ?
'un' : '') . 'hide'), 'hide');
678 * Adding CM element for a flag field of the input record
680 * @param string $table Table name
681 * @param array $rec Record array
682 * @param string $flagField Name of the flag field
683 * @param string $title Menu item Title
684 * @param string $name Name of the item used for icons and labels
685 * @param string $iconRelPath Icon path relative to typo3/ folder
686 * @return array Item array, element in $menuItems
687 * @todo Define visibility
689 public function DB_changeFlag($table, $rec, $flagField, $title, $name, $iconRelPath = 'gfx/') {
690 $uid = $rec['_ORIG_uid'] ?
: $rec['uid'];
692 $loc = 'top.content.list_frame';
693 $editOnClick = 'if(' . $loc . '){' . $loc . '.location.href=top.TS.PATH_typo3+\'tce_db.php?redirect=\'' . '+top.rawurlencode(' . $this->frameLocation(($loc . '.document')) . '.pathname+' . $this->frameLocation(($loc . '.document')) . '.search)+\'' . '&data[' . $table . '][' . $uid . '][' . $flagField . ']=' . ($rec[$flagField] ?
0 : 1) . '&prErr=1&vC=' . $GLOBALS['BE_USER']->veriCode() . BackendUtility
::getUrlToken('tceAction') . '\';}hideCM();top.nav.refresh.defer(500, top.nav);';
694 return $this->linkItem($title, $this->excludeIcon(IconUtility
::getSpriteIcon('actions-edit-' . ($rec[$flagField] ?
'un' : '') . 'hide')), $editOnClick . 'return false;', 1);
697 /***************************************
701 ***************************************/
703 * Make 1st level clickmenu:
705 * @param string $combinedIdentifier The combined identifier
706 * @return string HTML content
707 * @see \TYPO3\CMS\Core\Resource\ResourceFactory::retrieveFileOrFolderObject()
708 * @todo Define visibility
710 public function printFileClickMenu($combinedIdentifier) {
711 $menuItems = array();
712 $combinedIdentifier = rawurldecode($combinedIdentifier);
713 $fileObject = ResourceFactory
::getInstance()
714 ->retrieveFileOrFolderObject($combinedIdentifier);
717 $isStorageRoot = FALSE;
719 $userMayViewStorage = FALSE;
720 $userMayEditStorage = FALSE;
721 $identifier = $fileObject->getCombinedIdentifier();
722 if ($fileObject instanceof \TYPO3\CMS\Core\
Resource\Folder
) {
723 $icon = IconUtility
::getSpriteIconForResource($fileObject, array(
724 'class' => 'absmiddle',
725 'title' => htmlspecialchars($fileObject->getName())
728 if ($fileObject->getIdentifier() === $fileObject->getStorage()->getRootLevelFolder()->getIdentifier()) {
729 $isStorageRoot = TRUE;
730 if ($GLOBALS['BE_USER']->check('tables_select', 'sys_file_storage')) {
731 $userMayViewStorage = TRUE;
733 if ($GLOBALS['BE_USER']->check('tables_modify', 'sys_file_storage')) {
734 $userMayEditStorage = TRUE;
737 if (!$fileObject->getStorage()->isOnline()) {
741 $icon = IconUtility
::getSpriteIconForResource($fileObject, array(
742 'class' => 'absmiddle',
743 'title' => htmlspecialchars($fileObject->getName() . ' (' . GeneralUtility
::formatSize($fileObject->getSize()) . ')')
747 if (!in_array('hide', $this->disabledItems
) && $isStorageRoot && $userMayEditStorage) {
748 $record = BackendUtility
::getRecord('sys_file_storage', $fileObject->getStorage()->getUid());
749 $menuItems['hide'] = $this->DB_changeFlag(
753 $this->label($record['is_online'] ?
'offline' : 'online'),
758 if (!in_array('edit', $this->disabledItems
)) {
759 if (!$folder && !$isStorageRoot) {
760 $metaData = $fileObject->_getMetaData();
761 $menuItems['edit2'] = $this->DB_edit('sys_file_metadata', $metaData['uid']);
763 if (!$folder && GeneralUtility
::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $fileObject->getExtension())) {
764 $menuItems['edit'] = $this->FILE_launch($identifier, 'file_edit.php', 'editcontent', 'edit_file.gif');
765 } elseif ($isStorageRoot && $userMayEditStorage) {
766 $menuItems['edit'] = $this->DB_edit('sys_file_storage', $fileObject->getStorage()->getUid());
770 if (!in_array('rename', $this->disabledItems
) && !$isStorageRoot) {
771 $menuItems['rename'] = $this->FILE_launch($identifier, 'file_rename.php', 'rename', 'rename.gif');
774 if (!in_array('upload', $this->disabledItems
) && $folder && $isOnline) {
775 $menuItems['upload'] = $this->FILE_upload($identifier);
778 if (!in_array('new', $this->disabledItems
) && $folder && $isOnline) {
779 $menuItems['new'] = $this->FILE_launch($identifier, 'file_newfolder.php', 'new', 'new_file.gif');
782 if (!in_array('info', $this->disabledItems
)) {
783 if ($isStorageRoot && $userMayViewStorage) {
784 $menuItems['info'] = $this->DB_info('sys_file_storage', $fileObject->getStorage()->getUid());
785 } elseif (!$folder) {
786 $menuItems['info'] = $this->fileInfo($identifier);
789 $menuItems[] = 'spacer';
791 if (!in_array('copy', $this->disabledItems
) && !$isStorageRoot) {
792 $menuItems['copy'] = $this->FILE_copycut($identifier, 'copy');
795 if (!in_array('cut', $this->disabledItems
) && !$isStorageRoot) {
796 $menuItems['cut'] = $this->FILE_copycut($identifier, 'cut');
799 $elFromAllTables = count($this->clipObj
->elFromTable('_FILE'));
800 if (!in_array('paste', $this->disabledItems
) && $elFromAllTables && $folder) {
801 $elArr = $this->clipObj
->elFromTable('_FILE');
802 $selItem = reset($elArr);
805 basename($identifier),
806 $this->clipObj
->currentMode()
808 $menuItems['pasteinto'] = $this->FILE_paste($identifier, $selItem, $elInfo);
810 $menuItems[] = 'spacer';
812 if (!in_array('delete', $this->disabledItems
)) {
813 if ($isStorageRoot && $userMayEditStorage) {
814 $elInfo = array(GeneralUtility
::fixed_lgd_cs($fileObject->getStorage()->getName(), $GLOBALS['BE_USER']->uc
['titleLen']));
815 $menuItems['delete'] = $this->DB_delete('sys_file_storage', $fileObject->getStorage()->getUid(), $elInfo);
816 } elseif (!$isStorageRoot) {
817 $menuItems['delete'] = $this->FILE_delete($identifier);
821 // Adding external elements to the menuItems array
822 $menuItems = $this->processingByExtClassArray($menuItems, $identifier, 0);
823 // Processing by external functions?
824 $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
825 // Return the printed elements:
826 return $this->printItems($menuItems, $icon . $fileObject->getName());
830 * Processing the $menuItems array (for extension classes) (FILES)
832 * @param array $menuItems Array for manipulation.
833 * @return array Processed $menuItems array
834 * @todo Define visibility
836 public function externalProcessingOfFileMenuItems($menuItems) {
841 * Multi-function for adding an entry to the $menuItems array
843 * @param string $path Path to the file/directory (target)
844 * @param string $script Script (eg. file_edit.php) to pass &target= to
845 * @param string $type "type" is the code which fetches the correct label for the element from "cm.
846 * @param string $image icon image-filename from "gfx/" (12x12 icon)
847 * @param boolean $noReturnUrl If set, the return URL parameter will not be set in the link
848 * @return array Item array, element in $menuItems
850 * @todo Define visibility
852 public function FILE_launch($path, $script, $type, $image, $noReturnUrl = FALSE) {
853 $loc = 'top.content.list_frame';
854 $editOnClick = 'if(' . $loc . '){' . $loc . '.location.href=top.TS.PATH_typo3+\'' . $script . '?target=' . rawurlencode($path) . ($noReturnUrl ?
'\'' : '&returnUrl=\'+top.rawurlencode(' . $this->frameLocation(($loc . '.document')) . '.pathname+' . $this->frameLocation(($loc . '.document')) . '.search)') . ';}';
855 return $this->linkItem($this->label($type), $this->excludeIcon('<img' . IconUtility
::skinImg($this->PH_backPath
, ('gfx/' . $image), 'width="12" height="12"') . ' alt="" />'), $editOnClick . 'top.nav.refresh();return hideCM();');
859 * function for adding an upload entry to the $menuItems array
861 * @param string $path Path to the file/directory (target)
862 * @return array Item array, element in $menuItems
864 * @todo Define visibility
866 public function FILE_upload($path) {
867 $script = 'file_upload.php';
869 $image = 'upload.gif';
870 return $this->FILE_launch($path, $script, $type, $image, TRUE);
874 * Returns element for copy or cut of files.
876 * @param string $path Path to the file/directory (target)
877 * @param string $type Type: "copy" or "cut
878 * @return array Item array, element in $menuItems
880 * @todo Define visibility
882 public function FILE_copycut($path, $type) {
883 // Pseudo table name for use in the clipboard.
885 $uid = GeneralUtility
::shortmd5($path);
886 if ($this->clipObj
->current
== 'normal') {
887 $isSel = $this->clipObj
->isSelected($table, $uid);
890 if ($this->listFrame
) {
891 $addParam['reloadListFrame'] = $this->alwaysContentFrame ?
2 : 1;
893 return $this->linkItem($this->label($type), $this->excludeIcon(IconUtility
::getSpriteIcon('actions-edit-' . $type . ($isSel === $type ?
'-release' : ''))), 'top.loadTopMenu(\'' . $this->clipObj
->selUrlFile($path, ($type == 'copy' ?
1 : 0), ($isSel == $type), $addParam) . '\');return false;');
897 * Creates element for deleting of target
899 * @param string $path Path to the file/directory (target)
900 * @return array Item array, element in $menuItems
902 * @todo Define visibility
904 public function FILE_delete($path) {
906 $loc = 'top.content.list_frame';
907 if ($GLOBALS['BE_USER']->jsConfirmation(4)) {
908 $conf = 'confirm(' . GeneralUtility
::quoteJSvalue((sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:mess.delete'), basename($path)) . BackendUtility
::referenceCount('_FILE', $path, ' (There are %s reference(s) to this file!)'))) . ')';
912 $editOnClick = 'if(' . $loc . ' && ' . $conf . ' ){' . $loc . '.location.href=top.TS.PATH_typo3+\'tce_file.php?redirect=\'+top.rawurlencode(' . $this->frameLocation(($loc . '.document')) . '.pathname+' . $this->frameLocation(($loc . '.document')) . '.search)+\'' . '&file[delete][0][data]=' . rawurlencode($path) . '&vC=' . $GLOBALS['BE_USER']->veriCode() . BackendUtility
::getUrlToken('tceAction') . '\';}hideCM();';
913 return $this->linkItem($this->label('delete'), $this->excludeIcon(IconUtility
::getSpriteIcon('actions-edit-delete')), $editOnClick . 'return false;');
917 * Creates element for pasting files.
919 * @param string $path Path to the file/directory (target)
920 * @param string $target target - NOT USED.
921 * @param array $elInfo Various values for the labels.
922 * @return array Item array, element in $menuItems
924 * @todo Define visibility
926 public function FILE_paste($path, $target, $elInfo) {
928 $loc = 'top.content.list_frame';
929 if ($GLOBALS['BE_USER']->jsConfirmation(2)) {
930 $conf = $loc . ' && confirm(' . GeneralUtility
::quoteJSvalue(sprintf($GLOBALS['LANG']->sL(('LLL:EXT:lang/locallang_core.xlf:mess.' . ($elInfo[2] == 'copy' ?
'copy' : 'move') . '_into')), $elInfo[0], $elInfo[1])) . ')';
934 $editOnClick = 'if(' . $conf . '){' . $loc . '.location.href=top.TS.PATH_typo3+\'' . $this->clipObj
->pasteUrl('_FILE', $path, 0) . '&redirect=\'+top.rawurlencode(' . $this->frameLocation(($loc . '.document')) . '.pathname+' . $this->frameLocation(($loc . '.document')) . '.search); }hideCM();top.nav.refresh();';
935 return $this->linkItem($this->label('pasteinto'), $this->excludeIcon(IconUtility
::getSpriteIcon('actions-document-paste-into')), $editOnClick . 'return false;');
939 * Adding ClickMenu element for file info
941 * @param string $identifier The combined identifier of the file.
942 * @return array Item array, element in $menuItems
944 protected function fileInfo($identifier) {
945 return $this->DB_info('_FILE', $identifier);
948 /***************************************
952 ***************************************/
954 * Make 1st level clickmenu:
956 * @param string $table The absolute path
957 * @param integer $srcId UID for the current record.
958 * @param integer $dstId Destination ID
959 * @return string HTML content
960 * @todo Define visibility
962 public function printDragDropClickMenu($table, $srcId, $dstId) {
963 $menuItems = array();
964 // If the drag and drop menu should apply to PAGES use this set of menu items
965 if ($table == 'pages') {
967 $menuItems['movePage_into'] = $this->dragDrop_copymovepage($srcId, $dstId, 'move', 'into');
969 $menuItems['movePage_after'] = $this->dragDrop_copymovepage($srcId, $dstId, 'move', 'after');
971 $menuItems['copyPage_into'] = $this->dragDrop_copymovepage($srcId, $dstId, 'copy', 'into');
973 $menuItems['copyPage_after'] = $this->dragDrop_copymovepage($srcId, $dstId, 'copy', 'after');
975 // If the drag and drop menu should apply to FOLDERS use this set of menu items
976 if ($table == 'folders') {
978 $menuItems['moveFolder_into'] = $this->dragDrop_copymovefolder($srcId, $dstId, 'move');
980 $menuItems['copyFolder_into'] = $this->dragDrop_copymovefolder($srcId, $dstId, 'copy');
982 // Adding external elements to the menuItems array
983 $menuItems = $this->processingByExtClassArray($menuItems, 'dragDrop_' . $table, $srcId);
984 // to extend this, you need to apply a Context Menu to a "virtual" table called "dragDrop_pages" or similar
985 // Processing by external functions?
986 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
987 // Return the printed elements:
988 return $this->printItems($menuItems, IconUtility
::getSpriteIconForRecord($table, $this->rec
, array('title' => BackendUtility
::getRecordTitle($table, $this->rec
, TRUE))));
992 * Processing the $menuItems array (for extension classes) (DRAG'N DROP)
994 * @param array $menuItems Array for manipulation.
995 * @return array Processed $menuItems array
996 * @todo Define visibility
998 public function externalProcessingOfDragDropMenuItems($menuItems) {
1003 * Adding CM element for Copying/Moving a Page Into/After from a drag & drop action
1005 * @param integer $srcUid source UID code for the record to modify
1006 * @param integer $dstUid destination UID code for the record to modify
1007 * @param string $action Action code: either "move" or "copy
1008 * @param string $into Parameter code: either "into" or "after
1009 * @return array Item array, element in $menuItems
1011 * @todo Define visibility
1013 public function dragDrop_copymovepage($srcUid, $dstUid, $action, $into) {
1014 $negativeSign = $into == 'into' ?
'' : '-';
1016 $loc = 'top.content.list_frame';
1017 $editOnClick = 'if(' . $loc . '){' . $loc . '.document.location=top.TS.PATH_typo3+"tce_db.php?redirect="+top.rawurlencode(' . $this->frameLocation(($loc . '.document')) . '.pathname+' . $this->frameLocation(($loc . '.document')) . '.search)+"' . '&cmd[pages][' . $srcUid . '][' . $action . ']=' . $negativeSign . $dstUid . '&prErr=1&vC=' . $GLOBALS['BE_USER']->veriCode() . BackendUtility
::getUrlToken('tceAction') . '";}hideCM();top.nav.refresh();';
1018 return $this->linkItem($this->label($action . 'Page_' . $into), $this->excludeIcon(IconUtility
::getSpriteIcon('actions-document-paste-' . $into)), $editOnClick . 'return false;', 0);
1022 * Adding CM element for Copying/Moving a Folder Into from a drag & drop action
1024 * @param string $srcPath source path for the record to modify
1025 * @param string $dstPath destination path for the records to modify
1026 * @param string $action Action code: either "move" or "copy
1027 * @return array Item array, element in $menuItems
1029 * @todo Define visibility
1031 public function dragDrop_copymovefolder($srcPath, $dstPath, $action) {
1033 $loc = 'top.content.list_frame';
1034 $editOnClick = 'if(' . $loc . '){' . $loc . '.document.location=top.TS.PATH_typo3+"tce_file.php?redirect="+top.rawurlencode(' . $this->frameLocation(($loc . '.document')) . '.pathname+' . $this->frameLocation(($loc . '.document')) . '.search)+"' . '&file[' . $action . '][0][data]=' . $srcPath . '&file[' . $action . '][0][target]=' . $dstPath . '&prErr=1&vC=' . $GLOBALS['BE_USER']->veriCode() . BackendUtility
::getUrlToken('tceAction') . '";}hideCM();top.nav.refresh();';
1035 return $this->linkItem($this->label($action . 'Folder_into'), $this->excludeIcon(IconUtility
::getSpriteIcon('apps-pagetree-drag-move-into')), $editOnClick . 'return false;', 0);
1038 /***************************************
1042 **************************************/
1044 * Prints the items from input $menuItems array - as JS section for writing to the div-layers.
1046 * @param array $menuItems Array
1047 * @param string $item HTML code for the element which was clicked - shown in the end of the horizontal menu in topframe after the close-button.
1048 * @return string HTML code
1049 * @todo Define visibility
1051 public function printItems($menuItems, $item) {
1053 // Enable/Disable items:
1054 $menuItems = $this->enableDisableItems($menuItems);
1055 // Clean up spacers:
1056 $menuItems = $this->cleanUpSpacers($menuItems);
1058 $out .= $this->printLayerJScode($menuItems);
1059 // Return the content
1064 * Create the JavaScript section
1066 * @param array $menuItems The $menuItems array to print
1067 * @return string The JavaScript section which will print the content of the CM to the div-layer in the target frame.
1068 * @todo Define visibility
1070 public function printLayerJScode($menuItems) {
1072 // Clipboard must not be submitted - then it's probably a copy/cut situation.
1073 if ($this->isCMlayers()) {
1074 $frameName = '.' . ($this->listFrame ?
'list_frame' : 'nav_frame');
1075 if ($this->alwaysContentFrame
) {
1078 // Create the table displayed in the clickmenu layer:
1080 <table border="0" cellpadding="0" cellspacing="0" class="typo3-CSM">
1081 ' . implode('', $this->menuItemsForClickMenu($menuItems)) . '
1083 // Wrap the inner table in another table to create outer border:
1084 $CMtable = $this->wrapColorTableCM($CMtable);
1085 // Set back path place holder to real back path
1086 $CMtable = str_replace($this->PH_backPath
, $this->backPath
, $CMtable);
1088 $innerXML = '<data><clickmenu><htmltable><![CDATA[' . $CMtable . ']]></htmltable><cmlevel>' . $this->cmLevel
. '</cmlevel></clickmenu></data>';
1091 // Create JavaScript section:
1092 $script = $GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
1094 if (top.content && top.content' . $frameName . ' && top.content' . $frameName . '.Clickmenu) {
1095 top.content' . $frameName . '.Clickmenu.populateData(unescape("' . GeneralUtility
::rawurlencodeJS($CMtable) . '"),' . $this->cmLevel
. ');
1105 * Wrapping the input string in a table with background color 4 and a black border style.
1106 * For the pop-up menu
1108 * @param string $str HTML content to wrap in table.
1110 * @todo Define visibility
1112 public function wrapColorTableCM($str) {
1113 return '<div class="typo3-CSM-wrapperCM">
1119 * Traverses the menuItems and generates an output array for implosion in the topframe horizontal menu
1121 * @param array $menuItems Array
1122 * @return array Array of menu items for top frame.
1123 * @todo Define visibility
1125 public function menuItemsForTopFrame($menuItems) {
1127 foreach ($menuItems as $i) {
1128 // IF the topbar is the ONLY means of the click menu, then items normally disabled from
1129 // the top menu will appear anyways IF they are disabled with a "1" (2+ will still disallow
1130 // them in the topbar)
1131 if ($i[4] == 1 && !$GLOBALS['SOBE']->doc
->isCMlayers()) {
1134 if (is_array($i) && !$i[4]) {
1142 * Traverses the menuItems and generates an output array for implosion in the CM div-layers table.
1144 * @param array $menuItems Array
1145 * @return array array for implosion in the CM div-layers table.
1146 * @todo Define visibility
1148 public function menuItemsForClickMenu($menuItems) {
1150 foreach ($menuItems as $cc => $i) {
1151 // MAKE horizontal spacer
1152 if (is_string($i) && $i == 'spacer') {
1154 <tr class="bgColor2">
1155 <td colspan="2"><img src="clear.gif" width="1" height="1" alt="" /></td>
1158 // Just make normal element:
1160 $onClick = preg_replace('/return[[:space:]]+hideCM\\(\\)[[:space:]]*;/i', '', $onClick);
1161 $onClick = preg_replace('/return[[:space:]]+false[[:space:]]*;/i', '', $onClick);
1162 $onClick = preg_replace('/hideCM\\(\\);/i', '', $onClick);
1164 $onClick .= 'Clickmenu.hideAll();';
1166 $CSM = ' oncontextmenu="this.click();return false;"';
1168 <tr class="typo3-CSM-itemRow" onclick="' . htmlspecialchars($onClick) . '"' . $CSM . '>
1169 ' . (!$this->leftIcons ?
'<td class="typo3-CSM-item">' . $i[1] . '</td><td align="center">' . $i[2] . '</td>' : '<td align="center">' . $i[2] . '</td><td class="typo3-CSM-item">' . $i[1] . '</td>') . '
1177 * Adds or inserts a menu item
1178 * Can be used to set the position of new menu entries within the list of existing menu entries. Has this syntax: [cmd]:[menu entry key],[cmd].... cmd can be "after", "before" or "top" (or blank/"bottom" which is default). If "after"/"before" then menu items will be inserted after/before the existing entry with [menu entry key] if found. "after-spacer" and "before-spacer" do the same, but inserts before or after an item and a spacer. If not found, the bottom of list. If "top" the items are inserted in the top of the list.
1180 * @param array $menuItems Menu items array
1181 * @param array $newMenuItems Menu items array to insert
1182 * @param string $position Position command string. Has this syntax: [cmd]:[menu entry key],[cmd].... cmd can be "after", "before" or "top" (or blank/"bottom" which is default). If "after"/"before" then menu items will be inserted after/before the existing entry with [menu entry key] if found. "after-spacer" and "before-spacer" do the same, but inserts before or after an item and a spacer. If not found, the bottom of list. If "top" the items are inserted in the top of the list.
1183 * @return array Menu items array, processed.
1184 * @todo Define visibility
1186 public function addMenuItems($menuItems, $newMenuItems, $position = '') {
1187 if (is_array($newMenuItems)) {
1189 $posArr = GeneralUtility
::trimExplode(',', $position, TRUE);
1190 foreach ($posArr as $pos) {
1191 list($place, $menuEntry) = GeneralUtility
::trimExplode(':', $pos, TRUE);
1192 list($place, $placeExtra) = GeneralUtility
::trimExplode('-', $place, TRUE);
1194 $pointer = count($menuItems);
1197 switch (strtolower($place)) {
1205 if ((string)key($menuItems) === $menuEntry) {
1210 if (!next($menuItems)) {
1218 if ($place == 'before') {
1220 if ($placeExtra == 'spacer' and prev($menuItems) == 'spacer') {
1223 } elseif ($place == 'after') {
1224 if ($placeExtra == 'spacer' and next($menuItems) == 'spacer') {
1231 if (strtolower($place) == 'top') {
1234 $pointer = count($menuItems);
1244 $pointer = max(0, $pointer);
1245 $menuItemsBefore = array_slice($menuItems, 0, $pointer ?
: 0);
1246 $menuItemsAfter = array_slice($menuItems, $pointer);
1247 $menuItems = $menuItemsBefore +
$newMenuItems +
$menuItemsAfter;
1253 * Creating an array with various elements for the clickmenu entry
1255 * @param string $str The label, htmlspecialchar'ed already
1256 * @param string $icon <img>-tag for the icon
1257 * @param string $onClick JavaScript onclick event for label/icon
1258 * @param boolean $onlyCM ==1 and the element will NOT appear in clickmenus in the topframe (unless clickmenu is totally unavailable)! ==2 and the item will NEVER appear in top frame. (This is mostly for "less important" options since the top frame is not capable of holding so many elements horizontally)
1259 * @param boolean $dontHide If set, the clickmenu layer will not hide itself onclick - used for secondary menus to appear...
1260 * @return array $menuItem entry with 6 numerical entries: [0] is the HTML for display of the element with link and icon an mouseover etc., [1]-[5] is simply the input params passed through!
1261 * @todo Define visibility
1263 public function linkItem($str, $icon, $onClick, $onlyCM = 0, $dontHide = 0) {
1266 $onClick = str_replace('top.loadTopMenu', 'showClickmenu_raw', $onClick);
1269 IconUtility
::getSpriteIcon('empty-empty', array(
1270 'class' => 'c-roimg',
1271 'id' => ('roimg_' . $this->elCount
)
1272 )) . '<a href="#" onclick="' . htmlspecialchars($onClick) . '" onmouseover="mo(' . $this->elCount
. ');" onmouseout="mout(' . $this->elCount
. ');">' . $str . $icon . '</a>',
1282 * Returns the input string IF not a user setting has disabled display of icons.
1284 * @param string $iconCode The icon-image tag
1285 * @return string The icon-image tag prefixed with space char IF the icon should be printed at all due to user settings
1286 * @todo Define visibility
1288 public function excludeIcon($iconCode) {
1289 return $GLOBALS['BE_USER']->uc
['noMenuMode'] && $GLOBALS['BE_USER']->uc
['noMenuMode'] !== 'icons' ?
'' : ' ' . $iconCode;
1293 * Enabling / Disabling items based on list provided from GET var ($this->iParts[3])
1295 * @param array $menuItems Menu items array
1296 * @return array Menu items array, processed.
1297 * @todo Define visibility
1299 public function enableDisableItems($menuItems) {
1300 if ($this->iParts
[3]) {
1301 // Detect "only" mode: (only showing listed items)
1302 if ($this->iParts
[3][0] === '+') {
1303 $this->iParts
[3] = substr($this->iParts
[3], 1);
1309 // Transfer ONLY elements which are mentioned (or are spacers)
1311 $newMenuArray = array();
1312 foreach ($menuItems as $key => $value) {
1313 if (GeneralUtility
::inList($this->iParts
[3], $key) ||
is_string($value) && $value == 'spacer') {
1314 $newMenuArray[$key] = $value;
1317 $menuItems = $newMenuArray;
1319 // Traverse all elements except those listed (just unsetting them):
1320 $elements = GeneralUtility
::trimExplode(',', $this->iParts
[3], TRUE);
1321 foreach ($elements as $value) {
1322 unset($menuItems[$value]);
1326 // Return processed menu items:
1331 * Clean up spacers; Will remove any spacers in the start/end of menu items array plus any duplicates.
1333 * @param array $menuItems Menu items array
1334 * @return array Menu items array, processed.
1335 * @todo Define visibility
1337 public function cleanUpSpacers($menuItems) {
1339 $prevItemWasSpacer = FALSE;
1340 foreach ($menuItems as $key => $value) {
1341 if (is_string($value) && $value == 'spacer') {
1342 if ($prevItemWasSpacer) {
1343 unset($menuItems[$key]);
1345 $prevItemWasSpacer = TRUE;
1347 $prevItemWasSpacer = FALSE;
1352 $key = key($menuItems);
1353 $value = current($menuItems);
1354 if (is_string($value) && $value == 'spacer') {
1355 unset($menuItems[$key]);
1359 $key = key($menuItems);
1360 $value = current($menuItems);
1361 if (is_string($value) && $value == 'spacer') {
1362 unset($menuItems[$key]);
1364 // Return processed menu items:
1369 * Get label from locallang_core.xlf:cm.*
1371 * @param string $label The "cm."-suffix to get.
1373 * @todo Define visibility
1375 public function label($label) {
1376 return $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.' . $label, TRUE));
1380 * Returns TRUE if there should be writing to the div-layers (commands sent to clipboard MUST NOT write to div-layers)
1383 * @todo Define visibility
1385 public function isCMlayers() {
1390 * Appends ".location" to input string
1392 * @param string $str Input string, probably a JavaScript document reference
1394 * @todo Define visibility
1396 public function frameLocation($str) {
1397 return $str . '.location';