Add namespace.
This commit is contained in:
50
View/Helpers/BreadcrumbViewHelper.php
Normal file
50
View/Helpers/BreadcrumbViewHelper.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php namespace Majestic\View\Helpers;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
* @package Majestic
|
||||
* @subpackage View
|
||||
* @since 2010-03-16
|
||||
*/
|
||||
|
||||
class BreadcrumbViewHelper extends ViewHelper
|
||||
{
|
||||
|
||||
protected $separator = ' > ';
|
||||
|
||||
public function breadcrumb($text = false, $href = false)
|
||||
{
|
||||
if ($text) {
|
||||
$this->append($text, $href);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function prepend($text, $href)
|
||||
{
|
||||
\Majestic\Registry::set(__CLASS__, array($text => $href) + \Majestic\Registry::get(__CLASS__, array()));
|
||||
}
|
||||
|
||||
public function append($text, $href)
|
||||
{
|
||||
\Majestic\Registry::set(__CLASS__, \Majestic\Registry::get(__CLASS__, array()) + array($text => $href));
|
||||
}
|
||||
|
||||
public function setSeparator($sep)
|
||||
{
|
||||
$this->separator = $sep;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$data = array();
|
||||
foreach (\Majestic\Registry::get(__CLASS__, array()) as $text => $href) {
|
||||
if ($href) {
|
||||
$data[] = '<a href="' . $this->view->escape($href) . '">' . $this->view->escape($text) . '</a>';
|
||||
} else {
|
||||
$data[] = $this->view->escape($text);
|
||||
}
|
||||
}
|
||||
return implode($this->separator, $data);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user