Implementation of the Zend Navigation HelperAbstract that provides output in p4cms.ui.Menu / dijit.MenuItem format.
More...
List of all members.
Public Member Functions |
| htmlify (Zend_Navigation_Page $page) |
| This function detect what type of page is passed and then calls through to htmlify(Separator|Page|SubMenu).
|
| menu (Zend_Navigation_Container $container=null) |
| View helper entry point: Retrieves helper and optionally sets container to operate on.
|
| render (Zend_Navigation_Container $container=null) |
| Renders menu.
|
| renderMenu (Zend_Navigation_Container $container=null, array $options=array()) |
| Renders helper.
|
Protected Member Functions |
| _htmlifyPage ($page) |
| Returns an HTML string containing an 'div' element for the given page.
|
| _htmlifySeparator ($page) |
| Used to render seperator pages.
|
| _htmlifySubMenu ($page) |
| Used to render pages with sub-pages.
|
| _normalizeOptions (array $options=array()) |
| Normalizes given render options.
|
| _renderMenu (Zend_Navigation_Container $container, $indent, $attribs, $minDepth, $maxDepth) |
| Renders a normal menu (called from renderMenu())
|
Static Protected Attributes |
static | $_menuDijit = 'p4cms.ui.Menu' |
static | $_menuItemDijit = 'dijit.MenuItem' |
static | $_menuSeparatorDijit = 'dijit.MenuSeparator' |
static | $_popupMenuItemDijit = 'dijit.PopupMenuItem' |
Detailed Description
Implementation of the Zend Navigation HelperAbstract that provides output in p4cms.ui.Menu / dijit.MenuItem format.
- 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
Ui_View_Helper_DijitMenu::_htmlifyPage |
( |
$ |
page | ) |
[protected] |
Returns an HTML string containing an 'div' element for the given page.
If an 'onClick' property is present it will be rendered out and the href will be ignored. If no onClick is set the href will be converted to javascript and rendered. The 'class' property will appear as 'iconClass'. If specified, the 'onShow' property will be rendered.
Overrides Zend_View_Helper_Navigation_Abstract::htmlify().
- Parameters:
-
Zend_Navigation_Page | $page | page to generate HTML for |
- Returns:
- string HTML string for the given page
{
$label = $page->getLabel();
$title = $page->getTitle();
$attribs = array(
'id' => $page->getId(),
'iconClass' => $page->getClass(),
'disabled' => $page->disabled
);
if (!($onClick = $page->get('onClick')) && $page->getHref()) {
$onClick = 'window.location = ' . Zend_Json::encode($page->getHref());
}
if ($onClick) {
$onClick = '<script type="dojo/connect" event="onClick">'
. $onClick
. '</script>';
}
if (($onShow = $page->get('onShow'))) {
$onShow = '<script type="dojo/connect" event="onShow" args="menuItem,menu">'
. $onShow
. '</script>';
}
return '<div dojotype="' . static::$_menuItemDijit . '"'
. $this->_htmlAttribs($attribs) . '>'
. $onClick
. $onShow
. $this->view->escape($label)
. '</div>';
}
Ui_View_Helper_DijitMenu::_htmlifySeparator |
( |
$ |
page | ) |
[protected] |
Used to render seperator pages.
Will return the HTML representing the passed page entry.
- Parameters:
-
Zend_Navigation_Page | $page | page to generate HTML for |
- Returns:
- string HTML string for the given page
{
if (($onShow = $page->get('onShow'))) {
$onShow = '<script type="dojo/connect" event="onShow" args="menuItem,menu">'
. $onShow
. '</script>';
}
return '<div dojotype="' . static::$_menuSeparatorDijit . '">' . $onShow . '</div>';
}
Ui_View_Helper_DijitMenu::_htmlifySubMenu |
( |
$ |
page | ) |
[protected] |
Used to render pages with sub-pages.
Will return the HTML representing the passed page entry.
- Parameters:
-
Zend_Navigation_Page | $page | page to generate HTML for |
- Returns:
- string HTML string for the given page
{
return '<div dojotype="' . static::$_popupMenuItemDijit . '">'
. '<span>' . $this->view->escape($page->getLabel()) . '</span>';
}
Ui_View_Helper_DijitMenu::_normalizeOptions |
( |
array $ |
options = array() | ) |
[protected] |
Normalizes given render options.
- Parameters:
-
array | $options | [optional] options to normalize |
- Returns:
- array normalized options
{
if (isset($options['indent'])) {
$options['indent'] = $this->_getWhitespace($options['indent']);
} else {
$options['indent'] = $this->getIndent();
}
if (!isset($options['attribs']) || !is_array($options['attribs'])) {
$options['attribs'] = array();
}
if (array_key_exists('minDepth', $options)) {
if (null !== $options['minDepth']) {
$options['minDepth'] = (int) $options['minDepth'];
}
} else {
$options['minDepth'] = $this->getMinDepth();
}
if ($options['minDepth'] < 0 || $options['minDepth'] === null) {
$options['minDepth'] = 0;
}
if (array_key_exists('maxDepth', $options)) {
if (null !== $options['maxDepth']) {
$options['maxDepth'] = (int) $options['maxDepth'];
}
} else {
$options['maxDepth'] = $this->getMaxDepth();
}
return $options;
}
Ui_View_Helper_DijitMenu::_renderMenu |
( |
Zend_Navigation_Container $ |
container, |
|
|
$ |
indent, |
|
|
$ |
attribs, |
|
|
$ |
minDepth, |
|
|
$ |
maxDepth |
|
) |
| [protected] |
Renders a normal menu (called from renderMenu())
- Parameters:
-
Zend_Navigation_Container | $container | container to render |
string | $indent | initial indentation |
array | $attribs | attribs for the outer-most Menu div |
int | null | $minDepth | minimum depth |
int | null | $maxDepth | maximum depth |
- Returns:
- string
{
$html = '';
$wrapperClass = isset($attribs['wrapperClass']) ? $attribs['wrapperClass'] : '';
if (($found = $this->findActive($container, $minDepth, $maxDepth))) {
$foundPage = $found['page'];
$foundDepth = $found['depth'];
} else {
$foundPage = null;
}
$iterator = new RecursiveIteratorIterator($container,
RecursiveIteratorIterator::SELF_FIRST);
if (is_int($maxDepth)) {
$iterator->setMaxDepth($maxDepth);
}
$prevDepth = -1;
foreach ($iterator as $page) {
$depth = $iterator->getDepth();
$isActive = $page->isActive(true);
if ($depth < $minDepth || !$this->accept($page)) {
continue;
}
$depth -= $minDepth;
$myIndent = $indent . str_repeat(' ', $depth);
if ($depth > $prevDepth) {
$attribs['wrapperClass'] = $wrapperClass . ' level-' . $depth;
$html .= $myIndent . '<div dojoType="' . static::$_menuDijit . '"'
. $this->_htmlAttribs($attribs) . '>' . self::EOL;
$attribs = array();
} else if ($prevDepth > $depth) {
for ($i = $prevDepth; $i > $depth; $i--) {
$ind = $indent . str_repeat(' ', $i);
$html .= $ind . '</div>' . self::EOL;
$html .= $myIndent . ' ' . '</div>' . self::EOL;
}
}
$html .= $myIndent . ' ' . $this->htmlify($page) . self::EOL;
$prevDepth = $depth;
}
if ($html) {
for ($i = $prevDepth+1; $i > 0; $i--) {
$myIndent = $indent . str_repeat(' ', $i-1);
$html .= $myIndent . '</div>' . self::EOL;
if ($i > 1) {
$html .= $myIndent . '</div>' . self::EOL;
}
}
$html = rtrim($html, self::EOL);
}
return $html;
}
Ui_View_Helper_DijitMenu::htmlify |
( |
Zend_Navigation_Page $ |
page | ) |
|
This function detect what type of page is passed and then calls through to htmlify(Separator|Page|SubMenu).
Overrides Zend_View_Helper_Navigation_Abstract::htmlify().
- Parameters:
-
Zend_Navigation_Page | $page | page to generate HTML for |
- Returns:
- string HTML string for the given page
Ui_View_Helper_DijitMenu::menu |
( |
Zend_Navigation_Container $ |
container = null | ) |
|
View helper entry point: Retrieves helper and optionally sets container to operate on.
- Parameters:
-
Zend_Navigation_Container | $container | [optional] container to operate on |
- Returns:
- Zend_View_Helper_Navigation_Menu fluent interface, returns self
{
if (null !== $container) {
$this->setContainer($container);
}
return $this;
}
Ui_View_Helper_DijitMenu::render |
( |
Zend_Navigation_Container $ |
container = null | ) |
|
Ui_View_Helper_DijitMenu::renderMenu |
( |
Zend_Navigation_Container $ |
container = null , |
|
|
array $ |
options = array() |
|
) |
| |
Renders helper.
Renders a Menu dijit 'div' for the given $container with child MenuItem divs for any pages present. If $container is not given, the container registered in the helper will be used.
Available $options: indent attribs - html attribs that will apply to the outer-most Menu div minDepth maxDepth
- Parameters:
-
Zend_Navigation_Container | $container | [optional] container to create menu from. Default is to use the container retrieved from getContainer(). |
array | $options | [optional] options for controlling rendering |
- Returns:
- string rendered menu
{
if (null === $container) {
$container = $this->getContainer();
}
$options = $this->_normalizeOptions($options);
$html = $this->_renderMenu(
$container,
$options['indent'],
$options['attribs'],
$options['minDepth'],
$options['maxDepth']
);
return $html;
}
Member Data Documentation
Ui_View_Helper_DijitMenu::$_menuDijit = 'p4cms.ui.Menu' [static, protected] |
Ui_View_Helper_DijitMenu::$_menuItemDijit = 'dijit.MenuItem' [static, protected] |
Ui_View_Helper_DijitMenu::$_menuSeparatorDijit = 'dijit.MenuSeparator' [static, protected] |
Ui_View_Helper_DijitMenu::$_popupMenuItemDijit = 'dijit.PopupMenuItem' [static, protected] |
The documentation for this class was generated from the following file: