Omeka_Navigation

class Omeka_Navigation

Package: Navigation

Customized subclass of Zend Framework’s Zend_Navigation class.

__construct(array|Zend_Config $pages)

Creates a new navigation container

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

Saves the navigation in the global options table.

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

Loads the navigation from the global options table

Parameters:
  • $optionName (String) – The name of the option
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 bycalling {@link Zend_Navigation_Page::setParent()}.

Parameters:
  • $page (unknown) –
Returns:

Zend_Navigation_Container fluent interface, returns self

getChildByUid(string $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

addPageToContainer(Zend_Navigation_Page $page, Zend_Navigation_Container $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

createNavigationFromFilter(String $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
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 (unknown) –
Returns:

Zend_Navigation_Container fluent interface, returns self

mergePage(Zend_Navigation_Page $page, Zend_Navigation_Container $parentContainer)

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.

_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 (unknown) –
Returns:

int the last page order in the container

mergeNavigation(Omeka_Navigation $nav)

Merges a navigation object into this navigation.

Parameters:
addPagesFromFilter(String $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
getExpiredPagesFromNav(Omeka_Navigation $excludeNav)

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

Parameters:
Returns:

array The array of expired pages

prunePages($pages)

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

Parameters:
  • $pages (unknown) –
prunePage(Omeka_Navigation_Page_Mvc|Omeka_Navigation_Page_Uri $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
getOtherPages(array|null $excludePageUids)

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.

getPageByUid(String $pageUid, Zend_Navigation_Container $container)

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

createPageUid(String $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

removePageRecursive(Zend_Navigation_Page $page, Zend_Navigation_Container $parentContainer, boolean $reattach =)

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 (boolean) – Whether the subpages of the $page should be reattached to $parentContainer
Returns:

boolean Whether the page was removed

getNavigationOptionValueForInstall(String $optionName)

Returns the option value associated with the default navigation during installation

Parameters:
  • $optionName (String) – The option name for a stored navigation object.
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.

_normalizePageRecursive($page, $pageOptions = Array)

Normalizes a page and its subpages so it can be added

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

Omeka_Navigation_Page_Uri|Omeka_Navigation_Page_Mvc|null The normalized page

_convertZendToOmekaNavigationPage(Zend_Navigation_Page $page, string $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

_conditionalReplaceValueInArray(array $array, string $childKey, string $targetKey, mixed $oldValue, mixed $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