Jeff PHP framework  0.99
Modular, extensible, OOP, MVC, lightweight php framework designed to ease the programmers in the development of web applications.
menu.php
Go to the documentation of this file.
00001 <?php
00012 require_once("menuVoice.php");
00013 
00023 class menu {
00024 
00028         public $voices;
00029 
00036         function __construct($id) {
00037 
00038                 $this->_registry = registry::instance();
00039                 $this->voices = array();
00040                 if($id=='admin') $this->initAdminMenu();
00041                 elseif($id=='main') $this->initMainMenu();
00042         }
00043 
00049         private function initAdminMenu() {
00050         
00051                 $this->voices[__("Home")] = ROOT."/";
00052                 $this->voices[__("HomeAdmin")] = ROOT.'/admin/';
00053 
00054                 // configuration
00055                 if(     
00056                         access::check('siteSettings', 1) ||
00057                         access::check('datetimeSettings', 1) ||
00058                         access::check('language', 1)
00059                 ) {
00060                         $v = array();
00061                         if(access::check('siteSettings', 1)) $v[__("AppPref")] = $this->_registry->router->linkHref('siteSettings', 'manage');
00062                         if(access::check('datetimeSettings', 1)) $v[__("DatetimePref")] = $this->_registry->router->linkHref('datetimeSettings', 'manage');
00063                         if(access::check('language', 1)) $v[__("Languages")] = $this->_registry->router->linkHref('language', 'manage'); 
00064                         $this->voices[__("Configuration")] = $v;
00065                 }
00066 
00067                 // users
00068                 if(     
00069                         access::check('user', 1) ||
00070                         access::check('group', 1) ||
00071                         access::check('privileges', 1)
00072                 ) {
00073                         $v = array();
00074                         if(access::check('user', 1)) $v[__("Users")] = $this->_registry->router->linkHref('user', 'manage');
00075                         if(access::check('group', 1)) $v[__("Groups")] = $this->_registry->router->linkHref('group', 'manage');
00076                         if(access::check('privileges', 1)) $v[__("Permissions")] = $this->_registry->router->linkHref('privilege', 'manage'); 
00077                         $this->voices[__("Users")] = $v;
00078                 }
00079 
00080                 // aspect
00081                 if(access::check('layout', 1))
00082                         $this->voices[__("Aspect")] = array(__("Layout") => $this->_registry->router->linkHref('layout', 'manage')); 
00083                 
00084                 // menu
00085                 if(access::check('menu', 1))
00086                         $this->voices[__("Menu")] = $this->_registry->router->linkHref('menu', 'manage');
00087 
00088                 $this->voices[__("Logout")] = $this->_registry->router->linkHref('logout', null);
00089                                 
00090         }
00091         
00097         private function initMainMenu() {
00098         
00099                 $where = "parent='0'";
00100                 $voices = menuVoice::get(array("where"=>"parent='0'", "order"=>"position"));
00101 
00102                 foreach($voices as $v) {
00103 
00104                         if(!$v->groups || access::hasGroup(explode(",", $v->groups))) {
00105                                 $this->voices[] = array(
00106                                         "target"=>$v->target,
00107                                         "href"=>preg_match("#^http://#", $v->url) ? $v->url : ROOT.$v->url,
00108                                         "label"=>htmlVar($v->label),
00109                                         "sub"=>$this->subVoices($v->id) 
00110                                 );
00111                         }
00112                 }
00113 
00114         }
00115         
00122         private function subVoices($id) {
00123 
00124                 $sv = array();
00125 
00126                 $svoices = menuVoice::get(array("where"=>"parent='$id'", "order"=>"position"));
00127                 foreach($svoices as $v) {
00128                         $sv[] = array(
00129                                 "target"=>$v->target,
00130                                 "href"=>preg_match("#^http://#", $v->url) ? $v->url : ROOT.$v->url,
00131                                 "label"=>htmlVar($v->label),
00132                                 "sub"=>$this->subVoices($v->id) 
00133                         );
00134                 }
00135 
00136                 return $sv;
00137         }
00138 
00139 }
00140 
00141 ?>