summaryrefslogtreecommitdiff
path: root/manager/application/views/helpers/LeftNav.php
blob: 01d31e5026889929db1b7ccd89e07f12cbd1b2ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?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: LeftNav.php 8 2009-11-24 10:32:47Z 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_LeftNav extends Zend_View_Helper_Placeholder_Container_Standalone
{
    /**
     * Registry key for placeholder
     * @var string
     */
    protected $_regKey = 'Zend_View_Helper_LeftNav';

    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_LeftNav
     */
    public function leftNav($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();

        $output .= $indent . "<ul>\n";
        foreach ($this->items as $item) {
                $output .= $indent . "<li>" . $item . "</li>\n";
 		}
		$output .= $indent . "</ul>\n";

        return $output;
    }
}