1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
15:
16: plugin_include('repository', 'custom/FrontendNavigation.php');
17:
18: 19: 20: 21: 22: 23:
24: class pApiContentAllocationArticle extends pApiTree {
25:
26: 27: 28:
29: protected $_tpl = null;
30:
31: 32: 33:
34: protected $_template = '';
35:
36: 37: 38:
39: protected $_load = array();
40:
41: 42: 43: 44: 45:
46: public function __construct($uuid) {
47: $cfg = cRegistry::getConfig();
48:
49: parent::__construct($uuid);
50: $this->_tpl = new cTemplate();
51: $this->_template = $cfg['pica']['treetemplate_article'];
52: }
53:
54: 55: 56: 57: 58: 59: 60:
61: public function pApiContentAllocationArticle($uuid) {
62: cDeprecated('This method is deprecated and is not needed any longer. Please use __construct() as constructor function.');
63: return $this->__construct($uuid);
64: }
65:
66: 67: 68: 69: 70: 71:
72: protected function _buildRenderTree($tree) {
73:
74: $result = array();
75: foreach ($tree as $item_tmp) {
76: $item = array();
77:
78: $expandCollapseImg = 'images/spacer.gif';
79: $expandCollapse = '<img class="vAlignMiddle" src="'.$expandCollapseImg.'" alt="" border="0" width="11" height="11">';
80:
81: $item['ITEMNAME'] = $expandCollapse . ' ' . $item_tmp['name'];
82:
83: $item['ITEMINDENT'] = $item_tmp['level'] * 15 + 3;
84:
85:
86: $checked = '';
87: if (in_array($item_tmp['idpica_alloc'], $this->_load)) {
88: $checked = ' checked="checked"';
89: }
90: $item['CHECKBOX'] = '<input type="checkbox" name="allocation[]" value="'.$item_tmp['idpica_alloc'].'" '.$checked.'>';
91:
92: array_push($result, $item);
93:
94: if ($item_tmp['children']) {
95: $children = $this->_buildRenderTree($item_tmp['children']);
96: $result = array_merge($result, $children);
97: }
98: }
99:
100: return $result;
101: }
102:
103: 104: 105: 106: 107:
108: public function setChecked($load) {
109: $this->_load = $load;
110: }
111:
112: 113: 114: 115: 116: 117:
118: function renderTree($return = true) {
119: $this->_tpl->reset();
120:
121: $tree = $this->fetchTree();
122: if ($tree === false) {
123: return false;
124: }
125:
126: $tree = $this->_buildRenderTree($tree);
127:
128: $even = true;
129: foreach ($tree as $item) {
130: $even = !$even;
131: $bgcolor = ($even) ? '#FFFFFF' : '#F1F1F1';
132: $this->_tpl->set('d', 'BACKGROUND_COLOR', $bgcolor);
133: foreach ($item as $key => $value) {
134: $this->_tpl->set('d', $key, $value);
135: }
136: $this->_tpl->next();
137: }
138:
139: $this->_tpl->set('s', "CATEGORY", i18n("Category", 'content_allocation'));
140:
141: if ($return === true) {
142: return $this->_tpl->generate($this->_template, true);
143: } else {
144: $this->_tpl->generate($this->_template);
145: }
146: }
147: }
148: ?>