TYPO3  7.6
ContextMenuDataProvider.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend\ContextMenu\Pagetree;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 
23 {
31  protected $legacyContextMenuMapping = array(
32  'hide' => 'disable',
33  'paste' => 'pasteInto,pasteAfter',
34  'mount_as_treeroot' => 'mountAsTreeroot'
35  );
36 
42  protected function getDisableActions()
43  {
44  $tsConfig = $this->getBackendUser()->getTSConfig('options.contextMenu.' . $this->getContextMenuType() . '.disableItems');
45  $disableItems = array();
46  if (trim($tsConfig['value']) !== '') {
47  $disableItems = GeneralUtility::trimExplode(',', $tsConfig['value']);
48  }
49  $tsConfig = $this->getBackendUser()->getTSConfig('options.contextMenu.pageTree.disableItems');
50  $oldDisableItems = array();
51  if (trim($tsConfig['value']) !== '') {
52  $oldDisableItems = GeneralUtility::trimExplode(',', $tsConfig['value']);
53  }
54  $additionalItems = array();
55  foreach ($oldDisableItems as $item) {
56  if (!isset($this->legacyContextMenuMapping[$item])) {
57  $additionalItems[] = $item;
58  continue;
59  }
60  if (strpos($this->legacyContextMenuMapping[$item], ',')) {
61  $actions = GeneralUtility::trimExplode(',', $this->legacyContextMenuMapping[$item]);
62  $additionalItems = array_merge($additionalItems, $actions);
63  } else {
64  $additionalItems[] = $item;
65  }
66  }
67  return array_merge($disableItems, $additionalItems);
68  }
69 
76  public function getActionsForNode(\TYPO3\CMS\Backend\Tree\TreeNode $node)
77  {
78  $this->disableItems = $this->getDisableActions();
79  $configuration = $this->getConfiguration();
80  $contextMenuActions = array();
81  if (is_array($configuration)) {
82  $contextMenuActions = $this->getNextContextMenuLevel($configuration, $node);
83  }
84  return $contextMenuActions;
85  }
86 
92  protected function getBackendUser()
93  {
94  return $GLOBALS['BE_USER'];
95  }
96 }