From 815508d40ef5a698e5ac23b7529b5d6b6f13da62 Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 10 Jan 2013 11:53:13 +1100 Subject: [PATCH] Sync from PTA, split out lnApp --- application/bootstrap.php | 1 + application/classes/Config.php | 86 ++++++++++- application/classes/lnApp/Config.php | 137 ------------------ .../lnApp}/classes/Block.php | 0 .../lnApp}/classes/Block/Sub.php | 0 .../lnApp}/classes/BreadCrumb.php | 0 .../lnApp}/classes/Controller/Default.php | 0 modules/lnApp/classes/Controller/Login.php | 4 + .../lnApp}/classes/Controller/Logout.php | 0 .../lnApp}/classes/Controller/Media.php | 0 .../lnApp}/classes/Controller/Task.php | 0 .../lnApp}/classes/HTML.php | 0 .../lnApp}/classes/HTMLRender.php | 0 .../lnApp}/classes/HeadImages.php | 0 .../lnApp}/classes/Meta.php | 0 .../lnApp/classes/PWGen.php | 0 .../lnApp}/classes/Random.php | 0 .../lnApp}/classes/Script.php | 0 .../lnApp}/classes/Sort.php | 0 .../lnApp}/classes/Style.php | 0 .../lnApp}/classes/SystemMessage.php | 0 .../lnApp}/classes/Table.php | 0 .../lnApp}/classes/lnApp/Block.php | 0 .../lnApp}/classes/lnApp/Block/Sub.php | 0 .../lnApp}/classes/lnApp/BreadCrumb.php | 0 .../classes/lnApp/Controller/Default.php | 0 .../lnApp}/classes/lnApp/Controller/Login.php | 0 .../classes/lnApp/Controller/Logout.php | 0 .../lnApp}/classes/lnApp/Controller/Media.php | 0 .../lnApp}/classes/lnApp/Controller/Task.php | 0 .../lnApp/Controller/TemplateDefault.php | 0 .../lnApp}/classes/lnApp/Controller/Tree.php | 0 .../lnApp}/classes/lnApp/HTML.php | 0 .../lnApp}/classes/lnApp/HTMLRender.php | 0 .../lnApp}/classes/lnApp/HeadImages.php | 0 .../lnApp}/classes/lnApp/Meta.php | 0 .../lnApp}/classes/lnApp/PWgen.php | 0 .../lnApp}/classes/lnApp/Random.php | 0 .../lnApp}/classes/lnApp/Script.php | 0 .../lnApp}/classes/lnApp/Sort.php | 0 .../lnApp}/classes/lnApp/Style.php | 0 .../lnApp}/classes/lnApp/SystemMessage.php | 0 .../lnApp}/classes/lnApp/Table.php | 0 .../lnApp}/views/lnapp/default.php | 0 44 files changed, 89 insertions(+), 139 deletions(-) delete mode 100644 application/classes/lnApp/Config.php rename {application => modules/lnApp}/classes/Block.php (100%) rename {application => modules/lnApp}/classes/Block/Sub.php (100%) rename {application => modules/lnApp}/classes/BreadCrumb.php (100%) rename {application => modules/lnApp}/classes/Controller/Default.php (100%) create mode 100644 modules/lnApp/classes/Controller/Login.php rename {application => modules/lnApp}/classes/Controller/Logout.php (100%) rename {application => modules/lnApp}/classes/Controller/Media.php (100%) rename {application => modules/lnApp}/classes/Controller/Task.php (100%) rename {application => modules/lnApp}/classes/HTML.php (100%) rename {application => modules/lnApp}/classes/HTMLRender.php (100%) rename {application => modules/lnApp}/classes/HeadImages.php (100%) rename {application => modules/lnApp}/classes/Meta.php (100%) rename application/classes/PWgen.php => modules/lnApp/classes/PWGen.php (100%) rename {application => modules/lnApp}/classes/Random.php (100%) rename {application => modules/lnApp}/classes/Script.php (100%) rename {application => modules/lnApp}/classes/Sort.php (100%) rename {application => modules/lnApp}/classes/Style.php (100%) rename {application => modules/lnApp}/classes/SystemMessage.php (100%) rename {application => modules/lnApp}/classes/Table.php (100%) rename {application => modules/lnApp}/classes/lnApp/Block.php (100%) rename {application => modules/lnApp}/classes/lnApp/Block/Sub.php (100%) rename {application => modules/lnApp}/classes/lnApp/BreadCrumb.php (100%) rename {application => modules/lnApp}/classes/lnApp/Controller/Default.php (100%) rename {application => modules/lnApp}/classes/lnApp/Controller/Login.php (100%) rename {application => modules/lnApp}/classes/lnApp/Controller/Logout.php (100%) rename {application => modules/lnApp}/classes/lnApp/Controller/Media.php (100%) rename {application => modules/lnApp}/classes/lnApp/Controller/Task.php (100%) rename {application => modules/lnApp}/classes/lnApp/Controller/TemplateDefault.php (100%) rename {application => modules/lnApp}/classes/lnApp/Controller/Tree.php (100%) rename {application => modules/lnApp}/classes/lnApp/HTML.php (100%) rename {application => modules/lnApp}/classes/lnApp/HTMLRender.php (100%) rename {application => modules/lnApp}/classes/lnApp/HeadImages.php (100%) rename {application => modules/lnApp}/classes/lnApp/Meta.php (100%) rename {application => modules/lnApp}/classes/lnApp/PWgen.php (100%) rename {application => modules/lnApp}/classes/lnApp/Random.php (100%) rename {application => modules/lnApp}/classes/lnApp/Script.php (100%) rename {application => modules/lnApp}/classes/lnApp/Sort.php (100%) rename {application => modules/lnApp}/classes/lnApp/Style.php (100%) rename {application => modules/lnApp}/classes/lnApp/SystemMessage.php (100%) rename {application => modules/lnApp}/classes/lnApp/Table.php (100%) rename {application => modules/lnApp}/views/lnapp/default.php (100%) diff --git a/application/bootstrap.php b/application/bootstrap.php index aff6e0db..e28f1f37 100644 --- a/application/bootstrap.php +++ b/application/bootstrap.php @@ -109,6 +109,7 @@ Kohana::$config->attach(new Config_File); * Enable modules. Modules are referenced by a relative or absolute path. */ Kohana::modules(array( + 'lnapp' => MODPATH.'lnApp', 'auth' => SMDPATH.'auth', // Basic authentication 'cache' => SMDPATH.'cache', // Caching with multiple backends 'cron' => SMDPATH.'cron', // Kohana Cron Module diff --git a/application/classes/Config.php b/application/classes/Config.php index c88a79bc..cf9658d6 100644 --- a/application/classes/Config.php +++ b/application/classes/Config.php @@ -10,10 +10,11 @@ * @copyright (c) 2010 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Config extends lnApp_Config { +class Config extends Kohana_Config { // Our setup object public $so; public static $no_site_id_tables = array('setup','country','currency','language','tax'); + protected static $logo = 'img/logo-small.png'; /** * @compat Restore KH 3.1 functionality @@ -21,8 +22,16 @@ class Config extends lnApp_Config { */ protected static $_instance; + /** + * Some early initialisation + * + * At this point, KH hasnt been fully initialised either, so we cant rely on + * too many KH functions yet. + * NOTE: Kohana doesnt provide a parent construct for the Kohana_Config class. + */ public function __construct() { - parent::__construct(); + if (defined('PHPUNITTEST')) + $_SERVER['SERVER_NAME'] = PHPUNITTEST; // We need to know our site here, so that we can subsequently load our enabled modules. if (Kohana::$is_cli) { @@ -121,5 +130,78 @@ class Config extends lnApp_Config { public static function copywrite() { return '(c) Open Source Billing Development Team'; } + + /** + * Return our site name + */ + public static function site() { + return $_SERVER['SERVER_NAME']; + } + + public static function sitemodeverbose() { + $modes = array( + Kohana::PRODUCTION=>'Production', + Kohana::STAGING=>'Staging', + Kohana::TESTING=>'Testing', + Kohana::DEVELOPMENT=>'Development', + ); + + return (! isset($modes[static::sitemode()])) ? 'Unknown' : $modes[static::sitemode()]; + } + + public static function submode() { + $submode = Kohana::$config->load('config.debug.submode'); + + return (isset($submode[Request::$client_ip])) ? $submode[Request::$client_ip] : FALSE; + } + + public static function sitename() { + return Kohana::$config->load('config')->site_name; + } + + // Called in Invoice/Emailing to embed the file. + public static function logo_file() { + list ($path,$suffix) = explode('.',static::$logo); + 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() { + list ($path,$suffix) = explode('.',static::$logo); + return URL::site(Route::get('default/media')->uri(array('file'=>$path.'.'.$suffix),array('alt'=>static::sitename())),'http'); + } + + public static function logo() { + return HTML::image(static::logo_uri(),array('class'=>'headlogo','alt'=>_('Logo'))); + } + + public static function login_uri() { + return ($ao = Auth::instance()->get_user() AND is_object($ao)) ? HTML::anchor('user/account/edit',$ao->name()) : HTML::anchor('login',_('Login')); + } + + /** + * Return our caching mechanism + */ + public static function cachetype() { + return is_null(Kohana::$config->load('config')->cache_type) ? 'file' : Kohana::$config->load('config')->cache_type; + } + + /** + * See if our emails for the template should be sent to configured admin(s) + * + * @param string template - Template to test for + * @return mixed|array - Email to send test emails to + */ + public static function testmail($template) { + $config = Kohana::$config->load('config')->email_admin_only; + + if (is_null($config) OR ! is_array($config) OR empty($config[$template])) + return FALSE; + else + return $config[$template]; + } + + public static function theme() { + return Kohana::$config->load('config')->theme; + } } ?> diff --git a/application/classes/lnApp/Config.php b/application/classes/lnApp/Config.php deleted file mode 100644 index 75acf1a3..00000000 --- a/application/classes/lnApp/Config.php +++ /dev/null @@ -1,137 +0,0 @@ -load('config.site.id'); - } - - /** - * Work out our site mode (dev,test,prod) - */ - public static function sitemode() { - return Kohana::$config->load('config.site.mode'); - } - - public static function sitemodeverbose() { - $modes = array( - Kohana::PRODUCTION=>'Production', - Kohana::STAGING=>'Staging', - Kohana::TESTING=>'Testing', - Kohana::DEVELOPMENT=>'Development', - ); - - return (! isset($modes[static::sitemode()])) ? 'Unknown' : $modes[static::sitemode()]; - } - - public static function submode() { - $submode = Kohana::$config->load('config.debug.submode'); - - return (isset($submode[Request::$client_ip])) ? $submode[Request::$client_ip] : FALSE; - } - - public static function sitename() { - return Kohana::$config->load('config')->site_name; - } - - // Called in Invoice/Emailing to embed the file. - public static function logo_file() { - list ($path,$suffix) = explode('.',static::$logo); - 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() { - list ($path,$suffix) = explode('.',static::$logo); - return URL::site(Route::get('default/media')->uri(array('file'=>$path.'.'.$suffix),array('alt'=>static::sitename())),'http'); - } - - public static function logo() { - return HTML::image(static::logo_uri(),array('class'=>'headlogo','alt'=>_('Logo'))); - } - - public static function login_uri() { - return ($ao = Auth::instance()->get_user() AND is_object($ao)) ? HTML::anchor('user/account/edit',$ao->name()) : HTML::anchor('login',_('Login')); - } - - /** - * Return our caching mechanism - */ - public static function cachetype() { - return is_null(Kohana::$config->load('config')->cache_type) ? 'file' : Kohana::$config->load('config')->cache_type; - } - - /** - * Show a date using a site configured format - */ - public static function date($date) { - return $date ? date(Kohana::$config->load('config')->date_format,$date) : '>Not Set<'; - } - - /** - * Show a date using a site configured format - */ - public static function time($date) { - return date(Kohana::$config->load('config')->time_format,$date); - } - - /** - * Show a date using a site configured format - */ - public static function datetime($date) { - return sprintf('%s %s',static::date($date),static::time($date)); - } - - /** - * See if our emails for the template should be sent to configured admin(s) - * - * @param string template - Template to test for - * @return mixed|array - Email to send test emails to - */ - public static function testmail($template) { - $config = Kohana::$config->load('config')->email_admin_only; - - if (is_null($config) OR ! is_array($config) OR empty($config[$template])) - return FALSE; - else - return $config[$template]; - } - - public static function theme() { - return Kohana::$config->load('config')->theme; - } -} -?> diff --git a/application/classes/Block.php b/modules/lnApp/classes/Block.php similarity index 100% rename from application/classes/Block.php rename to modules/lnApp/classes/Block.php diff --git a/application/classes/Block/Sub.php b/modules/lnApp/classes/Block/Sub.php similarity index 100% rename from application/classes/Block/Sub.php rename to modules/lnApp/classes/Block/Sub.php diff --git a/application/classes/BreadCrumb.php b/modules/lnApp/classes/BreadCrumb.php similarity index 100% rename from application/classes/BreadCrumb.php rename to modules/lnApp/classes/BreadCrumb.php diff --git a/application/classes/Controller/Default.php b/modules/lnApp/classes/Controller/Default.php similarity index 100% rename from application/classes/Controller/Default.php rename to modules/lnApp/classes/Controller/Default.php diff --git a/modules/lnApp/classes/Controller/Login.php b/modules/lnApp/classes/Controller/Login.php new file mode 100644 index 00000000..74a18836 --- /dev/null +++ b/modules/lnApp/classes/Controller/Login.php @@ -0,0 +1,4 @@ + diff --git a/application/classes/Controller/Logout.php b/modules/lnApp/classes/Controller/Logout.php similarity index 100% rename from application/classes/Controller/Logout.php rename to modules/lnApp/classes/Controller/Logout.php diff --git a/application/classes/Controller/Media.php b/modules/lnApp/classes/Controller/Media.php similarity index 100% rename from application/classes/Controller/Media.php rename to modules/lnApp/classes/Controller/Media.php diff --git a/application/classes/Controller/Task.php b/modules/lnApp/classes/Controller/Task.php similarity index 100% rename from application/classes/Controller/Task.php rename to modules/lnApp/classes/Controller/Task.php diff --git a/application/classes/HTML.php b/modules/lnApp/classes/HTML.php similarity index 100% rename from application/classes/HTML.php rename to modules/lnApp/classes/HTML.php diff --git a/application/classes/HTMLRender.php b/modules/lnApp/classes/HTMLRender.php similarity index 100% rename from application/classes/HTMLRender.php rename to modules/lnApp/classes/HTMLRender.php diff --git a/application/classes/HeadImages.php b/modules/lnApp/classes/HeadImages.php similarity index 100% rename from application/classes/HeadImages.php rename to modules/lnApp/classes/HeadImages.php diff --git a/application/classes/Meta.php b/modules/lnApp/classes/Meta.php similarity index 100% rename from application/classes/Meta.php rename to modules/lnApp/classes/Meta.php diff --git a/application/classes/PWgen.php b/modules/lnApp/classes/PWGen.php similarity index 100% rename from application/classes/PWgen.php rename to modules/lnApp/classes/PWGen.php diff --git a/application/classes/Random.php b/modules/lnApp/classes/Random.php similarity index 100% rename from application/classes/Random.php rename to modules/lnApp/classes/Random.php diff --git a/application/classes/Script.php b/modules/lnApp/classes/Script.php similarity index 100% rename from application/classes/Script.php rename to modules/lnApp/classes/Script.php diff --git a/application/classes/Sort.php b/modules/lnApp/classes/Sort.php similarity index 100% rename from application/classes/Sort.php rename to modules/lnApp/classes/Sort.php diff --git a/application/classes/Style.php b/modules/lnApp/classes/Style.php similarity index 100% rename from application/classes/Style.php rename to modules/lnApp/classes/Style.php diff --git a/application/classes/SystemMessage.php b/modules/lnApp/classes/SystemMessage.php similarity index 100% rename from application/classes/SystemMessage.php rename to modules/lnApp/classes/SystemMessage.php diff --git a/application/classes/Table.php b/modules/lnApp/classes/Table.php similarity index 100% rename from application/classes/Table.php rename to modules/lnApp/classes/Table.php diff --git a/application/classes/lnApp/Block.php b/modules/lnApp/classes/lnApp/Block.php similarity index 100% rename from application/classes/lnApp/Block.php rename to modules/lnApp/classes/lnApp/Block.php diff --git a/application/classes/lnApp/Block/Sub.php b/modules/lnApp/classes/lnApp/Block/Sub.php similarity index 100% rename from application/classes/lnApp/Block/Sub.php rename to modules/lnApp/classes/lnApp/Block/Sub.php diff --git a/application/classes/lnApp/BreadCrumb.php b/modules/lnApp/classes/lnApp/BreadCrumb.php similarity index 100% rename from application/classes/lnApp/BreadCrumb.php rename to modules/lnApp/classes/lnApp/BreadCrumb.php diff --git a/application/classes/lnApp/Controller/Default.php b/modules/lnApp/classes/lnApp/Controller/Default.php similarity index 100% rename from application/classes/lnApp/Controller/Default.php rename to modules/lnApp/classes/lnApp/Controller/Default.php diff --git a/application/classes/lnApp/Controller/Login.php b/modules/lnApp/classes/lnApp/Controller/Login.php similarity index 100% rename from application/classes/lnApp/Controller/Login.php rename to modules/lnApp/classes/lnApp/Controller/Login.php diff --git a/application/classes/lnApp/Controller/Logout.php b/modules/lnApp/classes/lnApp/Controller/Logout.php similarity index 100% rename from application/classes/lnApp/Controller/Logout.php rename to modules/lnApp/classes/lnApp/Controller/Logout.php diff --git a/application/classes/lnApp/Controller/Media.php b/modules/lnApp/classes/lnApp/Controller/Media.php similarity index 100% rename from application/classes/lnApp/Controller/Media.php rename to modules/lnApp/classes/lnApp/Controller/Media.php diff --git a/application/classes/lnApp/Controller/Task.php b/modules/lnApp/classes/lnApp/Controller/Task.php similarity index 100% rename from application/classes/lnApp/Controller/Task.php rename to modules/lnApp/classes/lnApp/Controller/Task.php diff --git a/application/classes/lnApp/Controller/TemplateDefault.php b/modules/lnApp/classes/lnApp/Controller/TemplateDefault.php similarity index 100% rename from application/classes/lnApp/Controller/TemplateDefault.php rename to modules/lnApp/classes/lnApp/Controller/TemplateDefault.php diff --git a/application/classes/lnApp/Controller/Tree.php b/modules/lnApp/classes/lnApp/Controller/Tree.php similarity index 100% rename from application/classes/lnApp/Controller/Tree.php rename to modules/lnApp/classes/lnApp/Controller/Tree.php diff --git a/application/classes/lnApp/HTML.php b/modules/lnApp/classes/lnApp/HTML.php similarity index 100% rename from application/classes/lnApp/HTML.php rename to modules/lnApp/classes/lnApp/HTML.php diff --git a/application/classes/lnApp/HTMLRender.php b/modules/lnApp/classes/lnApp/HTMLRender.php similarity index 100% rename from application/classes/lnApp/HTMLRender.php rename to modules/lnApp/classes/lnApp/HTMLRender.php diff --git a/application/classes/lnApp/HeadImages.php b/modules/lnApp/classes/lnApp/HeadImages.php similarity index 100% rename from application/classes/lnApp/HeadImages.php rename to modules/lnApp/classes/lnApp/HeadImages.php diff --git a/application/classes/lnApp/Meta.php b/modules/lnApp/classes/lnApp/Meta.php similarity index 100% rename from application/classes/lnApp/Meta.php rename to modules/lnApp/classes/lnApp/Meta.php diff --git a/application/classes/lnApp/PWgen.php b/modules/lnApp/classes/lnApp/PWgen.php similarity index 100% rename from application/classes/lnApp/PWgen.php rename to modules/lnApp/classes/lnApp/PWgen.php diff --git a/application/classes/lnApp/Random.php b/modules/lnApp/classes/lnApp/Random.php similarity index 100% rename from application/classes/lnApp/Random.php rename to modules/lnApp/classes/lnApp/Random.php diff --git a/application/classes/lnApp/Script.php b/modules/lnApp/classes/lnApp/Script.php similarity index 100% rename from application/classes/lnApp/Script.php rename to modules/lnApp/classes/lnApp/Script.php diff --git a/application/classes/lnApp/Sort.php b/modules/lnApp/classes/lnApp/Sort.php similarity index 100% rename from application/classes/lnApp/Sort.php rename to modules/lnApp/classes/lnApp/Sort.php diff --git a/application/classes/lnApp/Style.php b/modules/lnApp/classes/lnApp/Style.php similarity index 100% rename from application/classes/lnApp/Style.php rename to modules/lnApp/classes/lnApp/Style.php diff --git a/application/classes/lnApp/SystemMessage.php b/modules/lnApp/classes/lnApp/SystemMessage.php similarity index 100% rename from application/classes/lnApp/SystemMessage.php rename to modules/lnApp/classes/lnApp/SystemMessage.php diff --git a/application/classes/lnApp/Table.php b/modules/lnApp/classes/lnApp/Table.php similarity index 100% rename from application/classes/lnApp/Table.php rename to modules/lnApp/classes/lnApp/Table.php diff --git a/application/views/lnapp/default.php b/modules/lnApp/views/lnapp/default.php similarity index 100% rename from application/views/lnapp/default.php rename to modules/lnApp/views/lnapp/default.php