private function init_metabox_data() { $this->metabox_data = array(); $this->active_languages = $this->sitepress->get_active_languages(); $this->default_language = $this->sitepress->get_default_language(); $this->metabox_data['title'] = __('WPML Translation', 'wpml-string-translation'); $this->metabox_data['package_language_title'] = sprintf(__('Language of this %s is %s', 'wpml-string-translation'), $this->package->kind, $this->active_languages[$this->default_language]['display_name']); $this->metabox_data['translate_title'] = sprintf(__('Send %s to translation', 'wpml-string-translation'), $this->package->kind); if ($this->got_package()) { $this->metabox_data['statuses_title'] = __('Translation status:', 'wpml-string-translation'); $this->init_translation_statuses(); } else { $this->metabox_data['statuses_title'] = __('There is nothing to translate.', 'wpml-string-translation'); } }
/** * @param string $slug * @param string|bool $language * * @return string */ function get_translated_slug($slug, $language = false) { if ($slug) { $current_language = $this->sitepress->get_current_language(); $language = $language ? $language : $current_language; if (!isset($this->translated_slugs[$slug][$language])) { $slugs_translations = $this->wpdb->get_results($this->wpdb->prepare("SELECT t.value, t.language\r\n\t\t\t\t\t\t\t\t\t\tFROM {$this->wpdb->prefix}icl_strings s\r\n\t\t\t\t\t\t\t\t\t\tJOIN {$this->wpdb->prefix}icl_string_translations t ON t.string_id = s.id\r\n\t\t\t\t\t\t\t\t\t\tWHERE s.name = %s\r\n\t\t\t\t\t\t\t\t\t\t AND (s.context = %s OR s.context = %s)\r\n\t\t\t\t\t\t\t\t\t\t\tAND t.status = %d\r\n\t\t\t\t\t\t\t\t\t\t\tAND t.value <> ''", 'URL slug: ' . $slug, 'default', 'WordPress', ICL_TM_COMPLETE)); foreach ($slugs_translations as $translation) { $this->translated_slugs[$slug][$translation->language] = $translation->value; } // Add empty values for languages not found. foreach ($this->sitepress->get_active_languages() as $lang) { if (!isset($this->translated_slugs[$slug][$lang['code']])) { $this->translated_slugs[$slug][$lang['code']] = ''; } } } if ($this->translated_slugs[$slug][$language]) { $has_translation = true; $slug = $this->translated_slugs[$slug][$language]; } else { $has_translation = false; } if ($has_translation) { return $slug; } } else { $has_translation = true; } return $has_translation ? $slug : $this->st_fallback($slug, $language); }
/** * @return bool */ function init() { $this->attachments = array(); $this->error = null; if ($this->sitepress->get_wp_api()->is_admin()) { add_action('admin_head', array($this, 'js_scripts')); add_action('wp_ajax_set_xliff_options', array($this, 'ajax_set_xliff_options'), 10, 2); if (!$this->sitepress->get_setting('xliff_newlines')) { $this->sitepress->set_setting('xliff_newlines', WPML_XLIFF_TM_NEWLINES_REPLACE, true); } if (!$this->sitepress->get_setting('tm_xliff_version')) { $this->sitepress->set_setting('tm_xliff_version', '12', true); } if (1 < count($this->sitepress->get_active_languages())) { add_filter('wpml_translation_queue_actions', array($this, 'translation_queue_add_actions')); add_action('wpml_xliff_select_actions', array($this, 'translation_queue_xliff_select_actions'), 10, 2); add_action('wpml_translation_queue_do_actions_export_xliff', array($this, 'translation_queue_do_actions_export_xliff'), 10, 2); add_action('wpml_translation_queue_after_display', array($this, 'translation_queue_after_display'), 10, 2); add_action('wpml_translator_notification', array($this, 'translator_notification'), 10, 0); add_filter('wpml_new_job_notification', array($this, 'new_job_notification'), 10, 2); add_filter('wpml_new_job_notification_attachments', array($this, 'new_job_notification_attachments')); } if (isset($_GET['wpml_xliff_action']) && $_GET['wpml_xliff_action'] === 'download' && wp_verify_nonce($_GET['nonce'], 'xliff-export')) { $archive = $this->get_xliff_archive($_GET["xliff_version"]); $this->stream_xliff_archive($archive); } if (isset($_POST['wpml_xliff_export_all_filtered']) && wp_verify_nonce($_POST['nonce'], 'xliff-export-all-filtered')) { $job_ids = $this->get_all_filtered_job_ids(); $archive = $this->get_xliff_archive($_POST["xliff_version"], $job_ids); $this->stream_xliff_archive($archive); } if (isset($_POST['xliff_upload'])) { $this->import_xliff($_FILES['import']); if (is_wp_error($this->error)) { add_action('admin_notices', array($this, '_error')); } } if (isset($_POST['icl_tm_action']) && $_POST['icl_tm_action'] === 'save_notification_settings') { $this->sitepress->save_settings(array('include_xliff_in_notification' => isset($_POST['include_xliff']) && $_POST['include_xliff'])); } } return true; }
/** * * get languages array */ public static function getArrLanguages() { self::validateWpmlExists(); $wpml = new SitePress(); $arrLangs = $wpml->get_active_languages(); $response = array(); $response["all"] = __("All Languages", REVSLIDER_TEXTDOMAIN); foreach ($arrLangs as $code => $arrLang) { $name = $arrLang["native_name"]; $response[$code] = $name; } return $response; }
/** * * get assoc array of lang codes */ public static function getArrLangCodes($getAllCode = true) { $arrCodes = array(); if ($getAllCode == true) { $arrCodes["all"] = "all"; } self::validateWpmlExists(); $wpml = new SitePress(); $arrLangs = $wpml->get_active_languages(); foreach ($arrLangs as $code => $arr) { $arrCodes[$code] = $code; } return $arrCodes; }
/** * @param string $slug * @param string $post_type * @param string|bool $language * * @return string */ function get_translated_slug($slug, $post_type, $language = false) { if ($post_type) { $language = $language ? $language : $this->sitepress->get_current_language(); if (!isset($this->translated_slugs[$post_type][$language])) { $slug_original = $this->wpdb->get_row($this->wpdb->prepare("SELECT s.value, s.language\r\r\n\t\t\t\t\t\t\t\t\t\tFROM {$this->wpdb->prefix}icl_strings s\r\r\n\t\t\t\t\t\t\t\t\t\tWHERE s.name = %s\r\r\n\t\t\t\t\t\t\t\t\t\t AND (s.context = %s OR s.context = %s)", 'URL slug: ' . $post_type, 'default', 'WordPress')); if ((bool) $slug_original === true) { $this->translated_slugs[$post_type][$slug_original->language] = $slug_original->value; $slugs_translations = $this->wpdb->get_results($this->wpdb->prepare("SELECT t.value, t.language\r\r\n\t\t\t\t\t\t\t\t\t\tFROM {$this->wpdb->prefix}icl_strings s\r\r\n\t\t\t\t\t\t\t\t\t\tJOIN {$this->wpdb->prefix}icl_string_translations t ON t.string_id = s.id\r\r\n\t\t\t\t\t\t\t\t\t\tWHERE s.name = %s\r\r\n\t\t\t\t\t\t\t\t\t\t AND (s.context = %s OR s.context = %s)\r\r\n\t\t\t\t\t\t\t\t\t\t\tAND t.status = %d\r\r\n\t\t\t\t\t\t\t\t\t\t\tAND t.value <> ''", 'URL slug: ' . $post_type, 'default', 'WordPress', ICL_TM_COMPLETE)); foreach ($slugs_translations as $translation) { $this->translated_slugs[$post_type][$translation->language] = $translation->value; } foreach ($this->sitepress->get_active_languages() as $lang) { if (!isset($this->translated_slugs[$post_type][$lang['code']])) { $this->translated_slugs[$post_type][$lang['code']] = $slug; } } } } $slug = !empty($this->translated_slugs[$post_type][$language]) ? $this->translated_slugs[$post_type][$language] : $slug; } return $slug; }
private function get_strings_summary($source_language) { $strings_query = "\n\t\t\t\tSELECT\n\t\t\t\t s.id, s.context as domain, s.gettext_context as context, s.name, s.value,\n\t\t\t\t (SELECT count(*)\n\t\t\t\t \tFROM {$this->wpdb->prefix}icl_string_translations t\n\t\t\t\t \tWHERE t.string_id = s.id AND t.language<>s.language) as translations\n\t\t\t\tFROM {$this->wpdb->prefix}icl_strings s\n\t\t\t\tWHERE s.language = %s\n\t\t\t\tORDER BY s.context, s.domain_name_context_md5;\n\t\t\t\t"; $strings_prepared = $this->wpdb->prepare($strings_query, $source_language); $strings = $this->wpdb->get_results($strings_prepared); $active_languages = $this->sitepress->get_active_languages(); $active_languages_count = count($active_languages); foreach ($strings as $string) { $wpml_string = new WPML_String($string->id, $this->sitepress, $this->wpdb); if (!isset($this->report['strings'])) { $this->init_strings_report($wpml_string); } $type = 'strings'; $this->report[$type]['count']['total']++; if ($string->translations < $active_languages_count) { $this->report[$type]['count']['untranslated'] += $active_languages_count - $string->translations - 1; } $element_attributes = array('element_id' => $string->id, 'element_type' => 'string', 'post_type' => 'string'); $words_count = $wpml_string->get_words_count(); $words_count = apply_filters('wpml_element_words_count', $words_count, $element_attributes); $this->report[$type]['words']['total'] += $words_count; $this->report[$type]['words']['untranslated'] = $this->report[$type]['words']['total'] * $this->report[$type]['count']['untranslated']; } }
public static function wpml_get_table_taxonomies(SitePress $sitepress) { $taxonomies = $sitepress->get_wp_api()->get_taxonomies(array(), 'objects'); $result = array("taxonomies" => array(), "activeLanguages" => array(), "allLanguages" => array()); $sitepress->set_admin_language(); $active_langs = $sitepress->get_active_languages(); $default_lang = $sitepress->get_default_language(); $result["activeLanguages"][$default_lang] = array("label" => $active_langs[$default_lang]['display_name'], "flag" => $sitepress->get_flag_url($default_lang)); foreach ($active_langs as $code => $lang) { if ($code !== $default_lang) { $result["activeLanguages"][$code] = array("label" => $lang['display_name'], "flag" => $sitepress->get_flag_url($code)); } } $all_languages = $sitepress->get_languages(); foreach ($all_languages as $code => $lang) { $result["allLanguages"][$code] = array("label" => $lang['display_name'], "flag" => $sitepress->get_flag_url($code)); } foreach ($taxonomies as $key => $tax) { if ($sitepress->is_translated_taxonomy($key)) { $result["taxonomies"][$key] = array("label" => $tax->label, "singularLabel" => $tax->labels->singular_name, "hierarchical" => $tax->hierarchical, "name" => $key); } } return $result; }
public function get_string_translations() { $string_translations = array(); $current_user = $this->sitepress->get_current_user(); $current_user_can_translate_strings = $this->sitepress->get_wp_helper()->current_user_can_translate_strings(); $user_lang_pairs = $this->sitepress->get_wp_helper()->get_user_language_pairs($current_user); $extra_cond = ""; if ($current_user_can_translate_strings && isset($_GET['status']) && preg_match("#" . ICL_TM_WAITING_FOR_TRANSLATOR . "-(.+)#", $_GET['status'], $matches)) { $status_filter = ICL_TM_WAITING_FOR_TRANSLATOR; $status_filter_lang = $matches[1]; $language_code_alias = str_replace('-', '', $status_filter_lang); $extra_cond .= " AND str_{$language_code_alias}.language = '{$status_filter_lang}' "; } else { $status_filter = isset($_GET['status']) ? intval($_GET['status']) : false; } $search_filter = isset($_GET['search']) ? $_GET['search'] : false; $exact_match = isset($_GET['em']) ? $_GET['em'] == 1 : false; if ($status_filter !== false) { if ($status_filter == ICL_TM_COMPLETE) { $extra_cond .= " AND s.status = " . ICL_TM_COMPLETE; } elseif ($status_filter != ICL_TM_WAITING_FOR_TRANSLATOR) { $extra_cond .= " AND status IN (" . ICL_STRING_TRANSLATION_PARTIAL . "," . ICL_TM_NEEDS_UPDATE . "," . ICL_TM_NOT_TRANSLATED . "," . ICL_TM_WAITING_FOR_TRANSLATOR . ")"; } } if ($search_filter != false) { if ($exact_match) { $extra_cond .= " AND s.value = '" . esc_sql($search_filter) . "' "; } else { $extra_cond .= " AND s.value LIKE '%" . esc_sql($search_filter) . "%' "; } } $extra_cond .= isset($_GET['context']) ? " AND s.context = '" . esc_sql($_GET['context']) . "'" : ''; if (isset($_GET['show_results']) && $_GET['show_results'] == 'all') { $limit = 9999; $offset = 0; } else { $limit = $this->get_strings_per_page(); $_GET['paged'] = isset($_GET['paged']) ? $_GET['paged'] : 1; $offset = ($_GET['paged'] - 1) * $limit; } /* TRANSLATOR - START */ if ($current_user_can_translate_strings) { $active_languages = $this->sitepress->get_active_languages(); foreach ($user_lang_pairs as $source_lang_code => $pair) { if (!isset($active_languages[$source_lang_code])) { $active_languages[$source_lang_code] = $this->sitepress->get_language_details($source_lang_code); } foreach (array_keys($pair) as $target_lang_code) { if (!isset($active_languages[$target_lang_code])) { $active_languages[$target_lang_code] = $this->sitepress->get_language_details($target_lang_code); } } } $_joins = $_sels = $_where = array(); foreach ($active_languages as $l) { $language_code_alias = esc_sql(str_replace('-', '', $l['code'])); $_sels[] = "str_{$language_code_alias}.id AS id_{$language_code_alias},\n\t str_{$language_code_alias}.status AS status_{$language_code_alias},\n\t str_{$language_code_alias}.value AS value_{$language_code_alias},\n\t str_{$language_code_alias}.translator_id AS translator_{$language_code_alias},\n\t str_{$language_code_alias}.translation_date AS date_{$language_code_alias}\n\t "; $_joins[] = $this->wpdb->prepare("LEFT JOIN {$this->wpdb->prefix}icl_string_translations str_{$language_code_alias}\n\t ON str_{$language_code_alias}.string_id = s.id AND str_{$language_code_alias}.language = %s ", $l['code']); if (empty($status_filter_lang)) { if ($status_filter == ICL_TM_COMPLETE) { $_where[] .= " AND str_{$language_code_alias}.status = " . ICL_TM_COMPLETE; } else { if (empty($_lwhere)) { $_lwheres = array(); $_lwhere = ' AND ('; foreach ($active_languages as $l2) { $l2code_alias = esc_sql(str_replace('-', '', $l2['code'])); $_lwheres[] = $this->wpdb->prepare(" str_{$l2code_alias}.status = %d\n\t OR str_{$l2code_alias}.translator_id = %d ", ICL_TM_WAITING_FOR_TRANSLATOR, $current_user->ID); } $_lwhere .= join(' OR ', $_lwheres) . ')'; $_where[] = $_lwhere; } } } } $sql_query = empty($status_filter_lang) ? " WHERE s.language IN ( " . wpml_prepare_in(array_keys($user_lang_pairs)) . " ) " . join(' ', $_where) : $this->wpdb->prepare(" WHERE str_{$status_filter_lang}.status = %d\n\t\t\t\t\t\t\t\t\t\t\tAND (str_{$status_filter_lang}.translator_id IS NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\tOR str_{$status_filter_lang}.translator_id = %d)", array(ICL_TM_WAITING_FOR_TRANSLATOR, $current_user->ID)); $res = $this->get_results($sql_query, $extra_cond, $offset, $limit, $_joins, $_sels); if ($res) { $string_translations = empty($status_filter_lang) ? $this->rows_from_unfiltered($res, $active_languages, $string_translations) : $this->rows_from_lang_status_filtered($res, $active_languages, $string_translations); } /* TRANSLATOR - END */ } else { if ($status_filter != ICL_TM_WAITING_FOR_TRANSLATOR) { $sql_query = " WHERE 1 "; } else { $sql_query = " JOIN {$this->wpdb->prefix}icl_string_translations str ON str.string_id = s.id\n\t WHERE str.status = " . ICL_TM_WAITING_FOR_TRANSLATOR; } $res = $this->get_results($sql_query, $extra_cond, $offset, $limit); if ($res) { $extra_cond = ''; if (isset($_GET['translation_language'])) { $extra_cond .= " AND language='" . esc_sql($_GET['translation_language']) . "'"; } foreach ($res as $row) { $string_translations[$row['string_id']] = $row; $tr = $this->wpdb->get_results($this->wpdb->prepare("\n\t SELECT id, language, status, value, translator_id, translation_date \n\t FROM {$this->wpdb->prefix}icl_string_translations \n\t WHERE string_id=%d {$extra_cond}\n\t ", $row['string_id']), ARRAY_A); if ($tr) { foreach ($tr as $t) { $string_translations[$row['string_id']]['translations'][$t['language']] = $t; } } } } } return $string_translations; }
public function get_string_translations() { $string_translations = array(); $current_user = $this->sitepress->get_current_user(); $active_languages = $this->sitepress->get_active_languages(); // error_log(serialize($active_languages), 3, WP_CONTENT_DIR . '/debug.log'); $current_user_can_translate_strings = $this->sitepress->get_wp_helper()->current_user_can_translate_strings(); $user_lang_pairs = $this->sitepress->get_wp_helper()->get_user_language_pairs($current_user); $extra_cond = ""; if ($current_user_can_translate_strings && isset($_GET['status']) && preg_match("#" . ICL_TM_WAITING_FOR_TRANSLATOR . "-(.+)#", $_GET['status'], $matches)) { $status_filter = ICL_TM_WAITING_FOR_TRANSLATOR; $status_filter_lang = $matches[1]; $language_code_alias = str_replace('-', '', $status_filter_lang); $extra_cond .= " AND str_{$language_code_alias}.language = '{$status_filter_lang}' "; } else { $status_filter = isset($_GET['status']) ? intval($_GET['status']) : false; } $search_filter = isset($_GET['search']) ? $_GET['search'] : false; $exact_match = isset($_GET['em']) ? $_GET['em'] == 1 : false; if ($status_filter !== false) { if ($status_filter == ICL_TM_COMPLETE) { $extra_cond .= " AND s.status = " . ICL_TM_COMPLETE; } elseif ($status_filter == ICL_TM_WAITING_FOR_TRANSLATOR) { // do nothing } else { $extra_cond .= " AND status IN (" . ICL_STRING_TRANSLATION_PARTIAL . "," . ICL_TM_NEEDS_UPDATE . "," . ICL_TM_NOT_TRANSLATED . "," . ICL_TM_WAITING_FOR_TRANSLATOR . ")"; } } if ($search_filter != false) { if ($exact_match) { $extra_cond .= " AND s.value = '" . esc_sql($search_filter) . "' "; } else { $extra_cond .= " AND s.value LIKE '%" . esc_sql($search_filter) . "%' "; } } $context_filter = isset($_GET['context']) ? $_GET['context'] : false; if ($context_filter !== false) { $extra_cond .= " AND s.context = '" . esc_sql($context_filter) . "'"; } if (isset($_GET['show_results']) && $_GET['show_results'] == 'all') { $limit = 9999; $offset = 0; } else { $limit = $this->sitepress_settings['st']['strings_per_page']; if (!isset($_GET['paged'])) { $_GET['paged'] = 1; } $offset = ($_GET['paged'] - 1) * $limit; } /* TRANSLATOR - START */ if ($current_user_can_translate_strings) { if (!empty($status_filter_lang)) { $_joins = $_sels = $_where = array(); foreach ($active_languages as $l) { if ($l['code'] == $this->sitepress_settings['st']['strings_language']) { continue; } $language_code_alias = esc_sql(str_replace('-', '', $l['code'])); $_sels[] = "str_{$language_code_alias}.id AS id_{$language_code_alias},\n\t str_{$language_code_alias}.status AS status_{$language_code_alias},\n\t str_{$language_code_alias}.value AS value_{$language_code_alias},\n\t str_{$language_code_alias}.translator_id AS translator_{$language_code_alias},\n\t str_{$language_code_alias}.translation_date AS date_{$language_code_alias}\n\t "; $_joins[] = $this->wpdb->prepare(" LEFT JOIN {$this->wpdb->prefix}icl_string_translations str_{$language_code_alias}\n\t ON str_{$language_code_alias}.string_id = s.id AND str_{$language_code_alias}.language = %s ", $l['code']); } $sql = "\n\t SELECT SQL_CALC_FOUND_ROWS s.id AS string_id, s.language AS string_language, s.context, s.gettext_context, s.name, s.value, s.status,\n\t " . join(", ", $_sels) . "\n\t FROM {$this->wpdb->prefix}icl_strings s \n\t " . join("\n", $_joins) . "\n\t WHERE \n\t str_{$status_filter_lang}.status = %d AND\n\t (str_{$status_filter_lang}.translator_id IS NULL OR str_{$status_filter_lang}.translator_id = %d)\n\t {$extra_cond}\n\t ORDER BY string_id DESC\n\t LIMIT {$offset},{$limit}\n\t "; $sql_prepared = $this->wpdb->prepare($sql, array(ICL_TM_WAITING_FOR_TRANSLATOR, $current_user->ID)); $res = $this->wpdb->get_results($sql_prepared, ARRAY_A); } else { $_joins = $_sels = $_where = array(); foreach ($active_languages as $l) { if ($l['code'] == $this->sitepress_settings['st']['strings_language'] || empty($user_lang_pairs[$this->sitepress_settings['st']['strings_language']][$l['code']])) { continue; } $language_code_alias = esc_sql(str_replace('-', '', $l['code'])); $_sels[] = "str_{$language_code_alias}.id AS id_{$language_code_alias},\n\t str_{$language_code_alias}.status AS status_{$language_code_alias},\n\t str_{$language_code_alias}.value AS value_{$language_code_alias},\n\t str_{$language_code_alias}.translator_id AS translator_{$language_code_alias},\n\t str_{$language_code_alias}.translation_date AS date_{$language_code_alias}\n\t "; $_joins[] = $this->wpdb->prepare("LEFT JOIN {$this->wpdb->prefix}icl_string_translations str_{$language_code_alias}\n\t ON str_{$language_code_alias}.string_id = s.id AND str_{$language_code_alias}.language = %s ", $l['code']); if ($status_filter == ICL_TM_COMPLETE) { $_where[] .= " AND str_{$language_code_alias}.status = " . ICL_TM_COMPLETE; } else { if (empty($_lwhere)) { $_lwheres = array(); $_lwhere = ' AND ('; foreach ($active_languages as $l2) { if ($l2['code'] == $this->sitepress_settings['st']['strings_language'] || empty($user_lang_pairs[$this->sitepress_settings['st']['strings_language']][$l2['code']])) { continue; } $l2code_alias = esc_sql(str_replace('-', '', $l2['code'])); $_lwheres[] = $this->wpdb->prepare(" str_{$l2code_alias}.status = %d\n\t OR str_{$l2code_alias}.translator_id = %d ", ICL_TM_WAITING_FOR_TRANSLATOR, $current_user->ID); } $_lwhere .= join(' OR ', $_lwheres) . ')'; $_where[] = $_lwhere; } } } $sql = "\n\t SELECT SQL_CALC_FOUND_ROWS s.id AS string_id, s.language AS string_language, s.context, s.gettext_context, s.name, s.value, s.status, " . join(', ', $_sels) . "\n\t FROM {$this->wpdb->prefix}icl_strings s " . join("\n", $_joins) . "\n\t WHERE s.language = '{$this->sitepress_settings['st']['strings_language']}' " . join(' ', $_where) . "\n\t {$extra_cond}\n\t ORDER BY s.id DESC\n\t LIMIT {$offset},{$limit}\n\t "; $res = $this->wpdb->get_results($sql, ARRAY_A); } $this->wp_query->found_posts = $this->wpdb->get_var("SELECT FOUND_ROWS()"); $this->wp_query->query_vars['posts_per_page'] = $limit; $this->wp_query->max_num_pages = ceil($this->wp_query->found_posts / $limit); if ($res) { if (!empty($status_filter_lang)) { foreach ($res as $row) { $_translations = array(); foreach ($active_languages as $l) { if ($l['code'] == $this->sitepress_settings['st']['strings_language']) { continue; } $language_code_alias = esc_sql(str_replace('-', '', $l['code'])); if ($row['id_' . $language_code_alias]) { $_translations[$l['code']] = array('id' => $row['id_' . $language_code_alias], 'status' => $row['status_' . $language_code_alias], 'language' => $l['code'], 'value' => $row['value_' . $language_code_alias], 'translator_id' => $row['translator_' . $language_code_alias], 'translation_date' => $row['date_' . $language_code_alias]); } } $string_translations[$row['string_id']] = array('string_id' => $row['string_id'], 'string_language' => $row['string_language'], 'context' => $row['context'], 'gettext_context' => $row['gettext_context'], 'name' => $row['name'], 'value' => $row['value'], 'status' => ICL_TM_WAITING_FOR_TRANSLATOR, 'translations' => $_translations); } } else { foreach ($res as $row) { $_translations = array(); $_status = ICL_TM_NOT_TRANSLATED; $_statuses = array(); foreach ($active_languages as $l) { if ($l['code'] == $this->sitepress_settings['st']['strings_language'] || empty($user_lang_pairs[$this->sitepress_settings['st']['strings_language']][$l['code']])) { continue; } $language_code_alias = str_replace('-', '', $l['code']); if ($row['id_' . $language_code_alias]) { $_translations[$l['code']] = array('id' => $row['id_' . $language_code_alias], 'status' => $row['status_' . $language_code_alias], 'language' => $l['code'], 'value' => $row['value_' . $language_code_alias], 'translator_id' => $row['translator_' . $language_code_alias], 'translation_date' => $row['date_' . $language_code_alias]); } $_statuses[$l['code']] = intval($row['status_' . $language_code_alias]); if ($row['status_' . $language_code_alias] == ICL_TM_WAITING_FOR_TRANSLATOR) { $_status = ICL_TM_WAITING_FOR_TRANSLATOR; } } $_statuses = array_values($_statuses); $_statuses = array_unique($_statuses); if ($_statuses == array(ICL_TM_NOT_TRANSLATED)) { $_status = ICL_TM_NOT_TRANSLATED; } elseif ($_statuses == array(ICL_TM_COMPLETE, ICL_TM_NOT_TRANSLATED)) { $_status = ICL_STRING_TRANSLATION_PARTIAL; } elseif ($_statuses == array(ICL_TM_COMPLETE)) { $_status = ICL_TM_COMPLETE; } elseif (in_array(ICL_TM_WAITING_FOR_TRANSLATOR, $_statuses) || in_array(ICL_TM_NEEDS_UPDATE, $_statuses)) { $_status = ICL_TM_WAITING_FOR_TRANSLATOR; } $string_translations[$row['string_id']] = array('string_id' => $row['string_id'], 'string_language' => $row['string_language'], 'context' => $row['context'], 'gettext_context' => $row['gettext_context'], 'name' => $row['name'], 'value' => $row['value'], 'status' => $_status, 'translations' => $_translations); } } } /* TRANSLATOR - END */ } else { // removed check for language = default lang if ($status_filter != ICL_TM_WAITING_FOR_TRANSLATOR) { $res = $this->wpdb->get_results("\n\t SELECT SQL_CALC_FOUND_ROWS id AS string_id, language AS string_language, context, gettext_context, name, value, status \n\t FROM {$this->wpdb->prefix}icl_strings s\n\t WHERE \n\t 1\n\t {$extra_cond}\n\t ORDER BY string_id DESC\n\t LIMIT {$offset},{$limit}\n\t ", ARRAY_A); } else { $res = $this->wpdb->get_results("\n\t SELECT SQL_CALC_FOUND_ROWS s.id AS string_id, s.language AS string_language, s.context, s.gettext_context, s.name, s.value, " . ICL_TM_WAITING_FOR_TRANSLATOR . " AS status\n\t FROM {$this->wpdb->prefix}icl_strings s\n\t JOIN {$this->wpdb->prefix}icl_string_translations str ON str.string_id = s.id\n\t WHERE \n\t str.status = " . ICL_TM_WAITING_FOR_TRANSLATOR . "\n\t {$extra_cond}\n\t ORDER BY string_id DESC\n\t LIMIT {$offset},{$limit}\n\t ", ARRAY_A); } if (!is_null($this->wp_query)) { $this->wp_query->found_posts = $this->wpdb->get_var("SELECT FOUND_ROWS()"); $this->wp_query->query_vars['posts_per_page'] = $limit; $this->wp_query->max_num_pages = ceil($this->wp_query->found_posts / $limit); } if ($res) { $extra_cond = ''; if (isset($_GET['translation_language'])) { $extra_cond .= " AND language='" . esc_sql($_GET['translation_language']) . "'"; } foreach ($res as $row) { $string_translations[$row['string_id']] = $row; $tr = $this->wpdb->get_results($this->wpdb->prepare("\n\t SELECT id, language, status, value, translator_id, translation_date \n\t FROM {$this->wpdb->prefix}icl_string_translations \n\t WHERE string_id=%d {$extra_cond}\n\t ", $row['string_id']), ARRAY_A); if ($tr) { foreach ($tr as $t) { $string_translations[$row['string_id']]['translations'][$t['language']] = $t; } } } } } return $string_translations; }