Example #1
0
 /**
  * Creates an Omeka Navigation object by adding
  * pages generated by Omeka plugins and other contributors via a filter (e.x. 'public_navigation_main').
  * The filter should provide an array pages like they are added to Zend_Navigation_Container::addPages
  * However, the page types should only be one of the following types:
  * Omeka_Navigation_Page_Uri or Zend_Navigation_Page_Mvc.  
  * If the associated uri of any page is invalid, it will not add that page to the navigation. 
  * Also, it removes expired pages from formerly active plugins and other former handlers of the filter.
  * 
  * @param String $filterName    The name of the filter
  * @throws Zend_Navigation_Exception if a filter page is invalid  
  */
 public static function createNavigationFromFilter($filterName = '')
 {
     if ($filterName == '') {
         $filterName = self::PUBLIC_NAVIGATION_MAIN_FILTER_NAME;
     }
     // create a new navigation object from the filterName
     $filterNav = new Omeka_Navigation();
     $theme = null;
     // get default pages for the filter
     $pageLinks = array();
     switch ($filterName) {
         case self::PUBLIC_NAVIGATION_MAIN_FILTER_NAME:
             // add the standard Browse Items and Browse Collections links to the main nav
             $pageLinks = array(new Omeka_Navigation_Page_Mvc(array('label' => __('Browse Items'), 'controller' => 'items', 'action' => 'browse', 'visible' => true, 'theme' => 'public')), new Omeka_Navigation_Page_Mvc(array('label' => __('Browse Collections'), 'controller' => 'collections', 'action' => 'browse', 'visible' => true, 'theme' => 'public')));
             $theme = 'public';
             break;
     }
     // gather other page links from filter handlers (e.g. plugins)
     if ($theme) {
         set_theme_base_url($theme);
     }
     $pageLinks = apply_filters($filterName, $pageLinks);
     if ($theme) {
         revert_theme_base_url();
     }
     foreach ($pageLinks as $pageLink) {
         // normalize the page and its subpages
         $page = $filterNav->_normalizePageRecursive($pageLink, array('can_delete' => false, 'theme' => $theme));
         $filterNav->baseAddNormalizedPage($page);
     }
     return $filterNav;
 }