1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-05 07:54:24 +03:00
ifhub.club/application/install/bootstrap.php

52 lines
1.3 KiB
PHP
Raw Normal View History

2014-07-28 09:23:41 +03:00
<?php
define('INSTALL_DIR',dirname(__FILE__));
define('VERSION','2.0.0');
2014-07-28 09:23:41 +03:00
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;
}
2014-07-28 09:23:41 +03:00
/**
* Загрузка классов инсталлятора
* пример - 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);
}
2014-07-28 09:23:41 +03:00
$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');