20 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
50 $this->_objects = &$objectArr;
52 $this->_parentId = $parentId;
53 if ( isset( $rootId ) ) {
54 $this->_rootId = $rootId;
65 foreach ( array_keys( $this->_objects ) as
$i ) {
66 $key1 = $this->_objects[
$i]->getVar( $this->_myId );
67 $this->_tree[$key1][
'obj'] = &$this->_objects[
$i];
68 $key2 = $this->_objects[
$i]->getVar( $this->_parentId );
69 $this->_tree[$key1][
'parent'] = $key2;
70 $this->_tree[$key2][
'child'][] = $key1;
71 if ( isset( $this->_rootId ) ) {
72 $this->_tree[$key1][
'root'] = $this->_objects[
$i]->getVar( $this->_rootId );
93 return $this->_tree[$key][
'obj'];
104 if ( isset( $this->_tree[$key][
'child'] ) ) {
105 foreach ( $this->_tree[$key][
'child'] as $childkey ) {
106 $ret[$childkey] = &$this->_tree[$childkey][
'obj'];
120 if ( isset( $this->_tree[$key][
'child'] ) ) {
121 foreach ( $this->_tree[$key][
'child'] as $childkey ) {
122 $ret[$childkey] = &$this->_tree[$childkey][
'obj'];
123 $children = &$this->getAllChild( $childkey,
$ret );
124 foreach ( array_keys( $children ) as $newkey ) {
125 $ret[$newkey] = &$children[$newkey];
142 if ( isset( $this->_tree[$key][
'parent'] ) && isset( $this->_tree[$this->_tree[$key][
'parent']][
'obj'] ) ) {
143 $ret[$uplevel] = &$this->_tree[$this->_tree[$key][
'parent']][
'obj'];
144 $parents = &$this->getAllParent( $this->_tree[$key][
'parent'],
$ret, $uplevel + 1 );
145 foreach ( array_keys( $parents ) as $newkey ) {
146 $ret[$newkey] = &$parents[$newkey];
167 $value = $this->_tree[$key][
'obj']->getVar( $this->_myId );
168 $ret .=
'<option value="' . $value .
'"';
169 if ( $value == $selected ) {
170 $ret .=
' selected="selected"';
172 $ret .=
'>' . $prefix_curr . $this->_tree[$key][
'obj']->getVar( $fieldName ) .
'</option>';
173 $prefix_curr .= $prefix_orig;
175 if ( isset( $this->_tree[$key][
'child'] ) && !empty( $this->_tree[$key][
'child'] ) ) {
176 foreach ( $this->_tree[$key][
'child'] as $childkey ) {
177 $this->_makeSelBoxOptions( $fieldName, $selected, $childkey,
$ret, $prefix_orig, $prefix_curr );
194 function makeSelBox( $name, $fieldName, $prefix =
'-', $selected =
'', $addEmptyOption =
false, $key = 0, $extra =
'' ) {
195 $ret =
'<select name="' . $name .
'" id="' . $name .
'" ' . $extra .
'>';
196 if (
false != $addEmptyOption ) {
197 $ret .=
'<option value="0"></option>';
199 $this->_makeSelBoxOptions( $fieldName, $selected, $key,
$ret, $prefix );
200 return $ret .
'</select>';