2011-12-29 23:54:54 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class overrides Kohana's Core
|
|
|
|
*
|
2013-03-19 22:35:19 +00:00
|
|
|
* @package OSB
|
|
|
|
* @category Modifications
|
2011-12-29 23:54:54 +00:00
|
|
|
* @author Deon George
|
2013-03-19 22:35:19 +00:00
|
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
|
|
|
* @license http://dev.osbill.net/license.html
|
2011-12-29 23:54:54 +00:00
|
|
|
*/
|
2012-11-09 23:13:57 +00:00
|
|
|
abstract class Kohana extends Kohana_Core {
|
2013-04-26 01:42:09 +00:00
|
|
|
/**
|
|
|
|
* Work out our Class Name as per Kohana's standards
|
|
|
|
*/
|
|
|
|
public static function classname($name) {
|
|
|
|
return str_replace(' ','_',ucwords(strtolower(str_replace('_',' ',$name))));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find files using a multi-site enabled application
|
|
|
|
*
|
|
|
|
* In order of precedence, we'll return:
|
|
|
|
* 1) site-theme file, ie: site/X/THEME/${file}
|
|
|
|
* 2) site file, ie: site/X/${file}
|
|
|
|
* 3) theme file, ie: THEME/${file}
|
|
|
|
* 4) normal search, ie: ${file}
|
|
|
|
*/
|
|
|
|
public static function find_file($dir,$file,$ext=NULL,$array=FALSE) {
|
|
|
|
// Limit our scope to the following dirs
|
|
|
|
// @note, we cannot have classes checked, since Config() doesnt exist yet
|
|
|
|
$dirs = array('views','media');
|
|
|
|
|
|
|
|
if (! in_array($dir,$dirs) OR PHP_SAPI === 'cli')
|
|
|
|
return parent::find_file($dir,$file,$ext,$array);
|
|
|
|
|
2013-06-19 09:26:07 +00:00
|
|
|
$prefixes = array('');
|
|
|
|
|
2013-04-26 01:42:09 +00:00
|
|
|
// Our search order.
|
2013-07-05 06:11:37 +00:00
|
|
|
array_unshift($prefixes,Config::theme().'/');
|
|
|
|
array_unshift($prefixes,sprintf('site/%s/',Config::siteid()));
|
|
|
|
array_unshift($prefixes,sprintf('site/%s/%s/',Config::siteid(),Config::theme()));
|
2013-04-26 01:42:09 +00:00
|
|
|
|
2013-05-28 11:35:54 +00:00
|
|
|
foreach ($prefixes as $p)
|
2013-04-26 01:42:09 +00:00
|
|
|
if ($x = parent::find_file($dir,$p.$file,$ext,$array))
|
2013-05-28 11:35:54 +00:00
|
|
|
break;
|
2013-04-26 01:42:09 +00:00
|
|
|
|
2013-05-28 11:35:54 +00:00
|
|
|
// We found a path.
|
2013-04-26 01:42:09 +00:00
|
|
|
return $x;
|
|
|
|
}
|
|
|
|
|
2011-12-29 23:54:54 +00:00
|
|
|
/**
|
|
|
|
* Override Kohana's shutdown_handler()
|
|
|
|
*
|
|
|
|
* When set up for multi-site, we need to disable Kohana's caching
|
|
|
|
* unless each site has exactly the same modules enabled.
|
|
|
|
* This is because Kohana::$file is cached with the enabled modules
|
|
|
|
* and is not OSB multi-site aware.
|
|
|
|
*/
|
|
|
|
public static function shutdown_handler() {
|
|
|
|
// If caching isnt enabled, we can skip this anyway
|
|
|
|
if (! Kohana::$caching)
|
2012-11-09 23:13:57 +00:00
|
|
|
return parent::shutdown_handler();
|
2011-12-29 23:54:54 +00:00
|
|
|
|
|
|
|
Kohana::$caching = FALSE;
|
|
|
|
$result = parent::shutdown_handler();
|
|
|
|
Kohana::$caching = TRUE;
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|