initial setup of framework code
[cacert-mgr.git] / manager / application / views / helpers / LeftNav.php
1 <?php
2 /**
3 * Zend Framework
4 *
5 * LICENSE
6 *
7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
14 *
15 * @category Zend
16 * @package Zend_View
17 * @subpackage Helper
18 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
19 * @version $Id: LeftNav.php 8 2009-11-24 10:32:47Z markus $
20 * @license http://framework.zend.com/license/new-bsd New BSD License
21 */
22
23 /** Zend_View_Helper_Placeholder_Container_Standalone */
24 require_once 'Zend/View/Helper/Placeholder/Container/Standalone.php';
25
26 /**
27 * Helper for building an applications top navigation bar
28 *
29 * @uses Zend_View_Helper_Placeholder_Container_Standalone
30 * @package Zend_View
31 * @subpackage Helper
32 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
33 * @license http://framework.zend.com/license/new-bsd New BSD License
34 */
35 class Zend_View_Helper_LeftNav extends Zend_View_Helper_Placeholder_Container_Standalone
36 {
37 /**
38 * Registry key for placeholder
39 * @var string
40 */
41 protected $_regKey = 'Zend_View_Helper_LeftNav';
42
43 protected $items = array();
44
45 /**
46 * Retrieve placeholder for navigation element and optionally set state
47 *
48 * Single Link elements to be made with $this->url(array('controller'=>'<controller>'), 'default', true);
49 *
50 * @param string $link
51 * @param string $setType
52 * @param string $setPos
53 * @return Zend_View_Helper_LeftNav
54 */
55 public function leftNav($link = null, $setType = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $setPos = 0)
56 {
57 $link = (string) $link;
58 if ($link !== '') {
59 if ($setType == Zend_View_Helper_Placeholder_Container_Abstract::SET) {
60 if ($setPos != 0)
61 $this->items[$setPos] = $link;
62 else
63 $this->items[] = $link;
64 } elseif ($setType == Zend_View_Helper_Placeholder_Container_Abstract::PREPEND) {
65 $this->items = array_merge(array($link), $this->items);
66 } else {
67 $this->items[] = $link;
68 }
69 }
70
71 return $this;
72 }
73
74 /**
75 * Turn helper into string
76 *
77 * @param string|null $indent
78 * @param string|null $locale
79 * @return string
80 */
81 public function __toString($indent = null, $locale = null)
82 {
83 $output = '';
84 $indent = (null !== $indent)
85 ? $this->getWhitespace($indent)
86 : $this->getIndent();
87
88 $output .= $indent . "<ul>\n";
89 foreach ($this->items as $item) {
90 $output .= $indent . "<li>" . $item . "</li>\n";
91 }
92 $output .= $indent . "</ul>\n";
93
94 return $output;
95 }
96 }