private static function load_laravel_3($lar_path) { // ----------- Grab The Database Config ----------------- // // We grab the array for detecting if this is a local or production env. // We assume the path.php file is one directory above the applications // directory. If it is not you will have to configure the CMS by hand. require $lar_path . '/../paths.php'; // The require above screws up the current working directory. So we fix. chdir(self::$_root_path); // Figure out what env we are in. if (!(self::$env = self::detect_env($environments, $_SERVER['HTTP_HOST']))) { self::$env = 'production'; } // Grab the default configs. $tmp = (require $lar_path . '/config/database.php'); $default = $tmp['default']; $database = $tmp['connections'][$default]; // If we are in a local dev env we look for a local folder and merge. $file = $lar_path . '/config/' . self::$env . '/database.php'; if (is_file($file)) { $tmp = (require $file); if (isset($tmp['connections'][$default])) { $database = array_merge($database, $tmp['connections'][$default]); } } // Set the database configs we sucked out of Laravel CMS\Libraries\Config::set('db_host', $database['host']); CMS\Libraries\Config::set('db_database', $database['database']); CMS\Libraries\Config::set('db_username', $database['username']); CMS\Libraries\Config::set('db_password', $database['password']); }
/** * Производит запуск веб-приложения * */ public function run() { try { if (!isset(self::$component_names['CMSStockroom'])) { Core::load('CMS.Stockroom'); } if (!isset(self::$component_names['CMSFSPages'])) { Core::load('CMS.FSPages'); } self::before_run(CMS::env()); // Если скрипт запущен из командной строки, то веб-приложение не запускается //TODO: create cli_application if (!isset($_SERVER['HTTP_HOST']) && !isset($_SERVER['REQUEST_URI'])) { CMS::$is_cli = true; Core::load('CMS.CLI'); CMS_CLI::run(); return; } if (self::$enable_rest) { self::application()->dispatcher(); } return WS::run(self::application()->cms_action()); } catch (Exception $e) { self::root_catcher($e); } }
static function file($id) { if (!isset(CMS::env()->files)) { return false; } if (!Core_Types::is_iterable(CMS::env()->files)) { return false; } if (isset(CMS::env()->files[$id])) { return CMS::env()->files[$id]; } foreach (CMS::env()->files as $file) { if ($file['alias'] == $id) { return $file; } } return false; }
public function run(WS_Environment $env) { CMS::$env = $env; CMS::$page = $env; $env->cms = new stdClass(); Core::load('Templates.HTML'); $env->meta = Templates_HTML::meta(); $env->mappers = CMS::mappers(); $env->auth = new stdClass(); $env->auth->user = false; CMS::$cfg = $env->config; if ($env->db->default) { CMS::$db = $env->db->default; } Templates_HTML::use_helper('fields', 'CMS.Fields.Helper'); Templates_HTML::use_helper('cms', 'CMS.Helper'); Templates::option('templates_root', array_merge(Templates::option('templates_root'), array(CMS::$views_path))); return $this->application->run($env); }