Fixed breadcrumb, added submode()
This commit is contained in:
@@ -23,17 +23,32 @@ class lnApp_Breadcrumb extends HTMLRender {
|
||||
public static function set($path) {
|
||||
if (is_string($path))
|
||||
static::$_data['path'] = explode('/',$path);
|
||||
else
|
||||
elseif (is_array($path))
|
||||
static::$_data['path'] = $path;
|
||||
else
|
||||
throw new Kohana_Exception('Path is not a string, nor an array');
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable a friendly name to be used for a path
|
||||
*/
|
||||
public static function name($path,$name) {
|
||||
public static function name($path,$name,$override=TRUE) {
|
||||
if (isset(static::$_data['name'][$path]) AND ! $override)
|
||||
return;
|
||||
|
||||
static::$_data['name'][$path] = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable specifying the URL for a path
|
||||
*/
|
||||
public static function URL($path,$url,$override=TRUE) {
|
||||
if (isset(static::$_data['url'][$path]) AND ! $override)
|
||||
return;
|
||||
|
||||
static::$_data['url'][$path] = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of this class
|
||||
*
|
||||
@@ -47,7 +62,9 @@ class lnApp_Breadcrumb extends HTMLRender {
|
||||
* Render this Breadcrumb
|
||||
*/
|
||||
protected function render() {
|
||||
$output = HTML::anchor('/',_('Home'));
|
||||
// @todo Make this into a view
|
||||
$output = '<table class="pagecontrol"><tr><td class="none">';
|
||||
$output .= HTML::anchor('/',_('Home'));
|
||||
|
||||
$data = empty(static::$_data['path']) ? explode('/',preg_replace('/^\//','',Request::detect_uri())) : static::$_data['path'];
|
||||
|
||||
@@ -55,9 +72,14 @@ class lnApp_Breadcrumb extends HTMLRender {
|
||||
$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]);
|
||||
$output .= HTML::anchor(
|
||||
(empty(static::$_data['url'][$p]) ? $p : static::$_data['url'][$p]),
|
||||
(empty(static::$_data['name'][$p]) ? ucfirst($v) : static::$_data['name'][$p])
|
||||
);
|
||||
}
|
||||
|
||||
$output .= '</td></tr></table>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user