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 cGuiMenu {
25:
26: public $link;
27: public $title;
28: public $tooltips;
29: public $caption;
30: public $type;
31: public $image;
32: public $alt;
33: public $actions;
34: public $imagewidth;
35: public $show;
36: protected $_marked;
37:
38: public function __construct() {
39: $this->rowmark = true;
40: $this->_marked = false;
41: }
42:
43: public function setTitle($item, $title) {
44: $this->title[$item] = $title;
45: }
46:
47: public function setTooltip($item, $tooltip) {
48: $this->tooltips[$item] = $tooltip;
49: }
50:
51: public function setRowmark($rowmark = true) {
52: $this->rowmark = $rowmark;
53: }
54:
55: public function setImage($item, $image, $maxwidth = 0) {
56: $show = '';
57:
58: $this->image[$item] = $image;
59: $this->imagewidth[$item] = $maxwidth;
60: $this->show[$item] = $show;
61: }
62:
63: public function setLink($item, $link) {
64: $this->link[$item] = $link;
65: }
66:
67: public function setActions($item, $key, $action) {
68: $this->actions[$item][$key] = $action;
69: }
70:
71: public function setMarked($item) {
72: $this->_marked = $item;
73: }
74:
75: public function render($print = true) {
76: global $cfg;
77:
78: $tpl = new cTemplate;
79:
80: $tpl->reset();
81:
82: if (is_array($this->link)) {
83: foreach ($this->link as $key => $value) {
84: if ($value != NULL) {
85: if ($this->imagewidth[$key] != 0) {
86: $value->setContent('<img border="0" alt="" src="' . $this->image[$key] . '" width="' . $this->imagewidth[$key] . '">');
87: $img = $value->render();
88: } else {
89: $value->setContent('<img border="0" alt="" src="' . $this->image[$key] . '">');
90: $img = $value->render();
91: }
92: $value->setContent($this->title[$key]);
93: $link = $value->render();
94: } else {
95: $link = $this->title[$key];
96:
97: if ($this->image[$key] != "") {
98: if ($this->imagewidth[$key] != 0) {
99: $img = '<img border="0" alt="" src="' . $this->image[$key] . '" width="' . $this->imagewidth[$key] . '">';
100: } else {
101: $img = '<img border="0" alt="" src="' . $this->image[$key] . '">';
102: }
103: } else {
104: $img = " ";
105: }
106: }
107:
108: $tpl->set('d', 'NAME', $link);
109:
110: if ($this->image[$key] == "") {
111: $tpl->set('d', 'ICON', '');
112: } else {
113: $tpl->set('d', 'ICON', $img);
114: }
115:
116: $extra = "";
117: if ($this->rowmark == true) {
118: $extra .= 'onmouseover="row.over(this)" onmouseout="row.out(this)" onclick="row.click(this)" ';
119: }
120: if ($this->_marked === $key) {
121: $extra .= "id='marked' ";
122: }
123: if ($this->tooltips[$key] != "") {
124: $extra .= "class='tooltip-north' original-title='" . $this->tooltips[$key] . "' ";
125: }
126: $tpl->set('d', 'EXTRA', $extra);
127:
128: $fullactions = "";
129: if (is_array($this->actions[$key])) {
130:
131: $fullactions = '<table border="0"><tr>';
132:
133: foreach ($this->actions[$key] as $key => $singleaction) {
134: $fullactions .= '<td nowrap="nowrap">' . $singleaction . '</td>';
135: }
136:
137: $fullactions .= '</tr></table>';
138: }
139:
140: $tpl->set('d', 'ACTIONS', $fullactions);
141: $tpl->next();
142: }
143: }
144: $rendered = $tpl->generate(cRegistry::getBackendPath() . $cfg['path']['templates'] . $cfg['templates']['generic_menu'], true);
145:
146: if ($print == true) {
147: echo $rendered;
148: } else {
149: return $rendered;
150: }
151: }
152:
153: }
154:
155: ?>