Fixes to work with KH 3.3

This commit is contained in:
Deon George
2012-11-26 16:57:18 +11:00
parent 5bd1841571
commit fc2ffd7bad
97 changed files with 5459 additions and 578 deletions

View File

@@ -10,7 +10,7 @@
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class lnApp_Breadcrumb extends HTMLRender {
abstract class lnApp_Breadcrumb extends HTMLRender {
protected static $_data = array();
protected static $_spacer = ' » ';
protected static $_required_keys = array('body');
@@ -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,17 +62,26 @@ class lnApp_Breadcrumb extends HTMLRender {
* Render this Breadcrumb
*/
protected function render() {
$output = HTML::anchor('/',_('Home'));
$output = '<ul id="breadcrumb">';
$output .= '<li>'.HTML::anchor('/',_('Home')).'</li>';
$data = empty(static::$_data['path']) ? explode('/',preg_replace('/^\//','',Request::detect_uri())) : static::$_data['path'];
$c = count($data);
$i=0;
foreach ($data as $k => $v) {
$output .= static::$_spacer;
$i++;
$p = join('/',array_slice($data,0,$k+1));
$output .= HTML::anchor($p,empty(static::$_data['name'][$p]) ? ucfirst($v) : static::$_data['name'][$p]);
$output .= $i==$c ? '<li id="active">' : '<li>';
$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 .= '</li>';
}
$output .= '</ul>';
return $output;
}
}