Fixed breadcrumb, added submode()

This commit is contained in:
Deon George
2011-12-09 15:10:53 +11:00
parent 56c11507f4
commit 08eab4b5f9
13 changed files with 75 additions and 26 deletions

View File

@@ -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,
);

View File

@@ -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());

View File

@@ -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']),
)
);
}

View File

@@ -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();
}
}
?>

View File

@@ -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);

View File

@@ -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'));
}
}
?>