/** * initialize application and load configs */ public function __construct() { include_once self::AUTOLOAD; if (strtolower(ini_get('display_errors')) === 'off') { define('ENVIRONMENT', 'LIVE'); } else { define('ENVIRONMENT', 'DEV'); } if (!session_start()) { Logger::error('failed to start session'); exit; } # load public & private config $this->config = (new Bucket())->applyIni(new File(self::CONFIG_PUBLIC))->applyIni(new File(self::CONFIG_PRIVATE)); # load MAPUrl if (stripos($_SERVER['SERVER_PROTOCOL'], 'HTTPS') !== false) { $scheme = 'https'; } else { $scheme = 'http'; } $this->request = new MAPUrl($scheme . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], $this->config); Logger::debug('REQUEST (' . 'mode: `' . $this->request->getMode() . '` ' . 'area: `' . $this->request->getArea() . '` ' . 'page: `' . $this->request->getPage() . '`'); # load area & page config $configPathList = array('private/src/area/' . $this->request->getArea() . '/config/area.ini', 'private/src/area/' . $this->request->getArea() . '/config/page/' . $this->request->getPage() . '.ini'); foreach ($configPathList as $configPath) { $configFile = new File($configPath); if (!$configFile->isFile()) { if (constant('ENVIRONMENT') === 'DEV') { Logger::info('config-file `' . $configFile . '` not found'); } continue; } $this->config->applyIni($configFile); } # load session config if (!isset($_SESSION['config'])) { $_SESSION['config'] = array(); } $this->config->applyArray($_SESSION['config']); }
/** * @return Bucket */ protected final function getTextBucket() { $texts = new Bucket(); if (isset($this->settings['multiLang']) && $this->settings['multiLang'] === true) { # additional lang-files if ($this->config->isArray('multiLang', 'loadList')) { $loadPathList = $this->config->get('multiLang', 'loadList'); } else { $loadPathList = array(); } # auto-loading lang-file if ($this->config->isTrue('multiLang', 'autoLoading')) { $language = $this->config->get('multiLang', 'language'); $area = $this->request->getArea(); $page = $this->request->getPage(); $loadPathList[] = 'area/' . $area . '/text/' . $language . '/page/' . $page . '.ini'; } foreach ($loadPathList as $loadPath) { $loadFile = (new File('private/src'))->attach($loadPath); if ($loadFile->isFile()) { $texts->applyIni($loadFile); } else { Logger::warning('lang-file `' . $loadFile . '` not found'); } } } return $texts; }