1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22: function b_legacy_mainmenu_show( $options ) {
23: $root =& XCube_Root::getSingleton();
24: $xoopsModule =& $root->mContext->mXoopsModule;
25: $xoopsUser =& $root->mController->mRoot->mContext->mXoopsUser;
26:
27: $block = array();
28: $block['_display_'] = true;
29:
30: $module_handler =& xoops_gethandler('module');
31: $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
32: $criteria->add(new Criteria('isactive', 1));
33: $criteria->add(new Criteria('weight', 0, '>'));
34: $modules =& $module_handler->getObjects($criteria, true);
35: $moduleperm_handler =& xoops_gethandler('groupperm');
36: $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
37: $read_allowed = $moduleperm_handler->getItemIds('module_read', $groups);
38: $all_links = (int)$options[0];
39: $mid = is_object($xoopsModule)?$xoopsModule->getVar('mid', 'N'):'';
40: foreach (array_keys($modules) as $i) {
41: if (in_array($i, $read_allowed)) {
42: $module = &$modules[$i];
43: $blockm = &$block['modules'][$i];
44: $blockm['name'] = $module->getVar('name');
45: $moddir = XOOPS_URL.'/modules/';
46: $moddir .= $blockm['directory'] = $module->getVar('dirname', 'N');
47: $info = $module->getInfo();
48: $sublinks =& $module->subLink();
49: if (count($sublinks)>0 && ($all_links || $i==$mid)) {
50: foreach($sublinks as $sublink){
51: $blockm['sublinks'][] = array('name' => $sublink['name'], 'url' => $moddir.'/'.$sublink['url']);
52: }
53: } else {
54: $blockm['sublinks'] = array();
55: }
56: }
57: }
58: return $block;
59: }
60:
61: function b_legacy_mainmenu_edit( $options ) {
62: $off='checked="checked"';
63: $on='';
64: if ($options[0]) {
65: $on = $off;
66: $off = '';
67: }
68: return "<div>"._MB_LEGACY_MAINMENU_EXPAND_SUB.
69: "<input type=\"radio\" name=\"options[0]\" value=\"0\" $off>"._NO.
70: " <input type=\"radio\" name=\"options[0]\" value=\"1\" $on>"._YES."</div>";
71: }
72: ?>
73: