2011-01-17 05:33:55 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class is for rendering a breadcrumb menu.
|
|
|
|
*
|
|
|
|
* @package lnApp
|
|
|
|
* @subpackage Page
|
|
|
|
* @category Helpers
|
|
|
|
* @author Deon George
|
|
|
|
* @copyright (c) 2010 Deon George
|
|
|
|
* @license http://dev.leenooks.net/license.html
|
|
|
|
*/
|
|
|
|
class lnApp_Breadcrumb extends HTMLRender {
|
|
|
|
protected static $_data = array();
|
|
|
|
protected static $_spacer = ' » ';
|
|
|
|
protected static $_required_keys = array('body');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the breadcrumb path
|
|
|
|
*
|
|
|
|
* @param array Block attributes
|
|
|
|
*/
|
|
|
|
public static function set($path) {
|
|
|
|
if (is_string($path))
|
|
|
|
static::$_data['path'] = explode('/',$path);
|
|
|
|
else
|
|
|
|
static::$_data['path'] = $path;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable a friendly name to be used for a path
|
|
|
|
*/
|
|
|
|
public static function name($path,$name) {
|
|
|
|
static::$_data['name'][$path] = $name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return an instance of this class
|
|
|
|
*
|
|
|
|
* @return Breadcrumb
|
|
|
|
*/
|
|
|
|
public static function factory() {
|
|
|
|
return new Breadcrumb;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render this Breadcrumb
|
|
|
|
*/
|
|
|
|
protected function render() {
|
|
|
|
$output = HTML::anchor('/',_('Home'));
|
|
|
|
|
2011-05-23 10:01:27 +00:00
|
|
|
$data = empty(static::$_data['path']) ? explode('/',preg_replace('/^\//','',Request::detect_uri())) : static::$_data['path'];
|
2011-01-17 05:33:55 +00:00
|
|
|
|
|
|
|
foreach ($data as $k => $v) {
|
|
|
|
$output .= static::$_spacer;
|
|
|
|
|
|
|
|
$p = join('/',array_slice($data,0,$k+1));
|
|
|
|
$output .= HTML::anchor($p,empty(static::$_data['name'][$p]) ? ucfirst($v) : static::$_data['name'][$p]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|