1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: plugin_include('repository', 'custom/FrontendNavigation.php');
19:
20: 21: 22: 23: 24: 25:
26: class pApiContentAllocationComplexList extends pApiTree {
27:
28: var $idSetter = true;
29: var $load = array();
30:
31: function pApiContentAllocationComplexList ($uuid) {
32: global $cfg;
33: parent::pApiTree($uuid);
34: }
35:
36: function _buildRenderTree ($tree) {
37: global $action, $frame, $area, $sess, $idart;
38:
39: $oldIdSetter = $this->idSetter;
40: $this->idSetter = false;
41:
42: $result = '';
43:
44: $even = true;
45:
46: $levelElms = sizeof($tree);
47: $cnt = 1;
48: foreach ($tree as $item_tmp) {
49: $item = '';
50: $checked = '';
51: if (in_array($item_tmp['idpica_alloc'], $this->load)) {
52: $checked = ' checked="checked"';
53: }
54:
55: $li_closeElm = '';
56: if ($cnt == $levelElms) {
57: $li_closeElm = 'class="lastElem"';
58: }
59: $cnt++;
60:
61: $even = !$even;
62: $bgcolor = ($even) ? 'bright' : 'dark';
63:
64:
65: $item_tmp['name'] = str_replace('-', '- ', $item_tmp['name']);
66:
67: $checkbox = '<input type="checkbox" name="allocation[]" onClick="addToList(this);" ' . $checked . '" id="e'.$item_tmp['idpica_alloc'].'" value="'.$item_tmp['idpica_alloc'].'">';
68: $item = "\n<li baseClass=\"" . $bgcolor . "\" ".$li_closeElm.">" . $checkbox . " " . $item_tmp['name'];
69:
70: $result .= $item;
71:
72: if ($item_tmp['children']) {
73: $children = $this->_buildRenderTree($item_tmp['children']);
74: $result .= "\n<ul>" . $children . "</li>";
75: } else {
76: $result .= "\n</li>";
77: }
78: }
79:
80: if ($oldIdSetter === true) {
81: return "\n<ul id=\"finder\">" . $result . "\n</ul>";
82: } else {
83: return $result . "\n</ul>";
84: }
85: }
86:
87: function setChecked($load) {
88: $this->load = $load;
89: }
90:
91: function renderTree ($return = true) {
92: $tree = $this->fetchTree();
93: if ($tree === false) {
94: return false;
95: }
96:
97: $tree = $this->_buildRenderTree($tree);
98: if ($return === true) {
99: return $tree;
100: }
101: }
102: }
103:
104: ?>