本文整理汇总了PHP中Zend_Navigation_Page::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Navigation_Page::factory方法的具体用法?PHP Zend_Navigation_Page::factory怎么用?PHP Zend_Navigation_Page::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Navigation_Page
的用法示例。
在下文中一共展示了Zend_Navigation_Page::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addDefaultPages
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: buildAdminNav
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: getModulePages
/**
*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: addDefaultPages
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: getSitemap
/**
*
*/
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: buildAdminNav
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: menu
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: _normalizePageRecursive
/**
* 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: buildAdminNav
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: buildAdminNav
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: testFactoryExceptionWhenNoPageTypeDetected
/**
* @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: addPage
/**
* 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: buildAdminNav
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: testToArrayMethod
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: testShouldFailIfUnableToDetermineType
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());
}
}