Zend Framework  1.12
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Zend_View_Helper_Navigation_Menu Class Reference

Public Member Functions

 menu (Zend_Navigation_Container $container=null)
 View helper entry point: Retrieves helper and optionally sets container to operate on.
 
 setUlClass ($ulClass)
 Sets CSS class to use for the first 'ul' element when rendering.
 
 getUlClass ()
 Returns CSS class to use for the first 'ul' element when rendering.
 
 setUlId ($ulId)
 Sets unique identifier (id) to use for the first 'ul' element when rendering.
 
 getUlId ()
 Returns unique identifier (id) to use for the first 'ul' element when rendering.
 
 setActiveClass ($activeClass)
 Sets CSS class to use for the active elements when rendering.
 
 getActiveClass ()
 Returns CSS class to use for the active elements when rendering.
 
 setParentClass ($parentClass)
 Sets CSS class to use for the parent li elements when rendering.
 
 getParentClass ()
 Returns CSS class to use for the parent lie elements when rendering.
 
 setRenderParentClass ($flag=true)
 Enables/disables rendering of parent class to the li element.
 
 getRenderParentClass ()
 Returns flag indicating whether parent class should be rendered to the li element.
 
 setOnlyActiveBranch ($flag=true)
 Sets a flag indicating whether only active branch should be rendered.
 
 getOnlyActiveBranch ()
 Returns a flag indicating whether only active branch should be rendered.
 
 setExpandSiblingNodesOfActiveBranch ($flag=true)
 Sets a flag indicating whether to expand all sibling nodes of the active branch.
 
 getExpandSiblingNodesOfActiveBranch ()
 Returns a flag indicating whether to expand all sibling nodes of the active branch.
 
 setRenderParents ($flag=true)
 Enables/disables rendering of parents when only rendering active branch.
 
 getRenderParents ()
 Returns flag indicating whether parents should be rendered when rendering only the active branch.
 
 setPartial ($partial)
 Sets which partial view script to use for rendering menu.
 
 getPartial ()
 Returns partial view script to use for rendering menu.
 
 addPageClassToLi ($flag=true)
 Adds CSS class from page to li element.
 
 getAddPageClassToLi ()
 Returns a flag indicating whether the CSS class from page to be added to li element.
 
 setInnerIndent ($indent)
 Set the inner indentation string for using in render(), optionally a number of spaces to indent with.
 
 getInnerIndent ()
 Returns inner indentation (format output is respected)
 
 htmlify (Zend_Navigation_Page $page)
 Returns an HTML string containing an 'a' element for the given page if the page's href is not empty, and a 'span' element if it is empty.
 
 renderMenu (Zend_Navigation_Container $container=null, array $options=array())
 Renders helper.
 
 renderSubMenu (Zend_Navigation_Container $container=null, $ulClass=null, $indent=null, $ulId=null, $addPageClassToLi=false, $innerIndent=null)
 Renders the inner-most sub menu for the active page in the $container.
 
 renderPartial (Zend_Navigation_Container $container=null, $partial=null)
 Renders the given $container by invoking the partial view helper.
 
 render (Zend_Navigation_Container $container=null)
 Renders menu.
 
- Public Member Functions inherited from Zend_View_Helper_Navigation_HelperAbstract
 setContainer (Zend_Navigation_Container $container=null)
 Sets navigation container the helper operates on by default.
 
 getContainer ()
 Returns the navigation container helper operates on by default.
 
 setMinDepth ($minDepth=null)
 Sets the minimum depth a page must have to be included when rendering.
 
 getMinDepth ()
 Returns minimum depth a page must have to be included when rendering.
 
 setMaxDepth ($maxDepth=null)
 Sets the maximum depth a page can have to be included when rendering.
 
 getMaxDepth ()
 Returns maximum depth a page can have to be included when rendering.
 
 setIndent ($indent)
 Set the indentation string for using in render(), optionally a number of spaces to indent with.
 
 getIndent ()
 Returns indentation (format output is respected)
 
 getEOL ()
 Returns the EOL character (format output is respected)
 
 setFormatOutput ($formatOutput=true)
 Sets whether HTML/XML output should be formatted.
 
 getFormatOutput ()
 Returns whether HTML/XML output should be formatted.
 
 setPrefixForId ($prefix)
 Sets prefix for IDs when they are normalized.
 
 getPrefixForId ()
 Returns prefix for IDs when they are normalized.
 
 skipPrefixForId ($flag=true)
 Skip the current prefix for IDs when they are normalized.
 
 setTranslator ($translator=null)
 Sets translator to use in helper.
 
 getTranslator ()
 Returns translator used in helper.
 
 setAcl (Zend_Acl $acl=null)
 Sets ACL to use when iterating pages.
 
 getAcl ()
 Returns ACL or null if it isn't set using setAcl() or setDefaultAcl().
 
 setRole ($role=null)
 Sets ACL role(s) to use when iterating pages.
 
 getRole ()
 Returns ACL role to use when iterating pages, or null if it isn't set using setRole() or setDefaultRole().
 
 setUseAcl ($useAcl=true)
 Sets whether ACL should be used.
 
 getUseAcl ()
 Returns whether ACL should be used.
 
 getRenderInvisible ()
 Return renderInvisible flag.
 
 setRenderInvisible ($renderInvisible=true)
 Render invisible items?
 
 setUseTranslator ($useTranslator=true)
 Sets whether translator should be used.
 
 getUseTranslator ()
 Returns whether translator should be used.
 
 __call ($method, array $arguments=array())
 Magic overload: Proxy calls to the navigation container.
 
 __toString ()
 Magic overload: Proxy to render().
 
 findActive (Zend_Navigation_Container $container, $minDepth=null, $maxDepth=-1)
 Finds the deepest active page in the given container.
 
 hasContainer ()
 Checks if the helper has a container.
 
 hasAcl ()
 Checks if the helper has an ACL instance.
 
 hasRole ()
 Checks if the helper has an ACL role.
 
 hasTranslator ()
 Checks if the helper has a translator.
 
 htmlify (Zend_Navigation_Page $page)
 Returns an HTML string containing an 'a' element for the given page.
 
 accept (Zend_Navigation_Page $page, $recursive=true)
 Determines whether a page should be accepted when iterating.
 
- Public Member Functions inherited from Zend_View_Helper_HtmlElement
 getClosingBracket ()
 Get the tag closing bracket.
 
- Public Member Functions inherited from Zend_View_Helper_Abstract
 setView (Zend_View_Interface $view)
 Set the View object.
 
 direct ()
 Strategy pattern: currently unutilized.
 

Protected Member Functions

 _normalizeOptions (array $options=array())
 Normalizes given render options.
 
 _renderDeepestMenu (Zend_Navigation_Container $container, $ulClass, $indent, $innerIndent, $minDepth, $maxDepth, $ulId, $addPageClassToLi, $activeClass, $parentClass, $renderParentClass)
 Renders the deepest active menu within [$minDepth, $maxDeth], (called from renderMenu())
 
 _renderMenu (Zend_Navigation_Container $container, $ulClass, $indent, $innerIndent, $minDepth, $maxDepth, $onlyActive, $expandSibs, $ulId, $addPageClassToLi, $activeClass, $parentClass, $renderParentClass)
 Renders a normal menu (called from renderMenu())
 
- Protected Member Functions inherited from Zend_View_Helper_Navigation_HelperAbstract
 _acceptAcl (Zend_Navigation_Page $page)
 Determines whether a page should be accepted by ACL when iterating.
 
 _getWhitespace ($indent)
 Retrieve whitespace representation of $indent.
 
 _htmlAttribs ($attribs)
 Converts an associative array to a string of tag attributes.
 
 _normalizeId ($value)
 Normalize an ID.
 
- Protected Member Functions inherited from Zend_View_Helper_HtmlElement
 _isXhtml ()
 Is doctype XHTML?
 
 _isHtml5 ()
 Is doctype HTML5?
 
 _isStrictDoctype ()
 Is doctype strict?
 
 _htmlAttribs ($attribs)
 Converts an associative array to a string of tag attributes.
 
 _normalizeId ($value)
 Normalize an ID.
 

Protected Attributes

 $_ulClass = 'navigation'
 
 $_ulId = null
 
 $_activeClass = 'active'
 
 $_parentClass = 'menu-parent'
 
 $_renderParentClass = false
 
 $_onlyActiveBranch = false
 
 $_renderParents = true
 
 $_partial = null
 
 $_expandSiblingNodesOfActiveBranch = false
 
 $_addPageClassToLi = false
 
 $_innerIndent = ' '
 
- Protected Attributes inherited from Zend_View_Helper_Navigation_HelperAbstract
 $_container
 
 $_minDepth
 
 $_maxDepth
 
 $_indent = ''
 
 $_formatOutput = true
 
 $_prefixForId = null
 
 $_skipPrefixForId = false
 
 $_translator
 
 $_acl
 
 $_renderInvisible = false
 
 $_role
 
 $_useTranslator = true
 
 $_useAcl = true
 
- Protected Attributes inherited from Zend_View_Helper_HtmlElement
 $_closingBracket = null
 

Additional Inherited Members

- Static Public Member Functions inherited from Zend_View_Helper_Navigation_HelperAbstract
static setDefaultAcl (Zend_Acl $acl=null)
 Sets default ACL to use if another ACL is not explicitly set.
 
static setDefaultRole ($role=null)
 Sets default ACL role(s) to use when iterating pages if not explicitly set later with setRole().
 
- Public Attributes inherited from Zend_View_Helper_HtmlElement
const EOL = "\n"
 EOL character.
 
- Static Protected Attributes inherited from Zend_View_Helper_Navigation_HelperAbstract
static $_defaultAcl
 
static $_defaultRole
 

Member Function Documentation

_normalizeOptions ( array  $options = array())
protected

Normalizes given render options.

Parameters
array$options[optional] options to normalize
Returns
array normalized options
_renderDeepestMenu ( Zend_Navigation_Container  $container,
  $ulClass,
  $indent,
  $innerIndent,
  $minDepth,
  $maxDepth,
  $ulId,
  $addPageClassToLi,
  $activeClass,
  $parentClass,
  $renderParentClass 
)
protected

Renders the deepest active menu within [$minDepth, $maxDeth], (called from renderMenu())

Parameters
Zend_Navigation_Container$containercontainer to render
string$ulClassCSS class for first UL
string$indentinitial indentation
string$innerIndentinner indentation
int | null$minDepthminimum depth
int | null$maxDepthmaximum depth
string | null$ulIdunique identifier (id) for first UL
bool$addPageClassToLiadds CSS class from page to li element
string | null$activeClassCSS class for active element
string$parentClassCSS class for parent li's
bool$renderParentClassRender parent class?
Returns
string rendered menu (HTML)
_renderMenu ( Zend_Navigation_Container  $container,
  $ulClass,
  $indent,
  $innerIndent,
  $minDepth,
  $maxDepth,
  $onlyActive,
  $expandSibs,
  $ulId,
  $addPageClassToLi,
  $activeClass,
  $parentClass,
  $renderParentClass 
)
protected

Renders a normal menu (called from renderMenu())

Parameters
Zend_Navigation_Container$containercontainer to render
string$ulClassCSS class for first UL
string$indentinitial indentation
string$innerIndentinner indentation
int | null$minDepthminimum depth
int | null$maxDepthmaximum depth
bool$onlyActiverender only active branch?
bool$expandSibsrender siblings of active branch nodes?
string | null$ulIdunique identifier (id) for first UL
bool$addPageClassToLiadds CSS class from page to li element
string | null$activeClassCSS class for active element
string$parentClassCSS class for parent li's
bool$renderParentClassRender parent class?
Returns
string rendered menu (HTML)
addPageClassToLi (   $flag = true)

Adds CSS class from page to li element.

Before: Bar

After: Bar

Parameters
bool$flag[optional] adds CSS class from page to li element
Returns
Zend_View_Helper_Navigation_Menu fluent interface, returns self
getActiveClass ( )

Returns CSS class to use for the active elements when rendering.

Returns
string CSS class
getAddPageClassToLi ( )

Returns a flag indicating whether the CSS class from page to be added to li element.

Returns
bool
getExpandSiblingNodesOfActiveBranch ( )

Returns a flag indicating whether to expand all sibling nodes of the active branch.

By default, this value is false, meaning the entire menu will be be rendered.

Returns
bool whether siblings of nodes in the active branch should be expanded
getInnerIndent ( )

Returns inner indentation (format output is respected)

See Also
getFormatOutput()
Returns
string indentation string or an empty string
getOnlyActiveBranch ( )

Returns a flag indicating whether only active branch should be rendered.

By default, this value is false, meaning the entire menu will be be rendered.

Returns
bool whether only active branch should be rendered
getParentClass ( )

Returns CSS class to use for the parent lie elements when rendering.

Returns
string CSS class
getPartial ( )

Returns partial view script to use for rendering menu.

Returns
string|array|null
getRenderParentClass ( )

Returns flag indicating whether parent class should be rendered to the li element.

Returns
bool whether parent class should be rendered
getRenderParents ( )

Returns flag indicating whether parents should be rendered when rendering only the active branch.

By default, this value is true.

Returns
bool whether parents should be rendered
getUlClass ( )

Returns CSS class to use for the first 'ul' element when rendering.

Returns
string CSS class
getUlId ( )

Returns unique identifier (id) to use for the first 'ul' element when rendering.

Returns
string|null Unique identifier (id); Default is 'null'
htmlify ( Zend_Navigation_Page  $page)

Returns an HTML string containing an 'a' element for the given page if the page's href is not empty, and a 'span' element if it is empty.

Overrides Zend_View_Helper_Navigation_Abstract::htmlify().

Parameters
Zend_Navigation_Page$pagepage to generate HTML for
Returns
string HTML string for the given page
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
render ( Zend_Navigation_Container  $container = null)

Renders menu.

Implements Zend_View_Helper_Navigation_Helper::render().

If a partial view is registered in the helper, the menu will be rendered using the given partial script. If no partial is registered, the menu will be rendered as an 'ul' element by the helper's internal method.

See Also
renderPartial()
renderMenu()
Parameters
Zend_Navigation_Container$container[optional] container to render. Default is to render the container registered in the helper.
Returns
string helper output

Implements Zend_View_Helper_Navigation_Helper.

renderMenu ( Zend_Navigation_Container  $container = null,
array  $options = array() 
)

Renders helper.

Renders a HTML 'ul' for the given $container. If $container is not given, the container registered in the helper will be used.

Available $options:

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
renderPartial ( Zend_Navigation_Container  $container = null,
  $partial = null 
)

Renders the given $container by invoking the partial view helper.

The container will simply be passed on as a model to the view script as-is, and will be available in the partial script as 'container', e.g. echo 'Number of pages: ', count($this->container);.

Parameters
Zend_Navigation_Container$container[optional] container to pass to view script. Default is to use the container registered in the helper.
string | array$partial[optional] partial view script to use. Default is to use the partial registered in the helper. If an array is given, it is expected to contain two values; the partial view script to use, and the module where the script can be found.
Returns
string helper output
Exceptions
Zend_View_ExceptionWhen no partial script is set
renderSubMenu ( Zend_Navigation_Container  $container = null,
  $ulClass = null,
  $indent = null,
  $ulId = null,
  $addPageClassToLi = false,
  $innerIndent = null 
)

Renders the inner-most sub menu for the active page in the $container.

This is a convenience method which is equivalent to the following call: renderMenu($container, array( 'indent' => $indent, 'ulClass' => $ulClass, 'minDepth' => null, 'maxDepth' => null, 'onlyActiveBranch' => true, 'renderParents' => false ));

Parameters
Zend_Navigation_Container$container[optional] container to render. Default is to render the container registered in the helper.
string | null$ulClass[optional] CSS class to use for UL element. Default is to use the value from getUlClass().
string | int$indent[optional] indentation as a string or number of spaces. Default is to use the value retrieved from getIndent().
string | null$ulId[optional] Unique identifier (id) use for UL element
bool$addPageClassToLiadds CSS class from page to li element
string | int$innerIndent[optional] inner indentation as a string or number of spaces. Default is to use the getInnerIndent().
Returns
string rendered content
setActiveClass (   $activeClass)

Sets CSS class to use for the active elements when rendering.

Parameters
string$activeClassCSS class to set
Returns
Zend_View_Helper_Navigation_Menu fluent interface, returns self
setExpandSiblingNodesOfActiveBranch (   $flag = true)

Sets a flag indicating whether to expand all sibling nodes of the active branch.

Parameters
bool$flag[optional] expand all siblings of nodes in the active branch. Default is true.
Returns
Zend_View_Helper_Navigation_Menu fluent interface, returns self
setInnerIndent (   $indent)

Set the inner indentation string for using in render(), optionally a number of spaces to indent with.

Parameters
string | int$indentindentation string or number of spaces
Returns
Zend_View_Helper_Navigation_HelperAbstract fluent interface, returns self
setOnlyActiveBranch (   $flag = true)

Sets a flag indicating whether only active branch should be rendered.

Parameters
bool$flag[optional] render only active branch. Default is true.
Returns
Zend_View_Helper_Navigation_Menu fluent interface, returns self
setParentClass (   $parentClass)

Sets CSS class to use for the parent li elements when rendering.

Parameters
string$parentClassCSS class to set to parents
Returns
Zend_View_Helper_Navigation_Menu fluent interface, returns self
setPartial (   $partial)

Sets which partial view script to use for rendering menu.

Parameters
string | array$partialpartial view script or null. If an array is given, it is expected to contain two values; the partial view script to use, and the module where the script can be found.
Returns
Zend_View_Helper_Navigation_Menu fluent interface, returns self
setRenderParentClass (   $flag = true)

Enables/disables rendering of parent class to the li element.

Parameters
bool$flag[optional] render with parent class. Default is true.
Returns
Zend_View_Helper_Navigation_Menu fluent interface, returns self
setRenderParents (   $flag = true)

Enables/disables rendering of parents when only rendering active branch.

See setOnlyActiveBranch() for more information.

Parameters
bool$flag[optional] render parents when rendering active branch. Default is true.
Returns
Zend_View_Helper_Navigation_Menu fluent interface, returns self
setUlClass (   $ulClass)

Sets CSS class to use for the first 'ul' element when rendering.

Parameters
string$ulClassCSS class to set
Returns
Zend_View_Helper_Navigation_Menu fluent interface, returns self
setUlId (   $ulId)

Sets unique identifier (id) to use for the first 'ul' element when rendering.

Parameters
string | null$ulIdUnique identifier (id) to set
Returns
Zend_View_Helper_Navigation_Menu fluent interface, returns self

Member Data Documentation

$_activeClass = 'active'
protected
$_addPageClassToLi = false
protected
$_expandSiblingNodesOfActiveBranch = false
protected
$_innerIndent = ' '
protected
$_onlyActiveBranch = false
protected
$_parentClass = 'menu-parent'
protected
$_partial = null
protected
$_renderParentClass = false
protected
$_renderParents = true
protected
$_ulClass = 'navigation'
protected
$_ulId = null
protected