/** * Konstruktor * @param string $langCode * @return boolean */ public function __construct($langCode) { if (!$langCode) { $langCode = FPCM_DEFAULT_LANGUAGE_CODE; } if (!is_dir(baseconfig::$langDir . $langCode)) { trigger_error('Try to load undefined language: ' . $langCode); return false; } $this->langCode = $langCode; $confFile = baseconfig::$langDir . $langCode . '/lang.cfg'; if (!file_exists($confFile)) { trigger_error('Unable to find language config file in: ' . $langCode); return false; } $this->langList[$langCode] = file_get_contents($confFile); $this->helpFile = baseconfig::$langDir . $langCode . '/help.php'; $this->cache = new cache('langcache_' . $langCode, 'system'); if (!$this->cache->isExpired()) { $this->langData = $this->cache->read(); return; } $moduleLangFiles = $langCode != FPCM_DEFAULT_LANGUAGE_CODE ? glob(baseconfig::$moduleDir . '*/*/lang/' . FPCM_DEFAULT_LANGUAGE_CODE . '/*.php') : array(); $moduleLangFiles_langcode = glob(baseconfig::$moduleDir . '*/*/lang/' . $langCode . '/*.php'); if (is_array($moduleLangFiles_langcode)) { $moduleLangFiles += $moduleLangFiles_langcode; } $langfiles = array_merge(glob(baseconfig::$langDir . $langCode . '/*.php'), is_array($moduleLangFiles) ? $moduleLangFiles : array()); foreach ($langfiles as $file) { if (strpos($file, 'help.php') !== false) { continue; } include $file; if (!isset($lang)) { trigger_error('No language data defined in:' . $file); continue; } $this->langData = array_merge($this->langData, $lang); } $this->cache->write($this->langData, FPCM_LANGCACHE_TIMEOUT); }
/** * Controller abrufen * @return array */ public static function getControllers() { $controllerCache = new cache('controllerCache', 'system'); if (!$controllerCache->isExpired()) { $controllerList = $controllerCache->read(); if (is_array($controllerList)) { return $controllerList; } } include_once loader::libGetFilePath('spyc', 'Spyc.php'); if (!file_exists(self::$controllerFiles['actions']) || !file_exists(self::$controllerFiles['ajax'])) { die('ERROR: Controller config files not found.'); } $actions = \Spyc::YAMLLoad(self::$controllerFiles['actions']); $ajaxs = \Spyc::YAMLLoad(self::$controllerFiles['ajax']); $modules = self::initModuleControllers(); $controllerList = array_unique(array_merge($actions, $ajaxs, $modules)); $controllerCache->write($controllerList, FPCM_LANGCACHE_TIMEOUT); return $controllerList; }