XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
cp_functions.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
26 {
28 
29  xoops_loadLanguage('cpanel', 'system');
30  $xoTheme->addStylesheet( XOOPS_URL . '/xoops.css');
31  $xoTheme->addStylesheet( XOOPS_URL . '/modules/system/themes/legacy/css/style.css');
32  include XOOPS_CACHE_PATH . '/adminmenu.php';
33  $moduleperm_handler =& xoops_gethandler('groupperm');
34  $admin_mids = $moduleperm_handler->getItemIds('module_admin', $xoopsUser->getGroups());
35  $xoTheme->addScript(XOOPS_URL . '/include/layersmenu.js');
36  $xoTheme->addScript('', '','
37  var thresholdY = 15; // in pixels; threshold for vertical repositioning of a layer
38  var ordinata_margin = 20; // to start the layer a bit above the mouse vertical coordinate');
39 
40  $xoTheme->addScript('', '',
41  $xoops_admin_menu_js . '
42  function moveLayers() { '. $xoops_admin_menu_ml . ' }
43  function shutdown() { ' . $xoops_admin_menu_sd . ' }
44  if (NS4) {
45  document.onmousedown = function() { shutdown(); }
46  } else {
47  document.onclick = function() { shutdown(); }
48  }');
49  foreach (array_keys($xoops_admin_menu_ft) as $adm ) {
50  if (in_array($adm, $admin_mids) ) {
51  $admin_menu['content'] = $xoops_admin_menu_ft[$adm];
52 
53  $tpl->append_by_ref( 'admin_menu', $admin_menu );
54  unset( $admin_menu );
55  }
56  }
57 }
58 
60 {
61  global $xoopsConfig, $xoopsLogger;
62 
63  include XOOPS_CACHE_PATH.'/adminmenu.php';
64  echo $xoops_admin_menu_dv;
65 }
66 
68 {
69  /************************************************************
70  * Based on:
71  * - PHP Layers Menu 1.0.7(c)2001,2002 Marco Pratesi <pratesi@telug.it>
72  * - TreeMenu 1.1 - Bjorge Dijkstra <bjorge@gmx.net>
73  ************************************************************
74  * - php code Optimized by DuGris
75  ************************************************************/
76 
77  $left = 105;
78  $top = 135;
79  $js = "";
80  $moveLayers = "";
81  $shutdown = "";
82  $firstleveltable = "";
83  $menu_layers = "";
84 
85  $module_handler =& xoops_gethandler('module');
86  $criteria = new CriteriaCompo();
87  $criteria->add(new Criteria('hasadmin', 1));
88  $criteria->add(new Criteria('isactive', 1));
89  $criteria->setSort('mid');
90  $mods = $module_handler->getObjects($criteria);
91 
92  foreach ($mods as $mod) {
93  $mid = $mod->getVar('mid');
94  $module_name = $mod->getVar('name');
95  $module_url = "\".XOOPS_URL.\"/modules/".$mod->getVar('dirname')."/".trim($mod->getInfo('adminindex'));
96  $module_img = "<img class='admin_layer_img' src='\".XOOPS_URL.\"/modules/".$mod->getVar('dirname')."/".$mod->getInfo('image')."' alt='' />";
97  $module_desc = "<strong>\"._VERSION.\":</strong> ".round($mod->getVar('version')/100 , 2)."<br /><strong>\"._DESCRIPTION.\":</strong> ".$mod->getInfo('description');
98 
99  $top = $top + 15;
100 
101  $js .= "\nfunction popUpL" . $mid . "() {\n shutdown();\n popUp('L" . $mid . "',true);}";
102  $moveLayers .= "\n setleft('L" . $mid . "'," . $left . ");\n settop('L" . $mid . "'," . $top . ");";
103  $shutdown .= "\n popUp('L" . $mid . "',false);";
104  $firstleveltable .= "$" . "xoops_admin_menu_ft[".$mid."] = \"<a href='" . $module_url . "' title='" . $module_name . "' onmouseover='moveLayerY(\\\"L" . $mid . "\\\", currentY, event) ; popUpL" . $mid . "(); ' >" . $module_img . "</a><br />\";\n";
105  $menu_layers .= "\n<div id='L" . $mid . "' style='position: absolute; visibility: hidden; z-index:1000;' >\n<table class='admin_layer' cellpadding='0' cellspacing='0'>\n<tr><th nowrap='nowrap'>" . $module_name . "</th></tr>\n<tr><td class='even' nowrap='nowrap'>";
106 
107  $adminmenu = $mod->getAdminMenu();
108 
109  if ($mod->getVar('hasnotification') || ($mod->getInfo('config') && is_array($mod->getInfo('config'))) || ($mod->getInfo('comments') && is_array($mod->getInfo('comments')))) {
110  $adminmenu[] = array('link' => '".XOOPS_URL."/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod='.$mid, 'title' => _PREFERENCES, 'absolute' => true);
111  }
112  if (count($adminmenu) != 0) {
113  $currenttarget = "";
114  foreach ( $adminmenu as $menuitem ) {
115  $menu_link = trim($menuitem['link']);
116  $menu_title = trim($menuitem['title']);
117  $menu_target = isset($menuitem['target']) ? " target='" . trim($menuitem['target']) . "'" : '';
118  if (isset($menuitem['absolute']) && $menuitem['absolute']) {
119  $menu_link = (empty($menu_link)) ? "#" : $menu_link;
120  } else {
121  $menu_link = (empty($menu_link)) ? "#" : "\".XOOPS_URL.\"/modules/".$mod->getVar('dirname')."/".$menu_link;
122  }
123 
124  $menu_layers .= "\n<img src='\".XOOPS_URL.\"/images/pointer.gif' width='8' height='8' alt='' />&nbsp;<a href='" . $menu_link . "'" . $menu_target ." onmouseover='popUpL" . $mid . "' >" .$menu_title. "</a><br />\n";
125  }
126  }
127 
128  $menu_layers .= "\n<div style='margin-top: 5px; font-size: smaller; text-align: right;'><a href='#' onmouseover='shutdown();'>["._CLOSE."]</a></div></td></tr><tr><th style='font-size: smaller; text-align: left;'>" . $module_img . "<br />" . $module_desc . "</th></tr></table></div>\n";
129  }
130 
131  $menu_layers .= "\n<script language='JavaScript' type='text/javascript'>\n<!--\nmoveLayers();\nloaded = 1;\n// -->\n</script>\n";
132 
133  $content = "<"."?php\n";
134  $content .= "\$xoops_admin_menu_js = \"".$js."\n\";\n\n";
135  $content .= "\$xoops_admin_menu_ml = \"".$moveLayers."\n\";\n\n";
136  $content .= "\$xoops_admin_menu_sd = \"".$shutdown."\n\";\n\n";
137  $content .= $firstleveltable . "\n";
138  $content .= "\$xoops_admin_menu_dv = \"".$menu_layers."\";\n";
139  $content .= "\n?".">";
140 
141  return $content;
142 }
143 
145 {
146  $filename = XOOPS_CACHE_PATH.'/adminmenu.php';
147  if (!$file = fopen($filename, "w") ) {
148  echo 'failed open file';
149  return false;
150  }
151  if (fwrite($file, $content) == -1 ) {
152  echo 'failed write file';
153  return false;
154  }
155  fclose($file);
156 
157  return true;
158 }
159 ?>