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 pApiContentAllocationArticle extends pApiTree {
27:
28: var $tpl = null;
29: var $template = '';
30:
31: var $load = array();
32:
33: function pApiContentAllocationArticle ($uuid) {
34: global $cfg;
35:
36: parent::pApiTree($uuid);
37: $this->tpl = new cTemplate;
38: $this->template = $cfg['pica']['treetemplate_article'];
39: }
40:
41: function _buildRenderTree ($tree) {
42: global $action, $frame, $area, $sess, $idart;
43:
44: $result = array();
45: foreach ($tree as $item_tmp) {
46: $item = array();
47:
48: $expandCollapseImg = 'images/spacer.gif';
49: $expandCollapse = '<img class="vAlignMiddle" src="'.$expandCollapseImg.'" border="0" width="11" height="11">';
50:
51: $item['ITEMNAME'] = $expandCollapse . ' ' . $item_tmp['name'];
52:
53: $item['ITEMINDENT'] = $item_tmp['level'] * 15 + 3;
54:
55:
56: $checked = '';
57: if (in_array($item_tmp['idpica_alloc'], $this->load)) {
58: $checked = ' checked="checked"';
59: }
60: $item['CHECKBOX'] = '<input type="checkbox" name="allocation[]" value="'.$item_tmp['idpica_alloc'].'" '.$checked.'>';
61:
62: array_push($result, $item);
63:
64: if ($item_tmp['children']) {
65: $children = $this->_buildRenderTree($item_tmp['children']);
66: $result = array_merge($result, $children);
67: }
68: }
69:
70: return $result;
71: }
72:
73: function setChecked($load) {
74: $this->load = $load;
75: }
76:
77: function renderTree ($return = true) {
78: $this->tpl->reset();
79:
80: $tree = $this->fetchTree();
81: if ($tree === false) {
82: return false;
83: }
84:
85: $tree = $this->_buildRenderTree($tree);
86:
87: $even = true;
88: foreach ($tree as $item) {
89: $even = !$even;
90: $bgcolor = ($even) ? '#FFFFFF' : '#F1F1F1';
91: $this->tpl->set('d', 'BACKGROUND_COLOR', $bgcolor);
92: foreach ($item as $key => $value) {
93: $this->tpl->set('d', $key, $value);
94: }
95: $this->tpl->next();
96: }
97:
98: $this->tpl->set('s', "CATEGORY", i18n("Category", 'content_allocation'));
99:
100: if ($return === true) {
101: return $this->tpl->generate($this->template, true);
102: } else {
103: $this->tpl->generate($this->template);
104: }
105: }
106: }
107:
108: ?>