You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.3 KiB
50 lines
1.3 KiB
<?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);
|
|
}
|
|
}
|