/**
  * Determines whether a page should be accepted when iterating
  *
  * Rules:
  * - If a page is not visible it is not accepted, unless RenderInvisible has
  *   been set to true.
  * - If helper has no ACL, page is accepted
  * - If helper has ACL, but no role, page is not accepted
  * - If helper has ACL and role:
  *  - Page is accepted if it has no resource or privilege
  *  - Page is accepted if ACL allows page's resource or privilege
  * - If page is accepted by the rules above and $recursive is true, the page
  *   will not be accepted if it is the descendant of a non-accepted page.
  *
  * @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)
 {
     // accept by default
     $accept = true;
     if (!$page->isVisible(false) && !$this->getRenderInvisible()) {
         // don't accept invisible pages
         $accept = false;
     } elseif ($this->getUseAcl() && !$this->_acceptAcl($page)) {
         // acl is not amused
         $accept = false;
     }
     if ($accept && $recursive) {
         $parent = $page->getParent();
         if ($parent instanceof Zend_Navigation_Page) {
             $accept = $this->accept($parent, true);
         }
     }
     return $accept;
 }
Esempio n. 2
0
 /**
  * Returns JSON with the hidden info for a navigation page link. 
  *
  * @param Zend_Navigation_Page $page The navigation page
  * @return String JSON with the hidden info for a navigation page link. 
  */
 protected function _getPageHiddenInfo(Zend_Navigation_Page $page)
 {
     $hiddenInfo = array('can_delete' => (bool) $page->can_delete, 'uri' => $page->getHref(), 'label' => $page->getLabel(), 'visible' => $page->isVisible());
     return json_encode($hiddenInfo);
 }