2014-08-22 06:50:01 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is class is for site level configuration
|
|
|
|
*
|
|
|
|
* @package lnApp
|
|
|
|
* @category Helpers
|
|
|
|
* @author Deon George
|
|
|
|
* @copyright (c) 2009-2013 Deon George
|
|
|
|
* @license http://dev.leenooks.net/license.html
|
|
|
|
*/
|
|
|
|
abstract class lnApp_Site {
|
|
|
|
/**
|
|
|
|
* Return our application name
|
|
|
|
*/
|
|
|
|
public static function Appname() {
|
|
|
|
return Kohana::$config->load('config')->appname;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a date using a site configured format
|
|
|
|
*/
|
|
|
|
public static function Date($date) {
|
2015-10-08 05:31:33 +00:00
|
|
|
return (is_null($date) OR ! is_numeric($date)) ? $date : date(Kohana::$config->load('config')->date_format,$date);
|
2014-08-22 06:50:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a date using a site configured format
|
|
|
|
* @note We need this function here, since we call self:: methods, which need to resolve to the child class.
|
|
|
|
*/
|
|
|
|
public static function Datetime($date) {
|
2015-09-29 05:40:15 +00:00
|
|
|
return $date ? sprintf('%s %s',self::Date($date),self::Time($date)) : NULL;
|
2014-08-22 06:50:01 +00:00
|
|
|
}
|
|
|
|
|
2014-08-22 13:34:38 +00:00
|
|
|
/**
|
2014-09-29 12:06:38 +00:00
|
|
|
* Return the site configured id
|
2014-08-22 13:34:38 +00:00
|
|
|
*/
|
2014-08-25 04:35:01 +00:00
|
|
|
public static function ID($format=FALSE) {
|
|
|
|
return $format ? sprintf('%02s',Kohana::$config->load('config')->id) : Kohana::$config->load('config')->id;
|
2014-08-22 13:34:38 +00:00
|
|
|
}
|
|
|
|
|
2014-08-22 06:50:01 +00:00
|
|
|
/**
|
|
|
|
* Return the site configured language
|
|
|
|
*/
|
|
|
|
public static function Language() {
|
2014-09-29 12:06:38 +00:00
|
|
|
foreach (Request::factory()->accept_lang() as $k=>$v) {
|
|
|
|
if (strlen($k) == 2)
|
|
|
|
$k = sprintf('%s_%s',strtolower($k),strtoupper($k));
|
|
|
|
else {
|
|
|
|
list($k,$v) = preg_split('/[-_]/',$k,2);
|
|
|
|
$k = sprintf('%s_%s',strtolower($k),strtoupper($v));
|
|
|
|
}
|
|
|
|
|
2014-10-03 14:35:26 +00:00
|
|
|
if ($x=ORM::factory('Language',array('iso'=>$k)) AND $x->loaded())
|
2014-09-29 12:06:38 +00:00
|
|
|
return $x;
|
|
|
|
}
|
|
|
|
|
2014-10-03 14:35:26 +00:00
|
|
|
return ORM::factory('Language',array('iso'=>Kohana::$config->load('config')->language));
|
2014-08-22 06:50:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the protocol that the site is using
|
|
|
|
*
|
|
|
|
* @param string URL to be included in the return
|
|
|
|
*/
|
|
|
|
public static function Protocol($url='') {
|
|
|
|
static $secure = NULL;
|
|
|
|
|
|
|
|
if (! $secure AND Request::current())
|
|
|
|
$secure = Request::current()->secure() ? 'https://' : 'http://';
|
|
|
|
|
|
|
|
return $secure.($url ? $url : '');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the site theme
|
|
|
|
*/
|
|
|
|
public static function Theme() {
|
|
|
|
return 'theme/'.Kohana::$config->load('config')->theme;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a time using a site configured format
|
|
|
|
*/
|
|
|
|
public static function Time($date) {
|
2014-08-22 07:06:15 +00:00
|
|
|
return date(Kohana::$config->load('config')->time_format,($date ? $date : time()));
|
2014-08-22 06:50:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|