Fixed breadcrumb, added submode()
This commit is contained in:
@@ -10,8 +10,7 @@
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_Admin_Welcome extends Controller_TemplateDefault {
|
||||
protected $auth_required = TRUE;
|
||||
class Controller_Admin_Welcome extends Controller_TemplateDefault_Admin {
|
||||
public $secure_actions = array(
|
||||
'index'=>TRUE,
|
||||
);
|
||||
|
@@ -39,9 +39,16 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
|
||||
* @var array actions that require a valid user
|
||||
*/
|
||||
protected $secure_actions = array(
|
||||
'menu' => FALSE,
|
||||
);
|
||||
|
||||
public function __construct(Request $request, Response $response) {
|
||||
// Our Menu's can run without method authentication by default.
|
||||
if (! isset($this->secure_actions['menu']))
|
||||
$this->secure_actions['menu'] = FALSE;
|
||||
|
||||
return parent::__construct($request,$response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check and see if this controller needs authentication
|
||||
*
|
||||
@@ -197,6 +204,10 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
|
||||
// In case there any style sheets for this render.
|
||||
$this->response->bodyadd(Style::factory());
|
||||
|
||||
// Since we are ajax, we should re-render the breadcrumb
|
||||
Session::instance()->set('breadcrumb',(string)Breadcrumb::factory());
|
||||
$this->response->bodyadd(Script::add(array('type'=>'stdin','data'=>'$().ready($("#ajCONTROL").load("'.URL::site('welcome/breadcrumb').'",null,function(x,s,r) {}));')));
|
||||
|
||||
// In case there any javascript for this render.
|
||||
$this->response->bodyadd(Script::factory());
|
||||
|
||||
|
@@ -101,7 +101,7 @@ $(function () {
|
||||
'attr'=>array('id'=>sprintf('B_%s',$branch['id'])),
|
||||
'state'=>$branch['state'],
|
||||
'data'=>array('title'=>$branch['name']),
|
||||
'attr'=>array('id'=>sprintf('N_%s',$branch['id']),'href'=>empty($branch['attr_href']) ? URL::site(sprintf('%s/menu',$branch['name'])) : $branch['attr_href']),
|
||||
'attr'=>array('id'=>sprintf('N_%s',$branch['id']),'href'=>empty($branch['attr_href']) ? URL::site(sprintf('user/%s/menu',$branch['name'])) : $branch['attr_href']),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@@ -22,9 +22,19 @@ class Controller_TemplateDefault_User extends Controller_TemplateDefault {
|
||||
|
||||
parent::before();
|
||||
|
||||
$this->ao = ORM::factory('account',Auth::instance()->get_user()->id);
|
||||
$this->ao = Auth::instance()->get_user();
|
||||
if (! $this->ao->loaded())
|
||||
throw new Kohana_Exception('Account doesnt exist :account ?',array(':account'=>Auth::instance()->get_user()->id));
|
||||
}
|
||||
|
||||
public function after() {
|
||||
$dc = 'welcome/index';
|
||||
$m = sprintf('%s/%s',Request::current()->directory(),Request::current()->controller());
|
||||
|
||||
Breadcrumb::URL(Request::current()->directory(),sprintf('%s/%s',Request::current()->directory(),$dc),FALSE);
|
||||
Breadcrumb::URL($m,method_exists($this,'action_menu') ? $m.'/menu' : sprintf('%s/%s',Request::current()->directory(),$dc),FALSE);
|
||||
|
||||
parent::after();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -10,8 +10,10 @@
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_User_Welcome extends Controller_TemplateDefault {
|
||||
protected $auth_required = TRUE;
|
||||
class Controller_User_Welcome extends Controller_TemplateDefault_User {
|
||||
protected $secure_actions = array(
|
||||
'index'=>FALSE,
|
||||
);
|
||||
|
||||
public function action_index() {
|
||||
$ao = ORM::factory('account',Auth::instance()->get_user()->id);
|
||||
|
@@ -37,5 +37,11 @@ class Controller_Welcome extends Controller_TemplateDefault {
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public function action_breadcrumb() {
|
||||
$this->auto_render = FALSE;
|
||||
|
||||
$this->response->body(Session::instance()->get_once('breadcrumb'));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user