8 define (
'CH_SECURITY_EXCEPTIONS',
true);
10 for ($i=1; $i<255 ; ++$i) {
15 require_once(
'../inc/header.inc.php' );
16 require_once( CH_DIRECTORY_PATH_INC .
'profiles.inc.php' );
17 require_once( CH_DIRECTORY_PATH_INC .
'design.inc.php' );
18 require_once( CH_DIRECTORY_PATH_INC .
'admin_design.inc.php' );
19 require_once( CH_DIRECTORY_PATH_INC .
'utils.inc.php' );
31 if (isset($_POST[
'save']) && isset($_POST[
'cat'])) {
35 if (isset($_POST[
'create_key_batch'])) {
36 $iLangId = (int) $_POST[
'lang'];
37 $iCategoryId = (int) $_POST[
'category'];
38 $sKeyList = trim($_POST[
'keylist']);
39 $iUpdateDup = (int) $_POST[
'updatedup'];
42 $sTmpFile = CH_DIRECTORY_PATH_TMP . md5(microtime()) .
'.txt';
43 file_put_contents($sTmpFile, $sKeyList);
44 $bMode1 = $bMode2 = $bMode3 =
true;
48 $file = fopen($sTmpFile,
"r");
49 while (!feof($file)) {
53 $line = rtrim($line,
',');
54 if (strpos($line,
',') ===
false)
56 if (strpos($line,
'=>') ===
false)
58 if (strpos($line,
'=') ===
false)
65 if ($bMode1 && !$bMode2 && !$bMode3) {
69 if ($bMode2 && !$bMode1 && !$bMode3) {
73 if ($bMode3 && !$bMode1 && !$bMode2) {
77 if (!$bMode1 && !$bMode2 && !$bMode3) {
89 $file = fopen($sTmpFile,
"r");
90 while (!feof($file)) {
95 $line = rtrim($line,
',');
96 $aLine = explode($sSep, $line, 2);
97 $sLangKey = trim($aLine[0],
" \t\n\r\0\x0B\x27\x22");
98 $sLangString = trim($aLine[1],
" \t\n\r\0\x0B\x27\x22");
99 $GLOBALS[
'MySQL']->query(
"INSERT IGNORE INTO `sys_localization_keys`(`IDCategory`, `Key`) VALUES('$iCategoryId', '$sLangKey')");
100 $iKeyId = (int)
$GLOBALS[
'MySQL']->lastId();
106 $GLOBALS[
'MySQL']->query(
"INSERT IGNORE INTO `sys_localization_strings`(`IDKey`, `IDLanguage`, `String`) VALUES('$iKeyId', '$iLangId', '$sLangString')");
110 $iKeyId = (int)
$GLOBALS[
'MySQL']->getOne(
"SELECT `ID` FROM `sys_localization_keys` WHERE `IDCategory` = '$iCategoryId' AND `Key` = '$sLangKey'");
112 $GLOBALS[
'MySQL']->query(
"UPDATE `sys_localization_strings` SET `String` = '$sLangString' WHERE `IDKey` = '$iKeyId' AND `IDLanguage` = '$iLangId'");
124 $aResults[
'keys-add-batch'] =
'Out of ' . $iKeyCount .
' keys, ' . $iKeyAddedCount .
' Keys were added, and ' . $iDupCount .
' duplicate keys were updated.';
126 $aResults[
'keys-add-batch'] =
'Out of ' . $iKeyCount .
' keys, ' . $iKeyAddedCount .
' Keys were added, and ' . $iDupCount .
' duplicate keys were ignored.';
129 $aResults[
'keys-add-batch'] = $iKeyAddedCount .
' keys were added';
132 $aResults[
'keys-add-batch'] =
'Unknown list format. Could not process keys.';
135 $aResults[
'keys-add-batch'] =
'Keys To Add was empty. No keys were added.';
140 if(isset($_POST[
'create_language'])) {
142 }
else if(isset($_POST[
'import_language'])) {
144 }
else if(isset($_POST[
'adm-lang-compile']) && !
empty($_POST[
'langs'])) {
145 foreach($_POST[
'langs']
as $iLangId)
147 $aResults[
'langs'] =
'_adm_txt_langs_cannot_compile';
151 $aResults[
'langs'] =
'_adm_txt_langs_success_compile';
152 }
else if(isset($_POST[
'adm-lang-delete']) && !
empty($_POST[
'langs'])) {
153 $sNameDefault =
getParam(
'lang_default');
154 foreach($_POST[
'langs']
as $iLangId) {
156 if(
$sName == $sNameDefault) {
157 $aResults[
'langs'] =
'_adm_txt_langs_cannot_delete_default';
162 $aResults[
'langs'] =
'_adm_txt_langs_cannot_delete';
168 $aResults[
'langs'] =
'_adm_txt_langs_success_delete';
169 }
else if(isset(
$_GET[
'action']) &&
$_GET[
'action'] ==
'export' && isset(
$_GET[
'id'])) {
170 $aLanguage =
$GLOBALS[
'MySQL']->getRow(
"SELECT `Name`, `Flag`, `Title`, `Direction`, `LanguageCountry` FROM `sys_localization_languages` WHERE `ID`= ? LIMIT 1", [
$_GET[
'id']]);
173 $aItems =
$GLOBALS[
'MySQL']->getAll(
"SELECT `tlk`.`Key` AS `key`, `tls`.`String` AS `string` FROM `sys_localization_keys` AS `tlk`
174 LEFT JOIN `sys_localization_strings` AS `tls` ON `tlk`.`ID`=`tls`.`IDKey` WHERE `tls`.`IDLanguage`= ? ", [
$_GET[
'id']]);
175 foreach($aItems
as $aItem)
176 $aContent[$aItem[
'key']] = $aItem[
'string'];
180 $sName =
'lang_' . $aLanguage[
'Name'] .
'.php';
181 $sContent =
"<?php\n\$aLangInfo=" . var_export($aLanguage,
true) .
";\n\$aLangContent=" . var_export($aContent,
true) .
";\n?>";
183 header (
"Cache-Control: must-revalidate, post-check=0, pre-check=0");
184 header (
"Content-type: application/octet-stream");
186 header (
"Content-Disposition: attachment; filename=" .
$sName);
189 }
else if(isset($_POST[
'action']) && $_POST[
'action'] ==
'get_edit_form_language') {
195 if(isset($_POST[
'action']) && $_POST[
'action'] ==
'get_edit_form_key') {
199 if(isset($_POST[
'create_key'])) {
201 $iCategoryId = (int)$_POST[
'category'];
203 $mixedResult =
$GLOBALS[
'MySQL']->query(
"INSERT INTO `sys_localization_keys`(`IDCategory`, `Key`) VALUES('" . $iCategoryId .
"', '" .
$sName .
"')",
false);
204 if($mixedResult !==
false) {
206 $iKeyId = (int)
$GLOBALS[
'MySQL']->lastId();
207 $aLanguages =
$GLOBALS[
'MySQL']->getAll(
"SELECT `ID` AS `id`, `Title` AS `title` FROM `sys_localization_languages`");
208 foreach($aLanguages
as $aLanguage)
209 if(isset($_POST[
'string_for_' . $aLanguage[
'id']])) {
210 $GLOBALS[
'MySQL']->query(
"INSERT INTO `sys_localization_strings`(`IDKey`, `IDLanguage`, `String`) VALUES('" . $iKeyId .
"', '" . $aLanguage[
'id'] .
"', '" .
process_db_input($_POST[
'string_for_' . $aLanguage[
'id']]) .
"')");
215 $aResult = $bCompiled ? array(
'code' => 0,
'message' =>
'_adm_txt_langs_success_key_save') : array(
'code' => 1,
'message' =>
'_adm_txt_langs_cannot_compile');
217 $aResult = array(
'code' => 2,
'message' =>
'_adm_txt_langs_already_exists');
221 echo
"<script>parent.onResult('add', " . json_encode(
$aResult) .
");</script>";
223 }
else if(isset($_POST[
'edit_key'])) {
224 $iId = (int)$_POST[
'id'];
227 $aLanguages =
$GLOBALS[
'MySQL']->getAll(
"SELECT `ID` AS `id`, `Title` AS `title` FROM `sys_localization_languages`");
228 foreach($aLanguages
as $aLanguage)
229 if(isset($_POST[
'string_for_' . $aLanguage[
'id']])) {
230 $GLOBALS[
'MySQL']->query(
"REPLACE INTO `sys_localization_strings`(`IDKey`, `IDLanguage`, `String`) VALUES('" .
$iId .
"', '" . $aLanguage[
'id'] .
"', '" .
process_db_input($_POST[
'string_for_' . $aLanguage[
'id']]) .
"')");
234 $aResult = $bCompiled ? array(
'code' => 0,
'message' =>
'_adm_txt_langs_success_key_save') : array(
'code' => 1,
'message' =>
'_adm_txt_langs_cannot_compile');
237 echo
"<script>parent.onResult('edit', " . json_encode(
$aResult) .
");</script>";
241 if(isset($_POST[
'adm-lang-key-delete']) && is_array($_POST[
'keys'])) {
242 foreach($_POST[
'keys']
as $iKeyId)
243 $GLOBALS[
'MySQL']->query(
"DELETE FROM `sys_localization_keys`, `sys_localization_strings` USING `sys_localization_keys`, `sys_localization_strings` WHERE `sys_localization_keys`.`ID`=`sys_localization_strings`.`IDKey` AND `sys_localization_keys`.`ID`='" . $iKeyId .
"'");
248 'css_name' => array(
'forms_adv.css',
'lang_file.css'),
249 'js_name' => array(
'lang_file.js'),
250 'header' =>
_t(
'_adm_page_cpt_lang_file'),
253 $sLangRssFeed =
'on' ==
getParam(
'feeds_enable') ?
DesignBoxAdmin (
_t(
'_adm_box_cpt_lang_files'),
'<div class="RSSAggrCont" rssid="cheetah_market_lang_files" rssnum="5" member="0">' .
$GLOBALS[
'oFunctions']->loadingBoxInline() .
'</div>') :
'';
256 'page_result_code' =>
'',
266 'adm-langs-btn-keys' => array(
'href' =>
'javascript:void(0)',
'onclick' =>
'javascript:onChangeType(this)',
'title' =>
_t(
'_adm_txt_langs_keys'),
'active' =>
empty(
$aResults) ? 1 : 0),
267 'adm-langs-btn-keys-add' => array(
'href' =>
'javascript:void(0)',
'onclick' =>
'javascript:onCreate()',
'title' =>
_t(
'_adm_txt_langs_add_key'),
'active' => 0),
268 'adm-langs-btn-keys-add-batch' => array(
'href' =>
'javascript:void(0)',
'onclick' =>
'javascript:onChangeType(this)',
'title' =>
_t(
'_adm_txt_langs_add_key_batch'),
'active' => isset(
$aResults[
'keys-add-batch']) ? 1 : 0),
269 'adm-langs-btn-langs' => array(
'href' =>
'javascript:void(0)',
'onclick' =>
'javascript:onChangeType(this)',
'title' =>
_t(
'_adm_txt_langs_languages'),
'active' => isset(
$aResults[
'langs']) ? 1 : 0),
270 'adm-langs-btn-langs-add' => array(
'href' =>
'javascript:void(0)',
'onclick' =>
'javascript:onChangeType(this)',
'title' =>
_t(
'_adm_txt_langs_languages_add'),
'active' => isset(
$aResults[
'langs-add']) ? 1 : 0),
271 'adm-langs-btn-langs-import' => array(
'href' =>
'javascript:void(0)',
'onclick' =>
'javascript:onChangeType(this)',
'title' =>
_t(
'_adm_txt_langs_languages_import'),
'active' => isset(
$aResults[
'langs-import']) ? 1 : 0),
272 'adm-langs-btn-settings' => array(
'href' =>
'javascript:void(0)',
'onclick' =>
'javascript:onChangeType(this)',
'title' =>
_t(
'_adm_txt_langs_settings'),
'active' => isset(
$aResults[
'settings']) ? 1 : 0),
273 'adm-langs-btn-help' => array(
'href' =>
'https://www.cheetahwsb.com/m/cheetah_docs/chapter/using-language-keys',
'target' =>
'_blank',
'title' =>
_t(
'_help'))
290 return $GLOBALS[
'MySQL']->fromCache(
'sys_localization_languages',
'getAllWithKey',
291 "SELECT `ID` AS `id`, `Name` AS `name`, `Title` AS `title`, `Flag` AS `flag` FROM `sys_localization_languages` ORDER BY `Name`",
'name');
297 return array_key_exists($sLangName, $aLangs);
302 $sFilterName =
'filter';
305 if(isset(
$_GET[$sFilterName])) {
308 $aKeys =
$GLOBALS[
'MySQL']->getAll(
"SELECT `tk`.`ID` AS `id`, `tk`.`Key` AS `key`, `tc`.`Name` AS `category` FROM `sys_localization_keys` AS `tk`
309 LEFT JOIN `sys_localization_strings` AS `ts` ON `tk`.`ID`=`ts`.`IDKey` LEFT JOIN `sys_localization_categories` AS `tc` ON `tk`.`IDCategory`=`tc`.`ID`
310 WHERE `tk`.`Key` LIKE ? OR `ts`.`String` LIKE ? GROUP BY `tk`.`ID`", [
"%{$sFilter}%",
"%{$sFilter}%"]);
311 foreach($aKeys
as $aKey)
314 'key' => $aKey[
'key'],
315 'category' => $aKey[
'category'],
316 'admin_url' =>
$GLOBALS[
'site'][
'url_admin']
322 'adm-lang-key-delete' =>
_t(
'_adm_txt_langs_delete')
328 if($mixedResult !==
true && !
empty($mixedResult))
329 $sFilter .=
MsgBox(
_t($mixedResult), 3);
331 return $GLOBALS[
'oAdmTemplate']->parseHtmlByName(
'langs_keys.html', array(
332 'display' => $bActive ?
'block' :
'none',
333 'filter_panel' => $sFilter,
334 'ch_repeat:items' => !
empty($aItems) ? $aItems :
MsgBox(
_t(
'_Empty')),
335 'control' => $sControls,
336 'url_admin' =>
$GLOBALS[
'site'][
'url_admin']
343 if ($mixedResult !==
true && !
empty($mixedResult)) {
348 'showclosebtn' =>
true,
349 'class' =>
'MsgBoxInfo ch-def-font-large',
350 'titleclass' =>
'MsgBoxTitleInfo ch-def-font-large'
352 $sResult = advMsgBox(
_t($mixedResult), $aOptions);
355 $aLanguages =
$GLOBALS[
'MySQL']->getAll(
"SELECT `ID`, `Title` FROM `sys_localization_languages`");
357 foreach ($aLanguages
as $aLanguage) {
358 $sLangOptions .=
'<option value="' . $aLanguage[
'ID'] .
'">' . $aLanguage[
'Title'] .
'</option>' .
"\r\n";
361 $aCategories =
$GLOBALS[
'MySQL']->getAll(
"SELECT `ID`, `Name` FROM `sys_localization_categories`");
363 foreach ($aCategories
as $aCategory) {
364 $sCatOptions .=
'<option value="' . $aCategory[
'ID'] .
'">' . $aCategory[
'Name'] .
'</option>' .
"\r\n";
367 return $GLOBALS[
'oAdmTemplate']->parseHtmlByName(
'langs_keys_batch.html', array(
368 'display' => $bActive ?
'block' :
'none',
370 'cat_options' => $sCatOptions,
371 'lang_options' => $sLangOptions
378 if($mixedResult !==
true && !
empty($mixedResult)) {
385 $sNameDefault =
getParam(
'lang_default');
387 $aLangs =
$GLOBALS[
'MySQL']->getAll(
"SELECT `ID` AS `id`, `Name` AS `name`, `Title` AS `title`, `Flag` AS `flag` FROM `sys_localization_languages` ORDER BY `Name`");
388 foreach($aLangs
as $aLang)
390 'name' => $aLang[
'name'],
391 'value' => $aLang[
'id'],
392 'title' => $aLang[
'title'],
393 'icon' =>
$GLOBALS[
'site'][
'flags'] . $aLang[
'flag'] .
'.gif',
394 'default' => $aLang[
'name'] == $sNameDefault ?
'(' .
_t(
'_adm_txt_langs_default') .
')' :
'',
395 'edit_link' =>
$GLOBALS[
'site'][
'url_admin'] .
'lang_file.php?action=edit&id=' . $aLang[
'id'],
396 'export_link' =>
$GLOBALS[
'site'][
'url_admin'] .
'lang_file.php?action=export&id=' . $aLang[
'id']
401 'adm-lang-compile' =>
_t(
'_adm_txt_langs_compile'),
402 'adm-lang-delete' =>
_t(
'_adm_txt_langs_delete')
406 return $GLOBALS[
'oAdmTemplate']->parseHtmlByName(
'langs_files.html', array(
407 'display' => $bActive ?
'block' :
'none',
409 'ch_repeat:items' => $aItems,
410 'controls' => $sControls
415 if (isset($_POST[
'action']) && $_POST[
'action'] ==
'get_edit_form_language' && isset($_POST[
'id'])) {
416 $aLanguage =
$GLOBALS[
'MySQL']->getRow(
"SELECT `ID` AS `id`, `Name` AS `name`, `Flag` AS `flag`, `Title` AS `title`, `Direction` AS `direction`, `LanguageCountry` AS `lang_country`
417 FROM `sys_localization_languages` WHERE `ID`= ? LIMIT 1", [$_POST[
'id']]);
421 $aFormCreate = array(
422 'form_attrs' => array(
423 'id' =>
'adm-settings-form-files',
424 'name' =>
'adm-settings-form-files',
425 'action' =>
$GLOBALS[
'site'][
'url_admin'] .
'lang_file.php',
427 'enctype' =>
'multipart/form-data'
430 'CopyLanguage_Title' => array(
432 'name' =>
'CopyLanguage_Title',
433 'caption' =>
_t(
'_adm_txt_langs_title'),
434 'value' => isset($aLanguage[
'title']) ? $aLanguage[
'title'] :
'',
436 'CopyLanguage_Name' => array(
438 'name' =>
'CopyLanguage_Name',
439 'caption' =>
_t(
'_adm_txt_langs_code'),
440 'value' => isset($aLanguage[
'name']) ? $aLanguage[
'name'] :
'',
442 'LanguageCountry' => array(
444 'name' =>
'LanguageCountry',
445 'caption' =>
_t(
'_adm_txt_langs_country_code'),
446 'value' => isset($aLanguage[
'lang_country']) ? $aLanguage[
'lang_country'] :
'',
448 'Direction' => array(
450 'name' =>
'Direction',
451 'caption' =>
_t(
'_adm_txt_langs_direction'),
452 'values' => array(
'LTR' =>
'LTR',
'RTL' =>
'RTL'),
453 'value' => isset($aLanguage[
'direction']) ? $aLanguage[
'direction'] :
'LTR',
458 'caption' =>
_t(
'_adm_txt_langs_flag'),
460 'value' => isset($aLanguage[
'flag']) ? $aLanguage[
'flag'] : strtolower(
getParam(
'default_country')),
462 'CopyLanguage_SourceLangID' => array(
464 'name' =>
'CopyLanguage_SourceLangID',
465 'caption' =>
_t(
'_adm_txt_langs_copy_from'),
468 'create_language' => array(
470 'name' =>
'create_language',
471 'value' =>
_t(
"_adm_btn_lang_save"),
481 $aCountries =
$GLOBALS[
'MySQL']->getAll(
"SELECT `ISO2` AS `code`, `Country` AS `title` FROM `sys_countries` ORDER BY `Country`");
482 foreach($aCountries AS $aCountry) {
483 $sCode = strtolower($aCountry[
'code']);
484 $aFormCreate[
'inputs'][
'Flag'][
'values'][] = array(
'key' =>
$sCode,
'value' => $aCountry[
'title']);
487 $bLanguage = !
empty($aLanguage);
489 unset($aFormCreate[
'inputs'][
'CopyLanguage_SourceLangID']);
490 $aFormCreate[
'inputs'][
'id'] = array(
493 'value' => $aLanguage[
'id']
499 if($mixedResult !==
true && !
empty($mixedResult)) {
504 return $GLOBALS[
'oAdmTemplate']->parseHtmlByName(
'langs_form_create.html', array(
505 'display' => $bActive || $bLanguage ?
'block' :
'none',
511 $aFormImport = array(
512 'form_attrs' => array(
513 'id' =>
'adm-settings-form-import',
514 'name' =>
'adm-settings-form-import',
515 'action' =>
$GLOBALS[
'site'][
'url_admin'] .
'lang_file.php',
517 'enctype' =>
'multipart/form-data'
520 'ImportLanguage_File' => array(
522 'name' =>
'ImportLanguage_File',
523 'caption' =>
_t(
'_adm_txt_langs_file'),
525 'import_language' => array(
527 'name' =>
'import_language',
528 'value' =>
_t(
'_adm_btn_lang_import'),
535 if($mixedResult !==
true && !
empty($mixedResult)) {
540 return $GLOBALS[
'oAdmTemplate']->parseHtmlByName(
'langs_form_import.html', array(
541 'display' => $bActive ?
'block' :
'none',
552 foreach (
$oForm->aInputs
as $k => $r) {
553 if (
'lang_default' != $r[
'name'])
555 $oForm->aInputs[$k] = array(
557 'name' =>
'lang_default',
558 'caption' =>
_t(
'_adm_txt_langs_def_lang'),
560 'value' =>
getParam(
'lang_default'),
572 if ($mixedResult !==
true && !
empty($mixedResult)) {
578 return $GLOBALS[
'oAdmTemplate']->parseHtmlByName(
'langs_form_settings.html', array(
579 'display' => $bActive ?
'block' :
'none',
587 'form_attrs' => array(
588 'id' =>
'adm-langs-add-key-form',
589 'name' =>
'adm-langs-add-key-form',
590 'action' =>
$GLOBALS[
'site'][
'url_admin'] .
'lang_file.php',
592 'enctype' =>
'multipart/form-data',
593 'target' =>
'adm-langs-add-key-iframe'
600 'caption' =>
_t(
'_adm_txt_keys_name'),
605 'name' =>
'category',
606 'caption' =>
_t(
'_adm_txt_keys_category'),
613 $aCategories =
$GLOBALS[
'MySQL']->getAll(
"SELECT `ID` AS `id`, `Name` AS `title` FROM `sys_localization_categories`");
614 foreach($aCategories
as $aCategory)
615 $aForm[
'inputs'][
'category'][
'values'][] = array(
'key' => $aCategory[
'id'],
'value' => $aCategory[
'title']);
617 $aLanguages =
$GLOBALS[
'MySQL']->getAll(
"SELECT `ID` AS `id`, `Title` AS `title` FROM `sys_localization_languages`");
618 foreach($aLanguages
as $aLanguage)
619 $aForm[
'inputs'][
'string_for_' . $aLanguage[
'id']] = array(
620 'type' =>
'textarea',
621 'name' =>
'string_for_' . $aLanguage[
'id'],
622 'caption' =>
_t(
'_adm_txt_keys_string_for', $aLanguage[
'title']),
626 $aForm[
'inputs'][
'create_key'] = array(
628 'name' =>
'create_key',
629 'value' =>
_t(
"_adm_btn_lang_save"),
633 $sContent =
$GLOBALS[
'oAdmTemplate']->parseHtmlByName(
'langs_key.html', array(
'type' =>
'add',
'content' =>
$oForm->getCode()));
634 return $GLOBALS[
'oFunctions']->popupBox(
'adm-langs-add-key',
_t(
'_adm_box_cpt_lang_key'),
$sContent);
639 'form_attrs' => array(
640 'id' =>
'adm-langs-edit-key-form',
641 'name' =>
'adm-langs-edit-key-form',
642 'action' =>
$GLOBALS[
'site'][
'url_admin'] .
'lang_file.php',
644 'enctype' =>
'multipart/form-data',
645 'target' =>
'adm-langs-edit-key-iframe'
657 'caption' =>
_t(
'_adm_txt_keys_name'),
658 'value' =>
$GLOBALS[
'MySQL']->getOne(
"SELECT `Key` FROM `sys_localization_keys` WHERE `ID`='" .
$iId .
"' LIMIT 1"),
660 'disabled' =>
'disabled'
666 $aStrings =
$GLOBALS[
'MySQL']->getAllWithKey(
"SELECT CONCAT('string_for_', `IDLanguage`) AS `key`, `String` AS `value` FROM `sys_localization_strings` WHERE `IDKey`= ?",
"key", [
$iId]);
667 $aLanguages =
$GLOBALS[
'MySQL']->getAll(
"SELECT `ID` AS `id`, `Title` AS `title` FROM `sys_localization_languages`");
668 foreach($aLanguages
as $aLanguage) {
669 $sKey =
'string_for_' . $aLanguage[
'id'];
671 $aForm[
'inputs'][$sKey] = array(
672 'type' =>
'textarea',
673 'name' =>
'string_for_' . $aLanguage[
'id'],
674 'caption' =>
_t(
'_adm_txt_keys_string_for', $aLanguage[
'title']),
675 'value' => $aStrings[$sKey][
'value'],
678 $aForm[
'inputs'][
'edit_key'] = array(
680 'name' =>
'edit_key',
681 'value' =>
_t(
"_adm_btn_lang_save"),
685 $sContent =
$GLOBALS[
'oAdmTemplate']->parseHtmlByName(
'langs_key.html', array(
'type' =>
'edit',
'content' =>
$oForm->getCode()));
686 return $GLOBALS[
'oFunctions']->popupBox(
'adm-langs-edit-key',
_t(
'_adm_box_cpt_lang_key'),
$sContent);
697 $iSourceId = isset($aData[
'CopyLanguage_SourceLangID']) ? (int)$aData[
'CopyLanguage_SourceLangID'] : 0;
700 return '_adm_txt_langs_empty_title';
702 return '_adm_txt_langs_empty_name';
704 if(isset($aData[
'id']) && (int)$aData[
'id'] != 0) {
705 $MySQL->query(
"UPDATE `sys_localization_languages` SET `Name`='" .
$sName .
"', `Flag`='" . $sFlag .
"', `Title`='" .
$sTitle .
"', `Direction`='" . $sDir .
"', `LanguageCountry`='" . $sLangCountry .
"' WHERE `ID`='" . (
int)$aData[
'id'] .
"'");
707 return '_adm_txt_langs_success_updated';
711 return '_adm_txt_langs_cannot_create';
713 $mixedResult = $MySQL->query(
"INSERT INTO `sys_localization_languages` (`Name`, `Flag`, `Title`, `Direction`, `LanguageCountry`) VALUES ('{$sName}', '{$sFlag}', '{$sTitle}', '{$sDir}', '{$sLangCountry}')");
714 if($mixedResult ===
false)
715 return '_adm_txt_langs_cannot_create';
716 $iId = (int)$MySQL->lastId();
718 $MySQL->cleanCache(
'sys_localization_languages');
720 $aStrings = $MySQL->getAll(
"SELECT `IDKey`, `String` FROM `sys_localization_strings` WHERE `IDLanguage` = ?", [$iSourceId]);
722 foreach($aStrings
as $aString){
723 $aString[
'String'] = addslashes($aString[
'String']);
724 $count = $MySQL->query(
"INSERT INTO `sys_localization_strings`(`IDKey`, `IDLanguage`, `String`) VALUES ('{$aString['IDKey']}', $iId, '{$aString['String']}')");
727 return '_adm_txt_langs_cannot_add_string';
730 return '_adm_txt_langs_success_create';
737 if(!file_exists($aFiles[
'ImportLanguage_File'][
'tmp_name']) || !move_uploaded_file($aFiles[
'ImportLanguage_File'][
'tmp_name'], $sTmpPath))
738 return '_adm_txt_langs_cannot_upload_file';
740 require_once($sTmpPath);
742 $aLangInfo = isset($aLangInfo) ? $aLangInfo :
$LANG_INFO;
745 return '_adm_txt_langs_cannot_create';
748 return '_adm_txt_langs_cannot_create';
750 $mixedResult = $MySQL->query(
"INSERT INTO `sys_localization_languages` (`Name`, `Flag`, `Title`, `Direction`, `LanguageCountry`)
751 VALUES (?, ?, ?, ?, ?)", [
755 $aLangInfo[
'Direction'],
756 $aLangInfo[
'LanguageCountry']
759 if($mixedResult ===
false) {
761 return '_adm_txt_langs_cannot_create';
763 $iId = (int)$MySQL->lastId();
765 $MySQL->cleanCache(
'sys_localization_languages');
767 $aKeys = $MySQL->getAllWithKey(
"SELECT `ID` AS `id`, `Key` AS `key` FROM `sys_localization_keys`",
"key");
769 if(!isset($aKeys[$sKey]))
772 $MySQL->query(
"INSERT INTO `sys_localization_strings`(`IDKey`, `IDLanguage`, `String`) VALUES ('" . $aKeys[$sKey][
'id'] .
"', " .
$iId .
", '" . addslashes($sString) .
"')");
778 return '_adm_txt_langs_success_import';
782 return $GLOBALS[
'MySQL']->getOne(
"SELECT `Name` FROM `sys_localization_languages` WHERE `ID`='" . (
int)
$iId .
"' LIMIT 1");