Fixed bug #16605: TCA tree: sorting is not working
[Packages/TYPO3.CMS.git] / t3lib / tree / tca / class.t3lib_tree_tca_databasenode.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010 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 * Represents a node in a TCA database setup
30 *
31 * @author Steffen Ritter <info@steffen-ritter.net>
32 * @package TYPO3
33 * @subpackage t3lib_tree
34 */
35
36 class t3lib_tree_Tca_DatabaseNode extends t3lib_tree_RepresentationNode {
37
38 /**
39 * @var boolean
40 */
41 protected $selectable;
42
43 /**
44 * @var boolean
45 */
46 protected $selected = FALSE;
47
48 /**
49 * @var boolean
50 */
51 protected $expanded = TRUE;
52
53 /**
54 * @var boolean
55 */
56 protected $hasChildren = FALSE;
57
58 /**
59 * @var mixed
60 */
61 private $sortValue;
62
63 /**
64 * Sets the expand state
65 *
66 * @param $expanded
67 * @return void
68 */
69 public function setExpanded($expanded) {
70 $this->expanded = $expanded;
71 }
72
73 /**
74 * Gets the expand state
75 *
76 * @return bool
77 */
78 public function getExpanded() {
79 return $this->expanded;
80 }
81
82 /**
83 * Sets the selectable property
84 *
85 * @param $selectable
86 * @return void
87 */
88 public function setSelectable($selectable) {
89 $this->selectable = $selectable;
90 }
91
92 /**
93 * Gets the selectable property
94 *
95 * @return bool
96 */
97 public function getSelectable() {
98 return $this->selectable;
99 }
100
101 /**
102 * Sets the select state
103 *
104 * @param $selected
105 * @return void
106 */
107 public function setSelected($selected) {
108 $this->selected = $selected;
109 }
110
111 /**
112 * Gets the select state
113 *
114 * @return bool
115 */
116 public function getSelected() {
117 return $this->selected;
118 }
119
120 /**
121 * Gets the hasChildren property
122 *
123 * @return bool
124 */
125 public function hasChildren() {
126 return $this->hasChildren;
127 }
128
129 /**
130 * Sets the hasChildren property
131 *
132 * @param $value
133 * @return void
134 */
135 public function setHasChildren($value) {
136 $this->hasChildren = (boolean) $value;
137 }
138
139 /**
140 * Compares a node to another one.
141 *
142 * Returns:
143 * 1 if its greater than the other one
144 * -1 if its smaller than the other one
145 * 0 if its equal
146 *
147 * @param t3lib_tree_Node $other
148 * @return int see description above
149 */
150 public function compareTo($other) {
151 if ($this->equals($other)) {
152 return 0;
153 }
154
155 return ($this->sortValue > $other->getSortValue()) ? 1 : -1;
156 }
157
158 /**
159 * Gets the sort value
160 *
161 * @return mixed
162 */
163 public function getSortValue() {
164 return $this->sortValue;
165 }
166
167 /**
168 * Sets the sort value
169 *
170 * @param mixed $sortValue
171 * @return void
172 */
173 public function setSortValue($sortValue) {
174 $this->sortValue = $sortValue;
175 }
176
177 }
178
179 ?>