phpldapadmin/application/classes/pla/config.php

106 lines
2.8 KiB
PHP
Raw Normal View History

2012-06-05 03:50:21 +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 PLA
* @subpackage Config
* @category Helpers
* @author Deon George
* @copyright (c) phpLDAPadmin Development Team
* @license http://dev.phpldapadmin.org/license.html
*/
abstract class PLA_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 (Kohana::$is_cli) {
if (! $site = CLI::options('site'))
throw new Kohana_Exception(_('Cant figure out the site, use --site= for CLI'));
else
$_SERVER['SERVER_NAME'] = $site['site'];
}
}
/**
* 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('config.site.id');
}
/**
* Work out our site mode (dev,test,prod)
*/
public static function sitemode() {
return Kohana::Config('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('config.debug.submode');
return (isset($submode[Request::$client_ip])) ? $submode[Request::$client_ip] : FALSE;
}
public static function sitename() {
return Kohana::Config('config.site.name');
}
// Called in Invoice/Emailing to embed the file.
public static function logo_file() {
list ($path,$suffix) = explode('.',static::$logo);
return Kohana::find_file(sprintf('media/%s',Config::siteid()),$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()) ? $ao->name() : HTML::anchor('login',_('Login'));
}
public static function copywrite() {
return '(c) phpLDAPadmin Development Team';
}
/**
* Return our caching mechanism
*/
public static function cachetype() {
return is_null(Kohana::config('config.cache_type')) ? 'file' : Kohana::config('config.cache_type');
}
}
?>