コード例 #1
0
ファイル: Admin.php プロジェクト: irovast/eyedock
 function addDefaultPages()
 {
     $separator = new Am_Navigation_Admin_Item_Separator();
     $this->addPage(array('id' => 'dashboard', 'controller' => 'admin', 'label' => ___('Dashboard')));
     $this->addPage(Zend_Navigation_Page::factory(array('id' => 'users', 'uri' => '#', 'label' => ___('Users'), 'resource' => 'grid_u', 'privilege' => 'browse', 'pages' => array_merge(array(array('id' => 'users-browse', 'controller' => 'admin-users', 'label' => ___('Browse Users'), 'resource' => 'grid_u', 'privilege' => 'browse', 'class' => 'bold'), array('id' => 'users-insert', 'uri' => REL_ROOT_URL . '/admin-users?_u_a=insert', 'label' => ___('Add User'), 'resource' => 'grid_u', 'privilege' => 'insert')), !Am_Di::getInstance()->config->get('manually_approve') ? array() : array(array('id' => 'user-not-approved', 'controller' => 'admin-users', 'action' => 'not-approved', 'label' => ___('Not Approved Users'), 'resource' => 'grid_u', 'privilege' => 'browse')), array(array('id' => 'users-email', 'controller' => 'admin-email', 'label' => ___('E-Mail Users'), 'resource' => Am_Auth_Admin::PERM_EMAIL), clone $separator, array('id' => 'users-import', 'controller' => 'admin-import', 'label' => ___('Import Users'), 'resource' => Am_Auth_Admin::PERM_IMPORT))))));
     $this->addPage(array('id' => 'reports', 'uri' => '#', 'label' => ___('Reports'), 'pages' => array(array('id' => 'reports-reports', 'controller' => 'admin-reports', 'label' => ___('Reports'), 'resource' => Am_Auth_Admin::PERM_REPORT), array('id' => 'reports-payments', 'type' => 'Am_Navigation_Page_Mvc', 'controller' => 'admin-payments', 'label' => ___('Payments'), 'resource' => array('grid_payment', 'grid_invoice')))));
     $this->addPage(array('id' => 'products', 'uri' => '#', 'label' => ___('Products'), 'pages' => array_filter(array(array('id' => 'products-manage', 'controller' => 'admin-products', 'label' => ___('Manage Products'), 'resource' => 'grid_product', 'class' => 'bold'), array('id' => 'products-coupons', 'controller' => 'admin-coupons', 'label' => ___('Coupons'), 'resource' => 'grid_coupon')))));
     /**
      *  Temporary disable this menu if user is on upgrade controller in order to avoid error: 
      *  Fatal error: Class Folder contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (ResourceAbstract::getAccessType)
      *  
      *   @todo Remove this in the future;
      * 
      */
     $content_pages = array();
     if (Zend_Controller_Front::getInstance()->getRequest()->getControllerName() != 'admin-upgrade') {
         foreach (Am_Di::getInstance()->resourceAccessTable->getAccessTables() as $t) {
             $k = $t->getPageId();
             $content_pages[] = array('id' => 'content-' . $k, 'module' => 'default', 'controller' => 'admin-content', 'action' => 'index', 'label' => $t->getAccessTitle(), 'resource' => 'grid_content', 'params' => array('page_id' => $k), 'route' => 'inside-pages');
         }
     }
     $this->addPage(array('id' => 'content', 'controller' => 'admin-content', 'label' => ___('Protect Content'), 'resource' => 'grid_content', 'class' => 'bold', 'pages' => $content_pages));
     $this->addPage(array('id' => 'configuration', 'uri' => '#', 'label' => ___('Configuration'), 'pages' => array_filter(array(array('id' => 'setup', 'controller' => 'admin-setup', 'label' => ___('Setup/Configuration'), 'resource' => Am_Auth_Admin::PERM_SETUP, 'class' => 'bold'), array('id' => 'saved-form', 'controller' => 'admin-saved-form', 'label' => ___('Forms Editor'), 'resource' => @constant('Am_Auth_Admin::PERM_FORM'), 'class' => 'bold'), array('id' => 'fields', 'controller' => 'admin-fields', 'label' => ___('Add User Fields'), 'resource' => @constant('Am_Auth_Admin::PERM_ADD_USER_FIELD')), array('id' => 'email-template-layout', 'controller' => 'admin-email-template-layout', 'label' => ___('Email Layouts'), 'resource' => Am_Auth_Admin::PERM_SETUP), array('id' => 'ban', 'controller' => 'admin-ban', 'label' => ___('Blocking IP/E-Mail'), 'resource' => @constant('Am_Auth_Admin::PERM_BAN')), array('id' => 'countries', 'controller' => 'admin-countries', 'label' => ___('Countries/States'), 'resource' => @constant('Am_Auth_Admin::PERM_COUNTRY_STATE')), array('id' => 'admins', 'controller' => 'admin-admins', 'label' => ___('Admin Accounts'), 'resource' => Am_Auth_Admin::PERM_SUPER_USER), array('id' => 'change-pass', 'controller' => 'admin-change-pass', 'label' => ___('Change Password'))))));
     $this->addPage(array('id' => 'utilites', 'uri' => '#', 'label' => ___('Utilities'), 'order' => 1000, 'pages' => array_filter(array(Am_Di::getInstance()->modules->isEnabled('cc') ? null : array('id' => 'backup', 'controller' => 'admin-backup', 'label' => ___('Backup'), 'resource' => Am_Auth_Admin::PERM_BACKUP_RESTORE), Am_Di::getInstance()->modules->isEnabled('cc') ? null : array('id' => 'restore', 'controller' => 'admin-restore', 'label' => ___('Restore'), 'resource' => Am_Auth_Admin::PERM_BACKUP_RESTORE), array('id' => 'rebuild', 'controller' => 'admin-rebuild', 'label' => ___('Rebuild Db'), 'resource' => @constant('Am_Auth_Admin::PERM_REBUILD_DB')), clone $separator, array('id' => 'logs', 'type' => 'Am_Navigation_Page_Mvc', 'controller' => 'admin-logs', 'label' => ___('Logs'), 'resource' => array(@constant('Am_Auth_Admin::PERM_LOGS'), @constant('Am_Auth_Admin::PERM_LOGS_ACCESS'), @constant('Am_Auth_Admin::PERM_LOGS_INVOICE'), @constant('Am_Auth_Admin::PERM_LOGS_MAIL'), @constant('Am_Auth_Admin::PERM_LOGS_ADMIN'))), array('id' => 'info', 'controller' => 'admin-info', 'label' => ___('System Info'), 'resource' => @constant('Am_Auth_Admin::PERM_SYSTEM_INFO')), clone $separator, array('id' => 'trans-global', 'controller' => 'admin-trans-global', 'label' => ___('Edit Messages'), 'resource' => @constant('Am_Auth_Admin::PERM_TRANSLATION')), array('id' => 'clear', 'controller' => 'admin-clear', 'label' => ___('Delete Old Records'), 'resource' => @constant('Am_Auth_Admin::PERM_CLEAR')), array('id' => 'build-demo', 'controller' => 'admin-build-demo', 'label' => ___('Build Demo'), 'resource' => @constant('Am_Auth_Admin::PERM_BUILD_DEMO'))))));
     $this->addPage(array('id' => 'help', 'uri' => '#', 'label' => ___('Help & Support'), 'order' => 1001, 'pages' => array_filter(array(array('id' => 'documentation', 'uri' => 'http://www.amember.com/docs/', 'target' => '_blank', 'label' => ___('Documentation')), array('id' => 'report-bugs', 'uri' => 'http://bt.amember.com/', 'target' => '_blank', 'label' => ___('Report Bugs'))))));
     Am_Di::getInstance()->hook->call(Am_Event::ADMIN_MENU, array('menu' => $this));
     /// workaround against using the current route for generating urls
     foreach (new RecursiveIteratorIterator($this, RecursiveIteratorIterator::SELF_FIRST) as $child) {
         if ($child instanceof Zend_Navigation_Page_Mvc && $child->getRoute() === null) {
             $child->setRoute('default');
         }
     }
 }
コード例 #2
0
 public function buildAdminNav()
 {
     $identity = Zend_Auth::getInstance()->getIdentity()->toArray();
     if ($identity['role'] === 'Root') {
         $visible = false;
     } else {
         $visible = false;
     }
     $pages = array(Zend_Navigation_Page::factory(array('label' => 'Accounts', 'action' => 'index', 'controller' => 'modify', 'module' => 'accounts', 'route' => 'admin', 'id' => 'accounts', 'order' => 990, 'visible' => $visible, 'resource' => new Accounts_Model_Acl_Resource_Accounts(), 'pages' => array(Zend_Navigation_Page::factory(array('label' => 'Create Account', 'action' => 'index', 'controller' => 'create', 'module' => 'accounts', 'route' => 'admin')), Zend_Navigation_Page::factory(array('label' => 'Modify Account', 'action' => 'index', 'controller' => 'modify', 'module' => 'accounts', 'route' => 'admin'))))));
     return $pages;
 }
コード例 #3
0
 /**
  *Takes the module menus and converts them to Zend_Navigation_Page
  * @param array $sections
  * @param array $moduleMenus
  * @param array $menus
  * @return
  */
 function getModulePages($sections, $moduleMenus, &$menus)
 {
     foreach ($sections as $section) {
         if (isset($moduleMenus[$section])) {
             foreach ($moduleMenus[$section] as $title => $mvc) {
                 $mvc['label'] = $title;
                 $menus[] = Zend_Navigation_Page::factory($mvc);
             }
         }
     }
     return $menus;
 }
コード例 #4
0
ファイル: Admin.php プロジェクト: subashemphasize/test_site
 function addDefaultPages()
 {
     $separator = new Am_Navigation_Admin_Item_Separator();
     $this->addPage(array('id' => 'dashboard', 'controller' => 'admin', 'label' => ___("Dashboard")));
     $this->addPage(Zend_Navigation_Page::factory(array('id' => 'users', 'uri' => '#', 'label' => ___("Users"), 'resource' => 'grid_u', 'privilege' => 'browse', 'pages' => array_merge(array(array('id' => 'users-browse', 'controller' => 'admin-users', 'label' => ___('Browse Users'), 'resource' => 'grid_u', 'privilege' => 'browse', 'class' => 'bold'), array('id' => 'users-insert', 'uri' => REL_ROOT_URL . '/admin-users?_u_a=insert', 'label' => ___('Add User'), 'resource' => 'grid_u', 'privilege' => 'insert')), !Am_Di::getInstance()->config->get('manually_approve') ? array() : array(array('id' => 'user-not-approved', 'controller' => 'admin-users', 'action' => 'not-approved', 'label' => ___('Not Approved Users'), 'resource' => 'grid_u', 'privilege' => 'browse')), array(array('id' => 'users-email', 'controller' => 'admin-email', 'label' => ___('E-Mail Users'), 'resource' => Am_Auth_Admin::PERM_EMAIL), clone $separator, array('id' => 'users-import', 'controller' => 'admin-import', 'label' => ___('Import Users'), 'resource' => Am_Auth_Admin::PERM_IMPORT))))));
     $this->addPage(array('id' => 'reports', 'uri' => '#', 'label' => ___("Reports"), 'pages' => array(array('id' => 'reports-reports', 'controller' => 'admin-reports', 'label' => ___('Reports'), 'resource' => Am_Auth_Admin::PERM_REPORT), array('id' => 'reports-payments', 'controller' => 'admin-payments', 'label' => ___('Payments'), 'resource' => Am_Auth_Admin::PERM_REPORT))));
     $this->addPage(array('id' => 'products', 'uri' => '#', 'label' => ___('Products'), 'pages' => array_filter(array(array('id' => 'products-manage', 'controller' => 'admin-products', 'label' => ___('Manage Products'), 'resource' => 'grid_product', 'class' => 'bold'), array('id' => 'products-protect', 'controller' => 'admin-content', 'label' => ___('Protect Content'), 'resource' => 'grid_content', 'class' => 'bold'), array('id' => 'products-coupons', 'controller' => 'admin-coupons', 'label' => ___('Coupons'), 'resource' => 'grid_coupon')))));
     $this->addPage(array('id' => 'configuration', 'uri' => '#', 'label' => ___('Configuration'), 'pages' => array_filter(array(array('controller' => 'admin-setup', 'label' => ___('Setup/Configuration'), 'resource' => Am_Auth_Admin::PERM_SETUP, 'class' => 'bold'), array('controller' => 'admin-tax', 'label' => ___('Tax Settings'), 'resource' => Am_Auth_Admin::PERM_SETUP), array('controller' => 'admin-fields', 'label' => ___('Add Fields'), 'resource' => Am_Auth_Admin::PERM_SUPER_USER), array('controller' => 'admin-admins', 'label' => ___('Admin Accounts'), 'resource' => Am_Auth_Admin::PERM_SUPER_USER), array('controller' => 'admin-saved-form', 'label' => ___('Forms Editor'), 'resource' => Am_Auth_Admin::PERM_SUPER_USER), array('controller' => 'admin-ban', 'label' => ___('Blocking IP/E-Mail'), 'resource' => Am_Auth_Admin::PERM_SUPER_USER), array('controller' => 'admin-change-pass', 'label' => ___('Change Password'))))));
     $this->addPage(array('id' => 'utilites', 'uri' => '#', 'label' => ___('Utilites'), 'order' => 1000, 'pages' => array_filter(array(array('controller' => 'admin-backup', 'label' => ___('Backup'), 'resource' => Am_Auth_Admin::PERM_BACKUP_RESTORE), array('controller' => 'admin-restore', 'label' => ___('Restore'), 'resource' => Am_Auth_Admin::PERM_BACKUP_RESTORE), array('controller' => 'admin-rebuild', 'label' => ___('Rebuild Db'), 'resource' => Am_Auth_Admin::PERM_SUPER_USER), clone $separator, array('controller' => 'admin-logs', 'label' => ___('Logs'), 'resource' => Am_Auth_Admin::PERM_SUPER_USER), array('controller' => 'admin-info', 'label' => ___('Version Info'), 'resource' => Am_Auth_Admin::PERM_SUPER_USER), clone $separator, array('controller' => 'admin-clear', 'label' => ___('Delete Old Records'), 'resource' => Am_Auth_Admin::PERM_SUPER_USER), array('controller' => 'admin-build-demo', 'label' => ___('Build Demo'), 'resource' => Am_Auth_Admin::PERM_SUPER_USER)))));
     $this->addPage(array('id' => 'help', 'uri' => '#', 'label' => ___('Help & Support'), 'pages' => array_filter(array(array('uri' => 'http://www.amember.com/docs/', 'label' => ___('Documentation')), array('uri' => 'http://bt.amember.com/', 'label' => ___('Report Bugs'))))));
     Am_Di::getInstance()->hook->call(Am_Event::ADMIN_MENU, array('menu' => $this));
     /// workaround against using the current route for generating urls
     foreach (new RecursiveIteratorIterator($this, RecursiveIteratorIterator::SELF_FIRST) as $child) {
         if ($child instanceof Zend_Navigation_Page_Mvc && $child->getRoute() === null) {
             $child->setRoute('default');
         }
     }
 }
コード例 #5
0
ファイル: Sitemap.php プロジェクト: cwcw/cms
 /**
  *
  */
 public function getSitemap()
 {
     if (is_null($this->_sitemap)) {
         $options = $this->getOptions();
         $front = $this->getBootstrap()->getResource('FrontController');
         $root = dirname($front->getModuleDirectory());
         //modules directory
         $acl = $this->getBootstrap()->getResource('Acl');
         $role = $this->getBootstrap()->getPluginResource('acl')->getRole();
         try {
             $dir = new DirectoryIterator($root);
         } catch (Exception $e) {
             throw new Streamwide_Exception("Directory {$root} not readable");
         }
         $this->_sitemap = new Zend_Navigation();
         foreach ($dir as $file) {
             if ($file->isDot() || !$file->isDir()) {
                 continue;
             }
             $module = $file->getFilename();
             // Don't use SCCS directories as modules
             if (preg_match('/^[^a-z]/i', $module) || 'CVS' == $module) {
                 continue;
             }
             $controllerPath = "{$root}/{$module}/controllers";
             $controllers = $this->_getControllers($controllerPath);
             foreach ($controllers as $controller => $class) {
                 $actions = $this->_getActions($class);
                 foreach ($actions as $action) {
                     $mca = new Streamwide_Web_Acl_Resource_Mca($module, strtolower($controller), strtolower($action));
                     $all = new Streamwide_Web_Acl_Resource_Mca('*', '*', '*');
                     if ($acl->has($mca) && !$acl->isAllowed($role, $mca)) {
                         continue;
                     }
                     if (!$acl->has($mca) && !$acl->isAllowed($role, $all)) {
                         continue;
                     }
                     $this->_sitemap->addPage(Zend_Navigation_Page::factory(array("label" => "{$module}/{$controller}/{$action}", "module" => $module, "controller" => $controller, "action" => $action)));
                 }
             }
         }
     }
     return $this->_sitemap;
 }
コード例 #6
0
 public function buildAdminNav()
 {
     $pages = array(Zend_Navigation_Page::factory(array('label' => 'Resources', 'action' => 'index', 'controller' => 'index', 'module' => 'resources', 'route' => 'admin-base', 'visible' => FALSE, 'order' => 999)));
     return $pages;
 }
コード例 #7
0
ファイル: Aclplugin.php プロジェクト: swastikit/devotees
 private function menu()
 {
     //Get bootstrap
     $bootstrap = Zend_Controller_Front::getInstance()->getParam("bootstrap");
     $db = $bootstrap->getPluginResource('db')->getDbAdapter();
     $auth = Zend_Auth::getInstance();
     $authArray = $auth->getIdentity();
     $roleid = $authArray['role_id'];
     $userid = $authArray['user_id'];
     //Get The Menu Items from Database
     $select = $db->select();
     $select->from(array('sm' => 'mst_user_method'), array('submenu_id' => 'sm.id', 'submenu_name' => 'sm.name', 'submenu_url' => 'sm.url_path'))->joinLeft(array('mm' => 'mst_user_menu_main'), 'sm.menu_id = mm.id', array('mainmenu_id' => 'mm.id', 'mainmenu_name' => 'mm.name', 'mainmenu_url' => 'mm.url_path'))->where('sm.show_in_menu = ?', 'Y')->where('sm.is_active = ?', 'Y')->where('mm.is_active = ?', 'Y');
     if ($roleid != Rgm_Constants::ROLE_ADMIN) {
         $select->where('sm.id IN (?)', new Zend_Db_Expr("select mst_user_method_vs_user.method_id from mst_user_method_vs_user where user_id=" + $userid));
     }
     $select->order('mm.sort_order ASC');
     $select->order('sm.sort_order ASC');
     $stmt = $select->query();
     $menuRows = $stmt->fetchAll();
     $container = new Zend_Navigation();
     //---------Get The Active Menu And Sub Menu Item----------------
     $activeIdmm = 0;
     $activeIdsm = 0;
     $menuIdSession = new Zend_Session_Namespace();
     if (!$this->getRequest()->isXmlHttpRequest()) {
         if ($this->getRequest()->getParam('mm_id')) {
             //Main menuId
             $activeIdmm = $this->getRequest()->getParam('mm_id');
         } else {
             if (isset($menuIdSession->Active_Main_Menu_id)) {
                 $activeIdmm = $menuIdSession->Active_Main_Menu_id;
             }
         }
         if ($this->getRequest()->getParam('sm_id')) {
             //Main menuId
             $activeIdsm = $this->getRequest()->getParam('sm_id');
         } else {
             if (isset($menuIdSession->Aactive_Sub_Menu_Id)) {
                 $activeIdsm = $menuIdSession->Aactive_Sub_Menu_Id;
             }
         }
         $menuIdSession->Active_Main_Menu_id = $activeIdmm;
         $menuIdSession->Aactive_Sub_Menu_Id = $activeIdsm;
     }
     if ($menuRows) {
         $tmpMainMenuId = 0;
         $tmpMainMenuPage = null;
         $tmpSubMenuPage = null;
         $tmpActive = 0;
         foreach ($menuRows as $r) {
             if ($tmpMainMenuId != $r['mainmenu_id']) {
                 //New Main Menu Item
                 $tmpMainMenuId = $r["mainmenu_id"];
                 //Add previously created main menu page to container;
                 if ($tmpMainMenuPage != null) {
                     $container->addPage($tmpMainMenuPage);
                 }
                 if ($r["mainmenu_id"] == $activeIdmm) {
                     $tmpActive = 1;
                 } else {
                     $tmpActive = 0;
                 }
                 $tmpMainMenuPage = Zend_Navigation_Page::factory(array('id' => 'mm' . $r["mainmenu_id"], 'label' => $r["mainmenu_name"], 'uri' => $r["mainmenu_url"] == null ? "#" : $r["mainmenu_url"] . '?mm_id=' . $r["mainmenu_id"] . '&sm_id=' . $r["submenu_id"], 'active' => $tmpActive));
             }
             //Create sub menu
             if ($r["submenu_id"] == $activeIdsm) {
                 $tmpActive = 1;
             } else {
                 $tmpActive = 0;
             }
             $tmpSubMenuPage = Zend_Navigation_Page::factory(array('id' => 'sm' . $r["submenu_id"], 'label' => $r["submenu_name"], 'uri' => $r["submenu_url"] == null ? "#" : $r["submenu_url"] . '?sm_id=' . $r["submenu_id"], 'active' => $tmpActive));
             //Add it to mainMenuPage
             $tmpMainMenuPage->addPage($tmpSubMenuPage);
         }
         //Last page
         if ($tmpMainMenuPage != null) {
             $container->addPage($tmpMainMenuPage);
         }
     }
     $view = $bootstrap->bootstrap('view')->getResource('view');
     $view->navigation($container);
 }
コード例 #8
0
ファイル: Navigation.php プロジェクト: kwiliarty/Omeka
 /**
  * Normalizes a page and its subpages so it can be added
  *
  * @param  Zend_Navigation_Page|array|Zend_Config $page  Page to normalize
  * @param  $pageOptions  The options to set during normalization for every page and subpage
  * @return Omeka_Navigation_Page_Uri|Omeka_Navigation_Page_Mvc|null The normalized page
  * @throws Zend_Navigation_Exception if a page or subpage is invalid  
  */
 protected function _normalizePageRecursive($page, $pageOptions = array())
 {
     if ($page === $this) {
         require_once 'Zend/Navigation/Exception.php';
         throw new Zend_Navigation_Exception('A page cannot have itself as a parent');
     }
     // convert an array or Zend_Config to a Zend_Navigation_Page
     if (is_array($page) || $page instanceof Zend_Config) {
         require_once 'Zend/Navigation/Page.php';
         $page = Zend_Navigation_Page::factory($page);
     }
     // convert a Zend_Navigation_Page_Uri page to an Omeka_Navigation_Page_Uri page
     // or convert a Zend_Navigation_Page_Mvc page to an Omeka_Navigation_Page_Mvc page
     if (get_class($page) == 'Zend_Navigation_Page_Uri') {
         $page = $this->_convertZendToOmekaNavigationPage($page, 'Uri');
     } elseif (get_class($page) == 'Zend_Navigation_Page_Mvc') {
         $page = $this->_convertZendToOmekaNavigationPage($page, 'Mvc');
     }
     // configure Omeka_Navigation_Page_Uri or Omeka_Navigation_Page_Mvc
     if ($page instanceof Omeka_Navigation_Page_Uri) {
         $page->setHref($page->getHref());
         // sets the href, which normalizes the uri from an href
     } elseif ($page instanceof Omeka_Navigation_Page_Mvc) {
         if ($page->getRoute() === null) {
             $page->setRoute('default');
         }
     }
     if (!($page instanceof Omeka_Navigation_Page_Mvc || $page instanceof Omeka_Navigation_Page_Uri)) {
         require_once 'Zend/Navigation/Exception.php';
         throw new Zend_Navigation_Exception('Invalid argument: $page must resolve to an instance of ' . 'Omeka_Navigation_Page_Mvc or Omeka_Navigation_Page_Uri');
     }
     // set options for the page
     $page->setOptions($pageOptions);
     // set the uid
     $uid = $this->createPageUid($page->getHref());
     $page->uid = $uid;
     // normalize sub pages
     $subPages = array();
     foreach ($page->getPages() as $subPage) {
         $subPages[] = $this->_normalizePageRecursive($subPage, $pageOptions);
     }
     $page->setPages($subPages);
     return $page;
 }
コード例 #9
0
 public function buildAdminNav()
 {
     $pages = array(Zend_Navigation_Page::factory(array('label' => 'Proposals', 'action' => 'index', 'controller' => 'index', 'module' => 'proposals', 'route' => 'admin', 'id' => 'proposals', 'order' => 600, 'visible' => true, 'resource' => new Proposals_Model_Acl_Resource_Proposals(), 'pages' => array(Zend_Navigation_Page::factory(array('label' => 'View Proposal', 'action' => 'index', 'controller' => 'view', 'module' => 'proposals', 'route' => 'admin'))))));
     return $pages;
 }
コード例 #10
0
 public function buildAdminNav()
 {
     $pages = array(Zend_Navigation_Page::factory(array('label' => 'Dashboard', 'action' => 'index', 'controller' => 'index', 'module' => 'dashboard', 'route' => 'admin-base', 'order' => -10)));
     return $pages;
 }
コード例 #11
0
 /**
  * @group ZF-11805
  */
 public function testFactoryExceptionWhenNoPageTypeDetected()
 {
     // Without label
     try {
         $page = Zend_Navigation_Page::factory(array());
         $this->fail('An invalid value was set, but a ' . 'Zend_Navigation_Exception was not thrown');
     } catch (Zend_Navigation_Exception $e) {
         $this->assertSame('Invalid argument: Unable to determine class to instantiate', $e->getMessage());
     }
     // With label
     try {
         $page = Zend_Navigation_Page::factory(array('label' => 'Foo'));
         $this->fail('An invalid value was set, but a ' . 'Zend_Navigation_Exception was not thrown');
     } catch (Zend_Navigation_Exception $e) {
         $this->assertSame('Invalid argument: Unable to determine class to instantiate' . ' (Page label: Foo)', $e->getMessage());
     }
 }
コード例 #12
0
 /**
  * Adds a page to the container
  *
  * This method will inject the container as the given page's parent by
  * calling {@link Zend_Navigation_Page::setParent()}.
  *
  * @param  Zend_Navigation_Page|array|Zend_Config $page  page to add
  * @return Zend_Navigation_Container                     fluent interface,
  *                                                       returns self
  * @throws Zend_Navigation_Exception                     if page is invalid
  */
 public function addPage($page)
 {
     if ($page === $this) {
         #require_once 'Zend/Navigation/Exception.php';
         throw new Zend_Navigation_Exception('A page cannot have itself as a parent');
     }
     if (is_array($page) || $page instanceof Zend_Config) {
         #require_once 'Zend/Navigation/Page.php';
         $page = Zend_Navigation_Page::factory($page);
     } elseif (!$page instanceof Zend_Navigation_Page) {
         #require_once 'Zend/Navigation/Exception.php';
         throw new Zend_Navigation_Exception('Invalid argument: $page must be an instance of ' . 'Zend_Navigation_Page or Zend_Config, or an array');
     }
     $hash = $page->hashCode();
     if (array_key_exists($hash, $this->_index)) {
         // page is already in container
         return $this;
     }
     // adds page to container and sets dirty flag
     $this->_pages[$hash] = $page;
     $this->_index[$hash] = $page->getOrder();
     $this->_dirtyIndex = true;
     // inject self as page parent
     $page->setParent($this);
     return $this;
 }
コード例 #13
0
 public function buildAdminNav()
 {
     $pages = array(Zend_Navigation_Page::factory(array('label' => 'Users', 'action' => 'index', 'controller' => 'index', 'module' => 'users', 'route' => 'admin', 'id' => 'users', 'order' => 900, 'visible' => FALSE, 'resource' => new Users_Model_Acl_Resource_Users(), 'pages' => array(Zend_Navigation_Page::factory(array('label' => 'Create User', 'action' => 'index', 'controller' => 'create', 'module' => 'users', 'route' => 'admin')), Zend_Navigation_Page::factory(array('label' => 'Modify User', 'action' => 'index', 'controller' => 'modify', 'module' => 'users', 'route' => 'admin'))))));
     return $pages;
 }
コード例 #14
0
ファイル: PageTest.php プロジェクト: netvlies/zf
 public function testToArrayMethod()
 {
     $options = array('label' => 'foo', 'uri' => '#', 'id' => 'my-id', 'class' => 'my-class', 'title' => 'my-title', 'target' => 'my-target', 'rel' => array(), 'rev' => array(), 'order' => 100, 'active' => true, 'visible' => false, 'resource' => 'joker', 'privilege' => null, 'foo' => 'bar', 'meaning' => 42, 'pages' => array(array('label' => 'foo.bar', 'uri' => '#'), array('label' => 'foo.baz', 'uri' => '#')));
     $page = Zend_Navigation_Page::factory($options);
     $toArray = $page->toArray();
     // tweak options to what we expect toArray() to contain
     $options['type'] = 'Zend_Navigation_Page_Uri';
     // calculate diff between toArray() and $options
     $diff = array_diff_assoc($toArray, $options);
     // should be no diff
     $this->assertEquals(array(), $diff);
     // $toArray should have 2 sub pages
     $this->assertEquals(2, count($toArray['pages']));
     // tweak options to what we expect sub page 1 to be
     $options['label'] = 'foo.bar';
     $options['order'] = null;
     $options['id'] = null;
     $options['class'] = null;
     $options['title'] = null;
     $options['target'] = null;
     $options['resource'] = null;
     $options['active'] = false;
     $options['visible'] = true;
     unset($options['foo']);
     unset($options['meaning']);
     // assert that there is no diff from what we expect
     $subPageOneDiff = array_diff_assoc($toArray['pages'][0], $options);
     $this->assertEquals(array(), $subPageOneDiff);
     // tweak options to what we expect sub page 2 to be
     $options['label'] = 'foo.baz';
     // assert that there is no diff from what we expect
     $subPageTwoDiff = array_diff_assoc($toArray['pages'][1], $options);
     $this->assertEquals(array(), $subPageTwoDiff);
 }
コード例 #15
0
ファイル: PageFactoryTest.php プロジェクト: jsnshrmn/Suma
 public function testShouldFailIfUnableToDetermineType()
 {
     try {
         $page = Zend_Navigation_Page::factory(array('label' => 'My Invalid Page'));
         $this->fail('An exception has not been thrown for invalid page type');
     } catch (Zend_Navigation_Exception $e) {
         $this->assertEquals('Invalid argument: Unable to determine class to instantiate ' . '(Page label: My Invalid Page)', $e->getMessage());
     }
 }
コード例 #16
0
ファイル: PageFactoryTest.php プロジェクト: netvlies/zf
 public function testShouldFailIfUnableToDetermineType()
 {
     try {
         $page = Zend_Navigation_Page::factory(array('label' => 'My Invalid Page'));
     } catch (Zend_Navigation_Exception $e) {
         return;
     }
     $this->fail('An exception has not been thrown for invalid page type');
 }
コード例 #17
0
 public function buildAdminNav()
 {
     $pages = array(Zend_Navigation_Page::factory(array('label' => 'Forms', 'action' => 'index', 'controller' => 'index', 'module' => 'forms', 'route' => 'admin', 'id' => 'forms', 'order' => 80, 'visible' => FALSE, 'pages' => array(Zend_Navigation_Page::factory(array('label' => 'Create', 'action' => 'index', 'controller' => 'create', 'module' => 'forms', 'route' => 'admin')), Zend_Navigation_Page::factory(array('label' => 'Manage', 'action' => 'index', 'controller' => 'modify', 'module' => 'forms', 'route' => 'admin')), Zend_Navigation_Page::factory(array('label' => 'Submissions', 'action' => 'index', 'controller' => 'submissions', 'module' => 'forms', 'route' => 'admin')), Zend_Navigation_Page::factory(array('label' => 'Layouts', 'action' => 'index', 'controller' => 'layouts', 'module' => 'forms', 'route' => 'admin')), Zend_Navigation_Page::factory(array('label' => 'Settings', 'action' => 'index', 'controller' => 'index', 'module' => 'settings', 'route' => 'module-settings', 'params' => array('settings' => 'forms')))))));
     return $pages;
 }
コード例 #18
0
 public function buildAdminNav()
 {
     $pages = array(Zend_Navigation_Page::factory(array('label' => 'Products', 'action' => 'index', 'controller' => 'index', 'module' => 'products', 'route' => 'admin', 'id' => 'products', 'order' => 500, 'resource' => new Products_Model_Acl_Resource_Products(), 'pages' => array(Zend_Navigation_Page::factory(array('label' => 'View Product', 'action' => 'view', 'controller' => 'index', 'module' => 'products', 'route' => 'admin')), Zend_Navigation_Page::factory(array('label' => 'Create Product', 'action' => 'index', 'controller' => 'create', 'module' => 'products', 'route' => 'admin', 'resource' => new Products_Model_Acl_Resource_Create())), Zend_Navigation_Page::factory(array('label' => 'Modify Product', 'action' => 'index', 'controller' => 'modify', 'module' => 'products', 'route' => 'admin', 'resource' => new Products_Model_Acl_Resource_Modify()))))));
     return $pages;
 }
コード例 #19
0
 public function buildAdminNav()
 {
     $pages = array(Zend_Navigation_Page::factory(array('label' => 'Tools', 'action' => 'index', 'controller' => 'index', 'module' => 'tools', 'route' => 'admin', 'id' => 'tools', 'order' => 950, 'visible' => FALSE, 'resource' => new Tools_Model_Acl_Resource_Tools(), 'pages' => array(Zend_Navigation_Page::factory(array('label' => 'Querrific', 'action' => 'index', 'controller' => 'query', 'module' => 'tools', 'route' => 'admin', 'resource' => new Tools_Model_Acl_Resource_Query())), Zend_Navigation_Page::factory(array('label' => 'Minopolize', 'action' => 'index', 'controller' => 'minification', 'module' => 'tools', 'route' => 'admin')), Zend_Navigation_Page::factory(array('label' => 'Cachify', 'action' => 'index', 'controller' => 'cache', 'module' => 'tools', 'route' => 'admin', 'resource' => new Tools_Model_Acl_Resource_Cache())), Zend_Navigation_Page::factory(array('label' => 'Mappapalooza', 'action' => 'index', 'controller' => 'sitemap', 'module' => 'tools', 'route' => 'admin', 'resource' => new Tools_Model_Acl_Resource_Sitemap())), Zend_Navigation_Page::factory(array('label' => 'Formula 301', 'action' => 'index', 'controller' => 'redirection', 'module' => 'tools', 'route' => 'admin', 'resource' => new Tools_Model_Acl_Resource_Redirection()))))));
     return $pages;
 }
コード例 #20
0
ファイル: ContainerTest.php プロジェクト: jsnshrmn/Suma
 public function testGetChildrenShouldReturnTheCurrentPage()
 {
     $container = new Zend_Navigation();
     $page = Zend_Navigation_Page::factory(array('type' => 'uri'));
     $container->addPage($page);
     $this->assertEquals($page, $container->getChildren());
 }
コード例 #21
0
ファイル: Navigation.php プロジェクト: rogercastaneda/owlsys
 /**
  *
  * @param Zend_Navigation_Page $pageParent
  * @param Zend_Db_Table_Row_Abstract $menuItem
  * @return Ambigous <Zend_Navigation_Page, Zend_Navigation_Page_Mvc, Zend_Navigation_Page_Uri, unknown>
  */
 private function addInternalPage(Zend_Navigation_Page $pageParent, Zend_Db_Table_Row_Abstract $menuItem)
 {
     $options = array('id' => 'mii-' . $menuItem->id, 'label' => $menuItem->title, 'title' => $menuItem->title, 'target' => $menuItem->wtype, 'resource' => strtolower($menuItem->module . ':' . $menuItem->controller), 'privilege' => strtolower($menuItem->actioncontroller), 'order' => $menuItem->ordering, 'visible' => $menuItem->isvisible, 'class' => $menuItem->css_class, 'module' => $menuItem->module, 'controller' => $menuItem->controller, 'action' => $menuItem->actioncontroller);
     $params = array();
     $subItemsParams = Zend_Json::decode($menuItem->params);
     if (!is_null($subItemsParams)) {
         $params = $subItemsParams;
     }
     $page = Zend_Navigation_Page::factory($options);
     $page->addParams($params);
     $pageParent->addPage($page);
     if (strlen($menuItem->id_alias) > 0) {
         $page->setRoute($menuItem->id_alias);
     } else {
         $page->setRoute(strtolower($menuItem->module . '-' . $menuItem->controller . '-' . $menuItem->actioncontroller));
     }
     return $page;
 }
コード例 #22
0
 public function buildAdminNav()
 {
     $pages = array(Zend_Navigation_Page::factory(array('label' => 'Agents', 'action' => 'index', 'controller' => 'index', 'module' => 'agents', 'route' => 'admin', 'id' => 'agents', 'order' => 100, 'resource' => new Agents_Model_Acl_Resource_Agents(), 'pages' => array(Zend_Navigation_Page::factory(array('label' => 'Create Agent', 'action' => 'index', 'controller' => 'create', 'module' => 'agents', 'route' => 'admin')), Zend_Navigation_Page::factory(array('label' => 'Modify Agent', 'action' => 'index', 'controller' => 'modify', 'module' => 'agents', 'route' => 'admin'))))));
     return $pages;
 }
コード例 #23
0
 public function buildAdminNav()
 {
     $pages = array(Zend_Navigation_Page::factory(array('label' => 'Layouts', 'action' => 'index', 'controller' => 'index', 'module' => 'layouts', 'route' => 'admin', 'id' => 'layouts', 'order' => 1000, 'visible' => FALSE, 'pages' => array(Zend_Navigation_Page::factory(array('label' => 'Modify Layout', 'action' => 'index', 'controller' => 'modify', 'module' => 'layouts', 'route' => 'admin'))))));
     return $pages;
 }
コード例 #24
0
 public function testAclFiltersAwayPagesFromPageProperty()
 {
     $acl = new Zend_Acl();
     $acl->addRole(new Zend_Acl_Role('member'));
     $acl->addRole(new Zend_Acl_Role('admin'));
     $acl->add(new Zend_Acl_Resource('protected'));
     $acl->allow('admin', 'protected');
     $this->_helper->setAcl($acl);
     $this->_helper->setRole($acl->getRole('member'));
     $samplePage = Zend_Navigation_Page::factory(array('label' => 'An example page', 'uri' => 'http://www.example.com/', 'resource' => 'protected'));
     $active = $this->_helper->findOneByLabel('Home');
     $expected = array('alternate' => false, 'stylesheet' => false, 'start' => false, 'next' => 'Page 1', 'prev' => false, 'contents' => false, 'index' => false, 'glossary' => false, 'copyright' => false, 'chapter' => 'array(4)', 'section' => false, 'subsection' => false, 'appendix' => false, 'help' => false, 'bookmark' => false);
     $actual = array();
     foreach ($expected as $type => $discard) {
         $active->addRel($type, $samplePage);
         $found = $this->_helper->findRelation($active, 'rel', $type);
         if (null === $found) {
             $actual[$type] = false;
         } elseif (is_array($found)) {
             $actual[$type] = 'array(' . count($found) . ')';
         } else {
             $actual[$type] = $found->getLabel();
         }
     }
     $this->assertEquals($expected, $actual);
 }
コード例 #25
0
 /**
  * @group ZF-10048
  */
 public function testMvcShouldFailIfOptionsContainsUriAndMvcProperties()
 {
     try {
         $page = Zend_Navigation_Page::factory(array('label' => 'MVC Page', 'action' => 'index', 'controller' => 'index', 'uri' => '#'));
         $this->fail('An exception has not been thrown for invalid properties');
     } catch (Zend_Navigation_Exception $e) {
         $this->assertEquals('Invalid argument: Unable to determine class to instantiate ' . '(Page label: MVC Page)', $e->getMessage());
     }
 }
コード例 #26
0
ファイル: Links.php プロジェクト: nhp/shopware-4
    /**
     * Converts a $mixed value to an array of pages
     *
     * @param  mixed $mixed                     mixed value to get page(s) from
     * @param  bool  $recursive                 whether $value should be looped
     *                                          if it is an array or a config
     * @return Zend_Navigation_Page|array|null  empty if unable to convert
     */
    protected function _convertToPages($mixed, $recursive = true)
    {
        if (is_object($mixed)) {
            if ($mixed instanceof Zend_Navigation_Page) {
                // value is a page instance; return directly
                return $mixed;
            } elseif ($mixed instanceof Zend_Navigation_Container) {
                // value is a container; return pages in it
                $pages = array();
                foreach ($mixed as $page) {
                    $pages[] = $page;
                }
                return $pages;
            } elseif ($mixed instanceof Zend_Config) {
                // convert config object to array and extract
                return $this->_convertToPages($mixed->toArray(), $recursive);
            }
        } elseif (is_string($mixed)) {
            // value is a string; make an URI page
            return Zend_Navigation_Page::factory(array(
                'type' => 'uri',
                'uri'  => $mixed
            ));
        } elseif (is_array($mixed) && !empty($mixed)) {
            if ($recursive && is_numeric(key($mixed))) {
                // first key is numeric; assume several pages
                $pages = array();
                foreach ($mixed as $value) {
                    if ($value = $this->_convertToPages($value, false)) {
                        $pages[] = $value;
                    }
                }
                return $pages;
            } else {
                // pass array to factory directly
                try {
                    $page = Zend_Navigation_Page::factory($mixed);
                    return $page;
                } catch (Exception $e) {
                }
            }
        }

        // nothing found
        return null;
    }
コード例 #27
0
 public function buildAdminNav()
 {
     $pages = array(Zend_Navigation_Page::factory(array('label' => 'Settings', 'action' => 'index', 'controller' => 'index', 'module' => 'settings', 'route' => 'module-settings', 'id' => 'settings', 'order' => 1010, 'visible' => FALSE, 'params' => array('settings' => 'settings'), 'pages' => array(), 'resource' => new Settings_Model_Acl_Resource_Settings())));
     return $pages;
 }