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.
khosb/application/classes/lnapp/config.php

117 lines
3.1 KiB
PHP
Raw Normal View History

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 {
2010-11-29 22:41:08 +00:00
/**
* Return our site name
*/
public static function site() {
if (! empty($_SERVER['SERVER_NAME']))
return $_SERVER['SERVER_NAME'];
if (! $site = CLI::options('site'))
throw new Kohana_Exception(_('Cant figure out the site, use --site= for CLI'));
return $site['site'];
}
/**
* Work out our site ID for multiehosting
* @todo Change this to query the DB for site number.
*/
public static function siteid() {
$sites = Kohana::config('config.site');
// If we havent been configured for sites
if (is_null($sites) OR ! is_array($sites) OR ! isset($sites[static::site()]))
return 0;
else
return $sites[static::site()];
}
/**
* Work out our site mode (dev,test,prod)
* @todo Change this to query the DB for mode.
*/
public static function sitemode() {
$sites = Kohana::config('config.site_mode');
// If we havent been configured for sites
if (is_null($sites) OR ! is_array($sites) OR ! isset($sites[static::site()]))
return Kohana::PRODUCTION;
else
return $sites[static::site()];
}
public static function sitename() {
return Kohana::config('config.site_name');
}
2011-05-02 12:20:56 +00:00
public static function logo_file() {
// @todo Move the logo filename to a config file
return Kohana::find_file(sprintf('media/%s',Config::siteid()),'img/logo-small','png');
}
2010-11-29 22:41:08 +00:00
public static function logo() {
2011-05-02 12:20:56 +00:00
// @todo Move the logo filename to a config file
2010-11-29 22:41:08 +00:00
$mediapath = Route::get('default/media');
$logo = $mediapath->uri(array('file'=>'img/logo-small.png'),array('alt'=>static::sitename()));
return HTML::image($logo,array('class'=>'headlogo','alt'=>_('Logo')));
}
/**
* Return our caching mechanism
*/
public static function cachetype() {
return is_null(Kohana::config('config.cache_type')) ? 'file' : Kohana::config('config.cache_type');
}
/**
* Show a date using a site configured format
*/
public static function date($date) {
return date(Kohana::config('config.date_format'),$date);
}
2011-08-16 02:27:19 +00:00
/**
* Show a date using a site configured format
*/
public static function time($date) {
return date(Kohana::config('config.time_format'),$date);
}
/**
* Show a date using a site configured format
*/
public static function datetime($date) {
return date(Kohana::config('config.date_format').' '.Kohana::config('config.time_format'),$date);
}
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) {
$config = Kohana::config('config.email_admin_only');
if (is_null($config) OR ! is_array($config) OR empty($config[$template]))
return FALSE;
else
return $config[$template];
}
}
?>