Sync from PTA, split out lnApp
This commit is contained in:
parent
19411b6352
commit
815508d40e
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -1,137 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class extends the core Kohana class by adding some core application
|
||||
* specific functions, and configuration.
|
||||
*
|
||||
* @package lnApp
|
||||
* @subpackage Core
|
||||
* @category Overrides
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
abstract class lnApp_Config extends Kohana_Config {
|
||||
protected static $logo = 'img/logo-small.png';
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
if (defined('PHPUNITTEST'))
|
||||
$_SERVER['SERVER_NAME'] = PHPUNITTEST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return our site name
|
||||
*/
|
||||
public static function site() {
|
||||
return $_SERVER['SERVER_NAME'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Work out our site ID for multiehosting
|
||||
*/
|
||||
public static function siteid() {
|
||||
return Kohana::$config->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;
|
||||
}
|
||||
}
|
||||
?>
|
4
modules/lnApp/classes/Controller/Login.php
Normal file
4
modules/lnApp/classes/Controller/Login.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
class Controller_Login extends lnApp_Controller_Login {}
|
||||
?>
|
Reference in New Issue
Block a user