71824dd9592c2948a2e5a3f43d27e1757142394f
[Packages/TYPO3.CMS.git] / t3lib / tree / tca / class.t3lib_tree_tca_abstracttcatreedataprovider.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010-2011 Steffen Ritter <info@steffen-ritter.net>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28 /**
29 * An abstract TCA tree data provider
30 *
31 * @author Steffen Ritter <info@steffen-ritter.net>
32 * @package TYPO3
33 * @subpackage t3lib_tree
34 */
35 abstract class t3lib_tree_Tca_AbstractTcaTreeDataProvider extends t3lib_tree_AbstractDataProvider {
36 /**
37 * @var boolean
38 */
39 protected $expandAll = FALSE;
40
41 /**
42 * @var int
43 */
44 protected $levelMaximum = 2;
45
46 /**
47 * @var t3lib_tree_AbstractNode
48 */
49 protected $treeData = NULL;
50
51 /**
52 * @var string
53 */
54 protected $nonSelectableLevelList = '0';
55
56 /**
57 * @var string
58 */
59 protected $expandedList = '';
60
61 /**
62 * @var string
63 */
64 protected $selectedList = '';
65
66 /**
67 * Contains all ids which may be allowed to display according to
68 * beUser Rights and foreign_table_where (if type db)
69 *
70 * @var array $itemWhiteList
71 */
72 protected $itemWhiteList = array();
73
74 /**
75 * Sets the id of the tree
76 *
77 * @param string $treeId
78 * @return void
79 */
80 public function setTreeId($treeId) {
81 $this->treeId = $treeId;
82 }
83
84 /**
85 * Gets the id of the tree
86 * @return string
87 */
88 public function getTreeId() {
89 return $this->treeId;
90 }
91
92
93 /**
94 * Sets the expandAll
95 *
96 * @param bool $expandAll
97 * @return void
98 */
99 public function setExpandAll($expandAll) {
100 $this->expandAll = $expandAll;
101 }
102
103 /**
104 * Gets the expamdAll
105 *
106 * @return bool
107 */
108 public function getExpandAll() {
109 return $this->expandAll;
110 }
111
112 /**
113 * Sets the levelMaximum
114 *
115 * @param int $levelMaximum
116 * @return void
117 */
118 public function setLevelMaximum($levelMaximum) {
119 $this->levelMaximum = $levelMaximum;
120 }
121
122 /**
123 * Gets the levelMaximum
124 *
125 * @return int
126 */
127 public function getLevelMaximum() {
128 return $this->levelMaximum;
129 }
130
131 /**
132 * Gets the expanded state of a given node
133 *
134 * @param t3lib_tree_AbstractNode $node
135 * @return bool
136 */
137 protected function isExpanded(t3lib_tree_Node $node) {
138 return $this->getExpandAll() || t3lib_div::inList($this->expandedList, $node->getId());
139 }
140
141
142 /**
143 * Sets the list for expanded nodes
144 *
145 * @param string $expandedList
146 * @return void
147 */
148 public function setExpandedList($expandedList) {
149 $this->expandedList = $expandedList;
150 }
151
152 /**
153 * Gets the list for expanded nodes
154 *
155 * @return string
156 */
157 public function getExpandedList() {
158 return $this->expandedList;
159 }
160
161 /**
162 * Read the list for expanded nodes from user settings
163 *
164 * @return void
165 */
166 public function initializeTreeData() {
167 $this->expandedList = $GLOBALS['BE_USER']->uc['tcaTrees'][$this->treeId];
168 }
169
170 /**
171 * Sets the list for selected nodes
172 *
173 * @param $selectedList
174 * @return void
175 */
176 public function setSelectedList($selectedList) {
177 $this->selectedList = $selectedList;
178 }
179
180 /**
181 * Gets the list for selected nodes
182 *
183 * @return string
184 */
185 public function getSelectedList() {
186 return $this->selectedList;
187 }
188
189 /**
190 * Sets the list for non selectabal tree levels
191 *
192 * @param $nonSelectableLevelList
193 * @return void
194 */
195 public function setNonSelectableLevelList($nonSelectableLevelList) {
196 $this->nonSelectableLevelList = $nonSelectableLevelList;
197 }
198
199 /**
200 * Gets the list for non selectabal tree levels
201 *
202 * @return string
203 */
204 public function getNonSelectableLevelList() {
205 return $this->nonSelectableLevelList;
206 }
207
208 /**
209 * Setter for the itemWhiteList
210 *
211 * @param array $itemWhiteList
212 * @return void
213 */
214 public function setItemWhiteList(array $itemWhiteList) {
215 $this->itemWhiteList = $itemWhiteList;
216 }
217
218 /**
219 * Getter for the itemWhiteList
220 *
221 * @return array
222 */
223 public function getItemWhiteList() {
224 return $this->itemWhiteList;
225 }
226 }
227
228 ?>