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.
lnapp/classes/lnApp/Core.php
2014-08-22 23:34:38 +10:00

53 lines
1.5 KiB
PHP

<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class overrides Kohana's Core
*
* @package lnApp
* @category Modifications
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
abstract class lnApp_Core extends Kohana_Core {
/**
* 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);
$prefixes = array('');
// Our search order.
array_unshift($prefixes,Site::Theme().'/');
array_unshift($prefixes,sprintf('site/%s/',Site::ID()));
array_unshift($prefixes,sprintf('site/%s/%s/',Site::ID(),Site::Theme()));
foreach ($prefixes as $p)
if ($x = parent::find_file($dir,$p.$file,$ext,$array))
break;
// We found a path.
return $x;
}
}
?>