Files
@ f43d1a4680a9
Branch filter:
Location: hot67beta/administrator/modules/mod_menu/helper.php
f43d1a4680a9
10.3 KiB
text/x-php
menubar 0 to 10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | <?php
/**
* @version $Id:mod_menu.php 2463 2006-02-18 06:05:38Z webImagery $
* @package Joomla
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
require_once(dirname(__FILE__).DS.'menu.php');
class modMenuHelper
{
/**
* Show the menu
* @param string The current user type
*/
function buildMenu()
{
global $mainframe;
$lang = & JFactory::getLanguage();
$user = & JFactory::getUser();
$db = & JFactory::getDBO();
$usertype = $user->get('usertype');
// cache some acl checks
$canCheckin = $user->authorize('com_checkin', 'manage');
$canConfig = $user->authorize('com_config', 'manage');
$manageTemplates = $user->authorize('com_templates', 'manage');
$manageTrash = $user->authorize('com_trash', 'manage');
$manageMenuMan = $user->authorize('com_menus', 'manage');
$manageLanguages = $user->authorize('com_languages', 'manage');
$installModules = $user->authorize('com_installer', 'module');
$editAllModules = $user->authorize('com_modules', 'manage');
$installPlugins = $user->authorize('com_installer', 'plugin');
$editAllPlugins = $user->authorize('com_plugins', 'manage');
$installComponents = $user->authorize('com_installer', 'component');
$editAllComponents = $user->authorize('com_components', 'manage');
$canMassMail = $user->authorize('com_massmail', 'manage');
$canManageUsers = $user->authorize('com_users', 'manage');
// Menu Types
require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_menus'.DS.'helpers'.DS.'helper.php' );
$menuTypes = MenusHelper::getMenuTypelist();
/*
* Get the menu object
*/
$menu = new JAdminCSSMenu();
/*
* Site SubMenu
*/
$menu->addChild(new JMenuNode(JText::_('Site')), true);
$menu->addChild(new JMenuNode(JText::_('Control Panel'), 'index.php', 'class:cpanel'));
$menu->addSeparator();
if ($canManageUsers) {
$menu->addChild(new JMenuNode(JText::_('User Manager'), 'index.php?option=com_users&task=view', 'class:user'));
}
$menu->addChild(new JMenuNode(JText::_('Media Manager'), 'index.php?option=com_media', 'class:media'));
$menu->addSeparator();
if ($canConfig) {
$menu->addChild(new JMenuNode(JText::_('Configuration'), 'index.php?option=com_config', 'class:config'));
$menu->addSeparator();
}
$menu->addChild(new JMenuNode(JText::_('Logout'), 'index.php?option=com_login&task=logout', 'class:logout'));
$menu->getParent();
/*
* Menus SubMenu
*/
$menu->addChild(new JMenuNode(JText::_('Menus')), true);
if ($manageMenuMan) {
$menu->addChild(new JMenuNode(JText::_('Menu Manager'), 'index.php?option=com_menus', 'class:menu'));
}
if ($manageTrash) {
$menu->addChild(new JMenuNode(JText::_('Menu Trash'), 'index.php?option=com_trash&task=viewMenu', 'class:trash'));
}
if($manageTrash || $manageMenuMan) {
$menu->addSeparator();
}
/*
* SPLIT HR
*/
if (count($menuTypes)) {
foreach ($menuTypes as $menuType) {
$menu->addChild(new JMenuNode($menuType->title.($menuType->home ? ' *' : ''), 'index.php?option=com_menus&task=view&menutype='.$menuType->menutype, 'class:menu'));
}
}
$menu->getParent();
/*
* Content SubMenu
*/
$menu->addChild(new JMenuNode(JText::_('Content')), true);
$menu->addChild(new JMenuNode(JText::_('Article Manager'), 'index.php?option=com_content', 'class:article'));
if ($manageTrash) {
$menu->addChild(new JMenuNode(JText::_('Article Trash'), 'index.php?option=com_trash&task=viewContent', 'class:trash'));
}
$menu->addSeparator();
$menu->addChild(new JMenuNode(JText::_('Section Manager'), 'index.php?option=com_sections&scope=content', 'class:section'));
$menu->addChild(new JMenuNode(JText::_('Category Manager'), 'index.php?option=com_categories§ion=com_content', 'class:category'));
$menu->addSeparator();
$menu->addChild(new JMenuNode(JText::_('Frontpage Manager'), 'index.php?option=com_frontpage', 'class:frontpage'));
$menu->getParent();
/*
* Components SubMenu
*/
if ($editAllComponents)
{
$menu->addChild(new JMenuNode(JText::_('Components')), true);
$query = 'SELECT *' .
' FROM #__components' .
' WHERE '.$db->NameQuote( 'option' ).' <> "com_frontpage"' .
' AND '.$db->NameQuote( 'option' ).' <> "com_media"' .
' AND enabled = 1' .
' ORDER BY ordering, name';
$db->setQuery($query);
$comps = $db->loadObjectList(); // component list
$subs = array(); // sub menus
$langs = array(); // additional language files to load
// first pass to collect sub-menu items
foreach ($comps as $row)
{
if ($row->parent)
{
if (!array_key_exists($row->parent, $subs)) {
$subs[$row->parent] = array ();
}
$subs[$row->parent][] = $row;
$langs[$row->option.'.menu'] = true;
} elseif (trim($row->admin_menu_link)) {
$langs[$row->option.'.menu'] = true;
}
}
// Load additional language files
if (array_key_exists('.menu', $langs)) {
unset($langs['.menu']);
}
foreach ($langs as $lang_name => $nothing) {
$lang->load($lang_name);
}
foreach ($comps as $row)
{
if ($editAllComponents | $user->authorize('administration', 'edit', 'components', $row->option))
{
if ($row->parent == 0 && (trim($row->admin_menu_link) || array_key_exists($row->id, $subs)))
{
$text = $lang->hasKey($row->option) ? JText::_($row->option) : $row->name;
$link = $row->admin_menu_link ? "index.php?$row->admin_menu_link" : "index.php?option=$row->option";
if (array_key_exists($row->id, $subs)) {
$menu->addChild(new JMenuNode($text, $link, $row->admin_menu_img), true);
foreach ($subs[$row->id] as $sub) {
$key = $row->option.'.'.$sub->name;
$text = $lang->hasKey($key) ? JText::_($key) : $sub->name;
$link = $sub->admin_menu_link ? "index.php?$sub->admin_menu_link" : null;
$menu->addChild(new JMenuNode($text, $link, $sub->admin_menu_img));
}
$menu->getParent();
} else {
$menu->addChild(new JMenuNode($text, $link, $row->admin_menu_img));
}
}
}
}
$menu->getParent();
}
/*
* Extensions SubMenu
*/
if ($installModules)
{
$menu->addChild(new JMenuNode(JText::_('Extensions')), true);
$menu->addChild(new JMenuNode(JText::_('Install/Uninstall'), 'index.php?option=com_installer', 'class:install'));
$menu->addSeparator();
if ($editAllModules) {
$menu->addChild(new JMenuNode(JText::_('Module Manager'), 'index.php?option=com_modules', 'class:module'));
}
if ($editAllPlugins) {
$menu->addChild(new JMenuNode(JText::_('Plugin Manager'), 'index.php?option=com_plugins', 'class:plugin'));
}
if ($manageTemplates) {
$menu->addChild(new JMenuNode(JText::_('Template Manager'), 'index.php?option=com_templates', 'class:themes'));
}
if ($manageLanguages) {
$menu->addChild(new JMenuNode(JText::_('Language Manager'), 'index.php?option=com_languages', 'class:language'));
}
$menu->getParent();
}
/*
* System SubMenu
*/
if ($canConfig || $canCheckin)
{
$menu->addChild(new JMenuNode(JText::_('Tools')), true);
if ($canConfig) {
$menu->addChild(new JMenuNode(JText::_('Read Messages'), 'index.php?option=com_messages', 'class:messages'));
$menu->addChild(new JMenuNode(JText::_('Write Message'), 'index.php?option=com_messages&task=add', 'class:messages'));
$menu->addSeparator();
}
if ($canMassMail) {
$menu->addChild(new JMenuNode(JText::_('Mass Mail'), 'index.php?option=com_massmail', 'class:massmail'));
$menu->addSeparator();
}
if ($canCheckin) {
$menu->addChild(new JMenuNode(JText::_('Global Checkin'), 'index.php?option=com_checkin', 'class:checkin'));
$menu->addSeparator();
}
$menu->addChild(new JMenuNode(JText::_('Clean Cache'), 'index.php?option=com_cache', 'class:config'));
$menu->addChild(new JMenuNode(JText::_('Purge Expired Cache'), 'index.php?option=com_cache&task=purgeadmin', 'class:config'));
$menu->getParent();
}
/*
* Help SubMenu
*/
$menu->addChild(new JMenuNode(JText::_('Help')), true);
$menu->addChild(new JMenuNode(JText::_('Joomla! Help'), 'index.php?option=com_admin&task=help', 'class:help'));
$menu->addChild(new JMenuNode(JText::_('System Info'), 'index.php?option=com_admin&task=sysinfo', 'class:info'));
$menu->getParent();
$menu->renderMenu('menu', '');
}
/**
* Show an disbaled version of the menu, used in edit pages
*
* @param string The current user type
*/
function buildDisabledMenu()
{
$lang =& JFactory::getLanguage();
$user =& JFactory::getUser();
$usertype = $user->get('usertype');
$canConfig = $user->authorize('com_config', 'manage');
$installModules = $user->authorize('com_installer', 'module');
$editAllModules = $user->authorize('com_modules', 'manage');
$installPlugins = $user->authorize('com_installer', 'plugin');
$editAllPlugins = $user->authorize('com_plugins', 'manage');
$installComponents = $user->authorize('com_installer', 'component');
$editAllComponents = $user->authorize('com_components', 'manage');
$canMassMail = $user->authorize('com_massmail', 'manage');
$canManageUsers = $user->authorize('com_users', 'manage');
$text = JText::_('Menu inactive for this Page', true);
// Get the menu object
$menu = new JAdminCSSMenu();
// Site SubMenu
$menu->addChild(new JMenuNode(JText::_('Site'), null, 'disabled'));
// Menus SubMenu
$menu->addChild(new JMenuNode(JText::_('Menus'), null, 'disabled'));
// Content SubMenu
$menu->addChild(new JMenuNode(JText::_('Content'), null, 'disabled'));
// Components SubMenu
if ($installComponents) {
$menu->addChild(new JMenuNode(JText::_('Components'), null, 'disabled'));
}
// Extensions SubMenu
if ($installModules) {
$menu->addChild(new JMenuNode(JText::_('Extensions'), null, 'disabled'));
}
// System SubMenu
if ($canConfig) {
$menu->addChild(new JMenuNode(JText::_('Tools'), null, 'disabled'));
}
// Help SubMenu
$menu->addChild(new JMenuNode(JText::_('Help'), null, 'disabled'));
$menu->renderMenu('menu', 'disabled');
}
}
?>
|