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