Menu.php
00001 <?php
00009 class Dsao_Module_Menu
00010 {
00011 const XML_MODULE_MENU_DIR = 'modules/meta/menu/';
00012
00016 protected $_menu = array();
00017
00024 public function __construct($role = null)
00025 {
00026 $xmlLoader = new Dsao_Xml_Loader(XML_DIR.self::XML_MODULE_MENU_DIR,
00027 Dsao_Module_Broker::getInstance()->getModulesActive(true));
00028
00029
00030 foreach ($xmlLoader->getXmlObjects() as $name => $xml)
00031 {
00032 $groups = array();
00033
00034
00035 foreach ($xml->children() as $child)
00036 {
00037
00038 $label = isset($child->label) ? (string) $child->label : null;
00039
00040
00041
00042 $childArray = (array) $child;
00043
00044
00045 $groups[] = new Dsao_Module_Menu_Group($label, (array) $childArray['uri']);
00046 }
00047
00048 $this->_menu[$name] = $groups;
00049 }
00050
00051
00052 if (null != $role)
00053 {
00054 $filter = new Dsao_Filter_Acl
00055 ((string) $role, Dsao_Registry::get('acl'));
00056
00057 $this->_menu = $filter->filter($this->_menu);
00058 }
00059
00060
00061 ksort($this->_menu);
00062 }
00063
00070 public function getModuleMenu($name)
00071 {
00072 $name = (string) $name;
00073
00074
00075 return (isset($this->_menu[$name]) ? $this->_menu[$name] : array());
00076 }
00077
00083 public function toArray()
00084 {
00085 return $this->_menu;
00086 }
00087 }