/** * Copyright: dtbaker 2012 * Licence: Please check CodeCanyon.net for licence details. * More licence clarification available here: http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca * Package Date: 2015-11-25 02:55:20 * IP Address: 67.79.165.254 */ if (!module_config::can_i('view', 'Settings')) { redirect_browser(_BASE_HREF); } if (!module_config::can_i('edit', 'Settings')) { redirect_browser(_BASE_HREF); } if (!module_language::can_i('edit', 'Language')) { redirect_browser(_BASE_HREF); } $language_id = (int) $_REQUEST['language_id']; $language = module_language::get_language($language_id); if (!$language || $language['language_id'] != $language_id) { $language_id = 0; $language = array('language_name' => '', 'language_code' => ''); } $translations = module_language::get_translations($language_id); $file_system_labels = array(); if ($language['language_code']) { $old_labels = isset($labels) ? $labels : false; if (is_file('includes/plugin_language/custom/' . basename($language['language_code']) . '.php')) { include 'includes/plugin_language/custom/' . basename($language['language_code']) . '.php'; } else {
public function process() { if ('language_reset' == $_REQUEST['_process'] && $_REQUEST['really'] == 'yes') { if (!module_form::check_secure_key()) { return; } // delete all language words and translations $sql = "DELETE FROM `" . _DB_PREFIX . "language_word` WHERE 1"; query($sql); $sql = "DELETE FROM `" . _DB_PREFIX . "language_translation` WHERE 1"; query($sql); set_message('Translation reset successfully'); redirect_browser($_SERVER['REQUEST_URI']); } if ('remove_duplicates' == $_REQUEST['_process'] && isset($_REQUEST['duplicate_ids'])) { if (!module_form::check_secure_key()) { return; } $duplicate_ids = json_decode($_REQUEST['duplicate_ids'], true); foreach ($duplicate_ids as $duplicate_id) { $sql = "DELETE FROM `" . _DB_PREFIX . "language_word` WHERE language_word_id = '" . (int) $duplicate_id . "' LIMIT 1"; query($sql); } set_message('Translation errors removed successfully'); redirect_browser($_SERVER['REQUEST_URI']); } else { if ('language_duplicate_remove' == $_REQUEST['_process'] && $_REQUEST['really'] == 'yep') { if (!module_form::check_secure_key()) { return; } // delete all language words and translations $sql = "SELECT `word`, COUNT(*) as cc FROM `" . _DB_PREFIX . "language_word` GROUP BY `word` HAVING cc > 1"; $res = qa($sql); foreach ($res as $r) { if ($r['word'] && $r['cc'] > 1) { // remove duplicates. $sql = "SELECT * FROM `" . _DB_PREFIX . "language_word` WHERE `word` = '" . mysql_real_escape_string($r['word']) . "' "; $duplicates = qa($sql); // doing this due to incorrect collate in earlier version of UCM $words_casesensitive = array(); foreach ($duplicates as $duplicate) { $words_casesensitive[$duplicate['word']][$duplicate['language_word_id']] = $duplicate['language_word_id']; } //print_r($words_casesensitive);exit; foreach ($words_casesensitive as $word => $duplicate_ids) { if (count($duplicate_ids) > 1) { $first = false; foreach ($duplicate_ids as $language_word_id) { if ($first === false) { $first = $language_word_id; } else { if ($first) { // remove this one and replace any translations with the first one. $sql = "DELETE FROM `" . _DB_PREFIX . "language_word` WHERE language_word_id = '" . (int) $language_word_id . "' LIMIT 1"; query($sql); $sql = "UPDATE `" . _DB_PREFIX . "language_translation` SET language_word_id = '" . (int) $first . "' WHERE language_word_id = '" . (int) $language_word_id . "'"; query($sql); } } } } } } } $sql = "DELETE FROM `" . _DB_PREFIX . "language_word` WHERE `word` LIKE 'SQL Error%'"; query($sql); // merge languages - error if case of language changes, keeps creating new language entries - eg FR fr $sql = "SELECT `language_id`, `language_code`, COUNT(*) as cc FROM `" . _DB_PREFIX . "language` GROUP BY `language_code`"; $res = query($sql); while ($row = mysql_fetch_assoc($res)) { if ($row['cc'] > 1) { // merge these! $sql = "SELECT language_id FROM `" . _DB_PREFIX . "language` WHERE `language_code` = '" . mysql_real_escape_string($row['language_code']) . "' AND language_id != " . (int) $row['language_id'] . ""; $to_merge = query($sql); while ($merge = mysql_fetch_assoc($to_merge)) { $sql = "UPDATE `" . _DB_PREFIX . "language_translation` SET language_id = " . (int) $row['language_id'] . " WHERE language_id = " . (int) $merge['language_id'] . ""; query($sql); // remove any that didn't update correctly (duplicate entries) $sql = "DELETE FROM `" . _DB_PREFIX . "language_translation` WHERE language_id = " . (int) $merge['language_id'] . ""; query($sql); $sql = "DELETE FROM `" . _DB_PREFIX . "language` WHERE language_id = " . (int) $merge['language_id'] . " LIMIT 1"; query($sql); } } } set_message('Translation duplicates removed successfully'); redirect_browser($_SERVER['REQUEST_URI']); } } if ('save_language_translation' == $_REQUEST['_process']) { if (!module_form::check_secure_key()) { return; } if (!module_config::can_i('view', 'Settings')) { redirect_browser(_BASE_HREF); } if (!module_config::can_i('edit', 'Settings')) { redirect_browser(_BASE_HREF); } if (!module_language::can_i('edit', 'Language')) { redirect_browser(_BASE_HREF); } $language_id = (int) $_REQUEST['language_id']; $language = module_language::get_language($language_id); if (!$language_id || !$language || $language['language_id'] != $language_id) { $language_id = false; $language = array(); } $language_id = update_insert('language_id', $language_id, 'language', $_POST); if (isset($_POST['translation']) && is_array($_POST['translation'])) { // save these values to the translation table for this particular langauge. foreach ($_POST['translation'] as $language_word_id => $translation) { if (_DEMO_MODE) { if (!isset($_SESSION['temp_translation'])) { $_SESSION['temp_translation'] = array(); } if (!isset($_SESSION['temp_translation'][$language_id])) { $_SESSION['temp_translation'][$language_id] = array(); } $_SESSION['temp_translation'][$language_id][$language_word_id] = $translation; } else { if (strlen($translation)) { $sql = "REPLACE INTO `" . _DB_PREFIX . "language_translation` SET `language_id` = " . (int) $language_id . ", "; $sql .= "`language_word_id` = " . (int) $language_word_id . ", `translation` = '" . mysql_real_escape_string($translation) . "'"; query($sql); } else { $sql = "DELETE FROM `" . _DB_PREFIX . "language_translation` WHERE `language_id` = " . (int) $language_id . " AND "; $sql .= "`language_word_id` = " . (int) $language_word_id . ""; query($sql); } } } } if (isset($_REQUEST['check_duplicates'])) { // redirect to duplicate check page. redirect_browser($_SERVER['REQUEST_URI'] . '&check_duplicates'); } else { set_message('Translation saved successfully'); redirect_browser(str_replace('language_id', 'done', $_SERVER['REQUEST_URI'])); } } }