[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/administrator/modules/ -> mod_fullmenu.php (source)

   1  <?php
   2  /**
   3  * @package Mambo
   4  * @author Mambo Foundation Inc see README.php
   5  * @copyright (C) 2000 - 2009 Mambo Foundation Inc.
   6  * See COPYRIGHT.php for copyright notices and details.
   7  * @license GNU/GPL Version 2, see LICENSE.php
   8  *
   9  * Redistributions of files must retain the above copyright notice.
  10  *
  11  * Mambo is free software; you can redistribute it and/or
  12  * modify it under the terms of the GNU General Public License
  13  * as published by the Free Software Foundation; version 2 of the License.
  14  */
  15  
  16  /** ensure this file is being included by a parent file */
  17  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  18  
  19  /**
  20  * Full DHTML Admnistrator Menus
  21  */
  22  class mosFullAdminMenu {
  23      /**
  24      * Show the menu
  25      * @param string The current user type
  26      */
  27  	function show( $usertype='' ) {
  28          global $acl, $database;
  29          global $mosConfig_live_site, $mosConfig_enable_stats, $mosConfig_caching;
  30  
  31          // cache some acl checks
  32          $canConfig             = $acl->acl_check( 'administration', 'config', 'users', $usertype );
  33  
  34          $manageTemplates     = $acl->acl_check( 'administration', 'manage', 'users', $usertype, 'components', 'com_templates' );
  35          $manageTrash         = $acl->acl_check( 'administration', 'manage', 'users', $usertype, 'components', 'com_trash' );
  36          $manageMenuMan         = $acl->acl_check( 'administration', 'manage', 'users', $usertype, 'components', 'com_menumanager' );
  37          $manageLanguages     = $acl->acl_check( 'administration', 'manage', 'users', $usertype, 'components', 'com_languages' );
  38          $installModules     = $acl->acl_check( 'administration', 'install', 'users', $usertype, 'modules', 'all' );
  39          $editAllModules     = $acl->acl_check( 'administration', 'edit', 'users', $usertype, 'modules', 'all' );
  40          $installMambots     = $acl->acl_check( 'administration', 'install', 'users', $usertype, 'mambots', 'all' );
  41          $editAllMambots     = $acl->acl_check( 'administration', 'edit', 'users', $usertype, 'mambots', 'all' );
  42          $installComponents     = $acl->acl_check( 'administration', 'install', 'users', $usertype, 'components', 'all' );
  43          $editAllComponents     = $acl->acl_check( 'administration', 'edit', 'users', $usertype, 'components', 'all' );
  44          $canMassMail         = $acl->acl_check( 'administration', 'manage', 'users', $usertype, 'components', 'com_massmail' );
  45          $canManageUsers     = $acl->acl_check( 'administration', 'manage', 'users', $usertype, 'components', 'com_users' );
  46  
  47          $query = "SELECT a.id, a.title, a.name,"
  48          . "\nCOUNT(DISTINCT c.id) AS numcat, COUNT(DISTINCT b.id) AS numarc"
  49          . "\n FROM #__sections AS a"
  50          . "\n LEFT JOIN #__categories AS c ON c.section=a.id"
  51          . "\n LEFT JOIN #__content AS b ON b.sectionid=a.id AND b.state=-1"
  52          . "\n WHERE a.scope='content'"
  53          . "\n GROUP BY a.id"
  54          . "\n ORDER BY a.ordering"
  55          ;
  56          $database->setQuery( $query );
  57          $sections = $database->loadObjectList();
  58          $nonemptySections = 0;
  59          if ($sections) foreach ($sections as $section)
  60              if ($section->numcat > 0)
  61                  $nonemptySections++;
  62          $menuTypes = mosAdminMenus::menutypes();
  63  ?>
  64          <div id="myMenuID"></div>
  65          <script type="text/javascript">
  66          var myMenu =
  67          [
  68  <?php
  69      // Home Sub-Menu
  70  ?>            [null,'<?php echo T_('Home') ?>','index2.php',null,'<?php echo T_('Control Panel') ?>'],
  71              _cmSplit,
  72  <?php
  73      // Site Sub-Menu
  74  ?>            [null,'<?php echo T_('Site') ?>',null,null,'<?php echo T_('Site Management') ?>',
  75  <?php
  76              if ($canConfig) {
  77  ?>                ['<img src="../includes/js/ThemeOffice/config.png" />','<?php echo T_('Global Configuration') ?>','index2.php?option=com_config&hidemainmenu=1',null,'<?php echo T_('Configuration') ?>'],
  78  <?php
  79              }
  80              if ($manageLanguages) {
  81  ?>                ['<img src="../includes/js/ThemeOffice/language.png" />','<?php echo T_('Language Manager') ?>','index2.php?option=com_languages',null,'<?php echo T_('Manage languages') ?>'],
  82  <?php
  83              }
  84  ?>                ['<img src="../includes/js/ThemeOffice/media.png" />','<?php echo T_('Media Manager') ?>','index2.php?option=com_media',null,'<?php echo T_('Manage Media Files') ?>'],
  85                      ['<img src="../includes/js/ThemeOffice/preview.png" />', '<?php echo T_('Preview') ?>', null, null, '<?php echo T_('Preview') ?>',
  86                      ['<img src="../includes/js/ThemeOffice/preview.png" />','<?php echo T_('In New Window') ?>','<?php echo $mosConfig_live_site; ?>/index.php','_blank','<?php echo $mosConfig_live_site; ?>'],
  87                      ['<img src="../includes/js/ThemeOffice/preview.png" />','<?php echo T_('Inline') ?>','index2.php?option=com_admin&task=preview',null,'<?php echo $mosConfig_live_site; ?>'],
  88                      ['<img src="../includes/js/ThemeOffice/preview.png" />','<?php echo T_('Inline with Positions') ?>','index2.php?option=com_admin&task=preview2',null,'<?php echo $mosConfig_live_site; ?>'],
  89                  ],
  90                  ['<img src="../includes/js/ThemeOffice/globe1.png" />', '<?php echo T_('Statistics') ?>', null, null, '<?php echo T_('Site Statistics') ?>',
  91  <?php
  92              if ($mosConfig_enable_stats == 1) {
  93  ?>                    ['<img src="../includes/js/ThemeOffice/globe4.png" />', '<?php echo T_('Browser, OS, Domain') ?>', 'index2.php?option=com_statistics', null, '<?php echo T_('Browser, OS, Domain') ?>'],
  94                        ['<img src="../includes/js/ThemeOffice/globe3.png" />', '<?php echo T_('Page Impressions') ?>', 'index2.php?option=com_statistics&task=pageimp', null, '<?php echo T_('Page Impressions') ?>'],
  95  <?php
  96              }
  97  ?>                    ['<img src="../includes/js/ThemeOffice/search_text.png" />', '<?php echo T_('Search Text') ?>', 'index2.php?option=com_statistics&task=searches', null, '<?php echo T_('Search Text') ?>']
  98                  ],
  99  <?php
 100              if ($manageTemplates) {
 101  ?>                ['<img src="../includes/js/ThemeOffice/template.png" />','<?php echo T_('Template Manager') ?>',null,null,'<?php echo T_('Change site template') ?>',
 102                        ['<img src="../includes/js/ThemeOffice/template.png" />','<?php echo T_('Site Templates') ?>','index2.php?option=com_templates',null,'<?php echo T_('Change site template') ?>'],
 103                        ['<img src="../includes/js/ThemeOffice/template.png" />','<?php echo T_('Administrator Templates') ?>','index2.php?option=com_templates&client=admin',null,'<?php echo T_('Change admin template') ?>'],
 104                        ['<img src="../includes/js/ThemeOffice/template.png" />','<?php echo T_('Module Positions') ?>','index2.php?option=com_templates&task=positions',null,'<?php echo T_('Template positions') ?>']
 105                    ],
 106  <?php
 107              }
 108              if ($manageTrash) {
 109  ?>                ['<img src="../includes/js/ThemeOffice/trash.png" />','<?php echo T_('Trash Manager') ?>','index2.php?option=com_trash',null,'<?php echo T_('Manage Trash') ?>'],
 110  <?php
 111              }
 112              if ($canManageUsers || $canMassMail) {
 113  ?>                ['<img src="../includes/js/ThemeOffice/users.png" />','<?php echo T_('User Manager') ?>','index2.php?option=com_users&task=view',null,'<?php echo T_('Manage users') ?>'],
 114  <?php
 115                  }
 116  ?>            ],
 117  <?php
 118      // Menu Sub-Menu
 119  ?>            _cmSplit,
 120              [null,'<?php echo T_('Menu') ?>',null,null,'<?php echo T_('Menu Management') ?>',
 121  <?php
 122              if ($manageMenuMan) {
 123  ?>                ['<img src="../includes/js/ThemeOffice/menus.png" />','<?php echo T_('Menu Manager') ?>','index2.php?option=com_menumanager',null,'<?php echo T_('Menu Manager') ?>'],
 124                  _cmSplit,
 125  <?php
 126              }
 127              foreach ( $menuTypes as $menuType ) {
 128  ?>                ['<img src="../includes/js/ThemeOffice/menus.png" />','<?php echo $menuType;?>','index2.php?option=com_menus&menutype=<?php echo $menuType;?>',null,''],
 129  <?php
 130              }
 131  ?>            ],
 132              _cmSplit,
 133  <?php
 134      // Content Sub-Menu
 135  ?>            [null,'<?php echo T_('Content') ?>',null,null,'<?php echo T_('Content Management') ?>',
 136  <?php
 137              if (count($sections) > 0) {
 138  ?>                ['<img src="../includes/js/ThemeOffice/edit.png" />','<?php echo T_('Content by Section') ?>',null,null,'<?php echo T_('Content Managers') ?>',
 139  <?php
 140                  foreach ($sections as $section) {
 141                      $txt = addslashes( $section->title ? $section->title : $section->name );
 142  ?>                    ['<img src="../includes/js/ThemeOffice/document.png" />','<?php echo $txt;?>', null, null,'<?php echo $txt;?>',
 143  <?php
 144                      if ($section->numcat) {
 145  ?>                        ['<img src="../includes/js/ThemeOffice/edit.png" />', '<?php echo $txt;?> <?php echo T_('Items') ?>', 'index2.php?option=com_content&sectionid=<?php echo $section->id;?>',null,null],
 146  <?php
 147                      }
 148  ?>                        ['<img src="../includes/js/ThemeOffice/add_section.png" />', '<?php echo T_('Add/Edit') ?> <?php echo $txt;?> <?php echo T_('Categories') ?>', 'index2.php?option=com_categories&section=<?php echo $section->id;?>',null, null],
 149  <?php
 150                      if ($section->numarc) {
 151  ?>                        ['<img src="../includes/js/ThemeOffice/backup.png" />', '<?php echo $txt;?> <?php echo T_('Archive') ?>', 'index2.php?option=com_content&task=showarchive&sectionid=<?php echo $section->id;?>',null,null],
 152  <?php
 153                      }
 154  ?>                    ],
 155  <?php
 156                  } // foreach
 157  ?>                ],
 158                  _cmSplit,
 159  <?php
 160              }
 161  ?>
 162                  ['<img src="../includes/js/ThemeOffice/edit.png" />','<?php echo T_('All Content Items') ?>','index2.php?option=com_content&sectionid=0',null,'<?php echo T_('Manage Content Items') ?>'],
 163                    ['<img src="../includes/js/ThemeOffice/edit.png" />','<?php echo T_('Static Content Manager') ?>','index2.php?option=com_typedcontent',null,'<?php echo T_('Manage Typed Content Items') ?>'],
 164                    _cmSplit,
 165                    ['<img src="../includes/js/ThemeOffice/add_section.png" />','<?php echo T_('Section Manager') ?>','index2.php?option=com_sections&scope=content',null,'<?php echo T_('Manage Content Sections') ?>'],
 166  <?php
 167              if (count($sections) > 0) {
 168  ?>                ['<img src="../includes/js/ThemeOffice/add_section.png" />','<?php echo T_('Category Manager') ?>','index2.php?option=com_categories&section=content',null,'<?php echo T_('Manage Content Categories') ?>'],
 169  <?php
 170              }
 171  ?>                _cmSplit,
 172                    ['<img src="../includes/js/ThemeOffice/home.png" />','<?php echo T_('Frontpage Manager') ?>','index2.php?option=com_frontpage',null,'<?php echo T_('Manage Frontpage Items') ?>'],
 173                    ['<img src="../includes/js/ThemeOffice/edit.png" />','<?php echo T_('Archive Manager') ?>','index2.php?option=com_content&task=showarchive&sectionid=0',null,'<?php echo T_('Manage Archive Items') ?>'],
 174              ],
 175  <?php
 176      // Components Sub-Menu
 177      if ($installComponents) {
 178  ?>            _cmSplit,
 179              [null,'<?php echo T_('Components') ?>',null,null,'<?php echo T_('Component Management') ?>',
 180                  ['<img src="../includes/js/ThemeOffice/install.png" />','<?php echo T_('Review/Uninstall') ?>','index2.php?option=com_installer&element=component',null,'<?php echo T_('Install/Uninstall components') ?>'],
 181                    _cmSplit,
 182  <?php
 183          $query = "SELECT * FROM #__components WHERE name <> 'frontpage' and name <> 'media manager' ORDER BY ordering,name"
 184          ;
 185          $database->setQuery( $query );
 186          $comps = $database->loadObjectList();   // component list
 187          $subs = array();    // sub menus
 188          // first pass to collect sub-menu items
 189          foreach ($comps as $row) {
 190              if ($row->parent) {
 191                  if (!array_key_exists( $row->parent, $subs )) {
 192                      $subs[$row->parent] = array();
 193                  }
 194                  $subs[$row->parent][] = $row;
 195              }
 196          }
 197          $topLevelLimit = 19; //You can get 19 top levels on a 800x600 Resolution
 198          $topLevelCount = 0;
 199          foreach ($comps as $row) {
 200              if ($editAllComponents | $acl->acl_check( 'administration', 'edit', 'users', $usertype, 'components', $row->option )) {
 201                  if ($row->parent == 0 && (trim( $row->admin_menu_link ) || array_key_exists( $row->id, $subs ))) {
 202                      $topLevelCount++;
 203                      if ($topLevelCount > $topLevelLimit) {
 204                          continue;
 205                      }
 206                      $name = addslashes( $row->name );
 207                      $alt = addslashes( $row->admin_menu_alt );
 208                      $link = $row->admin_menu_link ? "'index2.php?$row->admin_menu_link'" : "null";
 209                      echo "\t\t\t\t['<img src=\"../includes/$row->admin_menu_img\" />','$name',$link,null,'$alt'";
 210                      if (array_key_exists( $row->id, $subs )) {
 211                          foreach ($subs[$row->id] as $sub) {
 212                              echo ",\n";
 213                              $name = addslashes( $sub->name );
 214                              $alt = addslashes( $sub->admin_menu_alt );
 215                              $link = $sub->admin_menu_link ? "'index2.php?$sub->admin_menu_link'" : "null";
 216                              echo "\t\t\t\t\t['<img src=\"../includes/$sub->admin_menu_img\" />','$name',$link,null,'$alt']";
 217                          }
 218                      }
 219                      echo "\n\t\t\t\t],\n";
 220                  }
 221              }
 222          }
 223          if ($topLevelLimit < $topLevelCount) {
 224              echo "\t\t\t\t['<img src=\"../includes/js/ThemeOffice/sections.png\" />','".T_('More Components...')."','index2.php?option=com_admin&task=listcomponents',null,'".T_('More Components')."'],\n";
 225          }
 226  ?>
 227              ],
 228  <?php
 229      // Modules Sub-Menu
 230          if ($installModules | $editAllModules) {
 231  ?>            _cmSplit,
 232              [null,'<?php echo T_('Modules') ?>',null,null,'<?php echo T_('Module Management') ?>',
 233  <?php
 234              if ($installModules) {
 235  ?>                ['<img src="../includes/js/ThemeOffice/install.png" />', '<?php echo T_('Review/Uninstall') ?>', 'index2.php?option=com_installer&element=module', null, '<?php echo T_('Install custom modules') ?>'],
 236                  _cmSplit,
 237  <?php
 238              }
 239              if ($editAllModules) {
 240  ?>                ['<img src="../includes/js/ThemeOffice/module.png" />', '<?php echo T_('Site Modules') ?>', "index2.php?option=com_modules", null, '<?php echo T_('Manage Site modules') ?>'],
 241                  ['<img src="../includes/js/ThemeOffice/module.png" />', '<?php echo T_('Administrator Modules') ?>', "index2.php?option=com_modules&client=admin", null, '<?php echo T_('Manage Administrator modules') ?>'],
 242  <?php
 243              }
 244  ?>            ],
 245  <?php
 246          } // if ($installModules | $editAllModules)
 247      } // if $installComponents
 248      // Mambots Sub-Menu
 249      if ($installMambots | $editAllMambots) {
 250  ?>            _cmSplit,
 251              [null,'<?php echo T_('Mambots') ?>',null,null,'<?php echo T_('Mambot Management') ?>',
 252  <?php
 253          if ($installMambots) {
 254  ?>                ['<img src="../includes/js/ThemeOffice/install.png" />', '<?php echo T_('Review/Uninstall') ?>', 'index2.php?option=com_installer&element=mambot', null, '<?php echo T_('Install custom mambot') ?>'],
 255                  _cmSplit,
 256  <?php
 257          }
 258          if ($editAllMambots) {
 259  ?>                ['<img src="../includes/js/ThemeOffice/module.png" />', '<?php echo T_('Site Mambots') ?>', "index2.php?option=com_mambots", null, '<?php echo T_('Manage Site Mambots') ?>'],
 260  <?php
 261          }
 262  ?>            ],
 263  <?php
 264      }
 265  ?>
 266  <?php
 267      // Installer Sub-Menu
 268      if ($installModules) {
 269  ?>            _cmSplit,
 270              [null,'<?php echo T_('Installers') ?>',null,null,'<?php echo T_('Installer List') ?>',
 271                  ['<img src="../includes/js/ThemeOffice/install.png" />','<?php echo T_('Universal') ?>','index2.php?option=com_installer&element=universal&client=admin',null,'<?php echo T_('Install Any Plugin') ?>'],
 272                  <?php //this features uses simplexml which in not support pre php 5
 273                  if (phpversion() >=5) { ?>                 
 274                  ['<img src="../includes/js/ThemeOffice/install.png" />','<?php echo T_('Add-on Packages') ?>','index2.php?option=com_installer&task=addon&element=universal&client=admin',null,'<?php echo T_('Mambo Add-on Pakcages') ?>'],
 275                  <?php } ?>
 276                  //Commenting out The Source option for now since it is not working...
 277                  /*
 278                  <?php if (ini_get('allow_url_fopen')) { ?>
 279                  ['<img src="../includes/js/ThemeOffice/install.png" />','<?php echo T_('The Source') ?>','index2.php?option=com_installer&task=thesource&element=universal&client=admin',null,'<?php echo T_('Install from The Source') ?>'],
 280                  <?php } ?>
 281                  */
 282              ],
 283  <?php
 284      } // if ($installModules)
 285      // Messages Sub-Menu
 286      if ($canConfig) {
 287  ?>            _cmSplit,
 288                [null,'<?php echo T_('Messages') ?>',null,null,'<?php echo T_('Messaging Management') ?>',
 289                    ['<img src="../includes/js/ThemeOffice/messaging_inbox.png" />','<?php echo T_('Inbox') ?>','index2.php?option=com_messages',null,'<?php echo T_('Private Messages') ?>'],
 290                    ['<img src="../includes/js/ThemeOffice/messaging_config.png" />','<?php echo T_('Configuration') ?>','index2.php?option=com_messages&task=config&hidemainmenu=1',null,'<?php echo T_('Configuration') ?>']
 291                ],
 292  <?php
 293      // System Sub-Menu
 294  ?>            _cmSplit,
 295                [null,'<?php echo T_('System') ?>',null,null,'<?php echo T_('System Management') ?>',
 296  <?php
 297            if ($canConfig) {
 298  ?>                ['<img src="../includes/js/ThemeOffice/checkin.png" />', '<?php echo T_('Global Checkin') ?>', 'index2.php?option=com_checkin', null,'<?php echo T_('Check-in all checked-out items') ?>'],
 299                  ['<img src="../includes/js/ThemeOffice/sysinfo.png" />', '<?php echo T_('System Information') ?>', 'index2.php?option=com_admin&task=sysinfo', null, '<?php echo T_('View System Information') ?>'],
 300                  <?php //this features uses simplexml which in not support pre php 5
 301                  if (phpversion() >=5) { ?> 
 302                  ['<img src="../includes/js/ThemeOffice/globe2.png" />', '<?php echo T_('Check for Updates') ?>', 'index2.php?option=com_admin&task=versioninfo', null, '<?php echo T_('Check for Updates') ?>'],
 303                  <?php } ?>
 304  <?php
 305              if ($mosConfig_caching) {
 306  ?>                ['<img src="../includes/js/ThemeOffice/config.png" />','<?php echo T_('Clean Cache') ?>','index2.php?option=com_content&task=clean_cache',null,'<?php echo T_('Clean the content items cache') ?>'],
 307  <?php
 308              }
 309          }
 310  ?>            ],
 311  <?php
 312              }
 313  ?>            _cmSplit,
 314  <?php
 315      // Help Sub-Menu
 316              if(file_exists(mamboCore::get('rootPath').'/help/mambo.whatsnew.html')){?>[null,'<?php echo T_('Help') ?>','index2.php?option=com_admin&task=help',null,null]<?php } ?>
 317          ];
 318          cmDraw ('myMenuID', myMenu, 'hbr', cmThemeOffice, 'ThemeOffice');
 319          </script>
 320  <?php
 321      }
 322  }
 323  $cache =& mosCache::getCache( 'mos_fullmenu' );
 324  
 325  mosFullAdminMenu::show( $my->usertype );
 326  //$cache->call( 'mosFullAdminMenu::show', $my->usertype );
 327  ?>