This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
phptsmadmin/application/classes/lnApp/Config.php

138 lines
3.8 KiB
PHP
Raw Normal View History

2011-01-17 05:33:55 +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-23 10:01:27 +00:00
abstract class lnApp_Config extends Kohana_Config {
2012-11-26 05:57:18 +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() {
if (defined('PHPUNITTEST'))
$_SERVER['SERVER_NAME'] = PHPUNITTEST;
}
2011-01-17 05:33:55 +00:00
/**
* Return our site name
*/
public static function site() {
2012-11-26 05:57:18 +00:00
return $_SERVER['SERVER_NAME'];
2011-01-17 05:33:55 +00:00
}
/**
* Work out our site ID for multiehosting
*/
public static function siteid() {
2012-11-26 05:57:18 +00:00
return Kohana::$config->load('config.site.id');
2011-01-17 05:33:55 +00:00
}
/**
* Work out our site mode (dev,test,prod)
*/
public static function sitemode() {
2012-11-26 05:57:18 +00:00
return Kohana::$config->load('config.site.mode');
}
2011-01-17 05:33:55 +00:00
2012-11-26 05:57:18 +00:00
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;
2011-01-17 05:33:55 +00:00
}
public static function sitename() {
2012-11-26 05:57:18 +00:00
return Kohana::$config->load('config')->site_name;
2011-01-17 05:33:55 +00:00
}
2012-11-26 05:57:18 +00:00
// Called in Invoice/Emailing to embed the file.
2011-05-09 07:40:50 +00:00
public static function logo_file() {
2012-11-26 05:57:18 +00:00
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');
2011-05-09 07:40:50 +00:00
}
2011-01-17 05:33:55 +00:00
public static function logo() {
2012-11-26 05:57:18 +00:00
return HTML::image(static::logo_uri(),array('class'=>'headlogo','alt'=>_('Logo')));
}
2011-01-17 05:33:55 +00:00
2012-11-26 05:57:18 +00:00
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'));
2011-01-17 05:33:55 +00:00
}
/**
* Return our caching mechanism
*/
public static function cachetype() {
2012-11-26 05:57:18 +00:00
return is_null(Kohana::$config->load('config')->cache_type) ? 'file' : Kohana::$config->load('config')->cache_type;
2011-01-17 05:33:55 +00:00
}
/**
* Show a date using a site configured format
*/
public static function date($date) {
2012-11-26 05:57:18 +00:00
return $date ? date(Kohana::$config->load('config')->date_format,$date) : '&gt;Not Set&lt;';
}
/**
* 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));
2011-01-17 05:33:55 +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-26 05:57:18 +00:00
$config = Kohana::$config->load('config')->email_admin_only;
2011-01-17 05:33:55 +00:00
if (is_null($config) OR ! is_array($config) OR empty($config[$template]))
return FALSE;
else
return $config[$template];
}
2012-11-26 05:57:18 +00:00
public static function theme() {
return Kohana::$config->load('config')->theme;
}
2011-01-17 05:33:55 +00:00
}
?>