[BUGFIX] tcaTree: make own record unselectable
[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 * Contains all ids which are not allowed to be selected
76 */
77 protected $itemUnselectableList = array();
78
79 /**
80 * Sets the id of the tree
81 *
82 * @param string $treeId
83 * @return void
84 */
85 public function setTreeId($treeId) {
86 $this->treeId = $treeId;
87 }
88
89 /**
90 * Gets the id of the tree
91 * @return string
92 */
93 public function getTreeId() {
94 return $this->treeId;
95 }
96
97
98 /**
99 * Sets the expandAll
100 *
101 * @param bool $expandAll
102 * @return void
103 */
104 public function setExpandAll($expandAll) {
105 $this->expandAll = $expandAll;
106 }
107
108 /**
109 * Gets the expamdAll
110 *
111 * @return bool
112 */
113 public function getExpandAll() {
114 return $this->expandAll;
115 }
116
117 /**
118 * Sets the levelMaximum
119 *
120 * @param int $levelMaximum
121 * @return void
122 */
123 public function setLevelMaximum($levelMaximum) {
124 $this->levelMaximum = $levelMaximum;
125 }
126
127 /**
128 * Gets the levelMaximum
129 *
130 * @return int
131 */
132 public function getLevelMaximum() {
133 return $this->levelMaximum;
134 }
135
136 /**
137 * Gets the expanded state of a given node
138 *
139 * @param t3lib_tree_AbstractNode $node
140 * @return bool
141 */
142 protected function isExpanded(t3lib_tree_Node $node) {
143 return $this->getExpandAll() || t3lib_div::inList($this->expandedList, $node->getId());
144 }
145
146
147 /**
148 * Sets the list for expanded nodes
149 *
150 * @param string $expandedList
151 * @return void
152 */
153 public function setExpandedList($expandedList) {
154 $this->expandedList = $expandedList;
155 }
156
157 /**
158 * Gets the list for expanded nodes
159 *
160 * @return string
161 */
162 public function getExpandedList() {
163 return $this->expandedList;
164 }
165
166 /**
167 * Read the list for expanded nodes from user settings
168 *
169 * @return void
170 */
171 public function initializeTreeData() {
172 $this->expandedList = $GLOBALS['BE_USER']->uc['tcaTrees'][$this->treeId];
173 }
174
175 /**
176 * Sets the list for selected nodes
177 *
178 * @param $selectedList
179 * @return void
180 */
181 public function setSelectedList($selectedList) {
182 $this->selectedList = $selectedList;
183 }
184
185 /**
186 * Gets the list for selected nodes
187 *
188 * @return string
189 */
190 public function getSelectedList() {
191 return $this->selectedList;
192 }
193
194 /**
195 * Sets the list for non selectabal tree levels
196 *
197 * @param $nonSelectableLevelList
198 * @return void
199 */
200 public function setNonSelectableLevelList($nonSelectableLevelList) {
201 $this->nonSelectableLevelList = $nonSelectableLevelList;
202 }
203
204 /**
205 * Gets the list for non selectabal tree levels
206 *
207 * @return string
208 */
209 public function getNonSelectableLevelList() {
210 return $this->nonSelectableLevelList;
211 }
212
213 /**
214 * Setter for the itemWhiteList
215 *
216 * @param array $itemWhiteList
217 * @return void
218 */
219 public function setItemWhiteList(array $itemWhiteList) {
220 $this->itemWhiteList = $itemWhiteList;
221 }
222
223 /**
224 * Getter for the itemWhiteList
225 *
226 * @return array
227 */
228 public function getItemWhiteList() {
229 return $this->itemWhiteList;
230 }
231
232 /**
233 * Setter for $itemUnselectableList
234 *
235 * @param array $itemUnselectableList
236 * @return void
237 */
238 public function setItemUnselectableList(array $itemUnselectableList) {
239 $this->itemUnselectableList = $itemUnselectableList;
240 }
241
242 /**
243 * Getter for $itemUnselectableList
244 *
245 * @return array
246 */
247 public function getItemUnselectableList() {
248 return $this->itemUnselectableList;
249 }
250 }
251
252 ?>