Example #1
0
 public function testOptionOnlyActiveBranchNoParentsAndBothDepthsSpecified()
 {
     $options = array('minDepth' => 2, 'maxDepth' => 2, 'onlyActiveBranch' => true, 'renderParents' => false);
     $expected = $this->_getExpected('menu/onlyactivebranch_np_bd.html');
     $actual = $this->_helper->renderMenu(null, $options);
     $this->assertEquals($expected, $actual);
 }
Example #2
0
 /**
  * Normalizes given render options
  *
  * @param  array $options  [optional] options to normalize
  * @return array           normalized options
  */
 protected function _normalizeOptions(array $options = array())
 {
     if (!isset($options['expandBranch'])) {
         $options['expandBranch'] = $this->getExpandBranch();
     }
     return parent::_normalizeOptions($options);
 }
Example #3
0
 /**
  * @group ZF-9746
  */
 public function testRenderingWithAccesskey()
 {
     $this->_nav3->findOneBy('id', 'home')->setAccesskey('H');
     $this->_nav3->findOneBy('uri', 'contact')->setAccesskey('c');
     $this->_nav3->findOneBy('id', 'imprint')->setAccesskey('i');
     $expected = $this->_getExpected('menu/accesskey.html');
     $this->assertEquals($expected, $this->_helper->render($this->_nav3));
 }
 /**
  * @group ZF-8874
  */
 public function testRenderingWithInnerIndent()
 {
     $this->_helper->setIndent(4);
     // Inner indent = 0
     $this->_helper->setInnerIndent(0);
     $expected = $this->_getExpected('menu/innerindent0.html');
     $this->assertEquals($expected, $this->_helper->render($this->_nav1));
     // Inner indent = 4
     $this->_helper->setInnerIndent(4);
     $expected = $this->_getExpected('menu/innerindent4.html');
     $this->assertEquals($expected, $this->_helper->render($this->_nav1));
     // Inner indent = 8
     $this->_helper->setInnerIndent(8);
     $expected = $this->_getExpected('menu/innerindent8.html');
     $this->assertEquals($expected, $this->_helper->render($this->_nav1));
 }
 /**
  * Determines whether a page should be accepted by ACL when iterating
  *
  * Rules:
  * - If helper has no ACL, page is accepted
  * - If page has a resource or privilege defined, page is accepted
  *   if the ACL allows access to it using the helper's role
  * - If page has no resource or privilege, page is accepted
  *
  * @param  Zend_Navigation_Page $page  page to check
  * @return bool                        whether page is accepted by ACL
  */
 protected function _acceptAcl(Zend_Navigation_Page $page)
 {
     if (true == $page->get('invalid')) {
         return false;
     }
     return parent::_acceptAcl($page);
 }
Example #6
0
 public function htmlify(Zend_Navigation_Page $page)
 {
     $out = parent::htmlify($page);
     return $page->get('disabled') ? str_replace('<a', '<a onclick="return false;" ', $out) : $out;
 }
 /**
  * @group ZF-7212
  */
 public function testRenderingSubMenuWithUlId()
 {
     $this->assertContains('<ul class="navigation" id="foo">', $this->_helper->renderSubMenu(null, null, null, 'foo'));
 }
Example #8
0
 /**
  * This method tests the privileges required to see a given link
  *
  * @param string $propertyValue the value of the property for finding page
  * @param string $role          the role to test against
  * @param bool   $result        expected result
  * @param string $propertyName  if given method will try to find the given page
  *                              by this property instead of by label
  *
  * @dataProvider getAccessSampleData
  *
  * @return void
  */
 public function testNavigationAccess($propertyValue, $role, $result, $propertyName = 'label')
 {
     $acl = $this->getNavigationAcl();
     if (!$acl) {
         $this->markTestSkipped('You must override the getAcl method in order to use this test');
     }
     $page = $this->_navigation->findBy($propertyName, $propertyValue);
     $this->assertNotNull($page, sprintf("A page with %s set to %s should exists in navigation", ucfirst($propertyName), $propertyValue));
     $menu = new Zend_View_Helper_Navigation_Menu();
     $menu->setRole($role)->setAcl($acl);
     $this->assertSame($result, $menu->accept($page), "Page with label {$page->label} is not accepted for role " . ($role instanceof Zend_Acl_Role_Interface ? $role->getRoleId() : $role));
 }
Example #9
0
 public function render(Zend_Navigation_Container $container = null, array $options = array())
 {
     #define a partial utilizada para renderizar o menu.
     $this->menu()->setPartial("nav-horizontal-default.phtml");
     return parent::render($container, $options);
 }
Example #10
0
 /**
  * Overrides the parent function
  * @param  Zend_Navigation_Page $page      page to check
  * @param  bool                $recursive  [optional] if true, page will not
  *                                         be accepted if it is the
  *                                         descendant of a page that is not
  *                                         accepted. Default is true.
  * @return bool                            whether page should be accepted
  */
 public function accept(Zend_Navigation_Page $page, $recursive = true)
 {
     if ($this->_AclCheckFunction != NULL && is_callable($this->_AclCheckFunction)) {
         return call_user_func($this->_AclCheckFunction, $page);
     } else {
         return parent::accept($page, $recursive);
     }
 }
Example #11
0
 /**
  * View helper entry point:
  * Retrieves helper and optionally sets container to operate on
  *
  * @param  Zend_Navigation_Container $container  [optional] container to
  *                                               operate on
  * @return Zend_View_Helper_Navigation_Menu      fluent interface,
  *                                               returns self
  */
 public function fbmenu(Zend_Navigation_Container $container = null)
 {
     return parent::menu($container);
 }
Example #12
0
 /**
  * Intercept renderMenu() call and apply custom Twitter Bootstrap class/id
  * attributes.
  *
  * @see   Zend_View_Helper_Navigation_Menu::renderMenu()
  * @param Zend_Navigation_Container $container (Optional) The navigation container.
  * @param array                     $options   (Optional) Options for controlling rendering.
  *
  * @return string
  */
 public function renderMenu(Zend_Navigation_Container $container = null, array $options = array())
 {
     return $this->applyBootstrapClassesAndIds(parent::renderMenu($container, $options));
 }