TYPO3 CMS  TYPO3_7-6
ContextMenuDataProvider.php
Go to the documentation of this file.
1 <?php
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 {
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 = [];
46  if (trim($tsConfig['value']) !== '') {
47  $disableItems = GeneralUtility::trimExplode(',', $tsConfig['value']);
48  }
49  $tsConfig = $this->getBackendUser()->getTSConfig('options.contextMenu.pageTree.disableItems');
50  $oldDisableItems = [];
51  if (trim($tsConfig['value']) !== '') {
52  $oldDisableItems = GeneralUtility::trimExplode(',', $tsConfig['value']);
53  }
54  $additionalItems = [];
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  $disableItems = array_merge($disableItems, $additionalItems);
68 
69  // Further manipulation of disableItems array via hook
70  // @internal: This is an internal hook for extension impexp only, this hook may change without further notice
71  if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['backend']['contextMenu']['disableItems'])
72  && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['backend']['contextMenu']['disableItems'])
73  ) {
74  $hooks = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['backend']['contextMenu']['disableItems'];
75  foreach ($hooks as $hook) {
76  $parameterArray = [
77  'disableItems' => &$disableItems,
78  ];
79  $null = null;
80  GeneralUtility::callUserFunction($hook, $parameterArray, $null);
81  }
82  }
83 
84  return $disableItems;
85  }
86 
93  public function getActionsForNode(\TYPO3\CMS\Backend\Tree\TreeNode $node)
94  {
95  $this->disableItems = $this->getDisableActions();
96  $configuration = $this->getConfiguration();
97  $contextMenuActions = [];
98  if (is_array($configuration)) {
99  $contextMenuActions = $this->getNextContextMenuLevel($configuration, $node);
100  }
101  return $contextMenuActions;
102  }
103 
109  protected function getBackendUser()
110  {
111  return $GLOBALS['BE_USER'];
112  }
113 }
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
static callUserFunction($funcName, &$params, &$ref, $checkPrefix='', $errorMode=0)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']