Themeing work based on bootstrap
This commit is contained in:
@@ -14,18 +14,14 @@ class lnApp_Controller_Login extends Controller_TemplateDefault {
|
||||
protected $auth_required = FALSE;
|
||||
|
||||
public function action_index() {
|
||||
$output = '';
|
||||
|
||||
// If user already signed-in
|
||||
if (Auth::instance()->logged_in() != 0) {
|
||||
// Redirect to the user account
|
||||
if (Auth::instance()->logged_in())
|
||||
HTTP::redirect(URL::link('user','welcome/index'));
|
||||
}
|
||||
|
||||
// If there is a post and $_POST is not empty
|
||||
if ($_POST) {
|
||||
// Store our details in a session key
|
||||
Session::instance()->set(Kohana::$config->load('auth')->session_key,$_POST['username']);
|
||||
Session::instance()->set('password',$_POST['password']);
|
||||
|
||||
// If the post data validates using the rules setup in the user model
|
||||
if (Auth::instance()->login($_POST['username'],$_POST['password'])) {
|
||||
// Redirect to the user account
|
||||
@@ -37,37 +33,28 @@ class lnApp_Controller_Login extends Controller_TemplateDefault {
|
||||
HTTP::redirect(URL::link('user','welcome/index'));
|
||||
|
||||
} else {
|
||||
// We are not successful logging in, so delete our session data
|
||||
Session::instance()->delete(Kohana::$config->load('auth')->session_key);
|
||||
Session::instance()->delete('password');
|
||||
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('Invalid username or password'),
|
||||
'type'=>'error',
|
||||
'body'=>_('The username or password was invalid.')
|
||||
));
|
||||
SystemMessage::factory()
|
||||
->title(_('Invalid username or password'))
|
||||
->type('error')
|
||||
->body(_('The username or password was invalid.'));
|
||||
}
|
||||
}
|
||||
|
||||
Block::add(array(
|
||||
'title'=>_('Login to server'),
|
||||
'body'=>View::factory('login'),
|
||||
'style'=>array('css/login.css'=>'screen'),
|
||||
));
|
||||
$output .= View::factory('pages/login');
|
||||
|
||||
Script::add(array('type'=>'stdin','data'=>'
|
||||
$(document).ready(function() {
|
||||
$("#ajxbody").click(function() {$("#ajBODY").load("'.$this->request->uri().'/"); return false;});
|
||||
});'
|
||||
));
|
||||
Style::factory()
|
||||
->type('file')
|
||||
->data('media/theme/baseadmin/css/pages/login.css');
|
||||
|
||||
$this->template->content = $output;
|
||||
$this->template->shownavbar = FALSE;
|
||||
}
|
||||
|
||||
public function action_noaccess() {
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('No access to requested resource'),
|
||||
'type'=>'error',
|
||||
'body'=>_('You do not have access to the requested resource, please contact your administrator.')
|
||||
));
|
||||
SystemMessage::factory()
|
||||
->title(_('No access to requested resource'))
|
||||
->type('error')
|
||||
->body(_('You do not have access to the requested resource, please contact your administrator.'));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -13,15 +13,13 @@
|
||||
class lnApp_Controller_Logout extends Controller {
|
||||
public function action_index() {
|
||||
// If user already signed-in
|
||||
if (Auth::instance()->logged_in() != 0) {
|
||||
if (Auth::instance()->logged_in()) {
|
||||
$ao = Auth::instance()->get_user();
|
||||
|
||||
if (method_exists($ao,'log'))
|
||||
$ao->log('Logged Out');
|
||||
|
||||
Auth::instance()->logout();
|
||||
|
||||
HTTP::redirect('login');
|
||||
Auth::instance()->logout(TRUE);
|
||||
}
|
||||
|
||||
HTTP::redirect('welcome/index');
|
||||
|
@@ -30,16 +30,6 @@ abstract class lnApp_Controller_Media extends Controller {
|
||||
if ($fd = Session::instance()->get_once($this->request->param('file'))) {
|
||||
$this->response->body($fd);
|
||||
|
||||
// First try and find media files for the theme-site_id
|
||||
} elseif ($f = Kohana::find_file($x=sprintf('media/site/%s/theme/%s',Config::siteid(),Config::theme()),$file,$ext)) {
|
||||
// Send the file content as the response
|
||||
$this->response->body(file_get_contents($f));
|
||||
|
||||
// Try and find media files for the site_id
|
||||
} elseif ($f = Kohana::find_file(sprintf('media/site/%s',Config::siteid()),$file,$ext)) {
|
||||
// Send the file content as the response
|
||||
$this->response->body(file_get_contents($f));
|
||||
|
||||
// If not found try a default media file
|
||||
} elseif ($f = Kohana::find_file('media',$file,$ext)) {
|
||||
// Send the file content as the response
|
||||
@@ -51,7 +41,7 @@ abstract class lnApp_Controller_Media extends Controller {
|
||||
}
|
||||
|
||||
// Generate and check the ETag for this file
|
||||
if (Kohana::$environment === Kohana::PRODUCTION OR Kohana::$config->load('debug')->etag)
|
||||
if (Kohana::$environment < Kohana::TESTING OR Kohana::$config->load('debug')->etag)
|
||||
$this->check_cache(sha1($this->response->body()));
|
||||
|
||||
// Set the proper headers to allow caching
|
||||
|
@@ -1,20 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides the default controller for tasks.
|
||||
*
|
||||
* @package lnApp
|
||||
* @category lnApp/Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
abstract class lnApp_Controller_Task extends Controller {
|
||||
public function before() {
|
||||
if (! Kohana::$is_cli)
|
||||
throw new Kohana_Exception('Cant run :method, it must be run by the CLI',array(':method'=>$this->request->action()));
|
||||
|
||||
parent::before();
|
||||
}
|
||||
}
|
||||
?>
|
@@ -10,10 +10,6 @@
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
abstract class lnApp_Controller_TemplateDefault extends Controller_Template {
|
||||
/**
|
||||
* @var string page template
|
||||
*/
|
||||
public $template = 'theme/bootstrap/default';
|
||||
/**
|
||||
* @var object meta object information as per [meta]
|
||||
*/
|
||||
@@ -56,7 +52,7 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template {
|
||||
|
||||
return (($this->auth_required !== FALSE && Auth::instance()->logged_in(NULL,get_class($this).'|'.__METHOD__) === FALSE) ||
|
||||
(is_array($this->secure_actions) && array_key_exists($this->request->action(),$this->secure_actions) &&
|
||||
Auth::instance()->logged_in($this->secure_actions[$this->request->action()],get_class($this).'|'.__METHOD__) === FALSE));
|
||||
! Auth::instance()->logged_in($this->secure_actions[$this->request->action()],get_class($this).'|'.__METHOD__)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,6 +102,9 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template {
|
||||
}
|
||||
}
|
||||
|
||||
if (! $this->auto_render)
|
||||
return;
|
||||
|
||||
// For AJAX calls, we dont need to render the complete page.
|
||||
if ($this->request->is_ajax()) {
|
||||
$this->auto_render = FALSE;
|
||||
@@ -116,20 +115,8 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template {
|
||||
$this->meta = new Meta;
|
||||
View::bind_global('meta',$this->meta);
|
||||
|
||||
// Add our logo
|
||||
/*
|
||||
Style::add(array(
|
||||
'type'=>'stdin',
|
||||
'data'=>'h1 span{background:url('.Config::logo_uri().') no-repeat;}',
|
||||
));
|
||||
*/
|
||||
|
||||
// Our default script(s)
|
||||
/*
|
||||
foreach (array('file'=>array_reverse(array(
|
||||
'js/jquery-1.6.4.min.js',
|
||||
'js/jquery.jstree-1.0rc3.js',
|
||||
'js/jquery.cookie.js',
|
||||
))) as $type => $datas) {
|
||||
|
||||
foreach ($datas as $data) {
|
||||
@@ -139,54 +126,41 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template {
|
||||
),TRUE);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Initialise our content
|
||||
$this->template->left = '';
|
||||
$this->template->shownavbar = TRUE;
|
||||
$this->template->content = '';
|
||||
$this->template->right = '';
|
||||
$this->template->footer = '';
|
||||
}
|
||||
|
||||
public function after() {
|
||||
if (! is_string($this->template) AND empty($this->template->content))
|
||||
$this->template->content = Block::factory();
|
||||
|
||||
if ($this->auto_render) {
|
||||
$this->template->navbar = $this->template->shownavbar ? View::factory('pages/navbar') : '';
|
||||
|
||||
if (empty($this->template->content))
|
||||
$this->template->content = Block::factory()->render_all();
|
||||
|
||||
// Adjust our breadcrumb
|
||||
if (isset(URL::$method_directory[strtolower($this->request->directory())]))
|
||||
BreadCrumb::name(URL::$method_directory[strtolower($this->request->directory())],$this->request->directory());
|
||||
|
||||
// Application Title
|
||||
if (class_exists('Model_Module') AND $mo=ORM::factory('Module',array('name'=>Request::current()->controller())) AND $mo->loaded())
|
||||
$this->meta->title = sprintf('%s: %s',Kohana::$config->load('config')->appname,$mo->display('name'));
|
||||
else
|
||||
$this->meta->title = Config::sitename();
|
||||
|
||||
$this->template->title = '';
|
||||
|
||||
// Language
|
||||
$this->meta->language = Config::language();
|
||||
$this->meta->title = Kohana::$config->load('config')->appname;
|
||||
|
||||
// Description
|
||||
$this->meta->description = sprintf('%s::%s',$this->request->controller(),$this->request->action());
|
||||
|
||||
// Link images on the header line
|
||||
$this->template->headimages = $this->_headimages();
|
||||
|
||||
// System Messages line
|
||||
$this->template->sysmsg = $this->_sysmsg();
|
||||
|
||||
// Left Item
|
||||
$this->template->left = '';
|
||||
|
||||
// Right Item
|
||||
$this->template->right = '';
|
||||
|
||||
// Footer
|
||||
$this->template->footer = $this->_footer();
|
||||
// In case we have some scripting/styling, we need to get that out too
|
||||
} elseif ($this->request->is_ajax() AND $this->response->body()) {
|
||||
$this->response->bodyadd(Script::factory()->render_all());
|
||||
$this->response->bodyadd(Style::factory()->render_all());
|
||||
|
||||
// For any ajax rendered actions, we'll need to capture the content and put it in the response
|
||||
// @todo Do we come here for ajax?
|
||||
} elseif ($this->request->is_ajax() && isset($this->template->content) && ! $this->response->body()) {
|
||||
// @todo move this formatting to a view?
|
||||
if ($s = $this->_sysmsg() AND (string)$s)
|
||||
$this->response->body(sprintf('<table class="sysmsg"><tr><td>%s</td></tr></table>',$s));
|
||||
|
||||
// In case there any style sheets for this render.
|
||||
$this->response->bodyadd(Style::factory());
|
||||
|
||||
@@ -204,7 +178,8 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template {
|
||||
parent::after();
|
||||
|
||||
// Generate and check the ETag for this file
|
||||
$this->check_cache(sha1($this->response->body()));
|
||||
if (Kohana::$environment < Kohana::TESTING OR Kohana::$config->load('debug')->etag)
|
||||
$this->check_cache(sha1($this->response->body()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,24 +189,6 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template {
|
||||
$this->template->content = _('Please choose from the menu on the left - you may need to expand the items by pressing on the plus.');
|
||||
}
|
||||
|
||||
protected function _headimages() {
|
||||
HeadImages::add(array(
|
||||
'url'=>'http://dev.leenooks.net',
|
||||
'img'=>'img/forum-big.png',
|
||||
'attrs'=>array('onclick'=>"target='_blank';",'title'=>'Link')
|
||||
));
|
||||
|
||||
return HeadImages::factory();
|
||||
}
|
||||
|
||||
protected function _sysmsg() {
|
||||
return SystemMessage::factory();
|
||||
}
|
||||
|
||||
public function _footer() {
|
||||
return sprintf('© %s',Config::sitename());
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a view path to help View::factory() calls
|
||||
*
|
||||
@@ -240,6 +197,7 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template {
|
||||
* plugins
|
||||
*
|
||||
* @param string Plugin Name (optional)
|
||||
* @deprecated
|
||||
*/
|
||||
public function viewpath($plugin='') {
|
||||
$request = Request::current();
|
||||
|
@@ -1,116 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class extends renders OSB menu tree.
|
||||
*
|
||||
* @package lnApp
|
||||
* @category lnApp/Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class lnApp_Controller_Tree extends Controller_Default {
|
||||
/**
|
||||
* @var string page media route as per [Route]
|
||||
*/
|
||||
protected static $jsmediaroute = 'default/media';
|
||||
|
||||
public function after() {
|
||||
$this->response->headers('Content-Type','application/json');
|
||||
$this->response->body(json_encode($this->output));
|
||||
|
||||
parent::after();
|
||||
}
|
||||
|
||||
public static function js() {
|
||||
$mediapath = Route::get(static::$jsmediaroute);
|
||||
|
||||
return '
|
||||
<div id="tree" class=""></div>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
$(function () {
|
||||
var use_ajax = false;
|
||||
|
||||
$("#tree").jstree({
|
||||
themes : {
|
||||
"theme" : "classic",
|
||||
},
|
||||
ui : {
|
||||
"select_limit" : 1,
|
||||
"select_node" : false,
|
||||
},
|
||||
cookies : {
|
||||
"save_selected" : false,
|
||||
"cookie_options" : { path : "'.URL::site().'" }
|
||||
},
|
||||
json_data : {
|
||||
"correct_state" : "true",
|
||||
"progressive_render" : "true",
|
||||
"ajax" : {
|
||||
"url" : "'.URL::site('tree/json').'",
|
||||
"data" : function (n) {
|
||||
return { id : n.attr ? n.attr("id") : "N_"+0 };
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins : [ "themes", "json_data", "ui", "cookies" ],
|
||||
});
|
||||
|
||||
// On selection
|
||||
$("#tree").bind("select_node.jstree", function (e, data) {
|
||||
if (a = data.rslt.obj.attr(\'id\').indexOf(\'_\')) {
|
||||
id = data.rslt.obj.attr(\'id\').substr(a+1);
|
||||
|
||||
if (href = $("#N_"+id).attr("href")) {
|
||||
if (! use_ajax) {
|
||||
window.location = href;
|
||||
return;
|
||||
}
|
||||
|
||||
$("#ajBODY").empty().html("<img src=\"'.URL::site('media/img/ajax-progress.gif').'\" alt=\"Loading...\" />");
|
||||
$("#ajBODY").load(href, function(r,s,x) {
|
||||
if (s == "error") {
|
||||
var msg = "Sorry but there was an error: ";
|
||||
$("#ajBODY").html(msg + x.status + " " + x.statusText + r);
|
||||
}
|
||||
});
|
||||
} else
|
||||
alert("Unknown: "+id+" HREF:"+href);
|
||||
}
|
||||
});
|
||||
});
|
||||
// -->
|
||||
</script>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the Tree Menu
|
||||
*
|
||||
* The incoming ID is either a Branch B_x or a Node N_x
|
||||
* Where X is actually the module.
|
||||
*
|
||||
* @param array $data Tree data passed in by inherited methods
|
||||
*/
|
||||
public function action_json(array $data=array()) {
|
||||
if ($this->_auth_required() AND ! Auth::instance()->logged_in()) {
|
||||
$this->output = array('attr'=>array('id'=>'a_login'),
|
||||
'data'=>array('title'=>_('Please Login').'...','attr'=>array('id'=>'N_login','href'=>URL::site('login'))));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->output = array();
|
||||
|
||||
foreach ($data as $branch) {
|
||||
array_push($this->output,array(
|
||||
'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::link('user',$branch['name'].'/menu',TRUE) : $branch['attr_href']),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user