|
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 * Data Provider of the Page Tree 00030 * 00031 * @author Stefan Galinski <stefan.galinski@gmail.com> 00032 * @package TYPO3 00033 * @subpackage t3lib 00034 */ 00035 class t3lib_tree_pagetree_extdirect_Tree extends t3lib_tree_ExtDirect_AbstractExtJsTree { 00036 /** 00037 * Sets the data provider 00038 * 00039 * @return void 00040 */ 00041 protected function initDataProvider() { 00042 /** @var $dataProvider t3lib_tree_pagetree_DataProvider */ 00043 $dataProvider = t3lib_div::makeInstance('t3lib_tree_pagetree_DataProvider'); 00044 $this->setDataProvider($dataProvider); 00045 } 00046 00047 /** 00048 * Data Provider 00049 * 00050 * @return t3lib_tree_pagetree_DataProvider 00051 */ 00052 protected $dataProvider = NULL; 00053 00054 /** 00055 * Returns the root node of the tree 00056 * 00057 * @return array 00058 */ 00059 public function getRoot() { 00060 $this->initDataProvider(); 00061 $node = $this->dataProvider->getRoot(); 00062 00063 return $node->toArray(); 00064 } 00065 00066 /** 00067 * Fetches the next tree level 00068 * 00069 * @param int $nodeId 00070 * @param stdClass $nodeData 00071 * @return array 00072 */ 00073 public function getNextTreeLevel($nodeId, $nodeData) { 00074 $this->initDataProvider(); 00075 00076 /** @var $node t3lib_tree_pagetree_Node */ 00077 $node = t3lib_div::makeInstance('t3lib_tree_pagetree_Node', (array) $nodeData); 00078 00079 if ($nodeId === 'root') { 00080 $nodeCollection = $this->dataProvider->getTreeMounts(); 00081 } else { 00082 $nodeCollection = $this->dataProvider->getNodes($node); 00083 } 00084 00085 return $nodeCollection->toArray(); 00086 } 00087 00088 /** 00089 * Returns a tree that only contains elements that match the given search string 00090 * 00091 * @param int $nodeId 00092 * @param stdClass $nodeData 00093 * @param string $searchFilter 00094 * @return array 00095 */ 00096 public function getFilteredTree($nodeId, $nodeData, $searchFilter) { 00097 if (strval($searchFilter) === '') { 00098 return array(); 00099 } 00100 00101 /** @var $node t3lib_tree_pagetree_Node */ 00102 $node = t3lib_div::makeInstance('t3lib_tree_pagetree_Node', (array) $nodeData); 00103 00104 $this->initDataProvider(); 00105 if ($nodeId === 'root') { 00106 $nodeCollection = $this->dataProvider->getTreeMounts($searchFilter); 00107 } else { 00108 $nodeCollection = $this->dataProvider->getFilteredNodes($node, $searchFilter, $node->getMountPoint()); 00109 } 00110 00111 return $nodeCollection->toArray(); 00112 } 00113 00114 /** 00115 * Returns the localized list of doktypes to display 00116 * 00117 * Note: The list can be filtered by the user typoscript 00118 * option "options.pageTree.doktypesToShowInNewPageDragArea". 00119 * 00120 * @return array 00121 */ 00122 public function getNodeTypes() { 00123 $map = array( 00124 1 => 'LLL:EXT:lang/locallang_tca.php:doktype.I.0', 00125 3 => 'LLL:EXT:cms/locallang_tca.php:pages.doktype.I.8', 00126 4 => 'LLL:EXT:cms/locallang_tca.php:pages.doktype.I.2', 00127 6 => 'LLL:EXT:cms/locallang_tca.php:pages.doktype.I.4', 00128 7 => 'LLL:EXT:cms/locallang_tca.php:pages.doktype.I.5', 00129 199 => 'LLL:EXT:cms/locallang_tca.php:pages.doktype.I.7', 00130 254 => 'LLL:EXT:lang/locallang_tca.php:doktype.I.folder', 00131 255 => 'LLL:EXT:lang/locallang_tca.php:doktype.I.2' 00132 ); 00133 00134 $doktypes = t3lib_div::trimExplode( 00135 ',', $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.doktypesToShowInNewPageDragArea') 00136 ); 00137 00138 $output = array(); 00139 $allowedDoktypes = t3lib_div::trimExplode(',', $GLOBALS['BE_USER']->groupData['pagetypes_select']); 00140 $isAdmin = $GLOBALS['BE_USER']->isAdmin(); 00141 foreach ($doktypes as $doktype) { 00142 if (!$isAdmin && !in_array($doktype, $allowedDoktypes)) { 00143 continue; 00144 } 00145 00146 $label = $GLOBALS['LANG']->sL($map[$doktype], TRUE); 00147 $spriteIcon = t3lib_iconWorks::getSpriteIconClasses( 00148 $GLOBALS['TCA']['pages']['ctrl']['typeicon_classes'][$doktype] 00149 ); 00150 00151 $output[] = array( 00152 'nodeType' => $doktype, 00153 'cls' => 'typo3-pagetree-topPanel-button', 00154 'iconCls' => $spriteIcon, 00155 'title' => $label, 00156 'tooltip' => $label, 00157 ); 00158 } 00159 00160 return $output; 00161 } 00162 00163 /** 00164 * Returns 00165 * 00166 * @return array 00167 */ 00168 public function getIndicators() { 00169 /** @var $indicatorProvider t3lib_tree_pagetree_Indicator */ 00170 $indicatorProvider = t3lib_div::makeInstance('t3lib_tree_pagetree_Indicator'); 00171 $indicatorHtmlArr = $indicatorProvider->getAllIndicators(); 00172 $indicator = array( 00173 'html' => implode(' ', $indicatorHtmlArr), 00174 '_COUNT' => count($indicatorHtmlArr) 00175 ); 00176 00177 return $indicator; 00178 } 00179 00180 /** 00181 * Returns the language labels, sprites and configuration options for the pagetree 00182 * 00183 * @return void 00184 */ 00185 public function loadResources() { 00186 $file = 'LLL:EXT:lang/locallang_core.xml:'; 00187 $indicators = $this->getIndicators(); 00188 $configuration = array( 00189 'LLL' => array( 00190 'copyHint' => $GLOBALS['LANG']->sL($file . 'tree.copyHint', TRUE), 00191 'fakeNodeHint' => $GLOBALS['LANG']->sL($file . 'mess.please_wait', TRUE), 00192 'activeFilterMode' => $GLOBALS['LANG']->sL($file . 'tree.activeFilterMode', TRUE), 00193 'dropToRemove' => $GLOBALS['LANG']->sL($file . 'tree.dropToRemove', TRUE), 00194 'buttonRefresh' => $GLOBALS['LANG']->sL($file . 'labels.refresh', TRUE), 00195 'buttonNewNode' => $GLOBALS['LANG']->sL($file . 'tree.buttonNewNode', TRUE), 00196 'buttonFilter' => $GLOBALS['LANG']->sL($file . 'tree.buttonFilter', TRUE), 00197 'dropZoneElementRemoved' => $GLOBALS['LANG']->sL($file . 'tree.dropZoneElementRemoved', TRUE), 00198 'dropZoneElementRestored' => $GLOBALS['LANG']->sL($file . 'tree.dropZoneElementRestored', TRUE), 00199 'searchTermInfo' => $GLOBALS['LANG']->sL($file . 'tree.searchTermInfo', TRUE), 00200 'temporaryMountPointIndicatorInfo' => $GLOBALS['LANG']->sl($file . 'labels.temporaryDBmount', TRUE), 00201 'deleteDialogTitle' => $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xml:deleteItem', TRUE), 00202 'deleteDialogMessage' => $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xml:deleteWarning', TRUE), 00203 'recursiveDeleteDialogMessage' => $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xml:recursiveDeleteWarning', TRUE), 00204 ), 00205 00206 'Configuration' => array( 00207 'hideFilter' => $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.hideFilter'), 00208 'displayDeleteConfirmation' => $GLOBALS['BE_USER']->jsConfirmation(4), 00209 'canDeleteRecursivly' => $GLOBALS['BE_USER']->uc['recursiveDelete'] == TRUE, 00210 'disableIconLinkToContextmenu' => $GLOBALS['BE_USER']->getTSConfigVal( 00211 'options.pageTree.disableIconLinkToContextmenu' 00212 ), 00213 'indicator' => $indicators['html'], 00214 'temporaryMountPoint' => t3lib_tree_pagetree_Commands::getMountPointPath(), 00215 ), 00216 00217 'Sprites' => array( 00218 'Filter' => t3lib_iconWorks::getSpriteIconClasses('actions-system-tree-search-open'), 00219 'NewNode' => t3lib_iconWorks::getSpriteIconClasses('actions-page-new'), 00220 'Refresh' => t3lib_iconWorks::getSpriteIconClasses('actions-system-refresh'), 00221 'InputClear' => t3lib_iconWorks::getSpriteIconClasses('actions-input-clear'), 00222 'TrashCan' => t3lib_iconWorks::getSpriteIconClasses('actions-edit-delete'), 00223 'TrashCanRestore' => t3lib_iconWorks::getSpriteIconClasses('actions-edit-restore'), 00224 'Info' => t3lib_iconWorks::getSpriteIconClasses('actions-document-info'), 00225 ) 00226 ); 00227 00228 return $configuration; 00229 } 00230 } 00231 00232 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/tree/pagetree/extdirect/class.t3lib_tree_pagetree_extdirect_tree.php'])) { 00233 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/tree/pagetree/extdirect/class.t3lib_tree_pagetree_extdirect_tree.php']); 00234 } 00235 00236 ?>
1.8.0