本文整理汇总了PHP中ICanLocalizeQuery::build_cms_request_xml方法的典型用法代码示例。如果您正苦于以下问题:PHP ICanLocalizeQuery::build_cms_request_xml方法的具体用法?PHP ICanLocalizeQuery::build_cms_request_xml怎么用?PHP ICanLocalizeQuery::build_cms_request_xml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICanLocalizeQuery
的用法示例。
在下文中一共展示了ICanLocalizeQuery::build_cms_request_xml方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
//.........这里部分代码省略.........
$categories_to_translate[$term_taxonomy_id] = $pc;
}
}
sort($post_categories, SORT_STRING);
}
// CUSTOM TAXONOMIES
// ***************************************************************************
$taxonomies = $wpdb->get_col("\n SELECT DISTINCT tx.taxonomy \n FROM {$wpdb->term_taxonomy} tx JOIN {$wpdb->term_relationships} tr ON tx.term_taxonomy_id = tr.term_taxonomy_id\n WHERE tr.object_id = {$post_id}\n ");
foreach ($taxonomies as $t) {
if (@intval($sitepress_settings['taxonomies_sync_option'][$t]) == 1) {
$object_terms = $wpdb->get_results("\n SELECT x.term_taxonomy_id, t.name \n FROM {$wpdb->terms} t \n JOIN {$wpdb->term_taxonomy} x ON t.term_id=x.term_id\n JOIN {$wpdb->term_relationships} r ON x.term_taxonomy_id = r.term_taxonomy_id\n WHERE x.taxonomy = '{$t}' AND r.object_id = {$post_id}\n ");
foreach ($object_terms as $trm) {
$trid = $wpdb->get_var("SELECT trid FROM {$wpdb->prefix}icl_translations \n WHERE element_id='{$trm->term_taxonomy_id}' AND element_type='tax_{$t}'");
foreach ($target_languages as $lang) {
$not_translated = false;
if ($trid != $wpdb->get_var("\n SELECT trid FROM {$wpdb->prefix}icl_translations WHERE l.english_name='{$lang}' AND trid='{$trid} AND element_id IS NOT NULL'\n ")) {
$not_translated = true;
break;
}
}
if ($not_translated) {
$taxonomies_to_translate[$t][$trm->term_taxonomy_id] = $trm->name;
}
}
}
}
$data['url'] = htmlentities($post_url);
$data['contents']['title'] = array('translate' => 1, 'data' => base64_encode($post->post_title), 'format' => 'base64');
if (!empty($post->post_excerpt)) {
$data['contents']['excerpt'] = array('translate' => 1, 'data' => base64_encode($post->post_excerpt), 'format' => 'base64');
}
$data['contents']['body'] = array('translate' => 1, 'data' => base64_encode($post->post_content), 'format' => 'base64');
$data['contents']['original_id'] = array('translate' => 0, 'data' => $post_id);
$data['target_languages'] = array($target_for_server);
$custom_fields = array();
foreach ((array) $iclTranslationManagement->settings['custom_fields_translation'] as $cf => $op) {
if ($op == 2) {
$custom_fields[] = $cf;
}
}
foreach ($custom_fields as $cf) {
$custom_fields_value = get_post_meta($post_id, $cf, true);
if ($custom_fields_value != '') {
$data['contents']['field-' . $cf] = array('translate' => 1, 'data' => base64_encode($custom_fields_value), 'format' => 'base64');
$data['contents']['field-' . $cf . '-name'] = array('translate' => 0, 'data' => $cf);
$data['contents']['field-' . $cf . '-type'] = array('translate' => 0, 'data' => 'custom_field');
}
}
if (@is_array($categories_to_translate)) {
$data['contents']['categories'] = array('translate' => 1, 'data' => implode(',', array_map(create_function('$e', 'return \'"\'.base64_encode($e).\'"\';'), $categories_to_translate)), 'format' => 'csv_base64');
$data['contents']['category_ids'] = array('translate' => 0, 'data' => implode(',', array_keys($categories_to_translate)), 'format' => '');
}
if (@is_array($tags_to_translate)) {
$data['contents']['tags'] = array('translate' => 1, 'data' => implode(',', array_map(create_function('$e', 'return \'"\'.base64_encode($e).\'"\';'), $tags_to_translate)), 'format' => 'csv_base64');
$data['contents']['tag_ids'] = array('translate' => 0, 'data' => implode(',', array_keys($tags_to_translate)), 'format' => '');
}
if (@is_array($taxonomies_to_translate)) {
foreach ($taxonomies_to_translate as $k => $v) {
$data['contents'][$k] = array('translate' => 1, 'data' => implode(',', array_map(create_function('$e', 'return \'"\'.base64_encode($e).\'"\';'), $v)), 'format' => 'csv_base64');
$data['contents'][$k . '_ids'] = array('translate' => 0, 'data' => implode(',', array_keys($v)), 'format' => '');
}
}
if ($post->post_status == 'publish') {
$permlink = $post_url;
} else {
$permlink = false;
}
$note = get_post_meta($post_id, '_icl_translator_note', true);
// if this is an old request having a old request_id, include that
if ($wpdb->prefix . 'icl_content_status' == $wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}icl_content_status'")) {
$prev_rid = $wpdb->get_var($wpdb->prepare("SELECT MAX(rid) FROM {$wpdb->prefix}icl_content_status WHERE nid=%d", $post_id));
if (!empty($prev_rid)) {
$data['previous_cms_request_id'] = $prev_rid;
}
}
}
$data = apply_filters('icl_data_for_pro_translation', $data);
$xml = $iclq->build_cms_request_xml($data, $orig_lang_for_server);
$cms_id = sprintf('%s_%d_%s_%s', $post->post_type, $post->ID, $orig_lang, $target_lang);
$args = array('cms_id' => $cms_id, 'xml' => $xml, 'title' => $post->post_title, 'to_languages' => array($target_for_server), 'orig_language' => $orig_lang_for_server, 'permlink' => $permlink, 'translator_id' => $translator_id, 'note' => $note);
$res = $iclq->send_request($args);
if ($res > 0) {
$this->tmg->update_translation_status(array('translation_id' => $translation->translation_id, 'status' => ICL_TM_IN_PROGRESS, 'needs_update' => 0));
} else {
$_prevstate = $wpdb->get_var($wpdb->prepare("SELECT _prevstate FROM {$wpdb->prefix}icl_translation_status WHERE translation_id=%d", $translation->translation_id));
if (!empty($_prevstate)) {
$_prevstate = unserialize($_prevstate);
$wpdb->update($wpdb->prefix . 'icl_translation_status', array('status' => $_prevstate['status'], 'translator_id' => $_prevstate['translator_id'], 'status' => $_prevstate['status'], 'needs_update' => $_prevstate['needs_update'], 'md5' => $_prevstate['md5'], 'translation_service' => $_prevstate['translation_service'], 'translation_package' => $_prevstate['translation_package'], 'timestamp' => $_prevstate['timestamp'], 'links_fixed' => $_prevstate['links_fixed']), array('translation_id' => $translation->translation_id));
} else {
$wpdb->update($wpdb->prefix . 'icl_translation_status', array('status' => ICL_TM_NOT_TRANSLATED, 'needs_update' => 0), array('translation_id' => $translation->translation_id));
}
$err = true;
}
}
// if needs translation
}
// foreach target lang
return $err ? false : $res;
//last $ret
}
示例2: _icl_translation_send_strings_icanlocalize
function _icl_translation_send_strings_icanlocalize($string_ids, $target)
{
global $wpdb, $sitepress, $sitepress_settings;
if (!$sitepress_settings['st']['strings_language']) {
$sitepress_settings['st']['strings_language'] = $sitepress->get_default_language();
}
$target_details = $sitepress->get_language_details($target);
// get all the untranslated strings
$untranslated = array();
foreach ($string_ids as $st_id) {
$status = $wpdb->get_var($wpdb->prepare("SELECT status FROM {$wpdb->prefix}icl_string_translations WHERE string_id=%d and language=%s", $st_id, $target));
if ($status != ICL_STRING_TRANSLATION_COMPLETE) {
$untranslated[] = $st_id;
}
}
if (sizeof($untranslated) > 0) {
// Something to translate.
$target_for_server = array(ICL_Pro_Translation::server_languages_map($target_details['english_name']));
//filter some language names to match the names on the server
$data = array('url' => '', 'target_languages' => $target_for_server);
$string_values = array();
foreach ($untranslated as $st_id) {
$string = $wpdb->get_row($wpdb->prepare("SELECT context, name, value FROM {$wpdb->prefix}icl_strings WHERE id=%d", $st_id));
$string_values[$st_id] = $string->value;
$data['contents']['string-' . $st_id . '-context'] = array('translate' => 0, 'data' => base64_encode(htmlspecialchars($string->context)), 'format' => 'base64');
$data['contents']['string-' . $st_id . '-name'] = array('translate' => 0, 'data' => base64_encode(htmlspecialchars($string->name)), 'format' => 'base64');
$data['contents']['string-' . $st_id . '-value'] = array('translate' => 1, 'data' => base64_encode(htmlspecialchars($string->value)), 'format' => 'base64');
}
$iclq = new ICanLocalizeQuery($sitepress_settings['site_id'], $sitepress_settings['access_key']);
$orig_lang = $sitepress->get_language_details($sitepress_settings['st']['strings_language']);
$orig_lang_for_server = ICL_Pro_Translation::server_languages_map($orig_lang['english_name']);
$timestamp = date('Y-m-d H:i:s');
$xml = $iclq->build_cms_request_xml($data, $orig_lang_for_server);
$args = array('xml' => $xml, 'title' => "String translations", 'to_languages' => $target_for_server, 'orig_language' => $orig_lang_for_server);
$res = $iclq->send_request($args);
if ($res > 0) {
foreach ($string_values as $st_id => $value) {
$wpdb->insert($wpdb->prefix . 'icl_string_status', array('rid' => $res, 'string_translation_id' => $st_id, 'timestamp' => $timestamp, 'md5' => md5($value)));
//insert rid
}
$wpdb->insert($wpdb->prefix . 'icl_core_status', array('rid' => $res, 'origin' => $orig_lang['code'], 'target' => $target, 'status' => CMS_REQUEST_WAITING_FOR_PROJECT_CREATION));
return $res;
} else {
return 0;
}
}
}