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