1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-03 06:55:03 +03:00
ifhub.club/application/install/bootstrap.php
2014-10-08 15:49:34 +07:00

55 lines
1.4 KiB
PHP

<?php
define('INSTALL_DIR', dirname(__FILE__));
define('VERSION', '2.0.0');
function install_func_underscore($sStr)
{
return strtolower(preg_replace('/([^A-Z])([A-Z])/', "$1_$2", $sStr));
}
function install_func_camelize($sStr)
{
$aParts = explode('_', $sStr);
$sCamelized = '';
foreach ($aParts as $sPart) {
$sCamelized .= ucfirst($sPart);
}
return $sCamelized;
}
/**
* Загрузка классов инсталлятора
* пример - InstallCore, InstallStepInit
*
* @param $sClassName
* @return bool
*/
function install_autoload($sClassName)
{
$aPath = explode('_', install_func_underscore($sClassName));
if (count($aPath) < 2 or $aPath[0] != 'install') {
return;
}
array_shift($aPath);
if ($aPath[0] == 'step' and count($aPath) > 1) {
array_shift($aPath);
$sDir = 'step';
$sName = ucfirst(install_func_camelize(join('_', $aPath)));
$sName{0} = strtolower($sName{0});
} else {
$sName = array_pop($aPath);
$sDir = join(DIRECTORY_SEPARATOR, $aPath);
}
$sPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'backend' . DIRECTORY_SEPARATOR . ($sDir ? $sDir . DIRECTORY_SEPARATOR : '') . $sName . '.php';
if (file_exists($sPath)) {
require_once($sPath);
return true;
}
return false;
}
/**
* Подключаем загрузкик классов
*/
spl_autoload_register('install_autoload');