Exemple #1
0
 public function load($configName = null, $configLocation = null)
 {
     $configName = $configName ?: self::MAIN_CONFIG_NAME;
     $configLocation = $configLocation ?: \Kalibri::app()->getLocation() . 'App/Config/';
     $configPath = $configLocation . $configName . '.php';
     if (file_exists($configPath)) {
         $this->_data = array_merge($this->_data, include $configPath);
         (K_COMPILE_BASE || K_COMPILE_ROUTES) && \Kalibri::compiler()->skip($configPath);
         return $this;
     }
     throw new \Kalibri\Exception("Config '{$configName}' not found");
 }
Exemple #2
0
 protected function init()
 {
     K_COMPILE_ROUTES && \Kalibri::compiler()->compile(Compiler::NAME_BASE);
     \Kalibri::config()->load();
     if ($this->_mode) {
         try {
             \Kalibri::config()->load($this->_mode);
         } catch (\Exception $e) {
         }
     }
     // Set list of classes that will be auto inited on use
     \Kalibri::setAutoInitClasses(\Kalibri::config()->get('init.classes'));
     //\Kalibri::logger()->init( \Kalibri::config()->get('debug.log') );
     \Kalibri::router()->setSegments(\Kalibri::uri()->getSegments());
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
     if (\Kalibri::config()->get('debug.log.is-enabled', false)) {
         \Kalibri::logger()->add(\Kalibri\Logger\Base::L_DEBUG, 'init', $this);
     }
     ob_start();
 }
Exemple #3
0
date_default_timezone_set('Europe/Kiev');
define('K_TIME', $_SERVER['REQUEST_TIME']);
define('K_DATE', date('Y-m-d', K_TIME));
define('K_DATETIME', date('Y-m-d H:i:s', K_TIME));
!defined('K_ROOT') && define('K_ROOT', str_replace('\\', '/', realpath(dirname(__FILE__) . '/../')) . '/');
// Add app and kalibri to include path
set_include_path(str_replace('\\', '/', realpath(K_APP_FOLDER . '../')) . PATH_SEPARATOR . K_ROOT . PATH_SEPARATOR . get_include_path());
require_once 'Kalibri/Kalibri.php';
!defined('K_COMPILE_BASE') && define('K_COMPILE_BASE', false);
!defined('K_COMPILE_ROUTES') && define('K_COMPILE_ROUTES', false);
if (K_COMPILE_BASE || K_COMPILE_ROUTES) {
    require_once 'Kalibri/Utils/Compiler.php';
    \Kalibri::compiler(new \Kalibri\Utils\Compiler());
}
if (!K_COMPILE_BASE || !\Kalibri::compiler()->includeCached(\Kalibri\Utils\Compiler::NAME_BASE)) {
    require_once 'Kalibri/Autoload.php';
    require_once 'Kalibri/Application.php';
    require_once 'Kalibri/Config.php';
    require_once 'Kalibri/Controller/Base.php';
    require_once 'Kalibri/Uri.php';
    require_once 'Kalibri/Router.php';
    require_once 'Kalibri/Benchmark.php';
}
// Register autoloader
spl_autoload_register(function ($className) {
    if (@(include_once str_replace('\\', '/', $className) . '.php')) {
        return true;
    }
    // Not loaded yet, try to load helper
    return \Kalibri::autoload()->helper($className);
Exemple #4
0
 /**
  * Render view
  *
  * @param bool $asString
  *
  * @return mixed(string,bool)
  */
 public function render($asString = false, $path = null)
 {
     $output = null;
     if (!empty($this->_name)) {
         if ($this->isExists($this->_name, $path)) {
             \ob_start();
             \extract(\Kalibri::data()->getData());
             include $location = $this->getLocation(null, $path);
             $output = ob_get_contents();
             K_COMPILE_ROUTES && \Kalibri::compiler()->skip($location);
             @\ob_end_clean();
         } else {
             \Kalibri::error()->show("View with name '{$this->_name}' not found");
         }
     }
     if (!$asString) {
         echo $output;
     }
     \Kalibri::data()->set(self::VAR_CONTENT, $output);
     return $output;
 }