Omeka_Navigation

Package: Navigation

class Omeka_Navigation

extends Zend_Navigation

Customized subclass of Zend Framework’s Zend_Navigation class.

Omeka_Navigation::__construct($pages = null)

Creates a new navigation container

Parameters:
  • $pages (array|Zend_Config) – [optional] pages to add
Omeka_Navigation::saveAsOption($optionName)

Saves the navigation in the global options table.

Parameters:
  • $optionName (String) – The name of the option
Omeka_Navigation::loadAsOption($optionName)

Loads the navigation from the global options table

Parameters:
  • $optionName (String) – The name of the option
Omeka_Navigation::addPage($page)

Adds a page to the container. If a page does not have a valid id, it will give it one. If a direct child page already has another page with the same uid then it will not add the page. However, it will add the page as a child of this navigation if one of its descendants already has the page.

This method will inject the container as the given page’s parent by calling {@link Zend_Navigation_Page::setParent()}.

Parameters:
  • $page
Returns:

Zend_Navigation_Container fluent interface, returns self

Omeka_Navigation::getChildByUid($uid)

Returns an immediate child page that has a uid of $uid. If none exists, it returns null.

Parameters:
  • $uid (string) – The uid to search for in this navigation
Returns:

Zend_Navigation_Page The page

Omeka_Navigation::addPageToContainer($page, $container)

Adds a page to a container after normalizing it and its subpages

Parameters:
  • $page (Zend_Navigation_Page) – The page to add
  • $container (Zend_Navigation_Container) – The container to which to add the page
Returns:

Zend_Navigation_Container The container with the page added

Omeka_Navigation::createNavigationFromFilter($filterName = '')

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.

Parameters:
  • $filterName (String) – The name of the filter
Omeka_Navigation::baseAddNormalizedPage($normalizedPage)

Add a normalized page to the navigation using parent::addPage() This needs to wrapped so that methods like createNavigationFromFilter() can add pages directly using the parent class method.

Parameters:
  • $normalizedPage
Returns:

Zend_Navigation_Container fluent interface, returns self

Omeka_Navigation::mergePage(Zend_Navigation_Page $page, Zend_Navigation_Container $parentContainer = null)

Merges a page (and its subpages) into this navigation. If the page already exists in the navigation, then it attempts to add any new subpages of the page to it. If a subpages already exists in the navigation, then it it recursively attempts to add its new subpages to it, and so on.

Parameters:
  • $page (Zend_Navigation_Page) –
  • $parentContainer (Zend_Navigation_Container) –
Returns:

Zend_Navigation_Container $parentContainer the suggested parentContainer for the page. The parentContainer must already be in the navigation and remain so throughout the merge.

Omeka_Navigation::_getLastPageOrderInContainer($container)

Returns the page order of the last child page in the container. If no page exists in the container, it returns 0.

Parameters:
  • $container
Returns:

int the last page order in the container

Omeka_Navigation::mergeNavigation(Omeka_Navigation $nav)

Merges a navigation object into this navigation.

Parameters:
Omeka_Navigation::addPagesFromFilter($filterName = '')

Adds 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 Omeka_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.

Parameters:
  • $filterName (String) – The name of the filter
Omeka_Navigation::getExpiredPagesFromNav(Omeka_Navigation $freshNav)

Returns an array of expired pages from this navigation, where all pages in the $feshNav are considered non-expired.

Parameters:
Returns:

array The array of expired pages

Omeka_Navigation::prunePage($page)

Prune page from this navigation. When a page is pruned its children pages are reattached to the first non-pruneable ancestor page.

Parameters:
  • $page (Omeka_Navigation_Page_Mvc|Omeka_Navigation_Page_Uri) – The page to prune
Omeka_Navigation::getOtherPages($excludePageUids = null)

Returns an array of all pages from navigation that lack a uid in $excludePageUids

Parameters:
  • $excludePageUids (array|null) – The list uids for pages to exclude
Returns:

array The array of other pages.

Omeka_Navigation::getPageByUid($pageUid, $container = null)

Returns the navigation page associated with uid. It searches all descendant pages of this navigation If not page is associated, then it returns null.

Parameters:
  • $pageUid (String) – The uid of the page
  • $container (Zend_Navigation_Container) – The container within which to search for the page. By default, it uses this navigation.
Returns:

Omeka_Zend_Navigation_Page_Uri|Omeka_Navigation_Page_Mvc|null

Omeka_Navigation::createPageUid($href)

Returns the unique id for the page, which can be used to determine whether it can be added to the navigation

Parameters:
  • $href (String) – The href of the page.
Returns:

String

Omeka_Navigation::removePageRecursive(Zend_Navigation_Page $page, Zend_Navigation_Container $parentContainer = null, $reattach = false)

Recursively removes the given page from the parent container, including all subpages

Parameters:
  • $page (Zend_Navigation_Page) – The page to remove from the parent container and all its subpages.
  • $parentContainer (Zend_Navigation_Container) – The parent container (by default it is this navigation) from which to remove the page from its subpages
  • $reattach (bool) – Whether the subpages of the $page should be reattached to $parentContainer
Returns:

bool Whether the page was removed

Omeka_Navigation::getNavigationOptionValueForInstall()

Returns the option value associated with the default navigation during installation

Returns:String The option value associated with the default navigation during installation. If no option is found for the option name, then it returns an empty string.
Omeka_Navigation::_normalizePageRecursive($page, $pageOptions = array())

Normalizes a page and its subpages so it can be added

Parameters:
  • $page
  • $pageOptions – The options to set during normalization for every page and subpage
Returns:

Omeka_Navigation_Page_Uri|Omeka_Navigation_Page_Mvc|null The normalized page

Omeka_Navigation::_convertZendToOmekaNavigationPage(Zend_Navigation_Page $page, $subclassPostfix)

Converts a Zend_Navigation_Page subclass object to a corresponding Omeka object

Parameters:
  • $page (Zend_Navigation_Page) – The page to convert
  • $subclassPostfix (string) – The postfix of the subclass. Must be ‘Uri’ or ‘Mvc’
Returns:

Omeka_Navigation_Page_Uri|Omeka_Navigation_Page_Mvc The converted page

Omeka_Navigation::_conditionalReplaceValueInArray($array, $childKey, $targetKey, $oldValue, $newValue)

Returns an nested associative array such that all array elements have replaced an key value to a new key value only if it is equal to a specific old key value.

Parameters:
  • $array (array) – The associative array
  • $childKey (string) – The associative array
  • $targetKey (string) – The target key whose value can be replaced
  • $oldValue (mixed) – The old value of the element associated with the target key used to determine if the value should be changed
  • $newValue (mixed) – The new value of the element associated with the target key
Returns:

array The replaced associative array