Major theme rework

This commit is contained in:
Deon George
2012-01-29 17:23:24 +11:00
parent 3d1c43687c
commit 89bb9004ed
49 changed files with 663 additions and 1320 deletions

View File

@@ -66,5 +66,9 @@ class Config extends lnApp_Config {
public static function sitemode() {
return Config::instance()->loadsite()->so->status;
}
public static function copywrite() {
return '(c) Open Source Billing Development Team';
}
}
?>

View File

@@ -0,0 +1,63 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides access to rendering media items (javascript, images and css).
*
* @package lnApp
* @subpackage Page/Media
* @category Controllers
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
abstract class Controller_lnApp_Media extends Controller {
/**
* This action will render all the media related files for a page
*
* @return void
*/
final public function action_get() {
// Get the file path from the request
$file = $this->request->param('file');
// Find the file extension
$ext = pathinfo($file,PATHINFO_EXTENSION);
// Remove the extension from the filename
$file = substr($file,0,-(strlen($ext)+1));
$f = '';
// If our file is pathed with session, our file is in our session.
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
$this->response->body(file_get_contents($f));
} else {
// Return a 404 status
$this->response->status(404);
}
// Generate and check the ETag for this file
$this->response->check_cache(NULL,$this->request);
// Set the proper headers to allow caching
$this->response->headers('Content-Type',File::mime_by_ext($ext));
$this->response->headers('Content-Length',(string)$this->response->content_length());
$this->response->headers('Last-Modified',date('r',$f ? filemtime($f) : time()));
}
}
?>

View File

@@ -41,7 +41,7 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
protected $secure_actions = array(
);
public function __construct(Request $request, Response $response) {
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;
@@ -122,18 +122,11 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
$this->meta = new meta;
View::bind_global('meta',$this->meta);
// Our default style sheet(s)
foreach (array('file'=>array_reverse(array(
'css/default.css',
))) as $type => $datas) {
foreach ($datas as $data) {
Style::add(array(
'type'=>$type,
'data'=>$data,
),TRUE);
}
}
// 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(
@@ -168,27 +161,12 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
// Language
$this->meta->language = Config::instance()->so->language_id;
// Copyright
$this->meta->copywrite = Config::sitename();
// Copyright
// Description
$this->meta->description = sprintf('%s::%s',$this->request->controller(),$this->request->action());
// Style Sheets Properties
$this->meta->styles = Style::factory();
// Script Properties
$this->meta->scripts = Script::factory();
// Application logo
$this->template->logo = Config::logo();
// Link images on the header line
$this->template->headimages = $this->_headimages();
// Control Line
$this->template->control = $this->_control();
// System Messages line
$this->template->sysmsg = $this->_sysmsg();
@@ -245,13 +223,6 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
return HeadImages::factory();
}
/**
* Render our control menu bar
*/
protected function _control() {
return Breadcrumb::factory();
}
protected function _sysmsg() {
return SystemMessage::factory();
}
@@ -290,48 +261,5 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
return $path;
}
/**
* This action will render all the media related files for a page
* @return void
*/
final public function action_media() {
// Get the file path from the request
$file = $this->request->param('file');
// Find the file extension
$ext = pathinfo($file, PATHINFO_EXTENSION);
// Remove the extension from the filename
$file = substr($file, 0, -(strlen($ext) + 1));
$f = '';
// If our file is pathed with session, our file is in our session.
if ($fd = Session::instance()->get_once($this->request->param('file'))) {
$this->response->body($fd);
// First try and find media files for the site_id
} elseif ($f = Kohana::find_file(sprintf('media/%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
$this->response->body(file_get_contents($f));
} else {
// Return a 404 status
$this->response->status(404);
}
// Generate and check the ETag for this file
$this->response->check_cache(NULL,$this->request);
// Set the proper headers to allow caching
$this->response->headers('Content-Type',File::mime_by_ext($ext));
$this->response->headers('Content-Length',(string)$this->response->content_length());
$this->response->headers('Last-Modified',date('r', $f ? filemtime($f) : time()));
}
}
?>

View File

@@ -31,6 +31,8 @@ class Controller_lnApp_Tree extends Controller_Default {
<script type="text/javascript">
<!--
$(function () {
var use_ajax = false;
$("#tree").jstree({
themes : {
"theme" : "classic",
@@ -62,6 +64,12 @@ $(function () {
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") {

View File

@@ -0,0 +1,4 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
class Controller_Media extends Controller_lnApp_Media {}
?>

View File

@@ -11,6 +11,13 @@
* @license http://dev.leenooks.net/license.html
*/
class Controller_TemplateDefault extends Controller_lnApp_TemplateDefault {
public function __construct(Request $request, Response $response) {
if (Config::theme())
$this->template = Config::theme().'/page';
return parent::__construct($request,$response);
}
protected function _headimages() {
// This is where we should be able to change our country
// @todo To implement

View File

@@ -17,22 +17,8 @@ class Controller_Welcome extends Controller_TemplateDefault {
if (! Kohana::config('config.appname'))
Request::current()->redirect('guide/app');
Block::add(array(
'title'=>'Welcome to lnApp (public)!',
'subtitle'=>'Using lnApp',
'body'=>'Sample lnApp application',
'footer'=>'lnApp makes building websites easy! '.time(),
));
// @todo Show a login/logout on the breadcrumb
if (! Auth::instance()->logged_in()) {
Script::add(array('type'=>'stdin','data'=>'
$(document).ready(function() {
$("#ajxbody").click(function() {$("#ajBODY").load("'.URL::site('login').'",null,function(x,s,r) {}); return false;});
$("#ajBODY").ajaxSend(function() {$(this).html(\''.sprintf('%s <span class="ajaxmsg">%s<\/span>...',HTML::image('media/img/ajax-progress.gif',array('alt'=>_('Loading Login').'...')),_('Loading Login')).'\');return true;});
});'
));
}
// @todo This should be in the DB or something.
Request::current()->redirect('product/categorys');
}
public function action_breadcrumb() {

View File

@@ -62,24 +62,26 @@ class lnApp_Breadcrumb extends HTMLRender {
* Render this Breadcrumb
*/
protected function render() {
// @todo Make this into a view
$output = '<table class="pagecontrol"><tr><td class="none">';
$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 .= $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 .= '</td></tr></table>';
$output .= '</ul>';
return $output;
}
}

View File

@@ -75,7 +75,7 @@ abstract class lnApp_Config extends Kohana_Config {
// Called in Invoice/Emailing to embed the file.
public static function logo_file() {
list ($path,$suffix) = explode('.',static::$logo);
return Kohana::find_file(sprintf('media/%s',Config::siteid()),$path,$suffix);
return ($a=Kohana::find_file(sprintf('media/site/%s',Config::siteid()),$path,$suffix)) ? $a : Kohana::find_file('media',$path,$suffix);
}
public static function logo_uri() {
@@ -87,6 +87,10 @@ abstract class lnApp_Config extends Kohana_Config {
return HTML::image(static::logo_uri(),array('class'=>'headlogo','alt'=>_('Logo')));
}
public static function login_uri() {
return ($ao = Auth::instance()->get_user()) ? HTML::anchor('user/account/edit',$ao->name()) : HTML::anchor('login',_('Login'));
}
/**
* Return our caching mechanism
*/
@@ -129,5 +133,9 @@ abstract class lnApp_Config extends Kohana_Config {
else
return $config[$template];
}
public static function theme() {
return Kohana::config('config.theme');
}
}
?>