TYPO3 CMS  TYPO3_6-2
ClickMenu.php
Go to the documentation of this file.
1 <?php
3 
23 
30 class ClickMenu {
31 
32  // Internal, static: GPvar:
33  // Defines if the click menu is first level or second. Second means the click menu is triggered from another menu.
37  public $cmLevel = 0;
38 
39  // Clipboard array (submitted by eg. pressing the paste button)
43  public $CB;
44 
45  // Internal, static:
46  // Backpath for scripts/images.
50  public $backPath = '';
51 
52  // 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)
56  public $PH_backPath = '###BACK_PATH###';
57 
58  // If set, the calling document should be in the listframe of a frameset.
62  public $listFrame = 0;
63 
64  // If set, the menu is about database records, not files. (set if part 2 [1] of the item-var is NOT blank)
68  public $isDBmenu = 0;
69 
70  // If TRUE, the "content" frame is always used for reference (when condensed mode is enabled)
74  public $alwaysContentFrame = 0;
75 
76  // Stores the parts of the input $item string, splitted by "|":
77  // [0] = table/file, [1] = uid/blank, [2] = flag: If set, listFrame,
78  // If "2" then "content frame" is forced [3] = ("+" prefix = disable
79  // all by default, enable these. Default is to disable) Items key list
83  public $iParts = array();
84 
85  // Contains list of keywords of items to disable in the menu
89  public $disabledItems = array();
90 
91  // If TRUE, Show icons on the left.
95  public $leftIcons = 0;
96 
97  // 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.
101  public $extClassArray = array();
102 
103  // Enable/disable ajax behavior
107  public $ajax = 0;
108 
109  // Internal, dynamic:
110  // Counter for elements in the menu. Used to number the name / id of the mouse-over icon.
114  public $elCount = 0;
115 
116  // Set, when edit icon is drawn.
120  public $editPageIconSet = 0;
121 
122  // Set to TRUE, if editing of the element is OK.
126  public $editOK = 0;
127 
131  public $rec = array();
132 
139  public function init() {
140  // Setting GPvars:
141  $this->cmLevel = (int)GeneralUtility::_GP('cmLevel');
142  $this->CB = GeneralUtility::_GP('CB');
143  if (GeneralUtility::_GP('ajax')) {
144  $this->ajax = 1;
145  // XML has to be parsed, no parse errors allowed
146  @ini_set('display_errors', 0);
147  }
148  // Deal with Drag&Drop context menus
149  if ((string)GeneralUtility::_GP('dragDrop') !== '') {
150  return $this->printDragDropClickMenu(GeneralUtility::_GP('dragDrop'), GeneralUtility::_GP('srcId'), GeneralUtility::_GP('dstId'));
151  }
152  // Can be set differently as well
153  $this->iParts[0] = GeneralUtility::_GP('table');
154  $this->iParts[1] = GeneralUtility::_GP('uid');
155  $this->iParts[2] = GeneralUtility::_GP('listFr');
156  $this->iParts[3] = GeneralUtility::_GP('enDisItems');
157  // Setting flags:
158  if ($this->iParts[2]) {
159  $this->listFrame = 1;
160  }
161  if ($this->iParts[2] == 2) {
162  $this->alwaysContentFrame = 1;
163  }
164  if (isset($this->iParts[1]) && $this->iParts[1] !== '') {
165  $this->isDBmenu = 1;
166  }
167  $TSkey = ($this->isDBmenu ? 'page' : 'folder') . ($this->listFrame ? 'List' : 'Tree');
168  $this->disabledItems = GeneralUtility::trimExplode(',', $GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.' . $TSkey . '.disableItems'), TRUE);
169  $this->leftIcons = $GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.options.leftIcons');
170  // &cmLevel flag detected (2nd level menu)
171  if (!$this->cmLevel) {
172  // Make 1st level clickmenu:
173  if ($this->isDBmenu) {
174  $CMcontent = $this->printDBClickMenu($this->iParts[0], $this->iParts[1]);
175  } else {
176  $CMcontent = $this->printFileClickMenu($this->iParts[0]);
177  }
178  } else {
179  // Make 2nd level clickmenu (only for DBmenus)
180  if ($this->isDBmenu) {
181  $CMcontent = $this->printNewDBLevel($this->iParts[0], $this->iParts[1]);
182  }
183  }
184  // Return clickmenu content:
185  return $CMcontent;
186  }
187 
188  /***************************************
189  *
190  * DATABASE
191  *
192  ***************************************/
201  public function printDBClickMenu($table, $uid) {
202  $uid = (int)$uid;
203  // Get record:
204  $this->rec = BackendUtility::getRecordWSOL($table, $uid);
205  $menuItems = array();
206  $root = 0;
207  $DBmount = FALSE;
208  // Rootlevel
209  if ($table === 'pages' && $uid === 0) {
210  $root = 1;
211  }
212  // DB mount
213  if ($table === 'pages' && in_array($uid, $GLOBALS['BE_USER']->returnWebmounts())) {
214  $DBmount = TRUE;
215  }
216  // Used to hide cut,copy icons for l10n-records
217  $l10nOverlay = FALSE;
218  // Should only be performed for overlay-records within the same table
219  if (BackendUtility::isTableLocalizable($table) && !isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'])) {
220  $l10nOverlay = (int)$this->rec[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0;
221  }
222  // If record found (or root), go ahead and fill the $menuItems array which will contain data for the elements to render.
223  if (is_array($this->rec) || $root) {
224  // Get permissions
225  $lCP = $GLOBALS['BE_USER']->calcPerms(BackendUtility::getRecord('pages', $table == 'pages' ? $this->rec['uid'] : $this->rec['pid']));
226  // View
227  if (!in_array('view', $this->disabledItems)) {
228  if ($table === 'pages') {
229  $menuItems['view'] = $this->DB_view($uid);
230  }
231  if ($table === $GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']) {
232  $ws_rec = BackendUtility::getRecordWSOL($table, $this->rec['uid']);
233  $menuItems['view'] = $this->DB_view($ws_rec['pid']);
234  }
235  }
236  // Edit:
237  if (!$root && ($GLOBALS['BE_USER']->isPSet($lCP, $table, 'edit') || $GLOBALS['BE_USER']->isPSet($lCP, $table, 'editcontent'))) {
238  if (!in_array('edit', $this->disabledItems)) {
239  $menuItems['edit'] = $this->DB_edit($table, $uid);
240  }
241  $this->editOK = 1;
242  }
243  // New:
244  if (!in_array('new', $this->disabledItems) && $GLOBALS['BE_USER']->isPSet($lCP, $table, 'new')) {
245  $menuItems['new'] = $this->DB_new($table, $uid);
246  }
247  // Info:
248  if (!in_array('info', $this->disabledItems) && !$root) {
249  $menuItems['info'] = $this->DB_info($table, $uid);
250  }
251  $menuItems['spacer1'] = 'spacer';
252  // Copy:
253  if (!in_array('copy', $this->disabledItems) && !$root && !$DBmount && !$l10nOverlay) {
254  $menuItems['copy'] = $this->DB_copycut($table, $uid, 'copy');
255  }
256  // Cut:
257  if (!in_array('cut', $this->disabledItems) && !$root && !$DBmount && !$l10nOverlay) {
258  $menuItems['cut'] = $this->DB_copycut($table, $uid, 'cut');
259  }
260  // Paste:
261  $elFromAllTables = count($this->clipObj->elFromTable(''));
262  if (!in_array('paste', $this->disabledItems) && $elFromAllTables) {
263  $selItem = $this->clipObj->getSelectedRecord();
264  $elInfo = array(
265  GeneralUtility::fixed_lgd_cs($selItem['_RECORD_TITLE'], $GLOBALS['BE_USER']->uc['titleLen']),
266  $root ? $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] : GeneralUtility::fixed_lgd_cs(BackendUtility::getRecordTitle($table, $this->rec), $GLOBALS['BE_USER']->uc['titleLen']),
267  $this->clipObj->currentMode()
268  );
269  if ($table === 'pages' && $lCP & 8) {
270  if ($elFromAllTables) {
271  $menuItems['pasteinto'] = $this->DB_paste('', $uid, 'into', $elInfo);
272  }
273  }
274  $elFromTable = count($this->clipObj->elFromTable($table));
275  if (!$root && !$DBmount && $elFromTable && $GLOBALS['TCA'][$table]['ctrl']['sortby']) {
276  $menuItems['pasteafter'] = $this->DB_paste($table, -$uid, 'after', $elInfo);
277  }
278  }
279  // Delete:
280  $elInfo = array(GeneralUtility::fixed_lgd_cs(BackendUtility::getRecordTitle($table, $this->rec), $GLOBALS['BE_USER']->uc['titleLen']));
281  if (!in_array('delete', $this->disabledItems) && !$root && !$DBmount && $GLOBALS['BE_USER']->isPSet($lCP, $table, 'delete')) {
282  $menuItems['spacer2'] = 'spacer';
283  $menuItems['delete'] = $this->DB_delete($table, $uid, $elInfo);
284  }
285  if (!in_array('history', $this->disabledItems)) {
286  $menuItems['history'] = $this->DB_history($table, $uid, $elInfo);
287  }
288  }
289  // Adding external elements to the menuItems array
290  $menuItems = $this->processingByExtClassArray($menuItems, $table, $uid);
291  // Processing by external functions?
292  $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
293  if (!is_array($this->rec)) {
294  $this->rec = array();
295  }
296  // Return the printed elements:
297  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));
298  }
299 
308  public function printNewDBLevel($table, $uid) {
309  $uid = (int)$uid;
310  // Setting internal record to the table/uid :
311  $this->rec = BackendUtility::getRecordWSOL($table, $uid);
312  $menuItems = array();
313  $root = 0;
314  // Rootlevel
315  if ($table === 'pages' && $uid === 0) {
316  $root = 1;
317  }
318  // If record was found, check permissions and get menu items.
319  if (is_array($this->rec) || $root) {
320  $lCP = $GLOBALS['BE_USER']->calcPerms(BackendUtility::getRecord('pages', $table == 'pages' ? $this->rec['uid'] : $this->rec['pid']));
321  // Edit:
322  if (!$root && ($GLOBALS['BE_USER']->isPSet($lCP, $table, 'edit') || $GLOBALS['BE_USER']->isPSet($lCP, $table, 'editcontent'))) {
323  $this->editOK = 1;
324  }
325  $menuItems = $this->processingByExtClassArray($menuItems, $table, $uid);
326  }
327  // Return the printed elements:
328  if (!is_array($menuItems)) {
329  $menuItems = array();
330  }
331  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));
332  }
333 
341  public function externalProcessingOfDBMenuItems($menuItems) {
342  return $menuItems;
343  }
344 
354  public function processingByExtClassArray($menuItems, $table, $uid) {
355  if (is_array($this->extClassArray)) {
356  foreach ($this->extClassArray as $conf) {
357  $obj = GeneralUtility::makeInstance($conf['name']);
358  $menuItems = $obj->main($this, $menuItems, $table, $uid);
359  }
360  }
361  return $menuItems;
362  }
363 
374  public function urlRefForCM($url, $retUrl = '', $hideCM = 1, $overrideLoc = '') {
375  $loc = 'top.content.list_frame';
376  $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();' : '');
377  return $editOnClick;
378  }
379 
390  public function DB_copycut($table, $uid, $type) {
391  if ($this->clipObj->current == 'normal') {
392  $isSel = $this->clipObj->isSelected($table, $uid);
393  }
394  $addParam = array();
395  if ($this->listFrame) {
396  $addParam['reloadListFrame'] = $this->alwaysContentFrame ? 2 : 1;
397  }
398  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;');
399  }
400 
414  public function DB_paste($table, $uid, $type, $elInfo) {
415  $editOnClick = '';
416  $loc = 'top.content.list_frame';
417  if ($GLOBALS['BE_USER']->jsConfirmation(2)) {
418  $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])) . ')';
419  } else {
420  $conf = $loc;
421  }
422  $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();}';
423  return $this->linkItem($this->label('paste' . $type), $this->excludeIcon(IconUtility::getSpriteIcon('actions-document-paste-' . $type)), $editOnClick . 'return false;');
424  }
425 
435  public function DB_info($table, $uid) {
436  return $this->linkItem($this->label('info'), $this->excludeIcon(IconUtility::getSpriteIcon('actions-document-info')), 'top.launchView(\'' . $table . '\', \'' . $uid . '\'); return hideCM();');
437  }
438 
448  public function DB_history($table, $uid) {
449  $url = BackendUtility::getModuleUrl('record_history', array('element' => $table . ':' . $uid));
450  return $this->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_history')), $this->excludeIcon(IconUtility::getSpriteIcon('actions-document-history-open')), $this->urlRefForCM($url, 'returnUrl'), 0);
451  }
452 
463  public function DB_perms($table, $uid, $rec) {
464  if (!ExtensionManagementUtility::isLoaded('perm')) {
465  return '';
466  }
467 
468  $parameters = array(
469  'id' => $uid,
470  );
471 
472  if ($rec['perms_userid'] == $GLOBALS['BE_USER']->user['uid'] || $GLOBALS['BE_USER']->isAdmin()) {
473  $parameters['return_id'] = $uid;
474  $parameters['edit'] = '1';
475  }
476 
477  $url = BackendUtility::getModuleUrl('web_perm', $parameters);
478  return $this->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_perms')), $this->excludeIcon(IconUtility::getSpriteIcon('status-status-locked')), $this->urlRefForCM($url), 0);
479  }
480 
491  public function DB_db_list($table, $uid, $rec) {
492  $urlParams = array();
493  $urlParams['id'] = $table == 'pages' ? $uid : $rec['pid'];
494  $urlParams['table'] = $table == 'pages' ? '' : $table;
495  $url = BackendUtility::getModuleUrl('web_list', $urlParams, '', TRUE);
496  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);
497  }
498 
509  public function DB_moveWizard($table, $uid, $rec) {
510  // Hardcoded field for tt_content elements.
511  $url = 'move_el.php?table=' . $table . '&uid=' . $uid . ($table == 'tt_content' ? '&sys_language_uid=' . (int)$rec['sys_language_uid'] : '');
512  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);
513  }
514 
525  public function DB_newWizard($table, $uid, $rec) {
526  // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
527  $tmpTSc = BackendUtility::getModTSconfig($this->pageinfo['uid'], 'mod.web_list');
528  $tmpTSc = $tmpTSc['properties']['newContentWiz.']['overrideWithExtension'];
529  $newContentWizScriptPath = ExtensionManagementUtility::isLoaded($tmpTSc) ? ExtensionManagementUtility::extRelPath($tmpTSc) . 'mod1/db_new_content_el.php' : 'sysext/cms/layout/db_new_content_el.php';
530  $url = $table == 'pages' ? 'db_new.php?id=' . $uid . '&pagesOnly=1' : $newContentWizScriptPath . '?id=' . $rec['pid'] . '&sys_language_uid=' . (int)$rec['sys_language_uid'];
531  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);
532  }
533 
543  public function DB_editAccess($table, $uid) {
544  $addParam = '&columnsOnly=' . rawurlencode((implode(',', $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']) . ($table == 'pages' ? ',extendToSubpages' : '')));
545  $url = 'alt_doc.php?edit[' . $table . '][' . $uid . ']=edit' . $addParam;
546  return $this->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editAccess')), $this->excludeIcon(IconUtility::getSpriteIcon('actions-document-edit-access')), $this->urlRefForCM($url, 'returnUrl'), 1);
547  }
548 
557  public function DB_editPageProperties($uid) {
558  $url = 'alt_doc.php?edit[pages][' . $uid . ']=edit';
559  return $this->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editPageProperties')), $this->excludeIcon(IconUtility::getSpriteIcon('actions-page-open')), $this->urlRefForCM($url, 'returnUrl'), 1);
560  }
561 
571  public function DB_edit($table, $uid) {
572  // If another module was specified, replace the default Page module with the new one
573  $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
574  $pageModule = BackendUtility::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
575  $editOnClick = '';
576  $loc = 'top.content.list_frame';
577  $addParam = '';
578  $theIcon = 'actions-document-open';
579  if ($this->iParts[0] == 'pages' && $this->iParts[1] && $GLOBALS['BE_USER']->check('modules', $pageModule)) {
580  $theIcon = 'actions-page-open';
581  $this->editPageIconSet = 1;
582  if ($GLOBALS['BE_USER']->uc['classicPageEditMode']) {
583  $addParam = '&editRegularContentFromId=' . (int)$this->iParts[1];
584  } else {
585  $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 . '\';}';
586  }
587  }
588  if (!$editOnClick) {
589  $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 . '\';}';
590  }
591  return $this->linkItem($this->label('edit'), $this->excludeIcon(IconUtility::getSpriteIcon($theIcon)), $editOnClick . 'return hideCM();');
592  }
593 
603  public function DB_new($table, $uid) {
604  $editOnClick = '';
605  $loc = 'top.content.list_frame';
606  $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 . '\'') . ';}';
607  return $this->linkItem($this->label('new'), $this->excludeIcon(IconUtility::getSpriteIcon('actions-' . ($table === 'pages' ? 'page' : 'document') . '-new')), $editOnClick . 'return hideCM();');
608  }
609 
620  public function DB_delete($table, $uid, $elInfo) {
621  $loc = 'top.content.list_frame';
622  if ($GLOBALS['BE_USER']->jsConfirmation(4)) {
623  $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'))))) . ')';
624  } else {
625  $conf = '1==1';
626  }
627  $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();';
628  if ($table === 'pages') {
629  $editOnClick .= 'top.nav.refresh.defer(500, top.nav);';
630  }
631  return $this->linkItem($this->label('delete'), $this->excludeIcon(IconUtility::getSpriteIcon('actions-edit-delete')), $editOnClick . 'return false;');
632  }
633 
643  public function DB_view($id, $anchor = '') {
644  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();');
645  }
646 
655  public function DB_tempMountPoint($page_id) {
656  return $this->linkItem($this->label('tempMountPoint'), $this->excludeIcon(IconUtility::getSpriteIcon('apps-pagetree-page-mountpoint')), 'if (top.content.nav_frame) {
657  var node = top.TYPO3.Backend.NavigationContainer.PageTree.getSelected();
658  if (node === null) {
659  return false;
660  }
661 
662  var useNode = {
663  attributes: {
664  nodeData: {
665  id: ' . (int)$page_id . '
666  }
667  }
668  };
669 
670  node.ownerTree.commandProvider.mountAsTreeRoot(useNode, node.ownerTree);
671  }
672  return hideCM();
673  ');
674  }
675 
686  public function DB_hideUnhide($table, $rec, $hideField) {
687  return $this->DB_changeFlag($table, $rec, $hideField, $this->label(($rec[$hideField] ? 'un' : '') . 'hide'), 'hide');
688  }
689 
702  public function DB_changeFlag($table, $rec, $flagField, $title, $name, $iconRelPath = 'gfx/') {
703  $uid = $rec['_ORIG_uid'] ?: $rec['uid'];
704  $loc = 'top.content.list_frame';
705  $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();';
706  if ($table === 'pages') {
707  $editOnClick .= 'top.nav.refresh.defer(500, top.nav);';
708  }
709  return $this->linkItem($title, $this->excludeIcon(IconUtility::getSpriteIcon('actions-edit-' . ($rec[$flagField] ? 'un' : '') . 'hide')), $editOnClick . 'return false;', 1);
710  }
711 
712  /***************************************
713  *
714  * FILE
715  *
716  ***************************************/
725  public function printFileClickMenu($combinedIdentifier) {
726  $menuItems = array();
727  $combinedIdentifier = rawurldecode($combinedIdentifier);
728  $fileObject = ResourceFactory::getInstance()
729  ->retrieveFileOrFolderObject($combinedIdentifier);
730  if ($fileObject) {
731  $folder = FALSE;
732  $isStorageRoot = FALSE;
733  $isOnline = TRUE;
734  $userMayViewStorage = FALSE;
735  $userMayEditStorage = FALSE;
736  $identifier = $fileObject->getCombinedIdentifier();
737  if ($fileObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
738  $icon = IconUtility::getSpriteIconForResource($fileObject, array(
739  'class' => 'absmiddle',
740  'title' => htmlspecialchars($fileObject->getName())
741  ));
742  $folder = TRUE;
743  if ($fileObject->getIdentifier() === $fileObject->getStorage()->getRootLevelFolder()->getIdentifier()) {
744  $isStorageRoot = TRUE;
745  if ($GLOBALS['BE_USER']->check('tables_select', 'sys_file_storage')) {
746  $userMayViewStorage = TRUE;
747  }
748  if ($GLOBALS['BE_USER']->check('tables_modify', 'sys_file_storage')) {
749  $userMayEditStorage = TRUE;
750  }
751  }
752  if (!$fileObject->getStorage()->isOnline()) {
753  $isOnline = FALSE;
754  }
755  } else {
756  $icon = IconUtility::getSpriteIconForResource($fileObject, array(
757  'class' => 'absmiddle',
758  'title' => htmlspecialchars($fileObject->getName() . ' (' . GeneralUtility::formatSize($fileObject->getSize()) . ')')
759  ));
760  }
761  // Hide
762  if (!in_array('hide', $this->disabledItems) && $isStorageRoot && $userMayEditStorage) {
763  $record = BackendUtility::getRecord('sys_file_storage', $fileObject->getStorage()->getUid());
764  $menuItems['hide'] = $this->DB_changeFlag(
765  'sys_file_storage',
766  $record,
767  'is_online',
768  $this->label($record['is_online'] ? 'offline' : 'online'),
769  'hide'
770  );
771  }
772  // Edit
773  if (!in_array('edit', $this->disabledItems) && $fileObject->checkActionPermission('write')) {
774  if (!$folder && !$isStorageRoot && $fileObject->isIndexed()) {
775  $metaData = $fileObject->_getMetaData();
776  $menuItems['edit2'] = $this->DB_edit('sys_file_metadata', $metaData['uid']);
777  }
778  if (!$folder && GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $fileObject->getExtension()) && $fileObject->checkActionPermission('write')) {
779  $menuItems['edit'] = $this->FILE_launch($identifier, 'file_edit.php', 'editcontent', 'edit_file.gif');
780  } elseif ($isStorageRoot && $userMayEditStorage) {
781  $menuItems['edit'] = $this->DB_edit('sys_file_storage', $fileObject->getStorage()->getUid());
782  }
783  }
784  // Rename
785  if (!in_array('rename', $this->disabledItems) && !$isStorageRoot && $fileObject->checkActionPermission('rename')) {
786  $menuItems['rename'] = $this->FILE_launch($identifier, 'file_rename.php', 'rename', 'rename.gif');
787  }
788  // Upload
789  if (!in_array('upload', $this->disabledItems) && $folder && $isOnline && $fileObject->checkActionPermission('write')) {
790  $menuItems['upload'] = $this->FILE_upload($identifier);
791  }
792  // New
793  if (!in_array('new', $this->disabledItems) && $folder && $isOnline && $fileObject->checkActionPermission('write')) {
794  $menuItems['new'] = $this->FILE_launch($identifier, 'file_newfolder.php', 'new', 'new_file.gif');
795  }
796  // Info
797  if (!in_array('info', $this->disabledItems) && $fileObject->checkActionPermission('read')) {
798  if ($isStorageRoot && $userMayViewStorage) {
799  $menuItems['info'] = $this->DB_info('sys_file_storage', $fileObject->getStorage()->getUid());
800  } elseif (!$folder) {
801  $menuItems['info'] = $this->fileInfo($identifier);
802  }
803  }
804  $menuItems[] = 'spacer';
805  // Copy:
806  if (!in_array('copy', $this->disabledItems) && !$isStorageRoot && $fileObject->checkActionPermission('read')) {
807  $menuItems['copy'] = $this->FILE_copycut($identifier, 'copy');
808  }
809  // Cut:
810  if (!in_array('cut', $this->disabledItems) && !$isStorageRoot && $fileObject->checkActionPermission('move')) {
811  $menuItems['cut'] = $this->FILE_copycut($identifier, 'cut');
812  }
813  // Paste:
814  $elFromAllTables = count($this->clipObj->elFromTable('_FILE'));
815  if (!in_array('paste', $this->disabledItems) && $elFromAllTables && $folder && $fileObject->checkActionPermission('write')) {
816  $elArr = $this->clipObj->elFromTable('_FILE');
817  $selItem = reset($elArr);
818  $elInfo = array(
819  basename($selItem),
820  basename($identifier),
821  $this->clipObj->currentMode()
822  );
823  $clickedFileOrFolder = ResourceFactory::getInstance()->retrieveFileOrFolderObject($combinedIdentifier);
824  $fileOrFolderInClipBoard = ResourceFactory::getInstance()->retrieveFileOrFolderObject($selItem);
825  if (!$fileOrFolderInClipBoard instanceof Folder || !$fileOrFolderInClipBoard->getStorage()->isWithinFolder($fileOrFolderInClipBoard, $clickedFileOrFolder)) {
826  $menuItems['pasteinto'] = $this->FILE_paste($identifier, $selItem, $elInfo);
827  }
828  }
829  $menuItems[] = 'spacer';
830  // Delete:
831  if (!in_array('delete', $this->disabledItems) && $fileObject->checkActionPermission('delete')) {
832  if ($isStorageRoot && $userMayEditStorage) {
833  $elInfo = array(GeneralUtility::fixed_lgd_cs($fileObject->getStorage()->getName(), $GLOBALS['BE_USER']->uc['titleLen']));
834  $menuItems['delete'] = $this->DB_delete('sys_file_storage', $fileObject->getStorage()->getUid(), $elInfo);
835  } elseif (!$isStorageRoot) {
836  $menuItems['delete'] = $this->FILE_delete($identifier);
837  }
838  }
839  }
840  // Adding external elements to the menuItems array
841  $menuItems = $this->processingByExtClassArray($menuItems, $identifier, 0);
842  // Processing by external functions?
843  $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
844  // Return the printed elements:
845  return $this->printItems($menuItems, $icon . $fileObject->getName());
846  }
847 
855  public function externalProcessingOfFileMenuItems($menuItems) {
856  return $menuItems;
857  }
858 
871  public function FILE_launch($path, $script, $type, $image, $noReturnUrl = FALSE) {
872  $loc = 'top.content.list_frame';
873  $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)') . ';}';
874  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();');
875  }
876 
885  public function FILE_upload($path) {
886  $script = 'file_upload.php';
887  $type = 'upload';
888  $image = 'upload.gif';
889  return $this->FILE_launch($path, $script, $type, $image, TRUE);
890  }
891 
901  public function FILE_copycut($path, $type) {
902  // Pseudo table name for use in the clipboard.
903  $table = '_FILE';
904  $uid = GeneralUtility::shortmd5($path);
905  if ($this->clipObj->current == 'normal') {
906  $isSel = $this->clipObj->isSelected($table, $uid);
907  }
908  $addParam = array();
909  if ($this->listFrame) {
910  $addParam['reloadListFrame'] = $this->alwaysContentFrame ? 2 : 1;
911  }
912  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;');
913  }
914 
923  public function FILE_delete($path) {
924  $editOnClick = '';
925  $loc = 'top.content.list_frame';
926  if ($GLOBALS['BE_USER']->jsConfirmation(4)) {
927  $fileOrFolderObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($path);
928  $confirmMessage = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:mess.delete'), $fileOrFolderObject->getName());
929  if ($fileOrFolderObject instanceof Folder) {
930  $confirmMessage .= BackendUtility::referenceCount('_FILE', $fileOrFolderObject->getIdentifier(), ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.referencesToFolder'));
931  } else {
932  $confirmMessage .= BackendUtility::referenceCount('sys_file', $fileOrFolderObject->getUid(), ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.referencesToFile'));
933  }
934  $conf = 'confirm(' . GeneralUtility::quoteJSvalue($confirmMessage) . ')';
935  } else {
936  $conf = '1==1';
937  }
938  $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();';
939  return $this->linkItem($this->label('delete'), $this->excludeIcon(IconUtility::getSpriteIcon('actions-edit-delete')), $editOnClick . 'return false;');
940  }
941 
952  public function FILE_paste($path, $target, $elInfo) {
953  $editOnClick = '';
954  $loc = 'top.content.list_frame';
955  if ($GLOBALS['BE_USER']->jsConfirmation(2)) {
956  $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])) . ')';
957  } else {
958  $conf = $loc;
959  }
960  $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();';
961  return $this->linkItem($this->label('pasteinto'), $this->excludeIcon(IconUtility::getSpriteIcon('actions-document-paste-into')), $editOnClick . 'return false;');
962  }
963 
970  protected function fileInfo($identifier) {
971  return $this->DB_info('_FILE', $identifier);
972  }
973 
974  /***************************************
975  *
976  * DRAG AND DROP
977  *
978  ***************************************/
988  public function printDragDropClickMenu($table, $srcId, $dstId) {
989  $menuItems = array();
990  // If the drag and drop menu should apply to PAGES use this set of menu items
991  if ($table == 'pages') {
992  // Move Into:
993  $menuItems['movePage_into'] = $this->dragDrop_copymovepage($srcId, $dstId, 'move', 'into');
994  // Move After:
995  $menuItems['movePage_after'] = $this->dragDrop_copymovepage($srcId, $dstId, 'move', 'after');
996  // Copy Into:
997  $menuItems['copyPage_into'] = $this->dragDrop_copymovepage($srcId, $dstId, 'copy', 'into');
998  // Copy After:
999  $menuItems['copyPage_after'] = $this->dragDrop_copymovepage($srcId, $dstId, 'copy', 'after');
1000  }
1001  // If the drag and drop menu should apply to FOLDERS use this set of menu items
1002  if ($table == 'folders') {
1003  // Move Into:
1004  $menuItems['moveFolder_into'] = $this->dragDrop_copymovefolder($srcId, $dstId, 'move');
1005  // Copy Into:
1006  $menuItems['copyFolder_into'] = $this->dragDrop_copymovefolder($srcId, $dstId, 'copy');
1007  }
1008  // Adding external elements to the menuItems array
1009  $menuItems = $this->processingByExtClassArray($menuItems, 'dragDrop_' . $table, $srcId);
1010  // to extend this, you need to apply a Context Menu to a "virtual" table called "dragDrop_pages" or similar
1011  // Processing by external functions?
1012  $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
1013  // Return the printed elements:
1014  return $this->printItems($menuItems, IconUtility::getSpriteIconForRecord($table, $this->rec, array('title' => BackendUtility::getRecordTitle($table, $this->rec, TRUE))));
1015  }
1016 
1024  public function externalProcessingOfDragDropMenuItems($menuItems) {
1025  return $menuItems;
1026  }
1027 
1039  public function dragDrop_copymovepage($srcUid, $dstUid, $action, $into) {
1040  $negativeSign = $into == 'into' ? '' : '-';
1041  $editOnClick = '';
1042  $loc = 'top.content.list_frame';
1043  $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();';
1044  return $this->linkItem($this->label($action . 'Page_' . $into), $this->excludeIcon(IconUtility::getSpriteIcon('actions-document-paste-' . $into)), $editOnClick . 'return false;', 0);
1045  }
1046 
1057  public function dragDrop_copymovefolder($srcPath, $dstPath, $action) {
1058  $editOnClick = '';
1059  $loc = 'top.content.list_frame';
1060  $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();';
1061  return $this->linkItem($this->label($action . 'Folder_into'), $this->excludeIcon(IconUtility::getSpriteIcon('apps-pagetree-drag-move-into')), $editOnClick . 'return false;', 0);
1062  }
1063 
1064  /***************************************
1065  *
1066  * COMMON
1067  *
1068  **************************************/
1077  public function printItems($menuItems, $item) {
1078  $out = '';
1079  // Enable/Disable items:
1080  $menuItems = $this->enableDisableItems($menuItems);
1081  // Clean up spacers:
1082  $menuItems = $this->cleanUpSpacers($menuItems);
1083  // Adding JS part:
1084  $out .= $this->printLayerJScode($menuItems);
1085  // Return the content
1086  return $out;
1087  }
1088 
1096  public function printLayerJScode($menuItems) {
1097  $script = '';
1098  // Clipboard must not be submitted - then it's probably a copy/cut situation.
1099  if ($this->isCMlayers()) {
1100  $frameName = '.' . ($this->listFrame ? 'list_frame' : 'nav_frame');
1101  if ($this->alwaysContentFrame) {
1102  $frameName = '';
1103  }
1104  // Create the table displayed in the clickmenu layer:
1105  $CMtable = '
1106  <table border="0" cellpadding="0" cellspacing="0" class="typo3-CSM">
1107  ' . implode('', $this->menuItemsForClickMenu($menuItems)) . '
1108  </table>';
1109  // Wrap the inner table in another table to create outer border:
1110  $CMtable = $this->wrapColorTableCM($CMtable);
1111  // Set back path place holder to real back path
1112  $CMtable = str_replace($this->PH_backPath, $this->backPath, $CMtable);
1113  if ($this->ajax) {
1114  $innerXML = '<data><clickmenu><htmltable><![CDATA[' . $CMtable . ']]></htmltable><cmlevel>' . $this->cmLevel . '</cmlevel></clickmenu></data>';
1115  return $innerXML;
1116  } else {
1117  // Create JavaScript section:
1118  $script = $GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
1119 
1120  if (top.content && top.content' . $frameName . ' && top.content' . $frameName . '.Clickmenu) {
1121  top.content' . $frameName . '.Clickmenu.populateData(unescape("' . GeneralUtility::rawurlencodeJS($CMtable) . '"),' . $this->cmLevel . ');
1122  }
1123  hideCM();
1124  ');
1125  return $script;
1126  }
1127  }
1128  }
1129 
1138  public function wrapColorTableCM($str) {
1139  return '<div class="typo3-CSM-wrapperCM">
1140  ' . $str . '
1141  </div>';
1142  }
1143 
1151  public function menuItemsForTopFrame($menuItems) {
1152  $out = array();
1153  foreach ($menuItems as $i) {
1154  // IF the topbar is the ONLY means of the click menu, then items normally disabled from
1155  // the top menu will appear anyways IF they are disabled with a "1" (2+ will still disallow
1156  // them in the topbar)
1157  if ($i[4] == 1 && !$GLOBALS['SOBE']->doc->isCMlayers()) {
1158  $i[4] = 0;
1159  }
1160  if (is_array($i) && !$i[4]) {
1161  $out[] = $i[0];
1162  }
1163  }
1164  return $out;
1165  }
1166 
1174  public function menuItemsForClickMenu($menuItems) {
1175  $out = array();
1176  foreach ($menuItems as $cc => $i) {
1177  // MAKE horizontal spacer
1178  if (is_string($i) && $i == 'spacer') {
1179  $out[] = '
1180  <tr class="bgColor2">
1181  <td colspan="2"><img src="clear.gif" width="1" height="1" alt="" /></td>
1182  </tr>';
1183  } else {
1184  // Just make normal element:
1185  $onClick = $i[3];
1186  $onClick = preg_replace('/return[[:space:]]+hideCM\\(\\)[[:space:]]*;/i', '', $onClick);
1187  $onClick = preg_replace('/return[[:space:]]+false[[:space:]]*;/i', '', $onClick);
1188  $onClick = preg_replace('/hideCM\\(\\);/i', '', $onClick);
1189  if (!$i[5]) {
1190  $onClick .= 'Clickmenu.hideAll();';
1191  }
1192  $CSM = ' oncontextmenu="this.click();return false;"';
1193  $out[] = '
1194  <tr class="typo3-CSM-itemRow" onclick="' . htmlspecialchars($onClick) . '"' . $CSM . '>
1195  ' . (!$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>') . '
1196  </tr>';
1197  }
1198  }
1199  return $out;
1200  }
1201 
1212  public function addMenuItems($menuItems, $newMenuItems, $position = '') {
1213  if (is_array($newMenuItems)) {
1214  if ($position) {
1215  $posArr = GeneralUtility::trimExplode(',', $position, TRUE);
1216  foreach ($posArr as $pos) {
1217  list($place, $menuEntry) = GeneralUtility::trimExplode(':', $pos, TRUE);
1218  list($place, $placeExtra) = GeneralUtility::trimExplode('-', $place, TRUE);
1219  // Bottom
1220  $pointer = count($menuItems);
1221  $found = FALSE;
1222  if ($place) {
1223  switch (strtolower($place)) {
1224  case 'after':
1225 
1226  case 'before':
1227  if ($menuEntry) {
1228  $p = 1;
1229  reset($menuItems);
1230  while (TRUE) {
1231  if ((string)key($menuItems) === $menuEntry) {
1232  $pointer = $p;
1233  $found = TRUE;
1234  break;
1235  }
1236  if (!next($menuItems)) {
1237  break;
1238  }
1239  $p++;
1240  }
1241  if (!$found) {
1242  break;
1243  }
1244  if ($place == 'before') {
1245  $pointer--;
1246  if ($placeExtra == 'spacer' and prev($menuItems) == 'spacer') {
1247  $pointer--;
1248  }
1249  } elseif ($place == 'after') {
1250  if ($placeExtra == 'spacer' and next($menuItems) == 'spacer') {
1251  $pointer++;
1252  }
1253  }
1254  }
1255  break;
1256  default:
1257  if (strtolower($place) == 'top') {
1258  $pointer = 0;
1259  } else {
1260  $pointer = count($menuItems);
1261  }
1262  $found = TRUE;
1263  }
1264  }
1265  if ($found) {
1266  break;
1267  }
1268  }
1269  }
1270  $pointer = max(0, $pointer);
1271  $menuItemsBefore = array_slice($menuItems, 0, $pointer ?: 0);
1272  $menuItemsAfter = array_slice($menuItems, $pointer);
1273  $menuItems = $menuItemsBefore + $newMenuItems + $menuItemsAfter;
1274  }
1275  return $menuItems;
1276  }
1277 
1289  public function linkItem($str, $icon, $onClick, $onlyCM = 0, $dontHide = 0) {
1290  $this->elCount++;
1291  if ($this->ajax) {
1292  $onClick = str_replace('top.loadTopMenu', 'showClickmenu_raw', $onClick);
1293  }
1294  return array(
1295  IconUtility::getSpriteIcon('empty-empty', array(
1296  'class' => 'c-roimg',
1297  'id' => ('roimg_' . $this->elCount)
1298  )) . '<a href="#" onclick="' . htmlspecialchars($onClick) . '" onmouseover="mo(' . $this->elCount . ');" onmouseout="mout(' . $this->elCount . ');">' . $str . $icon . '</a>',
1299  $str,
1300  $icon,
1301  $onClick,
1302  $onlyCM,
1303  $dontHide
1304  );
1305  }
1306 
1314  public function excludeIcon($iconCode) {
1315  return $GLOBALS['BE_USER']->uc['noMenuMode'] && $GLOBALS['BE_USER']->uc['noMenuMode'] !== 'icons' ? '' : ' ' . $iconCode;
1316  }
1317 
1325  public function enableDisableItems($menuItems) {
1326  if ($this->iParts[3]) {
1327  // Detect "only" mode: (only showing listed items)
1328  if ($this->iParts[3][0] === '+') {
1329  $this->iParts[3] = substr($this->iParts[3], 1);
1330  $only = TRUE;
1331  } else {
1332  $only = FALSE;
1333  }
1334  // Do filtering:
1335  // Transfer ONLY elements which are mentioned (or are spacers)
1336  if ($only) {
1337  $newMenuArray = array();
1338  foreach ($menuItems as $key => $value) {
1339  if (GeneralUtility::inList($this->iParts[3], $key) || is_string($value) && $value == 'spacer') {
1340  $newMenuArray[$key] = $value;
1341  }
1342  }
1343  $menuItems = $newMenuArray;
1344  } else {
1345  // Traverse all elements except those listed (just unsetting them):
1346  $elements = GeneralUtility::trimExplode(',', $this->iParts[3], TRUE);
1347  foreach ($elements as $value) {
1348  unset($menuItems[$value]);
1349  }
1350  }
1351  }
1352  // Return processed menu items:
1353  return $menuItems;
1354  }
1355 
1363  public function cleanUpSpacers($menuItems) {
1364  // Remove doubles:
1365  $prevItemWasSpacer = FALSE;
1366  foreach ($menuItems as $key => $value) {
1367  if (is_string($value) && $value == 'spacer') {
1368  if ($prevItemWasSpacer) {
1369  unset($menuItems[$key]);
1370  }
1371  $prevItemWasSpacer = TRUE;
1372  } else {
1373  $prevItemWasSpacer = FALSE;
1374  }
1375  }
1376  // Remove first:
1377  reset($menuItems);
1378  $key = key($menuItems);
1379  $value = current($menuItems);
1380  if (is_string($value) && $value == 'spacer') {
1381  unset($menuItems[$key]);
1382  }
1383  // Remove last:
1384  end($menuItems);
1385  $key = key($menuItems);
1386  $value = current($menuItems);
1387  if (is_string($value) && $value == 'spacer') {
1388  unset($menuItems[$key]);
1389  }
1390  // Return processed menu items:
1391  return $menuItems;
1392  }
1393 
1401  public function label($label) {
1402  return $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.' . $label, TRUE));
1403  }
1404 
1411  public function isCMlayers() {
1412  return !$this->CB;
1413  }
1414 
1422  public function frameLocation($str) {
1423  return $str . '.location';
1424  }
1425 
1426 }
static referenceCount($table, $ref, $msg='', $count=NULL)
static translationCount($table, $ref, $msg='')
static skinImg($backPath, $src, $wHattribs='', $outputMode=0)
static getRecordWSOL($table, $uid, $fields=' *', $where='', $useDeleteClause=TRUE, $unsetMovePointers=FALSE)
printFileClickMenu($combinedIdentifier)
Definition: ClickMenu.php:725
$uid
Definition: server.php:36
urlRefForCM($url, $retUrl='', $hideCM=1, $overrideLoc='')
Definition: ClickMenu.php:374
addMenuItems($menuItems, $newMenuItems, $position='')
Definition: ClickMenu.php:1212
static getUrlToken($formName='securityToken', $tokenName='formToken')
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
static getRecordTitle($table, $row, $prep=FALSE, $forceResult=TRUE)
static getSpriteIconForRecord($table, array $row, array $options=array())
FILE_launch($path, $script, $type, $image, $noReturnUrl=FALSE)
Definition: ClickMenu.php:871
dragDrop_copymovepage($srcUid, $dstUid, $action, $into)
Definition: ClickMenu.php:1039
dragDrop_copymovefolder($srcPath, $dstPath, $action)
Definition: ClickMenu.php:1057
DB_paste($table, $uid, $type, $elInfo)
Definition: ClickMenu.php:414
static getSpriteIcon($iconName, array $options=array(), array $overlays=array())
processingByExtClassArray($menuItems, $table, $uid)
Definition: ClickMenu.php:354
static getRecordIconAltText($row, $table='pages')
linkItem($str, $icon, $onClick, $onlyCM=0, $dontHide=0)
Definition: ClickMenu.php:1289
static fixed_lgd_cs($string, $chars, $appendString='...')
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
DB_delete($table, $uid, $elInfo)
Definition: ClickMenu.php:620
printDragDropClickMenu($table, $srcId, $dstId)
Definition: ClickMenu.php:988