/** * Load translations from a given path. * * @access private * @param string $path * @throws Exception\Fatal * @version 1.2.0-dev * @since 1.2.0-dev */ private function loadFiles($path) { $localePath = $path . DS . 'locale'; $langs = Router::getLangs(); if (file_exists($localePath)) { $scannedDir = \FileManager::scanDir($localePath, 0); foreach ($scannedDir as $dirId => &$file) { list($lang, $type) = explode('.', $file); // check language if (!in_array($lang, $langs)) { unset($scannedDir[$dirId]); continue; } // import data from single file switch ($type) { case 'json': $fileTranslations = static::importFileJson($localePath . DS . $file, $lang); break; default: $fileTranslations = []; } // count translations per type $appPart = NULL; if (strpos($path, PATH_FW) !== FALSE) { $appPart = 'fw'; } elseif (strpos($path, PATH_MODULES) !== FALSE) { $appPart = 'module'; } elseif (strpos($path, PATH_APP) !== FALSE) { $appPart = 'app'; } // do counting per app part $counting = 0; foreach ($fileTranslations as $context => $translation) { $counting += count($translation); } $temp =& $this->amountLoadedPerType[$appPart]; switch ($appPart) { case 'module': $module = str_replace(PATH_MODULES, '', $path); $temp[$module][$lang] = $counting; break; case 'app': case 'fw': $temp[$lang] = $counting; break; } // merge data $this->loadedContent = array_replace_recursive($this->loadedContent, $fileTranslations); } } }
/** * this method will insert the new active modules in site database if * does not exist */ private function setNewModules() { foreach (FileManager::scanDir($this->modulesDir) as $module) { $ModuleConfig = $this->getModuleConfig($module); if ($ModuleConfig['active']) { $this->db->setSQL("SELECT * FROM modules WHERE `name` = '{$ModuleConfig['name']}'"); $moduleRecord = $this->db->fetchRecord(PDO::FETCH_ASSOC); if (empty($moduleRecord)) { $data['name'] = $ModuleConfig['name']; $data['enable'] = '0'; $data['installed_version'] = $ModuleConfig['version']; $this->db->setSQL($this->db->sqlBind($data, 'modules', 'I')); $this->db->execOnly(); } } } return; }
/** * this method will insert the new active modules in site database if * does not exist */ private function setNewModules() { foreach (FileManager::scanDir($this->modulesDir) as $module) { $m = $this->getModuleConfig($module); if ($m['active']) { $name = $m['name']; $this->db->setSQL("SELECT count(*) AS total FROM modules WHERE `name` = '{$name}'"); $rec = $this->db->fetchRecord(PDO::FETCH_ASSOC); if ($rec['total'] == 0) { $data['name'] = $m['name']; $data['enable'] = 0; $data['installed_version'] = $m['version']; $this->db->setSQL($this->db->sqlBind($data, 'modules', 'I')); $this->db->execOnly(); } } } return; }
/** * this method will insert the new active modules in site database if * does not exist */ private function setNewModules() { Matcha::pauseLog(true); foreach (FileManager::scanDir($this->modulesDir) as $module) { $ModuleConfig = $this->getModuleConfig($module); if ($ModuleConfig['active']) { $moduleRecord = $this->m->load(['name' => $ModuleConfig['name']])->one(); if (empty($moduleRecord)) { $data = new stdClass(); $data->title = $ModuleConfig['title']; $data->name = $ModuleConfig['name']; $data->description = $ModuleConfig['description']; $data->enable = '0'; $data->installed_version = $ModuleConfig['version']; $this->m->save($data); } } } Matcha::pauseLog(false); return; }