Changes to AgileBill
This commit is contained in:
@@ -1,180 +1,204 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* AgileBill - Open Billing Software
|
||||
*
|
||||
* This body of work is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Open AgileBill License
|
||||
* License as published at http://www.agileco.com/agilebill/license1-4.txt
|
||||
*
|
||||
* For questions, help, comments, discussion, etc., please join the
|
||||
* Agileco community forums at http://forum.agileco.com/
|
||||
*
|
||||
* Originally authored by Tony Landis, AgileBill LLC
|
||||
*
|
||||
* Recent modifications by Deon George
|
||||
*
|
||||
* @author Deon George <deonATleenooksDOTnet>
|
||||
* @copyright 2009 Deon George
|
||||
* @link http://osb.leenooks.net
|
||||
*
|
||||
* @link http://www.agileco.com/
|
||||
* @copyright 2004-2008 Agileco, LLC.
|
||||
* @license http://www.agileco.com/agilebill/license1-4.txt
|
||||
* @author Tony Landis <tony@agileco.com>
|
||||
* @author Tony Landis <tony@agileco.com>
|
||||
* @package AgileBill
|
||||
* @version 1.4.93
|
||||
* @subpackage Core
|
||||
*/
|
||||
|
||||
class CORE_theme
|
||||
{
|
||||
var $id;
|
||||
|
||||
function CORE_theme()
|
||||
{
|
||||
global $VAR, $C_debug, $C_translate, $smarty;
|
||||
/**
|
||||
* The main AgileBill CORE Theme Class
|
||||
*
|
||||
* @package AgileBill
|
||||
* @subpackage Core
|
||||
* @uses CORE_block
|
||||
*/
|
||||
class CORE_theme {
|
||||
public $id;
|
||||
|
||||
function __construct() {
|
||||
global $VAR,$C_debug,$C_translate,$smarty;
|
||||
|
||||
# Get the cuurent session theme:
|
||||
if(defined("SESS_THEME") && file_exists(PATH_THEMES . '' . SESS_THEME . '/template.tpl'))
|
||||
{
|
||||
if(SESS_THEME == 'default_admin' && SESS_LOGGED != true )
|
||||
define ('THEME_NAME', DEF_THEME_N);
|
||||
elseif (defined("ADMIN_FORCE"))
|
||||
define ('THEME_NAME', 'default_admin');
|
||||
elseif (!defined("ADMIN_FORCE") && SESS_THEME != 'default_admin')
|
||||
define ('THEME_NAME', SESS_THEME);
|
||||
if(defined('SESS_THEME') && file_exists(PATH_THEMES.SESS_THEME.'/template.tpl')) {
|
||||
if (SESS_THEME == 'default_admin' && SESS_LOGGED != true )
|
||||
define ('THEME_NAME',DEF_THEME_N);
|
||||
elseif (defined('ADMIN_FORCE'))
|
||||
define ('THEME_NAME','default_admin');
|
||||
elseif (! defined('ADMIN_FORCE') && SESS_THEME != 'default_admin')
|
||||
define ('THEME_NAME',SESS_THEME);
|
||||
else
|
||||
define ('THEME_NAME', DEF_THEME_N);
|
||||
define ('THEME_NAME',DEF_THEME_N);
|
||||
|
||||
} elseif(file_exists(PATH_THEMES.DEFAULT_THEME.'/template.tpl')) {
|
||||
define ('THEME_NAME',DEFAULT_THEME);
|
||||
|
||||
} else {
|
||||
define ('THEME_NAME',DEF_THEME_N);
|
||||
}
|
||||
elseif(file_exists(PATH_THEMES.DEFAULT_THEME.'/template.tpl'))
|
||||
{
|
||||
define ('THEME_NAME', DEFAULT_THEME);
|
||||
}
|
||||
else
|
||||
{
|
||||
define ('THEME_NAME', DEF_THEME_N);
|
||||
}
|
||||
|
||||
# load the block class
|
||||
$block = new CORE_block;
|
||||
|
||||
# set smarty vars
|
||||
if(isset($smarty->template_dir)) unset($smarty->template_dir);
|
||||
$smarty->use_sub_dirs = false;
|
||||
$smarty->template_dir = PATH_THEMES . '' . THEME_NAME . '/';
|
||||
$smarty->compile_dir = PATH_SMARTY . 'templates/';
|
||||
$smarty->config_dir = PATH_SMARTY . 'configs/';
|
||||
$smarty->cache_dir = PATH_SMARTY . 'cache/';
|
||||
$this->caching = false;
|
||||
$this->compile_check = true;
|
||||
$smarty->assign("THEME_NAME", THEME_NAME);
|
||||
# Set smarty vars
|
||||
if (isset($smarty->template_dir))
|
||||
unset($smarty->template_dir);
|
||||
|
||||
# Frame Theme Escape
|
||||
if(THEME_NAME == 'default_admin')
|
||||
{
|
||||
if (!empty($VAR['tid']) && empty($VAR['_escape']))
|
||||
{
|
||||
// get url string to pass to mainFrame
|
||||
$url='';
|
||||
$i=0;
|
||||
while(list($key,$val) = each($VAR)) {
|
||||
if($key != 'tid')
|
||||
{
|
||||
if($i==0) $url .= '?'; else $url .= '&';
|
||||
$url .= $key.'='.$val;
|
||||
$smarty->use_sub_dirs = false;
|
||||
$smarty->template_dir = PATH_THEMES.THEME_NAME.'/';
|
||||
$smarty->compile_dir = PATH_SMARTY.'templates/';
|
||||
$smarty->config_dir = PATH_SMARTY.'configs/';
|
||||
$smarty->cache_dir = PATH_SMARTY.'cache/';
|
||||
$this->caching = false;
|
||||
$this->compile_check = true;
|
||||
$smarty->assign('THEME_NAME',THEME_NAME);
|
||||
|
||||
# Frame Theme Escape
|
||||
if (THEME_NAME == 'default_admin') {
|
||||
if (! empty($VAR['tid']) && empty($VAR['_escape'])) {
|
||||
# Get URL string to pass to mainFrame
|
||||
$url = '';
|
||||
$i = 0;
|
||||
|
||||
while (list($key,$val) = each($VAR)) {
|
||||
if ($key != 'tid') {
|
||||
if ($i==0)
|
||||
$url .= '?';
|
||||
else
|
||||
$url .= '&';
|
||||
|
||||
$url .= sprintf('%s=%s',$key,$val);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$url = preg_replace('/tid=default_admin/', '', $url);
|
||||
$smarty->assign('mainFrameUrl', $url);
|
||||
$this_template = 'file:'.PATH_THEMES.''.THEME_NAME.'/template.tpl';
|
||||
|
||||
$url = preg_replace('/tid=default_admin/','',$url);
|
||||
$smarty->assign('mainFrameUrl',$url);
|
||||
$this_template = sprintf('file:%s%s/template.tpl',PATH_THEMES,THEME_NAME);
|
||||
$smarty->display($this_template);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (empty($VAR['_escape']))
|
||||
$block->display('core:top_frame');
|
||||
|
||||
# force or define page set?
|
||||
if(defined("FORCE_PAGE")) {
|
||||
$block->display(FORCE_PAGE);
|
||||
exit();
|
||||
} elseif (@$VAR['_page']) {
|
||||
$block->display($VAR['_page']);
|
||||
exit();
|
||||
} else {
|
||||
$block->display('core:admin');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (empty($VAR['_escape']))
|
||||
$block->display('core:top_frame');
|
||||
|
||||
# Force or define page set?
|
||||
if (defined('FORCE_PAGE')) {
|
||||
$block->display(FORCE_PAGE);
|
||||
|
||||
} elseif (@$VAR['_page']) {
|
||||
$block->display($VAR['_page']);
|
||||
|
||||
} else {
|
||||
$block->display('core:admin');
|
||||
}
|
||||
|
||||
if (empty($VAR['_escape']))
|
||||
$block->display('core:bottom_frame');
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
# Standard themes
|
||||
if(isset($VAR['_escape']))
|
||||
{
|
||||
if(isset($VAR['_print']))
|
||||
{
|
||||
# load printer friendly version
|
||||
if (isset($VAR['_escape'])) {
|
||||
if (isset($VAR['_print'])) {
|
||||
# Load printer friendly version
|
||||
$block->display('core:top_frame');
|
||||
$block->display($VAR['_page']);
|
||||
$block->display('core:bottom_print');
|
||||
exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
# check for force page:
|
||||
if(defined("FORCE_PAGE"))
|
||||
$block->display(FORCE_PAGE);
|
||||
|
||||
} else {
|
||||
# Check for force page:
|
||||
if(defined('FORCE_PAGE'))
|
||||
$block->display(FORCE_PAGE);
|
||||
else
|
||||
$block->display($VAR['_page']);
|
||||
$block->display($VAR['_page']);
|
||||
|
||||
exit();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(defined("FORCE_PAGE")) {
|
||||
define('THEME_PAGE', FORCE_PAGE);
|
||||
|
||||
} else {
|
||||
if (defined('FORCE_PAGE')) {
|
||||
define('THEME_PAGE',FORCE_PAGE);
|
||||
|
||||
} else {
|
||||
if(isset($VAR['_page']))
|
||||
define('THEME_PAGE', $VAR['_page']);
|
||||
if (isset($VAR['_page']))
|
||||
define('THEME_PAGE',$VAR['_page']);
|
||||
else
|
||||
define('THEME_PAGE', 'core:main');
|
||||
define('THEME_PAGE','core:main');
|
||||
}
|
||||
|
||||
# load the block normally
|
||||
$this_template = 'file:' . PATH_THEMES . '' . THEME_NAME . '/template.tpl';
|
||||
# Load the block normally
|
||||
$this_template = sprintf('file:%s%s/template.tpl',PATH_THEMES,THEME_NAME);
|
||||
$smarty->display($this_template);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CORE_block {
|
||||
public function display($block_r) {
|
||||
global $smarty;
|
||||
|
||||
$savedir = '';
|
||||
|
||||
# If we are in a module, we need to preserve our template path
|
||||
if (isset($smarty->_tpl_vars['meth'][0]) && $smarty->_tpl_vars['meth'][0] != 'core')
|
||||
$savedir = $smarty->template_dir;
|
||||
|
||||
class CORE_block
|
||||
{
|
||||
function display($block_r)
|
||||
{
|
||||
global $smarty;
|
||||
@$resource = explode(':',$block_r);
|
||||
@$module = $resource[0];
|
||||
@$block = $resource[1];
|
||||
if($module == 'TEMPLATE')
|
||||
{
|
||||
$smarty->template_dir = PATH_THEMES . '' . THEME_NAME . '/';
|
||||
$smarty->display('file:' . $smarty->template_dir . '' . $block . '.tpl');
|
||||
@$block = $resource[1];
|
||||
|
||||
$displayBlock = false;
|
||||
if ($module == 'TEMPLATE') {
|
||||
$smarty->template_dir = PATH_THEMES.THEME_NAME.'/';
|
||||
$displayBlock = true;
|
||||
|
||||
} else {
|
||||
if(is_file(PATH_THEMES . '' . THEME_NAME . '/blocks/' . $module . '/' . $block . '.tpl'))
|
||||
{
|
||||
$smarty->template_dir = PATH_THEMES . '' . THEME_NAME . '/blocks/' . $module . '/';
|
||||
$smarty->display('file:' . $smarty->template_dir . '' . $block . '.tpl');
|
||||
}
|
||||
elseif (is_file(PATH_THEMES . '' . DEF_THEME_N . '/blocks/' . $module . '/' . $block . '.tpl'))
|
||||
{
|
||||
$smarty->template_dir = PATH_THEMES . '' . DEF_THEME_N . '/blocks/' . $module . '/';
|
||||
$smarty->display('file:' . $smarty->template_dir . '' . $block . '.tpl');
|
||||
}
|
||||
elseif (is_file(PATH_THEMES . 'default/blocks/' . $module . '/' . $block . '.tpl'))
|
||||
{
|
||||
$smarty->template_dir = PATH_THEMES . 'default/blocks/' . $module . '/';
|
||||
$smarty->display('file:' . $smarty->template_dir . '' . $block . '.tpl');
|
||||
}
|
||||
else
|
||||
{
|
||||
$smarty->display('file:'. PATH_THEMES . '' . DEF_THEME_N . '/blocks/core/invalid_page.tpl');
|
||||
}
|
||||
}
|
||||
if (is_file(sprintf('%s%s/blocks/%s/%s.tpl',PATH_THEMES,THEME_NAME,$module,$block))) {
|
||||
$smarty->template_dir = sprintf('%s%s/blocks/%s/',PATH_THEMES,THEME_NAME,$module);
|
||||
$displayBlock = true;
|
||||
|
||||
} elseif (is_file(sprintf('%s%s/blocks/%s/%s.tpl',PATH_THEMES,DEF_THEME_N,$module,$block))) {
|
||||
$smarty->template_dir = sprintf('%s%s/blocks/%s/',PATH_THEMES,DEF_THEME_N,$module);
|
||||
$displayBlock = true;
|
||||
|
||||
} elseif (is_file(sprintf('%s%s/blocks/%s/%s.tpl',PATH_THEMES,'default',$module,$block))) {
|
||||
$smarty->template_dir = sprintf('%s%s/blocks/%s/',PATH_THEMES,'default',$module);
|
||||
$displayBlock = true;
|
||||
|
||||
} else {
|
||||
$smarty->display(sprintf('file:%s%s/blocks/core/invalid_page.tpl',PATH_THEMES,DEF_THEME_N));
|
||||
}
|
||||
}
|
||||
|
||||
if ($displayBlock) {
|
||||
if (! isset($smarty->_tpl_vars['VAR']['_page']) || ! $smarty->_tpl_vars['VAR']['_page'])
|
||||
$smarty->_tpl_vars['VAR']['_page'] = $block_r;
|
||||
|
||||
$smarty->display(sprintf('file:%s%s.tpl',$smarty->template_dir,$block));
|
||||
}
|
||||
|
||||
if ($savedir)
|
||||
$smarty->template_dir = $savedir;
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
Reference in New Issue
Block a user