You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cacert-testmgr/manager/application/views/helpers/TopNav.php

100 lines
3.1 KiB
PHP

<?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)
{
$link = (string) $link;
if ($link !== '') {
if ($setType == Zend_View_Helper_Placeholder_Container_Abstract::SET) {
if ($setPos != 0)
$this->items[$setPos] = $link;
else
$this->items[] = $link;
} 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)
{
$output = '';
$indent = (null !== $indent)
? $this->getWhitespace($indent)
: $this->getIndent();
ksort($this->items);
$output .= $indent . "<ul>\n";
foreach ($this->items as $item) {
$output .= $indent . "<li>" . $item . "</li>\n";
}
$output .= $indent . "</ul>\n";
return $output;
}
}