Extend Zend_Navigation to return pages in sorted order.
More...
List of all members.
Public Member Functions |
| addPage ($page) |
| Add a page to the raw navigation container in this menu.
|
| addPages ($pages) |
| Adds several pages at once Extends parent to accept a navigation container.
|
| getPages () |
| Extend parent to return pages in sorted order.
|
Static Public Member Functions |
static | expandMacros ($value, Zend_Navigation_Page $page) |
| Utility method to assist with expanding macros in page properties.
|
static | inferPageType ($page) |
| A function to infer types of navigation items so that specifying the type is optional - operates recursively (on sub-pages).
|
Static Protected Member Functions |
static | _detectPageType (array $page) |
| Determine the appropriate page type for a given page definition.
|
Detailed Description
Extend Zend_Navigation to return pages in sorted order.
- Copyright:
- 2011-2012 Perforce Software. All rights reserved
- License:
- Please see LICENSE.txt in top-level folder of this distribution.
- Version:
- 2012.2/486814
Member Function Documentation
static P4Cms_Navigation::_detectPageType |
( |
array $ |
page | ) |
[static, protected] |
Determine the appropriate page type for a given page definition.
- Parameters:
-
array | $page | array definition of a page. |
- Returns:
- string the detected page type.
{
if (isset($page['handler'])) {
return 'P4Cms_Navigation_Page_Dynamic';
}
if (isset($page['contentId'])) {
return 'P4Cms_Navigation_Page_Content';
}
if (isset($page['action'])
|| isset($page['controller'])
|| isset($page['module'])
|| isset($page['route'])
) {
return 'P4Cms_Navigation_Page_Mvc';
}
if (isset($page['uri'])) {
return 'P4Cms_Navigation_Page_Uri';
}
if (isset($page['label']) && preg_match('/^-+$/', $page['label'])) {
return 'P4Cms_Navigation_Page_Separator';
}
return 'P4Cms_Navigation_Page_Heading';
}
P4Cms_Navigation::addPage |
( |
$ |
page | ) |
|
Add a page to the raw navigation container in this menu.
- Parameters:
-
array | Zend_Navigation_Page | Zend_Config | $page | a page to add to the menu. |
- Returns:
- P4Cms_Navigation provides fluent interface.
P4Cms_Navigation::addPages |
( |
$ |
pages | ) |
|
Adds several pages at once Extends parent to accept a navigation container.
- Parameters:
-
array | Zend_Config | Zend_Navigation_Container | $pages | pages to add |
- Returns:
- Zend_Navigation_Container fluent interface, returns self
- Exceptions:
-
Zend_Navigation_Exception | if $pages is not array or Zend_Config |
{
if ($pages instanceof Zend_Navigation_Container) {
$pages = iterator_to_array($pages);
}
return parent::addPages($pages);
}
static P4Cms_Navigation::expandMacros |
( |
$ |
value, |
|
|
Zend_Navigation_Page $ |
page |
|
) |
| [static] |
Utility method to assist with expanding macros in page properties.
Only expands macros in given value if page has expandMacros = true
- Parameters:
-
string | $value | the value to expand macros in |
Zend_Navigation_Page | $page | the page for context |
- Returns:
- string the value with macros expanded (if enabled)
{
if (!$page->get('expandMacros')) {
return $value;
}
$macro = new P4Cms_Filter_Macro;
$macro->setContext(array('page' => $page));
return $macro->filter($value);
}
P4Cms_Navigation::getPages |
( |
| ) |
|
Extend parent to return pages in sorted order.
- Returns:
- array Zend_Navigation_Page instances
{
$this->_sort();
$pages = array();
foreach ($this->_index as $hash => $order) {
$pages[] = $this->_pages[$hash];
}
return $pages;
}
static P4Cms_Navigation::inferPageType |
( |
$ |
page | ) |
[static] |
A function to infer types of navigation items so that specifying the type is optional - operates recursively (on sub-pages).
- Parameters:
-
mixed | $page | a page definition array to set the type on. note: non-array inputs are returned as-is. |
- Returns:
- mixed the given page definition updated with types set.
{
if (!is_array($page)) {
return $page;
}
if (isset($page['type']) && !class_exists($page['type'])) {
unset($page['type']);
}
if (!isset($page['type'])) {
$page['type'] = static::_detectPageType($page);
$page['typeInferred'] = true;
}
if (array_key_exists('pages', $page) && is_array($page['pages'])) {
foreach ($page['pages'] as $key => $subPage) {
$page['pages'][$key] = static::inferPageType($subPage);
}
}
return $page;
}
The documentation for this class was generated from the following file: