|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2010-2011 TYPO3 Tree Team <http://forge.typo3.org/projects/typo3v4-extjstrees> 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 00028 /** 00029 * Context Menu Data Provider for the Page Tree 00030 * 00031 * @author Stefan Galinski <stefan.galinski@gmail.com> 00032 * @package TYPO3 00033 * @subpackage t3lib 00034 */ 00035 class t3lib_contextmenu_pagetree_DataProvider extends t3lib_contextmenu_AbstractDataProvider { 00036 /** 00037 * Old Context Menu Options (access mapping) 00038 * 00039 * Note: Only option with different namings are mapped! 00040 * 00041 * @var array 00042 */ 00043 protected $legacyContextMenuMapping = array( 00044 'hide' => 'disable', 00045 'paste' => 'pasteInto,pasteAfter', 00046 'mount_as_treeroot' => 'mountAsTreeroot', 00047 ); 00048 00049 /** 00050 * Fetches the items that should be disabled from the context menu 00051 * 00052 * @return array 00053 */ 00054 protected function getDisableActions() { 00055 $tsConfig = $GLOBALS['BE_USER']->getTSConfig( 00056 'options.contextMenu.' . $this->getContextMenuType() . '.disableItems' 00057 ); 00058 00059 $disableItems = array(); 00060 if (trim($tsConfig['value']) !== '') { 00061 $disableItems = t3lib_div::trimExplode(',', $tsConfig['value']); 00062 } 00063 00064 $tsConfig = $GLOBALS['BE_USER']->getTSConfig('options.contextMenu.pageTree.disableItems'); 00065 $oldDisableItems = array(); 00066 if (trim($tsConfig['value']) !== '') { 00067 $oldDisableItems = t3lib_div::trimExplode(',', $tsConfig['value']); 00068 } 00069 00070 $additionalItems = array(); 00071 foreach ($oldDisableItems as $item) { 00072 if (!isset($this->legacyContextMenuMapping[$item])) { 00073 $additionalItems[] = $item; 00074 continue; 00075 } 00076 00077 if (strpos($this->legacyContextMenuMapping[$item], ',')) { 00078 $actions = t3lib_div::trimExplode(',', $this->legacyContextMenuMapping[$item]); 00079 $additionalItems = array_merge($additionalItems, $actions); 00080 } else { 00081 $additionalItems[] = $item; 00082 } 00083 } 00084 00085 return array_merge($disableItems, $additionalItems); 00086 } 00087 00088 /** 00089 * Returns the actions for the node 00090 * 00091 * @param t3lib_tree_pagetree_Node $node 00092 * @return t3lib_contextmenu_ActionCollection 00093 */ 00094 public function getActionsForNode(t3lib_tree_Node $node) { 00095 $this->disableItems = $this->getDisableActions(); 00096 $configuration = $this->getConfiguration(); 00097 $contextMenuActions = array(); 00098 if (is_array($configuration)) { 00099 $contextMenuActions = $this->getNextContextMenuLevel($configuration, $node); 00100 } 00101 00102 return $contextMenuActions; 00103 } 00104 } 00105 00106 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/contextmenu/pagetree/class.t3lib_contextmenu_pagetree_dataprovider.php']) { 00107 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/contextmenu/pagetree/class.t3lib_contextmenu_pagetree_dataprovider.php']); 00108 } 00109 00110 ?>
1.8.0