2015-08-09 20:11:39 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Zend Framework
|
|
|
|
*
|
|
|
|
* LICENSE
|
|
|
|
*
|
|
|
|
* This source file is subject to the new BSD license that is bundled
|
|
|
|
* with this package in the file LICENSE.txt.
|
|
|
|
* It is also available through the world-wide-web at this URL:
|
|
|
|
* http://framework.zend.com/license/new-bsd
|
|
|
|
* If you did not receive a copy of the license and are unable to
|
|
|
|
* obtain it through the world-wide-web, please send an email
|
|
|
|
* to license@zend.com so we can send you a copy immediately.
|
|
|
|
*
|
|
|
|
* @category Zend
|
|
|
|
* @package Zend_View
|
|
|
|
* @subpackage Helper
|
|
|
|
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
|
|
|
* @version $Id: TopNav.php 20 2009-12-01 14:26:22Z markus $
|
|
|
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Zend_View_Helper_Placeholder_Container_Standalone */
|
|
|
|
require_once 'Zend/View/Helper/Placeholder/Container/Standalone.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper for building an applications top navigation bar
|
|
|
|
*
|
|
|
|
* @uses Zend_View_Helper_Placeholder_Container_Standalone
|
|
|
|
* @package Zend_View
|
|
|
|
* @subpackage Helper
|
|
|
|
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
|
|
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
|
|
|
*/
|
|
|
|
class Zend_View_Helper_TopNav extends Zend_View_Helper_Placeholder_Container_Standalone
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Registry key for placeholder
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $_regKey = 'Zend_View_Helper_TopNav';
|
|
|
|
|
|
|
|
protected $items = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve placeholder for navigation element and optionally set state
|
|
|
|
*
|
|
|
|
* Single Link elements to be made with $this->url(array('controller'=>'<controller>'), 'default', true);
|
|
|
|
*
|
|
|
|
* @param string $link
|
|
|
|
* @param string $setType
|
|
|
|
* @param string $setPos
|
|
|
|
* @return Zend_View_Helper_TopNav
|
|
|
|
*/
|
|
|
|
public function topNav($link = null, $setType = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $setPos = 0)
|
|
|
|
{
|
2015-08-09 17:12:51 +00:00
|
|
|
$link = (string) $link;
|
2015-08-09 20:11:39 +00:00
|
|
|
if ($link !== '') {
|
|
|
|
if ($setType == Zend_View_Helper_Placeholder_Container_Abstract::SET) {
|
|
|
|
if ($setPos != 0)
|
2015-08-09 17:12:51 +00:00
|
|
|
$this->items[$setPos] = $link;
|
2015-08-09 20:11:39 +00:00
|
|
|
else
|
2015-08-09 17:12:51 +00:00
|
|
|
$this->items[] = $link;
|
2015-08-09 20:11:39 +00:00
|
|
|
} elseif ($setType == Zend_View_Helper_Placeholder_Container_Abstract::PREPEND) {
|
|
|
|
$this->items = array_merge(array($link), $this->items);
|
|
|
|
} else {
|
|
|
|
$this->items[] = $link;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Turn helper into string
|
|
|
|
*
|
|
|
|
* @param string|null $indent
|
|
|
|
* @param string|null $locale
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function toString($indent = null, $locale = null)
|
|
|
|
{
|
2015-08-09 17:12:51 +00:00
|
|
|
$output = '';
|
|
|
|
$indent = (null !== $indent)
|
2015-08-09 20:11:39 +00:00
|
|
|
? $this->getWhitespace($indent)
|
|
|
|
: $this->getIndent();
|
|
|
|
|
|
|
|
ksort($this->items);
|
|
|
|
|
|
|
|
$output .= $indent . "<ul>\n";
|
|
|
|
|
|
|
|
foreach ($this->items as $item) {
|
|
|
|
$output .= $indent . "<li>" . $item . "</li>\n";
|
2015-08-09 17:12:51 +00:00
|
|
|
}
|
|
|
|
$output .= $indent . "</ul>\n";
|
2015-08-09 20:11:39 +00:00
|
|
|
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
}
|