/** * Get Page data as array * * @return array Returns an array of the page data, otherwise an empty array */ protected function _getPageAsArray($item = null) { if (empty($item)) { $item = $this->getItem(); } $baseUrl = $this->view->baseUrl(); $mdlMenu = new Model_Menu(); $page = array('active' => $this->isActive(false), 'class' => 'menuItem', 'id' => $item->id, 'label' => Digitalus_Toolbox_Page::getLabel($item), 'name' => $item->name, 'resource' => strtolower(Digitalus_Toolbox_String::replaceEmptySpace($item->name)), 'title' => Digitalus_Toolbox_Page::getLabel($item), 'uri' => $baseUrl . '/' . Digitalus_Toolbox_String::replaceEmptySpace(Digitalus_Toolbox_Page::getUrl($item)), 'visible' => $this->isVisible($item)); $subPages = array(); if ($mdlMenu->hasChildren($this->id)) { $children = $mdlMenu->getChildren($this->id); foreach ($children as $child) { $subPages[] = new Digitalus_Menu_Item(null, $child); } $page['pages'] = $subPages; } return $page; }
public function loadResources() { $front = Zend_Controller_Front::getInstance(); $ctlPaths = $front->getControllerDirectory(); //set the path to all of the modules foreach ($ctlPaths as $module => $path) { if ($module != 'public' && $module != 'front') { //clear the resource list items $resourceListItems = null; $path = str_replace('controllers', 'acl.xml', $path); //load the module resource $this->addResource(new Zend_Acl_Resource($module)); //attempt to load each acl file if (file_exists($path)) { if ($xml = @simplexml_load_file($path)) { $controllers = $xml->children(); foreach ($controllers as $controller) { $controllerName = (string) $controller->attributes()->name; $controllerActions = $controller->children(); if (count($controllerActions) > 0) { foreach ($controllerActions as $action) { //load each action separately $actionName = (string) $action; $key = $module . '_' . $controllerName . '_' . $actionName; $this->addResource(new Zend_Acl_Resource($key), $module); //add the action to the public resource list $resourceListItems[$controllerName][] = $actionName; } } else { //set the resource at the controller level $key = $module . '_' . $controllerName; $this->addResource(new Zend_Acl_Resource($key), $module); //add the controller to the public resource list $resourceListItems[$controllerName] = null; } } } else { throw new Digitalus_Acl_Exception('xml file is not valid: ' . $path); } } $this->_resourceList[$module] = $resourceListItems; } else { //load the module resource $this->addResource(new Zend_Acl_Resource($module)); $mdlPage = new Model_Page(); $pageNames = $mdlPage->getPageNamesArray(); foreach ($pageNames as $pageName) { $pageName = strtolower(Digitalus_Toolbox_String::replaceEmptySpace($pageName)); $this->_resourceList[$pageName] = $pageName; $this->addResource(new Zend_Acl_Resource($pageName), $module); } } } }