1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
17:
18:
19:
20: 21: 22:
23: class SystemMenuHandler
24: {
25: 26: 27: 28:
29: public $_menutop = array();
30: public $_menutabs = array();
31: public $_obj;
32: public $_header;
33: public $_subheader;
34:
35: 36: 37:
38: public function __construct()
39: {
40: global $xoopsModule;
41: $this->_obj = $xoopsModule;
42: }
43:
44: 45: 46:
47: public function getAddon($addon)
48: {
49: $this->_obj =& $addon;
50: }
51:
52: 53: 54: 55:
56: public function addMenuTop($value, $name = '')
57: {
58: if ($name !== '') {
59: $this->_menutop[$value] = $name;
60: } else {
61: $this->_menutop[$value] = $value;
62: }
63: }
64:
65: 66: 67: 68:
69: public function addMenuTopArray($options, $multi = true)
70: {
71: if (is_array($options)) {
72: if ($multi === true) {
73: foreach ($options as $k => $v) {
74: $this->addOptionTop($k, $v);
75: }
76: } else {
77: foreach ($options as $k) {
78: $this->addOptiontop($k, $k);
79: }
80: }
81: }
82: }
83:
84: 85: 86: 87:
88: public function addMenuTabs($value, $name = '')
89: {
90: if ($name !== '') {
91: $this->_menutabs[$value] = $name;
92: } else {
93: $this->_menutabs[$value] = $value;
94: }
95: }
96:
97: 98: 99: 100:
101: public function addMenuTabsArray($options, $multi = true)
102: {
103: if (is_array($options)) {
104: if ($multi === true) {
105: foreach ($options as $k => $v) {
106: $this->addMenuTabsTop($k, $v);
107: }
108: } else {
109: foreach ($options as $k) {
110: $this->addMenuTabsTop($k, $k);
111: }
112: }
113: }
114: }
115:
116: 117: 118:
119: public function addHeader($value)
120: {
121: $this->_header = $value;
122: }
123:
124: 125: 126:
127: public function addSubHeader($value)
128: {
129: $this->_subheader = $value;
130: }
131:
132: 133: 134: 135: 136:
137: public function breadcrumb_nav($basename = 'Home')
138: {
139: global $bc_site, $bc_label;
140: $site = $bc_site;
141: $return_str = "<a href=\"/\">$basename</a>";
142: $str = substr(dirname(xoops_getenv('PHP_SELF')), 1);
143:
144: $arr = explode('/', $str);
145: $num = count($arr);
146:
147: if ($num > 1) {
148: foreach ($arr as $val) {
149: $return_str .= ' > <a href="' . $site . $val . '/">' . $bc_label[$val] . '</a>';
150: $site .= $val . '/';
151: }
152: } elseif ($num == 1) {
153: $arr = $str;
154: $return_str .= ' > <a href="' . $bc_site . $arr . '/">' . $bc_label[$arr] . '</a>';
155: }
156:
157: return $return_str;
158: }
159:
160: 161: 162: 163: 164: 165:
166: public function render($currentoption = 1, $display = true)
167: {
168: global $modversion;
169: $_dirname = $this->_obj->getVar('dirname');
170: $i = 0;
171:
172: 173: 174:
175: foreach ($this->_menutabs as $k => $menus) {
176: $menuItems[] = $menus;
177: }
178: $breadcrumb = $menuItems[$currentoption];
179: $menuItems[$currentoption] = 'current';
180: $menu = "<div id='buttontop_mod'>";
181: $menu .= "<table style='width: 100%; padding: 0;' cellspacing='0'>\n<tr>";
182: $menu .= "<td style='font-size: 10px; text-align: left; color: #2F5376; padding: 0 6px; line-height: 18px;'>";
183: foreach ($this->_menutop as $k => $v) {
184: $menu .= " <a href=\"$k\">$v</a> |";
185: }
186: $menu = substr($menu, 0, -1);
187:
188: $menu .= '</td>';
189: $menu .= "<td style='text-align: right;'><strong>" . $this->_obj->getVar('name') . '</strong> : ' . $breadcrumb . '</td>';
190: $menu .= "</tr>\n</table>\n";
191: $menu .= "</div>\n";
192: $menu .= "<div id='buttonbar_mod'><ul>";
193: foreach ($this->_menutabs as $k => $v) {
194: $menu .= "<li id='" . $menuItems[$i] . "'><a href='" . XOOPS_URL . '/modules/' . $this->_obj->getVar('dirname') . '/' . $k . "'><span>$v</span></a></li>\n";
195: ++$i;
196: }
197: $menu .= "</ul>\n</div>\n";
198: if ($this->_header) {
199: $menu .= "<h4 class='admin_header'>";
200: if (isset($modversion['name'])) {
201: if ($modversion['image'] && $this->_obj->getVar('mid') == 1) {
202: $system_image = XOOPS_URL . '/modules/system/images/system/' . $modversion['image'];
203: } else {
204: $system_image = XOOPS_URL . '/modules/' . $_dirname . '/images/' . $modversion['image'];
205: }
206: $menu .= "<img src='$system_image' align='middle' height='32' width='32' alt='' />";
207: $menu .= ' ' . $modversion['name'] . "</h4>\n";
208: } else {
209: $menu .= ' ' . $this->_header . "</h4>\n";
210: }
211: }
212: if ($this->_subheader) {
213: $menu .= "<div class='admin_subheader'>" . $this->_subheader . "</div>\n";
214: }
215: $menu .= '<div class="clear"> </div>';
216: unset($this->_obj);
217: if ($display === true) {
218: echo $menu;
219: } else {
220: return $menu;
221: }
222:
223: return null;
224: }
225: }
226: