2010-11-29 22:41:08 +00:00
|
|
|
<?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
|
|
|
|
*/
|
2011-05-14 07:35:33 +00:00
|
|
|
abstract class lnApp_Config extends Kohana_Config {
|
2011-09-29 07:13:32 +00:00
|
|
|
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() {
|
2012-08-23 10:14:46 +00:00
|
|
|
if (defined('PHPUNITTEST'))
|
|
|
|
$_SERVER['SERVER_NAME'] = PHPUNITTEST;
|
2011-09-29 07:13:32 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 22:41:08 +00:00
|
|
|
/**
|
|
|
|
* Return our site name
|
|
|
|
*/
|
|
|
|
public static function site() {
|
2011-09-29 07:13:32 +00:00
|
|
|
return $_SERVER['SERVER_NAME'];
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Work out our site ID for multiehosting
|
|
|
|
*/
|
|
|
|
public static function siteid() {
|
2012-11-09 23:13:57 +00:00
|
|
|
return Kohana::$config->load('config.site.id');
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Work out our site mode (dev,test,prod)
|
|
|
|
*/
|
|
|
|
public static function sitemode() {
|
2012-11-09 23:13:57 +00:00
|
|
|
return Kohana::$config->load('config.site.mode');
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
|
2011-09-17 10:45:08 +00:00
|
|
|
public static function sitemodeverbose() {
|
|
|
|
$modes = array(
|
|
|
|
Kohana::PRODUCTION=>'Production',
|
|
|
|
Kohana::STAGING=>'Staging',
|
|
|
|
Kohana::TESTING=>'Testing',
|
|
|
|
Kohana::DEVELOPMENT=>'Development',
|
|
|
|
);
|
|
|
|
|
2011-09-29 07:13:32 +00:00
|
|
|
return (! isset($modes[static::sitemode()])) ? 'Unknown' : $modes[static::sitemode()];
|
2011-09-17 10:45:08 +00:00
|
|
|
}
|
|
|
|
|
2011-12-09 04:10:53 +00:00
|
|
|
public static function submode() {
|
2012-11-09 23:13:57 +00:00
|
|
|
$submode = Kohana::$config->load('config.debug.submode');
|
2011-12-09 04:10:53 +00:00
|
|
|
|
|
|
|
return (isset($submode[Request::$client_ip])) ? $submode[Request::$client_ip] : FALSE;
|
|
|
|
}
|
|
|
|
|
2010-11-29 22:41:08 +00:00
|
|
|
public static function sitename() {
|
2012-11-09 23:13:57 +00:00
|
|
|
return Kohana::$config->load('config')->site_name;
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 07:13:32 +00:00
|
|
|
// Called in Invoice/Emailing to embed the file.
|
2011-05-02 12:20:56 +00:00
|
|
|
public static function logo_file() {
|
2011-09-29 07:13:32 +00:00
|
|
|
list ($path,$suffix) = explode('.',static::$logo);
|
2012-01-29 06:23:24 +00:00
|
|
|
return ($a=Kohana::find_file(sprintf('media/site/%s',Config::siteid()),$path,$suffix)) ? $a : Kohana::find_file('media',$path,$suffix);
|
2011-05-02 12:20:56 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 07:13:32 +00:00
|
|
|
public static function logo_uri() {
|
|
|
|
list ($path,$suffix) = explode('.',static::$logo);
|
2011-10-12 22:20:08 +00:00
|
|
|
return URL::site(Route::get('default/media')->uri(array('file'=>$path.'.'.$suffix),array('alt'=>static::sitename())),'http');
|
2011-09-29 07:13:32 +00:00
|
|
|
}
|
2010-11-29 22:41:08 +00:00
|
|
|
|
2011-09-29 07:13:32 +00:00
|
|
|
public static function logo() {
|
|
|
|
return HTML::image(static::logo_uri(),array('class'=>'headlogo','alt'=>_('Logo')));
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
|
2012-01-29 06:23:24 +00:00
|
|
|
public static function login_uri() {
|
2012-02-22 08:15:46 +00:00
|
|
|
return ($ao = Auth::instance()->get_user() AND is_object($ao)) ? HTML::anchor('user/account/edit',$ao->name()) : HTML::anchor('login',_('Login'));
|
2012-01-29 06:23:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 22:41:08 +00:00
|
|
|
/**
|
|
|
|
* Return our caching mechanism
|
|
|
|
*/
|
|
|
|
public static function cachetype() {
|
2012-11-09 23:13:57 +00:00
|
|
|
return is_null(Kohana::$config->load('config')->cache_type) ? 'file' : Kohana::$config->load('config')->cache_type;
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a date using a site configured format
|
|
|
|
*/
|
|
|
|
public static function date($date) {
|
2012-11-09 23:13:57 +00:00
|
|
|
return $date ? date(Kohana::$config->load('config')->date_format,$date) : '>Not Set<';
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
|
2011-08-16 02:27:19 +00:00
|
|
|
/**
|
|
|
|
* Show a date using a site configured format
|
|
|
|
*/
|
|
|
|
public static function time($date) {
|
2012-11-09 23:13:57 +00:00
|
|
|
return date(Kohana::$config->load('config')->time_format,$date);
|
2011-08-16 02:27:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a date using a site configured format
|
|
|
|
*/
|
|
|
|
public static function datetime($date) {
|
2012-08-23 10:14:46 +00:00
|
|
|
return sprintf('%s %s',static::date($date),static::time($date));
|
2011-08-16 02:27:19 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 22:41:08 +00:00
|
|
|
/**
|
|
|
|
* 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) {
|
2012-11-09 23:13:57 +00:00
|
|
|
$config = Kohana::$config->load('config')->email_admin_only;
|
2010-11-29 22:41:08 +00:00
|
|
|
|
|
|
|
if (is_null($config) OR ! is_array($config) OR empty($config[$template]))
|
|
|
|
return FALSE;
|
|
|
|
else
|
|
|
|
return $config[$template];
|
|
|
|
}
|
2012-01-29 06:23:24 +00:00
|
|
|
|
|
|
|
public static function theme() {
|
2012-11-09 23:13:57 +00:00
|
|
|
return Kohana::$config->load('config')->theme;
|
2012-01-29 06:23:24 +00:00
|
|
|
}
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
?>
|