function _addLanguage($aLanguage, $aLangInfo) { $oDb = new BxDolModuleDb(); if (getLangIdByName($aLangInfo['Name'])) { // language already exists return false; } $sLangName = $aLangInfo['Name']; $sLangFlag = $aLangInfo['Flag']; $sLangTitle = $aLangInfo['Title']; $sLangDir = isset($aLangInfo['Direction']) && $aLangInfo['Direction'] ? $aLangInfo['Direction'] : 'LTR'; $sLangCountryCode = isset($aLangInfo['LanguageCountry']) && $aLangInfo['LanguageCountry'] ? $aLangInfo['LanguageCountry'] : $aLangInfo['Name'] . '_' . strtoupper($aLangInfo['Flag']); if (!$oDb->res("INSERT INTO `sys_localization_languages` VALUES (?, ?, ?, ?, ?, ?)", [NULL, $sLangName, $sLangFlag, $sLangTitle, $sLangDir, $sLangCountryCode])) { return false; } $iLangKey = $oDb->lastId(); foreach ($aLanguage as $sKey => $sValue) { $sDbKey = $sKey; $sDbValue = $sValue; $iExistedKey = $oDb->getOne("SELECT `ID` FROM `sys_localization_keys` WHERE `Key` = ?", [$sDbKey]); if (!$iExistedKey) { // key is missing, insert new key if (!$oDb->res("INSERT INTO `sys_localization_keys` VALUES (NULL, ?, ?)", [BX_DOL_LANGUAGE_CATEGORY_SYSTEM, $sDbKey])) { continue; } $iExistedKey = $oDb->lastId(); } $oDb->res("INSERT INTO `sys_localization_strings` VALUES(?, ?, ?)", [$iExistedKey, $iLangKey, $sDbValue]); } return true; }
function _addLanguage($aLanguage, $aLangInfo) { $oDb = new BxDolModuleDb(); if (getLangIdByName($aLangInfo['Name'])) { // language already exists return false; } $sLangName = $oDb->escape($aLangInfo['Name']); $sLangFlag = $oDb->escape($aLangInfo['Flag']); $sLangTitle = $oDb->escape($aLangInfo['Title']); if (!$oDb->res("INSERT INTO `sys_localization_languages` VALUES (NULL, '{$sLangName}', '{$sLangFlag}', '{$sLangTitle}')")) { return false; } $iLangKey = $oDb->lastId(); foreach ($aLanguage as $sKey => $sValue) { $sDbKey = $oDb->escape($sKey); $sDbValue = $oDb->escape($sValue); $iExistedKey = $oDb->getOne("SELECT `ID` FROM `sys_localization_keys` WHERE `Key` = '{$sDbKey}'"); if (!$iExistedKey) { // key is missing, insert new key if (!$oDb->res("INSERT INTO `sys_localization_keys` VALUES (NULL, " . BX_DOL_LANGUAGE_CATEGORY_SYSTEM . ", '{$sDbKey}')")) { continue; } $iExistedKey = $oDb->lastId(); } $oDb->res("INSERT INTO `sys_localization_strings` VALUES({$iExistedKey}, {$iLangKey}, '{$sDbValue}')"); } return true; }
function uninstall($aParams) { $oModuleDb = new BxDolModuleDb(); $sTitle = _t('_adm_txt_modules_operation_uninstall', $this->_aConfig['title']); //--- Check whether the module was already installed ---// if (!$oModuleDb->isModule($this->_aConfig['home_uri'])) { return array('operation_title' => $sTitle, 'message' => _t('_adm_txt_modules_already_uninstalled'), 'result' => false); } //--- Check for dependent modules ---// $bDependent = false; $aDependents = $oModuleDb->getDependent($this->_aConfig['home_uri']); if (is_array($aDependents) && !empty($aDependents)) { $bDependent = true; $sMessage = '<br />-- -- ' . _t('_adm_txt_modules_has_dependents') . '<br />'; foreach ($aDependents as $aDependent) { $sMessage .= '-- -- ' . $aDependent['title'] . '<br />'; } } if ($bDependent) { return array('operation_title' => $sTitle, 'message' => $this->_displayResult('check_dependencies', false, $sMessage), 'result' => false); } $aResult = $this->_perform('uninstall', 'Uninstallation'); if ($aResult['result']) { $iModuleId = (int) $oModuleDb->getOne("SELECT `id` FROM `sys_modules` WHERE `vendor`='" . $this->_aConfig['vendor'] . "' AND `path`='" . $this->_aConfig['home_dir'] . "' LIMIT 1"); $oModuleDb->query("DELETE FROM `sys_modules` WHERE `vendor`='" . $this->_aConfig['vendor'] . "' AND `path`='" . $this->_aConfig['home_dir'] . "' LIMIT 1"); $oModuleDb->query("DELETE FROM `sys_modules_file_tracks` WHERE `module_id`='" . $iModuleId . "'"); deleteStringFromLanguage(BxDolModule::getTitleKey($this->_aConfig['home_uri'])); compileLanguage(); $GLOBALS['MySQL']->cleanMemory('sys_modules_' . $this->_aConfig['home_uri']); $GLOBALS['MySQL']->cleanMemory('sys_modules_' . $iModuleId); $GLOBALS['MySQL']->cleanMemory('sys_modules'); } $aResult['operation_title'] = $sTitle; return $aResult; }