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: 19: 20: 21: 22: 23:
24: class {
25:
26: 27: 28: 29:
30: public $link;
31:
32: 33: 34: 35:
36: public $title;
37:
38: 39: 40: 41:
42: public $tooltips;
43:
44: 45: 46: 47:
48: public $image;
49:
50: 51: 52: 53:
54: public $alt;
55:
56: 57: 58: 59:
60: public $actions;
61:
62: 63: 64: 65:
66: public $imagewidth;
67:
68: 69: 70: 71: 72:
73: public $caption;
74:
75: 76: 77: 78: 79:
80: public $type;
81:
82: 83: 84: 85: 86:
87: public $show;
88:
89: 90: 91: 92: 93:
94: protected $_marked = false;
95:
96: 97: 98:
99: public function __construct() {
100: $this->rowmark = true;
101: }
102:
103: 104: 105: 106: 107:
108: public function setTitle($item, $title) {
109: $this->title[$item] = $title;
110: }
111:
112: 113: 114: 115: 116:
117: public function setTooltip($item, $tooltip) {
118: $this->tooltips[$item] = $tooltip;
119: }
120:
121: 122: 123: 124:
125: public function setRowmark($rowmark = true) {
126: $this->rowmark = $rowmark;
127: }
128:
129: 130: 131: 132: 133: 134:
135: public function setImage($item, $image, $maxwidth = 0) {
136: $this->image[$item] = $image;
137: $this->imagewidth[$item] = $maxwidth;
138: $this->show[$item] = '';
139: }
140:
141: 142: 143: 144: 145:
146: public function setLink($item, $link) {
147: $this->link[$item] = $link;
148: }
149:
150: 151: 152: 153: 154: 155:
156: public function setActions($item, $key, $action) {
157: $this->actions[$item][$key] = $action;
158: }
159:
160: 161: 162: 163:
164: public function setMarked($item) {
165: $this->_marked = $item;
166: }
167:
168: 169: 170: 171: 172:
173: public function render($print = true) {
174: global $cfg;
175:
176: $tpl = new cTemplate;
177:
178: $tpl->reset();
179:
180: if (is_array($this->link)) {
181: foreach ($this->link as $key => $value) {
182: if ($value != NULL) {
183: if ($this->imagewidth[$key] != 0) {
184: $value->setContent('<img border="0" alt="" src="' . $this->image[$key] . '" width="' . $this->imagewidth[$key] . '">');
185: $img = $value->render();
186: } else {
187: $value->setContent('<img border="0" alt="" src="' . $this->image[$key] . '">');
188: $img = $value->render();
189: }
190: $value->setContent($this->title[$key]);
191: $link = $value->render();
192: } else {
193: $link = $this->title[$key];
194:
195: if ($this->image[$key] != "") {
196: if ($this->imagewidth[$key] != 0) {
197: $img = '<img border="0" alt="" src="' . $this->image[$key] . '" width="' . $this->imagewidth[$key] . '">';
198: } else {
199: $img = '<img border="0" alt="" src="' . $this->image[$key] . '">';
200: }
201: } else {
202: $img = " ";
203: }
204: }
205:
206: $tpl->set('d', 'NAME', $link);
207:
208: if ($this->image[$key] == "") {
209: $tpl->set('d', 'ICON', '');
210: } else {
211: $tpl->set('d', 'ICON', $img);
212: }
213:
214: $extra = "";
215: if ($this->rowmark == true) {
216: $extra .= 'onmouseover="row.over(this)" onmouseout="row.out(this)" onclick="row.click(this)" ';
217: }
218: if ($this->_marked === $key) {
219: $extra .= "id='marked' ";
220: }
221: if ($this->tooltips[$key] != "") {
222: $extra .= "class='tooltip-north' original-title='" . $this->tooltips[$key] . "' ";
223: }
224: $tpl->set('d', 'EXTRA', $extra);
225:
226: $fullactions = "";
227: if (is_array($this->actions[$key])) {
228:
229: $fullactions = '<table border="0"><tr>';
230:
231: foreach ($this->actions[$key] as $key => $singleaction) {
232: $fullactions .= '<td nowrap="nowrap">' . $singleaction . '</td>';
233: }
234:
235: $fullactions .= '</tr></table>';
236: }
237:
238: $tpl->set('d', 'ACTIONS', $fullactions);
239: $tpl->next();
240: }
241: }
242: $rendered = $tpl->generate(cRegistry::getBackendPath() . $cfg['path']['templates'] . $cfg['templates']['generic_menu'], true);
243:
244: if ($print == true) {
245: echo $rendered;
246: } else {
247: return $rendered;
248: }
249: }
250:
251: }
252: