65 public function __construct(&$objectArr, $myId, $parentId, $rootId = null)
67 $this->_objects = $objectArr;
69 $this->_parentId = $parentId;
71 $this->_rootId = $rootId;
84 foreach ($this->_objects as $object) {
85 $key1 = $object->getVar($this->_myId);
86 $this->_tree[$key1][
'obj'] = $object;
87 $key2 = $object->getVar($this->_parentId);
88 $this->_tree[$key1][
'parent'] = $key2;
89 $this->_tree[$key2][
'child'][] = $key1;
90 if (isset($this->_rootId)) {
91 $this->_tree[$key1][
'root'] = $object->getVar($this->_rootId);
114 return $this->_tree[$key][
'obj'];
126 if (isset($this->_tree[$key][
'child'])) {
127 foreach ($this->_tree[$key][
'child'] as $childkey) {
128 $ret[$childkey] = $this->_tree[$childkey][
'obj'];
143 if (isset($this->_tree[$key][
'child'])) {
144 foreach ($this->_tree[$key][
'child'] as $childkey) {
145 $ret[$childkey] = $this->_tree[$childkey][
'obj'];
147 foreach (array_keys($children) as $newkey) {
148 $ret[$newkey] = $children[$newkey];
166 if (isset($this->_tree[$key][
'parent']) && isset($this->_tree[$this->_tree[$key][
'parent']][
'obj'])) {
167 $ret[$uplevel] = $this->_tree[$this->_tree[$key][
'parent']][
'obj'];
168 $parents = $this->
getAllParent($this->_tree[$key][
'parent'], $ret, $uplevel + 1);
169 foreach (array_keys($parents) as $newkey) {
170 $ret[$newkey] = $parents[$newkey];
189 private function _makeSelBoxOptions($fieldName, $selected, $key, &$ret, $prefix_orig, $prefix_curr =
'')
193 $object = $this->_tree[$key][
'obj'];
194 $value = $object->getVar($this->_myId);
195 $ret .=
'<option value="' . $value .
'"';
196 if ($value == $selected) {
197 $ret .=
' selected="selected"';
199 $ret .=
'>' . $prefix_curr . $object->getVar($fieldName) .
'</option>';
200 $prefix_curr .= $prefix_orig;
202 if (isset($this->_tree[$key][
'child']) && !empty($this->_tree[$key][
'child'])) {
203 foreach ($this->_tree[$key][
'child'] as $childkey) {
204 $this->
_makeSelBoxOptions($fieldName, $selected, $childkey, $ret, $prefix_orig, $prefix_curr);
222 public function makeSelBox(
$name, $fieldName, $prefix =
'-', $selected =
'', $addEmptyOption =
false, $key = 0, $extra =
'')
224 $ret =
'<select name="' .
$name .
'" id="' .
$name .
'" ' . $extra .
'>';
225 if (
false != $addEmptyOption) {
226 $ret .=
'<option value="0"></option>';
229 return $ret .
'</select>';
260 $value = $this->_tree[$key][
'obj']->getVar( $this->_myId );
261 $ret[$value] = $prefix_curr . $this->_tree[$key][
'obj']->getVar( $fieldName );
262 $prefix_curr .= $prefix_orig;
265 if ( isset( $this->_tree[$key][
'child'] ) && !empty( $this->_tree[$key][
'child'] ) ) {
266 foreach ( $this->_tree[$key][
'child'] as $childkey ) {
_makeArrayTreeOptions($fieldName, $key, &$ret, $prefix_orig, $prefix_curr= '')
getAllChild($key, $ret=array())
makeArrayTree($fieldName, $prefix= '-', $key=0)
getAllParent($key, $ret=array(), $uplevel=1)
__construct(&$objectArr, $myId, $parentId, $rootId=null)
_makeSelBoxOptions($fieldName, $selected, $key, &$ret, $prefix_orig, $prefix_curr= '')
makeSelBox($name, $fieldName, $prefix= '-', $selected= '', $addEmptyOption=false, $key=0, $extra= '')