|
|
@@ -42,7 +42,7 @@ class multilingual{
|
|
|
if (empty($langkey) || strtoupper($langkey) == "ALL") {
|
|
|
// 如果没传或传 ALL,直接查询所有激活语言的 ID
|
|
|
// 优化点:直接查 id,不需要先查 key 再查 id
|
|
|
- $langSql = "SELECT id FROM kln_i18n_languages";
|
|
|
+ $langSql = "SELECT id FROM public.kln_i18n_languages";
|
|
|
$langRows = common::excuteListSql($langSql);
|
|
|
if ($langRows) {
|
|
|
$langIds = array_column($langRows, 'id');
|
|
|
@@ -61,7 +61,7 @@ class multilingual{
|
|
|
if (!empty($safeLangs)) {
|
|
|
// 拼接 IN 条件:('english', 'french')
|
|
|
$inClause = implode(',', $safeLangs);
|
|
|
- $langSql = "SELECT id FROM kln_i18n_languages WHERE lang_key IN ($inClause)";
|
|
|
+ $langSql = "SELECT id FROM public.kln_i18n_languages WHERE lang_key IN ($inClause)";
|
|
|
$langRows = common::excuteListSql($langSql);
|
|
|
if ($langRows) {
|
|
|
$langIds = array_column($langRows, 'id');
|
|
|
@@ -95,10 +95,85 @@ class multilingual{
|
|
|
$this->_multilingual_save($multilingual_param);
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ * multilingual_save
|
|
|
+ */
|
|
|
+ if ($operate == "multilingual_save_all") {
|
|
|
+ $multilingual_param = $_POST['multilingual_param'];
|
|
|
+ $this->_multilingual_save_oneself($multilingual_param);
|
|
|
+ }
|
|
|
+
|
|
|
if ($operate == "load_all_pages_by_lang") {
|
|
|
$langkey = common::check_input($_POST['langkey']);
|
|
|
$this->_loadAllPagesByLang($langkey);
|
|
|
}
|
|
|
+
|
|
|
+ if ($operate == "edi_doc_type"){
|
|
|
+ $json = common::excuteOneSql("select data from public.kln_i18n_pages_init where id = 3");
|
|
|
+ $data = json_decode($json,true);
|
|
|
+
|
|
|
+ $successCount = 0;
|
|
|
+ $errorCount = 0;
|
|
|
+ foreach ($data['data'] as $row) {
|
|
|
+ try {
|
|
|
+ $code = isset($row['code']) ? "'" . common::check_input($row['code']) . "'" : "NULL";
|
|
|
+ $name = isset($row['name']) ? "'" . common::check_input($row['name']) . "'" : "NULL";
|
|
|
+ $description = isset($row['description']) ? "'" . common::check_input($row['description']) . "'" : "NULL";
|
|
|
+ $version_policy = isset($row['versionPolicy']) ? "'" . common::check_input($row['versionPolicy']) . "'" : "NULL";
|
|
|
+
|
|
|
+ // 处理 "1"/"0" 字符串或数字
|
|
|
+ $visible_to_customer = isset($row['visibleToCustomer']) ? "'" . common::check_input($row['visibleToCustomer']) . "'" : "NULL";
|
|
|
+ $can_delete = isset($row['canDelete']) ? "'" . common::check_input($row['canDelete']) . "'" : "NULL";
|
|
|
+ $to_destination = isset($row['toDestination']) ? intval($row['toDestination']) : "NULL";
|
|
|
+
|
|
|
+ $maximum_file_size = isset($row['maximumFileSize']) ? floatval($row['maximumFileSize']) : "NULL";
|
|
|
+
|
|
|
+ $supported_suffixes = isset($row['supportedSuffixes']) ? "'" . common::check_input($row['supportedSuffixes']) . "'" : "NULL";
|
|
|
+ $biz_type = isset($row['bizType']) ? "'" . common::check_input($row['bizType']) . "'" : "NULL";
|
|
|
+ $shipment_type = isset($row['shipmentType']) ? "'" . common::check_input($row['shipmentType']) . "'" : "NULL";
|
|
|
+ $field_code = isset($row['fieldCode']) ? "'" . common::check_input($row['fieldCode']) . "'" : "NULL";
|
|
|
+
|
|
|
+ $rule_exp = isset($row['ruleExp']) ? "'" . common::check_input($row['ruleExp']) . "'" : "NULL";
|
|
|
+
|
|
|
+ $old_code = isset($row['oldCode']) ? "'" . common::check_input($row['oldCode']) . "'" : "NULL";
|
|
|
+ $old_name = isset($row['oldName']) ? "'" . common::check_input($row['oldName']) . "'" : "NULL";
|
|
|
+
|
|
|
+ $biz_cate = isset($row['bizCate']) ? "'" . common::check_input($row['bizCate']) . "'" : "NULL";
|
|
|
+ $is_old = isset($row['isOld']) ? "'" . common::check_input($row['isOld']) . "'" : "NULL";
|
|
|
+ $is_business = isset($row['isBusiness']) ? "'" . common::check_input($row['isBusiness']) . "'" : "NULL";
|
|
|
+
|
|
|
+ $upload_file_name_rule_suffix = isset($row['uploadFileNameRuleSuffix']) ? "'" . common::check_input($row['uploadFileNameRuleSuffix']) . "'" : "NULL";
|
|
|
+
|
|
|
+ $customer_upload = isset($row['customerUpload']) ? "'" . common::check_input($row['customerUpload']) . "'" : "NULL";
|
|
|
+
|
|
|
+ // 处理 null 值 (数据库 NULL)
|
|
|
+ $notify_station = isset($row['notifyStation']) ? "'" . common::check_input($row['notifyStation']) . "'" : "NULL";
|
|
|
+ $auto_sync_to_station = isset($row['autoSyncToStation']) ? "'" . common::check_input($row['autoSyncToStation']) . "'" : "NULL";
|
|
|
+
|
|
|
+ // --- 拼接 SQL 语句 ---
|
|
|
+ // 注意:表名使用双引号 "document_codes" 以确保大小写敏感(如果表名是小写 codes 可能不需要,但为了保险)
|
|
|
+ $insertSQL = "INSERT INTO doc_type (
|
|
|
+ code, name, description, version_policy, visible_to_customer,
|
|
|
+ can_delete, to_destination, maximum_file_size, supported_suffixes,
|
|
|
+ biz_type, shipment_type, field_code, rule_exp, old_code,
|
|
|
+ old_name, biz_cate, is_old, is_business, upload_file_name_rule_suffix,
|
|
|
+ customer_upload, notify_station, auto_sync_to_station
|
|
|
+ ) VALUES (
|
|
|
+ $code, $name, $description, $version_policy, $visible_to_customer,
|
|
|
+ $can_delete, $to_destination, $maximum_file_size, $supported_suffixes,
|
|
|
+ $biz_type, $shipment_type, $field_code, $rule_exp, $old_code,
|
|
|
+ $old_name, $biz_cate, $is_old, $is_business, $upload_file_name_rule_suffix,
|
|
|
+ $customer_upload, $notify_station, $auto_sync_to_station
|
|
|
+ )";
|
|
|
+ common::excuteUpdateSql($insertSQL);
|
|
|
+ $successCount++;
|
|
|
+ } catch (PDOException $e) {
|
|
|
+ echo "插入失败 (Code: {$row['code']}): " . $e->getMessage() . "\n";
|
|
|
+ $errorCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ echo "数据处理完成。\n成功插入: $successCount 条\n失败: $errorCount 条\n";
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private function _multilingual_init() {
|
|
|
@@ -141,36 +216,36 @@ class multilingual{
|
|
|
global $db;
|
|
|
$db->StartTrans();
|
|
|
try {
|
|
|
- // 第一步:处理页面表 (kln_i18n_pages)
|
|
|
+ // 第一步:处理页面表 (public.kln_i18n_pages)
|
|
|
$pageId = null;
|
|
|
|
|
|
// --- 模式判断:如果是覆盖模式,先删除旧数据 ---
|
|
|
if ($mode === 'replace') {
|
|
|
- // 1. 先删子表 (kln_i18n_keys)
|
|
|
- $kikSqlDelete = "DELETE FROM kln_i18n_keys WHERE page_id IN (SELECT id FROM kln_i18n_pages WHERE page_key = '$pageKey')";
|
|
|
+ // 1. 先删子表 (public.kln_i18n_keys)
|
|
|
+ $kikSqlDelete = "DELETE FROM public.kln_i18n_keys WHERE page_id IN (SELECT id FROM public.kln_i18n_pages WHERE page_key = '$pageKey')";
|
|
|
$db->Execute($kikSqlDelete) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $kikSqlDelete), 0));
|
|
|
|
|
|
- // 2. 再删主表 (kln_i18n_pages) - 虽然上面删了子表,这里为了保险或者重置页面信息也可以删,
|
|
|
- $delPageSql = "DELETE FROM kln_i18n_pages WHERE page_key = '$pageKey'";
|
|
|
+ // 2. 再删主表 (public.kln_i18n_pages) - 虽然上面删了子表,这里为了保险或者重置页面信息也可以删,
|
|
|
+ $delPageSql = "DELETE FROM public.kln_i18n_pages WHERE page_key = '$pageKey'";
|
|
|
$db->Execute($delPageSql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $delPageSql), 0));
|
|
|
}
|
|
|
|
|
|
// --- 查询页面是否存在 ---
|
|
|
- $checkPageSql = "SELECT id FROM kln_i18n_pages WHERE page_key = '$pageKey'";
|
|
|
+ $checkPageSql = "SELECT id FROM public.kln_i18n_pages WHERE page_key = '$pageKey'";
|
|
|
$checkPageRes = $db->GetRow($checkPageSql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $checkPageSql), 0));
|
|
|
|
|
|
if (!empty($checkPageRes)) {
|
|
|
// 存在 -> 更新
|
|
|
$pageId = $checkPageRes['id'];
|
|
|
- $updatePageSql = "UPDATE kln_i18n_pages SET unverified_number = $unverifiedNumber WHERE id = $pageId";
|
|
|
+ $updatePageSql = "UPDATE public.kln_i18n_pages SET unverified_number = $unverifiedNumber WHERE id = $pageId";
|
|
|
$db->Execute($updatePageSql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $updatePageSql), 0));
|
|
|
} else {
|
|
|
// 不存在 -> 插入
|
|
|
- $insertPageSql = "INSERT INTO kln_i18n_pages (page_key, unverified_number, description) VALUES ('$pageKey', $unverifiedNumber, '')";
|
|
|
+ $insertPageSql = "INSERT INTO public.kln_i18n_pages (page_key, unverified_number, description) VALUES ('$pageKey', $unverifiedNumber, '')";
|
|
|
$db->Execute($insertPageSql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $insertPageSql), 0));
|
|
|
|
|
|
// 获取新生成的 ID (PostgreSQL)
|
|
|
- $seqSql = "SELECT currval('kln_i18n_pages_id_seq')";
|
|
|
+ $seqSql = "SELECT currval('public.kln_i18n_pages_id_seq')";
|
|
|
$pageIdRow = $db->GetRow($seqSql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $seqSql), 0));
|
|
|
$pageId = $pageIdRow['currval'];
|
|
|
}
|
|
|
@@ -187,43 +262,43 @@ class multilingual{
|
|
|
$statusKey = common::check_input($jsonKey . 'Status');
|
|
|
$status = isset($item[$statusKey]) ? intval($item[$statusKey]) : 0;
|
|
|
|
|
|
- // --- 1. 处理语言表 (kln_i18n_languages) ---
|
|
|
+ // --- 1. 处理语言表 (public.kln_i18n_languages) ---
|
|
|
$langKey = common::check_input($jsonKey);
|
|
|
$langName = common::check_input($langInfo['name']);
|
|
|
$localeCode = common::check_input($langInfo['code']);
|
|
|
|
|
|
// 查询语言是否存在
|
|
|
- $checkLangSql = "SELECT id FROM kln_i18n_languages WHERE lang_key = '$langKey'";
|
|
|
+ $checkLangSql = "SELECT id FROM public.kln_i18n_languages WHERE lang_key = '$langKey'";
|
|
|
$checkLangRes = $db->GetRow($checkLangSql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $checkLangSql), 0));
|
|
|
|
|
|
if (!empty($checkLangRes)) {
|
|
|
// 存在 -> 更新
|
|
|
$langId = $checkLangRes['id'];
|
|
|
- $updateLangSql = "UPDATE kln_i18n_languages SET lang_name = '$langName', locale_code = '$localeCode' WHERE id = $langId";
|
|
|
+ $updateLangSql = "UPDATE public.kln_i18n_languages SET lang_name = '$langName', locale_code = '$localeCode' WHERE id = $langId";
|
|
|
$db->Execute($updateLangSql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $updateLangSql), 0));
|
|
|
} else {
|
|
|
// 不存在 -> 插入
|
|
|
- $insertLangSql = "INSERT INTO kln_i18n_languages (lang_key, lang_name, locale_code, is_active) VALUES ('$langKey', '$langName', '$localeCode', true)";
|
|
|
+ $insertLangSql = "INSERT INTO public.kln_i18n_languages (lang_key, lang_name, locale_code, is_active) VALUES ('$langKey', '$langName', '$localeCode', true)";
|
|
|
$db->Execute($insertLangSql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $updateLangSql), 0));
|
|
|
|
|
|
// 获取 ID
|
|
|
- $seqLangSql = "SELECT currval('kln_i18n_languages_id_seq')";
|
|
|
+ $seqLangSql = "SELECT currval('public.kln_i18n_languages_id_seq')";
|
|
|
$langIdRow = $db->GetRow($seqLangSql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $seqLangSql), 0));
|
|
|
$langId = $langIdRow['currval'];
|
|
|
}
|
|
|
|
|
|
- // --- 2. 处理词条表 (kln_i18n_keys) ---
|
|
|
+ // --- 2. 处理词条表 (public.kln_i18n_keys) ---
|
|
|
// 查询词条是否存在
|
|
|
- $checkKeySql = "SELECT id FROM kln_i18n_keys WHERE page_id = $pageId AND lang_id = $langId AND trans_key = '$transKey'";
|
|
|
+ $checkKeySql = "SELECT id FROM public.kln_i18n_keys WHERE page_id = $pageId AND lang_id = $langId AND trans_key = '$transKey'";
|
|
|
$checkKeyRes = $db->GetRow($checkKeySql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $checkKeySql), 0));
|
|
|
|
|
|
if (!empty($checkKeyRes)) {
|
|
|
// 存在 -> 更新
|
|
|
- $updateKeySql = "UPDATE kln_i18n_keys SET trans_value = '$transValue', orgin_value = '$originValue', status = $status WHERE id = " . $checkKeyRes['id'];
|
|
|
+ $updateKeySql = "UPDATE public.kln_i18n_keys SET trans_value = '$transValue', orgin_value = '$originValue', status = $status WHERE id = " . $checkKeyRes['id'];
|
|
|
$db->Execute($updateKeySql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $updateKeySql), 0));
|
|
|
} else {
|
|
|
// 不存在 -> 插入
|
|
|
- $insertKeySql = "INSERT INTO kln_i18n_keys (page_id, lang_id, trans_key, trans_value, orgin_value, status) VALUES ($pageId, $langId, '$transKey', '$transValue', '$originValue', $status)";
|
|
|
+ $insertKeySql = "INSERT INTO public.kln_i18n_keys (page_id, lang_id, trans_key, trans_value, orgin_value, status) VALUES ($pageId, $langId, '$transKey', '$transValue', '$originValue', $status)";
|
|
|
$db->Execute($insertKeySql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $insertKeySql), 0));
|
|
|
}
|
|
|
}
|
|
|
@@ -259,7 +334,7 @@ class multilingual{
|
|
|
// 1. 统一处理 $pageIds 数组
|
|
|
if (empty($pageKey) || strtoupper($pageKey) == "ALL") {
|
|
|
// 如果没传或传 ALL,直接查询所有页面的 ID
|
|
|
- $pageSql = "SELECT id FROM kln_i18n_pages";
|
|
|
+ $pageSql = "SELECT id FROM public.kln_i18n_pages";
|
|
|
$pageRows = common::excuteListSql($pageSql);
|
|
|
|
|
|
if ($pageRows) {
|
|
|
@@ -279,7 +354,7 @@ class multilingual{
|
|
|
if (!empty($safePages)) {
|
|
|
$inClause = implode(',', $safePages);
|
|
|
// 优化点:一次查询获取所有匹配的 ID 和 unverified_number
|
|
|
- $pageSql = "SELECT id, unverified_number FROM kln_i18n_pages WHERE page_key IN ($inClause)";
|
|
|
+ $pageSql = "SELECT id, unverified_number FROM public.kln_i18n_pages WHERE page_key IN ($inClause)";
|
|
|
$pageRows = common::excuteListSql($pageSql);
|
|
|
|
|
|
if ($pageRows) {
|
|
|
@@ -299,7 +374,7 @@ class multilingual{
|
|
|
if (empty($langkey) || strtoupper($langkey) == "ALL") {
|
|
|
// 如果没传或传 ALL,直接查询所有激活语言的 ID
|
|
|
// 优化点:直接查 id,不需要先查 key 再查 id
|
|
|
- $langSql = "SELECT id FROM kln_i18n_languages";
|
|
|
+ $langSql = "SELECT id FROM public.kln_i18n_languages";
|
|
|
$langRows = common::excuteListSql($langSql);
|
|
|
|
|
|
if ($langRows) {
|
|
|
@@ -319,7 +394,7 @@ class multilingual{
|
|
|
if (!empty($safeLangs)) {
|
|
|
// 拼接 IN 条件:('english', 'french')
|
|
|
$inClause = implode(',', $safeLangs);
|
|
|
- $langSql = "SELECT id FROM kln_i18n_languages WHERE lang_key IN ($inClause)";
|
|
|
+ $langSql = "SELECT id FROM public.kln_i18n_languages WHERE lang_key IN ($inClause)";
|
|
|
$langRows = common::excuteListSql($langSql);
|
|
|
if ($langRows) {
|
|
|
$langIds = array_column($langRows, 'id');
|
|
|
@@ -335,9 +410,9 @@ class multilingual{
|
|
|
k.orgin_value,
|
|
|
l.lang_key,
|
|
|
p.page_key AS key_page
|
|
|
- FROM kln_i18n_keys k
|
|
|
- JOIN kln_i18n_languages l ON k.lang_id = l.id
|
|
|
- JOIN kln_i18n_pages p ON k.page_id = p.id
|
|
|
+ FROM public.kln_i18n_keys k
|
|
|
+ JOIN public.kln_i18n_languages l ON k.lang_id = l.id
|
|
|
+ JOIN public.kln_i18n_pages p ON k.page_id = p.id
|
|
|
WHERE k.page_id IN (" . implode(',', $pageIds) . ")
|
|
|
AND k.lang_id IN (" . implode(',', $langIds) . ")
|
|
|
ORDER BY k.trans_key, p.page_key";
|
|
|
@@ -417,20 +492,20 @@ class multilingual{
|
|
|
$status = $param['status'];
|
|
|
|
|
|
// 查询页面ID
|
|
|
- $pageSql = "SELECT id FROM kln_i18n_pages WHERE page_key = '".$pageKey."'";
|
|
|
+ $pageSql = "SELECT id FROM public.kln_i18n_pages WHERE page_key = '".$pageKey."'";
|
|
|
$pageId = $db->GetOne($pageSql);
|
|
|
if (!$pageId) {
|
|
|
throw new Exception("Page not found: " . $pageKey);
|
|
|
}
|
|
|
|
|
|
// 查询语言ID
|
|
|
- $langSql = "SELECT id FROM kln_i18n_languages WHERE lang_key = '".$langKey."'";
|
|
|
+ $langSql = "SELECT id FROM public.kln_i18n_languages WHERE lang_key = '".$langKey."'";
|
|
|
$langId = $db->GetOne($langSql);
|
|
|
if (!$langId) {
|
|
|
throw new Exception("Language not found: " . $langKey);
|
|
|
}
|
|
|
// 更新翻译状态
|
|
|
- $updateTransSql = "UPDATE kln_i18n_keys SET status = $status, trans_value = '$trans_value' ".
|
|
|
+ $updateTransSql = "UPDATE public.kln_i18n_keys SET status = $status, trans_value = '$trans_value' ".
|
|
|
" WHERE page_id = " . $pageId .
|
|
|
" AND lang_id = " . $langId .
|
|
|
" AND trans_key = '".$transKey."'";
|
|
|
@@ -450,6 +525,92 @@ class multilingual{
|
|
|
exit();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存多语言数据 (自己使用,包含跟多字段的编辑和添加)
|
|
|
+ *
|
|
|
+ * @param array $multilingual_param 页面未审核数量参数,格式:[{unverifiedNumber: 3, page: 'login'}, ...]
|
|
|
+ * @param array $multilingual_trans_param 翻译状态参数,格式:[{page: 'login', lang: 'traditionalChinese', trans_key: 'username', status: 1}, ...]
|
|
|
+ * @return bool 是否保存成功
|
|
|
+ */
|
|
|
+ public function _multilingual_save_oneself($multilingual_param) {
|
|
|
+ global $db;
|
|
|
+ try {
|
|
|
+ // 开启事务确保数据一致性
|
|
|
+ $db->StartTrans();
|
|
|
+ //2. 处理翻译词条状态更新
|
|
|
+ foreach ($multilingual_param as $param) {
|
|
|
+ $pageKey = common::check_input($param['page']);
|
|
|
+ $langKey = common::check_input($param['lang']);
|
|
|
+ $transKey = common::check_input($param['trans_key']);
|
|
|
+ $trans_value = common::check_input($param['trans_value']);
|
|
|
+ $status = $param['status'];
|
|
|
+
|
|
|
+ // 查询页面ID
|
|
|
+ $pageSql = "SELECT id FROM public.kln_i18n_pages WHERE page_key = '".$pageKey."'";
|
|
|
+ $pageId = $db->GetOne($pageSql);
|
|
|
+ if (!$pageId) {
|
|
|
+ throw new Exception("Page not found: " . $pageKey);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询语言ID
|
|
|
+ $langSql = "SELECT id FROM public.kln_i18n_languages WHERE lang_key = '".$langKey."'";
|
|
|
+ $langId = $db->GetOne($langSql);
|
|
|
+ if (!$langId) {
|
|
|
+ throw new Exception("Language not found: " . $langKey);
|
|
|
+ }
|
|
|
+
|
|
|
+ if( $langId == 'originEnglish'){
|
|
|
+ $ii8_Sql = "SELECT id FROM public.kln_i18n_keys WHERE page_id = " . $pageId . " AND trans_key = '".$transKey."'";
|
|
|
+ $ii8 = $db->GetOne($ii8_Sql);
|
|
|
+ if (!$ii8) {
|
|
|
+ $langAllSql = "SELECT id FROM public.kln_i18n_languages";
|
|
|
+ $langAllId = $db->GetAll($langAllSql);
|
|
|
+ foreach($langAllId as $_langAllId){
|
|
|
+ // 不存在 -> 插入
|
|
|
+ $insertKeySql = "INSERT INTO public.kln_i18n_keys (page_id, lang_id, trans_key, trans_value, status)
|
|
|
+ VALUES ($pageId, ".$_langAllId['id'].", '$transKey', '$trans_value', 0)";
|
|
|
+ $db->Execute($insertKeySql);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ // 更新翻译状态
|
|
|
+ $updateTransSql = "UPDATE public.kln_i18n_keys SET status = 0, orgin_value = '$trans_value' ".
|
|
|
+ " WHERE page_id = " . $pageId .
|
|
|
+ " AND trans_key = '".$transKey."'";
|
|
|
+ $db->Execute($updateTransSql);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $ii8_Sql = "SELECT id FROM public.kln_i18n_keys WHERE page_id = " . $pageId . " AND lang_id = ".$langId." AND trans_key = '".$transKey."'";
|
|
|
+ $ii8 = $db->GetOne($ii8_Sql);
|
|
|
+ if (!$ii8) {
|
|
|
+ // 不存在 -> 插入
|
|
|
+ $insertKeySql = "INSERT INTO public.kln_i18n_keys (page_id, lang_id, trans_key, trans_value, status)
|
|
|
+ VALUES ($pageId, $langId, '$transKey', '$trans_value', $status)";
|
|
|
+ $db->Execute($insertKeySql);
|
|
|
+
|
|
|
+ }else{
|
|
|
+ // 更新翻译状态
|
|
|
+ $updateTransSql = "UPDATE public.kln_i18n_keys SET status = $status, trans_value = '$trans_value' ".
|
|
|
+ " WHERE page_id = " . $pageId .
|
|
|
+ " AND lang_id = " . $langId .
|
|
|
+ " AND trans_key = '".$transKey."'";
|
|
|
+ $db->Execute($updateTransSql);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception $e) {
|
|
|
+ // 捕获异常,标记错误,以便回滚
|
|
|
+ error_log("Exception in multilingual_save: " . $e->getMessage());
|
|
|
+ }
|
|
|
+ // 结束事务
|
|
|
+ if ($db->CompleteTrans() === FALSE) {
|
|
|
+ $msg = 'Save Error';
|
|
|
+ } else {
|
|
|
+ $msg = 'Save Success';
|
|
|
+ }
|
|
|
+ common::echo_json_encode(200, $msg);
|
|
|
+ exit();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* load page info
|
|
|
@@ -463,7 +624,7 @@ class multilingual{
|
|
|
page_id,
|
|
|
trans_key,
|
|
|
BOOL_OR(status = 0) AS all_unverified
|
|
|
- FROM kln_i18n_keys
|
|
|
+ FROM public.kln_i18n_keys
|
|
|
WHERE lang_id IN (" . implode(',', $langIds) . ")
|
|
|
GROUP BY page_id, trans_key
|
|
|
) AS subquery
|
|
|
@@ -502,8 +663,8 @@ class multilingual{
|
|
|
$langSql = "SELECT
|
|
|
l.lang_key,
|
|
|
COUNT(k.id) AS unverified_count
|
|
|
- FROM kln_i18n_languages l
|
|
|
- LEFT JOIN kln_i18n_keys k ON l.id = k.lang_id
|
|
|
+ FROM public.kln_i18n_languages l
|
|
|
+ LEFT JOIN public.kln_i18n_keys k ON l.id = k.lang_id
|
|
|
$page_id_sql
|
|
|
AND k.status = 0
|
|
|
WHERE
|
|
|
@@ -539,7 +700,7 @@ class multilingual{
|
|
|
}
|
|
|
try {
|
|
|
// 2. 查询指定语言的 ID
|
|
|
- $langSql = "SELECT id FROM kln_i18n_languages WHERE lang_key = ? AND is_active = TRUE limit 1";
|
|
|
+ $langSql = "SELECT id FROM public.kln_i18n_languages WHERE lang_key = ? AND is_active = TRUE limit 1";
|
|
|
$langObj = common::excuteObjectPrepareSql($langSql,array($langKey));
|
|
|
|
|
|
if (empty($langObj)) {
|
|
|
@@ -549,7 +710,7 @@ class multilingual{
|
|
|
$langId = $langObj['id'];
|
|
|
|
|
|
// 3. 查询所有激活的页面
|
|
|
- $pageSql = "SELECT id, page_key FROM kln_i18n_pages WHERE 1=1";
|
|
|
+ $pageSql = "SELECT id, page_key FROM public.kln_i18n_pages WHERE 1=1";
|
|
|
$pageRows = common::excuteListSql($pageSql);
|
|
|
|
|
|
// 4. 构建页面 ID 列表,用于后续查询
|
|
|
@@ -562,7 +723,7 @@ class multilingual{
|
|
|
// 5. 查询该语言下所有页面的所有翻译词条
|
|
|
$inClause = implode(',', $pageIds);
|
|
|
$transSql = "SELECT page_id, trans_key, trans_value
|
|
|
- FROM kln_i18n_keys
|
|
|
+ FROM public.kln_i18n_keys
|
|
|
WHERE lang_id = $langId
|
|
|
AND page_id IN ($inClause)";
|
|
|
|