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

Public Member Functions

 links (Zend_Navigation_Container $container=null)
 View helper entry point: Retrieves helper and optionally sets container to operate on.
 
 __call ($method, array $arguments=array())
 Magic overload: Proxy calls to findRelation() or container.
 
 setRenderFlag ($renderFlag)
 Sets the helper's render flag.
 
 getRenderFlag ()
 Returns the helper's render flag.
 
 findAllRelations (Zend_Navigation_Page $page, $flag=null)
 Finds all relations (forward and reverse) for the given $page.
 
 findRelation (Zend_Navigation_Page $page, $rel, $type)
 Finds relations of the given $rel=$type from $page.
 
 searchRelStart (Zend_Navigation_Page $page)
 Searches the root container for the forward 'start' relation of the given $page.
 
 searchRelNext (Zend_Navigation_Page $page)
 Searches the root container for the forward 'next' relation of the given $page.
 
 searchRelPrev (Zend_Navigation_Page $page)
 Searches the root container for the forward 'prev' relation of the given $page.
 
 searchRelChapter (Zend_Navigation_Page $page)
 Searches the root container for forward 'chapter' relations of the given $page.
 
 searchRelSection (Zend_Navigation_Page $page)
 Searches the root container for forward 'section' relations of the given $page.
 
 searchRelSubsection (Zend_Navigation_Page $page)
 Searches the root container for forward 'subsection' relations of the given $page.
 
 searchRevSection (Zend_Navigation_Page $page)
 Searches the root container for the reverse 'section' relation of the given $page.
 
 searchRevSubsection (Zend_Navigation_Page $page)
 Searches the root container for the reverse 'section' relation of the given $page.
 
 renderLink (Zend_Navigation_Page $page, $attrib, $relation)
 Renders the given $page as a link element, with $attrib = $relation.
 
 render (Zend_Navigation_Container $container=null)
 Renders helper.
 
- 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.
 

Public Attributes

const RENDER_ALTERNATE = 0x0001
 
const RENDER_STYLESHEET = 0x0002
 
const RENDER_START = 0x0004
 
const RENDER_NEXT = 0x0008
 
const RENDER_PREV = 0x0010
 
const RENDER_CONTENTS = 0x0020
 
const RENDER_INDEX = 0x0040
 
const RENDER_GLOSSARY = 0x0080
 
const RENDER_COPYRIGHT = 0x0100
 
const RENDER_CHAPTER = 0x0200
 
const RENDER_SECTION = 0x0400
 
const RENDER_SUBSECTION = 0x0800
 
const RENDER_APPENDIX = 0x1000
 
const RENDER_HELP = 0x2000
 
const RENDER_BOOKMARK = 0x4000
 
const RENDER_CUSTOM = 0x8000
 
const RENDER_ALL = 0xffff
 

Protected Member Functions

 _findFromProperty (Zend_Navigation_Page $page, $rel, $type)
 Finds relations of given $type for $page by checking if the relation is specified as a property of $page.
 
 _findFromSearch (Zend_Navigation_Page $page, $rel, $type)
 Finds relations of given $rel=$type for $page by using the helper to search for the relation in the root container.
 
 _findRoot (Zend_Navigation_Page $page)
 Returns the root container of the given page.
 
 _convertToPages ($mixed, $recursive=true)
 Converts a $mixed value to an array of pages.
 
- 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

 $_renderFlag = self::RENDER_ALL
 
 $_root
 
- 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
 

Static Protected Attributes

static $_RELATIONS
 
- Static Protected Attributes inherited from Zend_View_Helper_Navigation_HelperAbstract
static $_defaultAcl
 
static $_defaultRole
 

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().
 

Member Function Documentation

__call (   $method,
array  $arguments = array() 
)

Magic overload: Proxy calls to findRelation() or container.

Examples of finder calls: // METHOD // SAME AS $h->findRelNext($page); // $h->findRelation($page, 'rel', 'next') $h->findRevSection($page); // $h->findRelation($page, 'rev', 'section'); $h->findRelFoo($page); // $h->findRelation($page, 'rel', 'foo');

Parameters
string$methodmethod name
array$argumentsmethod arguments
Exceptions
Zend_Navigation_Exceptionif method does not exist in container
_convertToPages (   $mixed,
  $recursive = true 
)
protected

Converts a $mixed value to an array of pages.

Parameters
mixed$mixedmixed value to get page(s) from
bool$recursivewhether $value should be looped if it is an array or a config
Returns
Zend_Navigation_Page|array|null empty if unable to convert
_findFromProperty ( Zend_Navigation_Page  $page,
  $rel,
  $type 
)
protected

Finds relations of given $type for $page by checking if the relation is specified as a property of $page.

Parameters
Zend_Navigation_Page$pagepage to find relations for
string$relrelation, 'rel' or 'rev'
string$typelink type, e.g. 'start', 'next'
Returns
Zend_Navigation_Page|array|null page(s), or null if not found
_findFromSearch ( Zend_Navigation_Page  $page,
  $rel,
  $type 
)
protected

Finds relations of given $rel=$type for $page by using the helper to search for the relation in the root container.

Parameters
Zend_Navigation_Page$pagepage to find relations for
string$relrelation, 'rel' or 'rev'
string$typelink type, e.g. 'start', 'next', etc
Returns
array|null array of pages, or null if not found
_findRoot ( Zend_Navigation_Page  $page)
protected

Returns the root container of the given page.

When rendering a container, the render method still store the given container as the root container, and unset it when done rendering. This makes sure finder methods will not traverse above the container given to the render method.

Parameters
Zend_Navigaiton_Page$pagepage to find root for
Returns
Zend_Navigation_Container the root container of the given page
findAllRelations ( Zend_Navigation_Page  $page,
  $flag = null 
)

Finds all relations (forward and reverse) for the given $page.

The form of the returned array: // $page denotes an instance of Zend_Navigation_Page $returned = array( 'rel' => array( 'alternate' => array($page, $page, $page), 'start' => array($page), 'next' => array($page), 'prev' => array($page), 'canonical' => array($page) ), 'rev' => array( 'section' => array($page) ) );

Parameters
Zend_Navigation_Page$pagepage to find links for
Returns
array related pages
findRelation ( Zend_Navigation_Page  $page,
  $rel,
  $type 
)

Finds relations of the given $rel=$type from $page.

This method will first look for relations in the page instance, then by searching the root container if nothing was found in the page.

Parameters
Zend_Navigation_Page$pagepage to find relations for
string$relrelation, "rel" or "rev"
string$typelink type, e.g. 'start', 'next'
Returns
Zend_Navigaiton_Page|array|null page(s), or null if not found
Exceptions
Zend_View_Exceptionif $rel is not "rel" or "rev"
getRenderFlag ( )

Returns the helper's render flag.

Returns
int render flag
links ( 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_Links fluent interface, returns self
render ( Zend_Navigation_Container  $container = null)

Renders helper.

Implements Zend_View_Helper_Navigation_Helper::render().

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.

renderLink ( Zend_Navigation_Page  $page,
  $attrib,
  $relation 
)

Renders the given $page as a link element, with $attrib = $relation.

Parameters
Zend_Navigation_Page$pagethe page to render the link for
string$attribthe attribute to use for $type, either 'rel' or 'rev'
string$relationrelation type, muse be one of; alternate, appendix, bookmark, chapter, contents, copyright, glossary, help, home, index, next, prev, section, start, stylesheet, subsection
Returns
string rendered link element
Exceptions
Zend_View_Exceptionif $attrib is invalid
searchRelChapter ( Zend_Navigation_Page  $page)

Searches the root container for forward 'chapter' relations of the given $page.

From http://www.w3.org/TR/html4/types.html#type-links: Refers to a document serving as a chapter in a collection of documents.

Parameters
Zend_Navigation_Page$pagepage to find relation for
Returns
Zend_Navigation_Page|array|null page(s) or null
searchRelNext ( Zend_Navigation_Page  $page)

Searches the root container for the forward 'next' relation of the given $page.

From http://www.w3.org/TR/html4/types.html#type-links: Refers to the next document in a linear sequence of documents. User agents may choose to preload the "next" document, to reduce the perceived load time.

Parameters
Zend_Navigation_Page$pagepage to find relation for
Returns
Zend_Navigation_Page|null page(s) or null
searchRelPrev ( Zend_Navigation_Page  $page)

Searches the root container for the forward 'prev' relation of the given $page.

From http://www.w3.org/TR/html4/types.html#type-links: Refers to the previous document in an ordered series of documents. Some user agents also support the synonym "Previous".

Parameters
Zend_Navigation_Page$pagepage to find relation for
Returns
Zend_Navigation_Page|null page or null
searchRelSection ( Zend_Navigation_Page  $page)

Searches the root container for forward 'section' relations of the given $page.

From http://www.w3.org/TR/html4/types.html#type-links: Refers to a document serving as a section in a collection of documents.

Parameters
Zend_Navigation_Page$pagepage to find relation for
Returns
Zend_Navigation_Page|array|null page(s) or null
searchRelStart ( Zend_Navigation_Page  $page)

Searches the root container for the forward 'start' relation of the given $page.

From http://www.w3.org/TR/html4/types.html#type-links: Refers to the first document in a collection of documents. This link type tells search engines which document is considered by the author to be the starting point of the collection.

Parameters
Zend_Navigation_Page$pagepage to find relation for
Returns
Zend_Navigation_Page|null page or null
searchRelSubsection ( Zend_Navigation_Page  $page)

Searches the root container for forward 'subsection' relations of the given $page.

From http://www.w3.org/TR/html4/types.html#type-links: Refers to a document serving as a subsection in a collection of documents.

Parameters
Zend_Navigation_Page$pagepage to find relation for
Returns
Zend_Navigation_Page|array|null page(s) or null
searchRevSection ( Zend_Navigation_Page  $page)

Searches the root container for the reverse 'section' relation of the given $page.

From http://www.w3.org/TR/html4/types.html#type-links: Refers to a document serving as a section in a collection of documents.

Parameters
Zend_Navigation_Page$pagepage to find relation for
Returns
Zend_Navigation_Page|null page(s) or null
searchRevSubsection ( Zend_Navigation_Page  $page)

Searches the root container for the reverse 'section' relation of the given $page.

From http://www.w3.org/TR/html4/types.html#type-links: Refers to a document serving as a subsection in a collection of documents.

Parameters
Zend_Navigation_Page$pagepage to find relation for
Returns
Zend_Navigation_Page|null page(s) or null
setRenderFlag (   $renderFlag)

Sets the helper's render flag.

The helper uses the bitwise '&' operator against the hex values of the render constants. This means that the flag can is "bitwised" value of the render constants. Examples: // render all links except glossary $flag = Zend_View_Helper_Navigation_Links:RENDER_ALL ^ Zend_View_Helper_Navigation_Links:RENDER_GLOSSARY; $helper->setRenderFlag($flag);

// render only chapters and sections $flag = Zend_View_Helper_Navigation_Links:RENDER_CHAPTER | Zend_View_Helper_Navigation_Links:RENDER_SECTION; $helper->setRenderFlag($flag);

// render only relations that are not native W3C relations $helper->setRenderFlag(Zend_View_Helper_Navigation_Links:RENDER_CUSTOM);

// render all relations (default) $helper->setRenderFlag(Zend_View_Helper_Navigation_Links:RENDER_ALL);

Note that custom relations can also be rendered directly using the renderLink() method.

Parameters
int$renderFlagrender flag
Returns
Zend_View_Helper_Navigation_Links fluent interface, returns self

Member Data Documentation

$_RELATIONS
staticprotected
Initial value:
= array(
self::RENDER_ALTERNATE => 'alternate',
self::RENDER_STYLESHEET => 'stylesheet',
self::RENDER_START => 'start',
self::RENDER_NEXT => 'next',
self::RENDER_PREV => 'prev',
self::RENDER_CONTENTS => 'contents',
self::RENDER_INDEX => 'index',
self::RENDER_GLOSSARY => 'glossary',
self::RENDER_COPYRIGHT => 'copyright',
self::RENDER_CHAPTER => 'chapter',
self::RENDER_SECTION => 'section',
self::RENDER_SUBSECTION => 'subsection',
self::RENDER_APPENDIX => 'appendix',
self::RENDER_HELP => 'help',
self::RENDER_BOOKMARK => 'bookmark'
)
$_renderFlag = self::RENDER_ALL
protected
$_root
protected
const RENDER_ALL = 0xffff
const RENDER_ALTERNATE = 0x0001
const RENDER_APPENDIX = 0x1000
const RENDER_BOOKMARK = 0x4000
const RENDER_CHAPTER = 0x0200
const RENDER_CONTENTS = 0x0020
const RENDER_COPYRIGHT = 0x0100
const RENDER_CUSTOM = 0x8000
const RENDER_GLOSSARY = 0x0080
const RENDER_HELP = 0x2000
const RENDER_INDEX = 0x0040
const RENDER_NEXT = 0x0008
const RENDER_PREV = 0x0010
const RENDER_SECTION = 0x0400
const RENDER_START = 0x0004
const RENDER_STYLESHEET = 0x0002
const RENDER_SUBSECTION = 0x0800