当前位置: 首页>>代码示例>>PHP>>正文


PHP ICL_Pro_Translation类代码示例

本文整理汇总了PHP中ICL_Pro_Translation的典型用法代码示例。如果您正苦于以下问题:PHP ICL_Pro_Translation类的具体用法?PHP ICL_Pro_Translation怎么用?PHP ICL_Pro_Translation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ICL_Pro_Translation类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process_forms

 function process_forms()
 {
     global $wpdb;
     require_once ICL_PLUGIN_PATH . '/lib/Snoopy.class.php';
     require_once ICL_PLUGIN_PATH . '/lib/xml2array.php';
     require_once ICL_PLUGIN_PATH . '/lib/icl_api.php';
     if (isset($_POST['icl_post_action'])) {
         switch ($_POST['icl_post_action']) {
             case 'save_theme_localization':
                 $locales = array();
                 foreach ($_POST as $k => $v) {
                     if (0 !== strpos($k, 'locale_file_name_') || !trim($v)) {
                         continue;
                     }
                     $locales[str_replace('locale_file_name_', '', $k)] = $v;
                 }
                 if (!empty($locales)) {
                     $this->set_locale_file_names($locales);
                 }
                 break;
         }
         return;
     }
     $create_account = isset($_POST['icl_create_account_nonce']) && $_POST['icl_create_account_nonce'] == wp_create_nonce('icl_create_account');
     $create_account_and_transfer = isset($_POST['icl_create_account_and_transfer_nonce']) && $_POST['icl_create_account_and_transfer_nonce'] == wp_create_nonce('icl_create_account_and_transfer');
     $config_account = isset($_POST['icl_configure_account_nonce']) && $_POST['icl_configure_account_nonce'] == wp_create_nonce('icl_configure_account');
     $create_support_account = isset($_POST['icl_create_support_account_nonce']) && $_POST['icl_create_support_account_nonce'] == wp_create_nonce('icl_create_support_account');
     $config_support_account = isset($_POST['icl_configure_support_account_nonce']) && $_POST['icl_configure_support_account_nonce'] == wp_create_nonce('icl_configure_support_account');
     $use_existing_account = isset($_POST['icl_use_account_nonce']) && $_POST['icl_use_account_nonce'] == wp_create_nonce('icl_use_account');
     $transfer_to_account = isset($_POST['icl_transfer_account_nonce']) && $_POST['icl_transfer_account_nonce'] == wp_create_nonce('icl_transfer_account');
     if ($create_account || $config_account || $create_support_account || $config_support_account) {
         if (isset($_POST['icl_content_trans_setup_back_2'])) {
             // back button in wizard mode.
             $this->settings['content_translation_setup_wizard_step'] = 2;
             $this->save_settings();
         } else {
             $user = $_POST['user'];
             $user['create_account'] = isset($_POST['icl_create_account_nonce']) || isset($_POST['icl_create_support_account_nonce']) ? 1 : 0;
             $user['platform_kind'] = 2;
             $user['cms_kind'] = 1;
             $user['blogid'] = $wpdb->blogid ? $wpdb->blogid : 1;
             $user['url'] = get_home_url();
             $user['title'] = get_option('blogname');
             $user['description'] = $this->settings['icl_site_description'];
             $user['is_verified'] = 1;
             if ($user['create_account'] && defined('ICL_AFFILIATE_ID') && defined('ICL_AFFILIATE_KEY')) {
                 $user['affiliate_id'] = ICL_AFFILIATE_ID;
                 $user['affiliate_key'] = ICL_AFFILIATE_KEY;
             }
             $user['interview_translators'] = $this->settings['interview_translators'];
             $user['project_kind'] = $this->settings['website_kind'];
             /*
              if(is_null($user['project_kind']) || $user['project_kind']==''){
             	$_POST['icl_form_errors'] = __('Please select the kind of website','sitepress');
             	return;
             }
             */
             $user['pickup_type'] = intval($this->settings['translation_pickup_method']);
             $notifications = 0;
             if ($this->settings['icl_notify_complete']) {
                 $notifications += 1;
             }
             if ($this->settings['alert_delay']) {
                 $notifications += 2;
             }
             $user['notifications'] = $notifications;
             // prepare language pairs
             $pay_per_use = $this->settings['translator_choice'] == 1;
             $language_pairs = $this->settings['language_pairs'];
             $lang_pairs = array();
             if (isset($language_pairs)) {
                 foreach ($language_pairs as $k => $v) {
                     $english_fr = $wpdb->get_var("SELECT english_name FROM {$wpdb->prefix}icl_languages WHERE code='{$k}' ");
                     $pay_per_use_increment = 0;
                     foreach ($v as $k => $v) {
                         $pay_per_use_increment++;
                         $english_to = $wpdb->get_var("SELECT english_name FROM {$wpdb->prefix}icl_languages WHERE code='{$k}' ");
                         $lang_pairs['from_language' . $pay_per_use_increment] = ICL_Pro_Translation::server_languages_map($english_fr);
                         $lang_pairs['to_language' . $pay_per_use_increment] = ICL_Pro_Translation::server_languages_map($english_to);
                         if ($pay_per_use) {
                             $lang_pairs['pay_per_use' . $pay_per_use_increment] = 1;
                         }
                     }
                 }
             }
             $icl_query = new ICanLocalizeQuery();
             list($site_id, $access_key) = $icl_query->createAccount(array_merge($user, $lang_pairs));
             if (!$site_id) {
                 $user['pickup_type'] = ICL_PRO_TRANSLATION_PICKUP_POLLING;
                 list($site_id, $access_key) = $icl_query->createAccount(array_merge($user, $lang_pairs));
             }
             if (!$site_id) {
                 if ($access_key) {
                     $_POST['icl_form_errors'] = $access_key;
                 } else {
                     $_POST['icl_form_errors'] = __('An unknown error has occurred when communicating with the ICanLocalize server. Please try again.', 'sitepress');
                     // We will force the next try to be http.
                     update_option('_force_mp_post_http', 1);
                 }
             } else {
//.........这里部分代码省略.........
开发者ID:pablomarsan,项目名称:iftheme-docs,代码行数:101,代码来源:sitepress.class.php

示例2: icl_register_string

function icl_register_string($context, $name, $value, $allow_empty_value = false)
{
    global $wpdb, $sitepress, $sitepress_settings, $ICL_Pro_Translation;
    // if the default language is not set up return without doing anything
    if (!isset($sitepress_settings['existing_content_language_verified']) || !$sitepress_settings['existing_content_language_verified']) {
        return;
    }
    // Check if cached (so exists)
    $cached = icl_t_cache_lookup($context, $name);
    if ($cached && isset($cached['original']) && $cached['original'] == $value) {
        return;
    }
    $language = $sitepress->get_default_language();
    $res = $wpdb->get_row("SELECT id, value, status, language FROM {$wpdb->prefix}icl_strings WHERE context='" . $wpdb->escape($context) . "' AND name='" . $wpdb->escape($name) . "'");
    if ($res) {
        $string_id = $res->id;
        $update_string = array();
        if ($value != $res->value) {
            $update_string['value'] = $value;
        }
        if ($language != $res->language) {
            $update_string['language'] = $language;
        }
        if (!empty($update_string)) {
            $wpdb->update($wpdb->prefix . 'icl_strings', $update_string, array('id' => $string_id));
            $wpdb->update($wpdb->prefix . 'icl_string_translations', array('status' => ICL_STRING_TRANSLATION_NEEDS_UPDATE), array('string_id' => $string_id));
            icl_update_string_status($string_id);
        }
    } else {
        if (!empty($value) && is_scalar($value) && trim($value) || $allow_empty_value) {
            $string = array('language' => $language, 'context' => $context, 'name' => $name, 'value' => $value, 'status' => ICL_STRING_TRANSLATION_NOT_TRANSLATED);
            $wpdb->insert($wpdb->prefix . 'icl_strings', $string);
            $string_id = $wpdb->insert_id;
        } else {
            $string_id = 0;
        }
    }
    global $WPML_Sticky_Links;
    if (!empty($WPML_Sticky_Links) && $WPML_Sticky_Links->settings['sticky_links_strings']) {
        require_once ICL_PLUGIN_PATH . '/inc/translation-management/pro-translation.class.php';
        ICL_Pro_Translation::_content_make_links_sticky($string_id, 'string', false);
    }
    return $string_id;
}
开发者ID:GeraldScott,项目名称:OpenEvSys,代码行数:44,代码来源:generate.php

示例3: send_comment_to_translation

 function send_comment_to_translation($comment_id, $to_language)
 {
     global $wpdb, $sitepress_settings, $sitepress;
     $iclq = new ICanLocalizeQuery($sitepress_settings['site_id'], $sitepress_settings['access_key']);
     $from_lang = $sitepress->get_language_details($this->user_language);
     $to_lang = $sitepress->get_language_details($to_language);
     $from_lang_server = ICL_Pro_Translation::server_languages_map($from_lang['english_name']);
     $to_lang_server = ICL_Pro_Translation::server_languages_map($to_lang['english_name']);
     $body = $wpdb->get_var("SELECT comment_content FROM {$wpdb->comments} WHERE comment_ID={$comment_id}");
     $rid = $iclq->cms_create_message($body, $from_lang_server, $to_lang_server);
     if ($rid > 0) {
         // does this comment already exist in the messages status queue?
         $msid = $wpdb->get_var("SELECT id FROM {$wpdb->prefix}icl_message_status WHERE object_type='comment' AND object_id={$comment_id}");
         if ($msid) {
             $wpdb->update($wpdb->prefix . 'icl_message_status', array('rid' => $rid, 'md5' => md5($body), 'status' => MESSAGE_TRANSLATION_IN_PROGRESS), array('id' => $msid));
         } else {
             $wpdb->insert($wpdb->prefix . 'icl_message_status', array('rid' => $rid, 'object_id' => $comment_id, 'from_language' => $this->user_language, 'to_language' => $to_language, 'md5' => md5($body), 'object_type' => 'comment', 'status' => MESSAGE_TRANSLATION_IN_PROGRESS));
         }
     }
 }
开发者ID:batruji,项目名称:metareading,代码行数:20,代码来源:functions.php

示例4: _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;
        }
    }
}
开发者ID:besimhu,项目名称:LDF-site,代码行数:47,代码来源:functions.php

示例5: get_translation_jobs


//.........这里部分代码省略.........
             if (!empty($to)) {
                 // get 'from' languages corresdonding to $to (to $translator_id)
                 $from_languages = array();
                 foreach ($language_pairs as $fl => $tls) {
                     if (isset($tls[$to])) {
                         $from_languages[] = $fl;
                     }
                 }
                 if ($from_languages) {
                     $where .= PHP_EOL . sprintf(" AND t.source_language_code IN(%s)", "'" . join("','", $from_languages) . "'");
                 }
             } else {
                 // all to all case
                 // get all possible combinations for $translator_id
                 $from_languages = array_keys($language_pairs);
                 $where_conditions = array();
                 foreach ($from_languages as $fl) {
                     $to_languages = "'" . join("','", array_keys($language_pairs[$fl])) . "'";
                     $where_conditions[] = sprintf(" (t.source_language_code='%s' AND t.language_code IN (%s)) ", $fl, $to_languages);
                 }
                 if (!empty($where_conditions)) {
                     $where .= PHP_EOL . ' AND ( ' . join(' OR ', $where_conditions) . ')';
                 }
             }
         }
     }
     // HANDLE TO
     if (!empty($to)) {
         $where .= PHP_EOL . " AND t.language_code='" . esc_sql($to) . "'";
     } else {
         // only if we filter by translator, make sure to use just the 'from' languages that apply
         // in no translator_id, omit condition and all will be pulled
         if ($translator_id) {
             if (!empty($from)) {
                 // get languages the user can translate into from $from
                 $tos = isset($language_pairs[$from]) ? array_keys($language_pairs[$from]) : array();
                 if ($tos) {
                     $where .= PHP_EOL . sprintf(" AND t.language_code IN(%s)", "'" . join("','", $tos) . "'");
                 }
             } else {
                 // covered by 'all to all case' above
             }
         }
     }
     // ORDER BY
     if ($include_unassigned) {
         $orderby[] = 'j.translator_id DESC';
     }
     $orderby[] = ' j.job_id DESC ';
     $orderby = join(', ', $orderby);
     // LIMIT
     if (!isset($_GET['paged'])) {
         $_GET['paged'] = 1;
     }
     $offset = ($_GET['paged'] - 1) * $limit_no;
     $limit = " " . $offset . ',' . $limit_no;
     $jobs = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS\n\t\t\t\tj.job_id, t.trid, t.language_code, t.source_language_code,\n\t\t\t\ts.translation_id, s.status, s.needs_update, s.translator_id, u.display_name AS translator_name, s.translation_service\n\t\t\t\tFROM {$wpdb->prefix}icl_translate_job j\n\t\t\t\t\tJOIN {$wpdb->prefix}icl_translation_status s ON j.rid = s.rid\n\t\t\t\t\tJOIN {$wpdb->prefix}icl_translations t ON s.translation_id = t.translation_id\n\t\t\t\t\tLEFT JOIN {$wpdb->users} u ON s.translator_id = u.ID\n\t\t\t\tWHERE {$where} AND revision IS NULL\n\t\t\t\tORDER BY {$orderby}\n\t\t\t\tLIMIT {$limit}\n\t\t\t");
     //echo '<pre>';
     //print_r($wpdb->last_query);
     //echo '</pre>';
     $count = $wpdb->get_var("SELECT FOUND_ROWS()");
     $wp_query->found_posts = $count;
     $wp_query->query_vars['posts_per_page'] = $limit_no;
     $wp_query->max_num_pages = ceil($wp_query->found_posts / $limit_no);
     foreach ($jobs as $k => $row) {
         //original
         $post_id = $wpdb->get_var($wpdb->prepare("\n\t\t\t\t\t\t\t\t\t\t\t\t\t SELECT field_data\n\t\t\t\t\t\t\t\t\t\t\t\t\t FROM {$wpdb->prefix}icl_translate\n\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE job_id=%d and field_type='original_id'", $row->job_id));
         $parts = explode('_', $post_id);
         if ($parts[0] == 'external') {
             $jobs[$k]->original_doc_id = $post_id;
             $jobs[$k]->post_title = base64_decode($wpdb->get_var($wpdb->prepare("\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t SELECT field_data\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t FROM {$wpdb->prefix}icl_translate\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE job_id=%d and field_type='name'", $row->job_id)));
             if ($jobs[$k]->post_title == "") {
                 // try the title field.
                 $jobs[$k]->post_title = base64_decode($wpdb->get_var($wpdb->prepare("\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t SELECT field_data\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t FROM {$wpdb->prefix}icl_translate\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE job_id=%d and field_type='title'", $row->job_id)));
             }
             $jobs[$k]->post_title = apply_filters('WPML_translation_job_title', $jobs[$k]->post_title, $post_id);
             $jobs[$k]->edit_link = self::tm_post_link($post_id);
             $ldf = $sitepress->get_language_details($row->source_language_code);
         } else {
             $doc = $wpdb->get_row($wpdb->prepare("SELECT ID, post_title, post_type FROM {$wpdb->posts} WHERE ID=%d", $post_id));
             if ($doc) {
                 $jobs[$k]->post_title = $doc->post_title;
                 $jobs[$k]->original_doc_id = $doc->ID;
                 $jobs[$k]->edit_link = get_edit_post_link($doc->ID);
                 $ldf = $sitepress->get_language_details($sitepress->get_element_language_details($post_id, 'post_' . $doc->post_type)->language_code);
             } else {
                 $jobs[$k]->post_title = __("The original has been deleted!", "sitepress");
                 $jobs[$k]->original_doc_id = 0;
                 $jobs[$k]->edit_link = "";
                 $ldf['display_name'] = __("Deleted", "sitepress");
             }
         }
         $ldt = $sitepress->get_language_details($row->language_code);
         $jobs[$k]->lang_text = $ldf['display_name'] . ' &raquo; ' . $ldt['display_name'];
         if ($row->translation_service == 'icanlocalize') {
             $row->translator_name = ICL_Pro_Translation::get_translator_name($row->translator_id);
         }
     }
     return $jobs;
 }
开发者ID:Calraiser,项目名称:flux,代码行数:101,代码来源:translation-management.class.php

示例6: wp_nonce_field

        echo $post->post_type;
        ?>
" />
    <?php 
        wp_nonce_field('send_translation_request_nonce', '_icl_nonce_pt_' . $post->ID);
        ?>
    <input type="button" disabled="disabled" id="icl_pt_send" class="button-primary alignright" value="<?php 
        echo esc_html(__('Send to translation', 'wpml-translation-management'));
        ?>
" style="clear: right;"/>
    <br clear="all" />
    <?php 
    } else {
        ?>
    <?php 
        $estimated_cost = sprintf("%.2f", (ICL_Pro_Translation::estimate_word_count($post, $selected_language) + ICL_Pro_Translation::estimate_custom_field_word_count($post->ID, $selected_language)) * 0.09);
        ?>
    <div style="text-align: right;margin:0 5px 5px 0;white-space:nowrap;">
    <?php 
        printf(__('Estimated cost: %s USD', 'wpml-translation-management'), $estimated_cost);
        ?>
<br />
    (<?php 
        echo $sitepress->create_icl_popup_link('http://www.icanlocalize.com/destinations/go?name=cms-cost-estimate&iso=' . $sitepress->get_locale($sitepress->get_admin_language()) . '&src=' . get_option('home'), array('ar' => 1, 'title' => __('Cost estimate', 'wpml-translation-management'))) . __('why estimated?', 'wpml-translation-management');
        ?>
</a>)
    </div>
        
    <br />
    <p><b><?php 
        echo $sitepress->create_icl_popup_link('http://www.icanlocalize.com/destinations/go?name=moreinfo-wp&iso=' . $sitepress->get_locale($sitepress->get_admin_language()) . '&src=' . get_option('home'), array('title' => __('About Our Translators', 'wpml-translation-management'), 'ar' => 1));
开发者ID:PHQ-Design,项目名称:souza-lima,代码行数:31,代码来源:_icl_post_menu.php

示例7: isset

// included from Sitepress::reminder_popups
//
// NOTE: this is also used for other popup links to ICanLocalize
global $wpdb;
$target = $_GET['target'];
$auto_resize = isset($_GET['auto_resize']) && $_GET['auto_resize'];
$unload_cb = isset($_GET['unload_cb']) ? $_GET['unload_cb'] : false;
if (preg_match('|^@select-translators;([^;]+);([^;]+)@|', $target, $matches)) {
    $from_lang = $matches[1];
    $to_lang = $matches[2];
    require_once ICL_PLUGIN_PATH . '/lib/Snoopy.class.php';
    require_once ICL_PLUGIN_PATH . '/lib/xml2array.php';
    require_once ICL_PLUGIN_PATH . '/lib/icl_api.php';
    $icl_query = new ICanLocalizeQuery();
    foreach ($this->get_active_languages() as $lang) {
        $lang_server[$lang['code']] = ICL_Pro_Translation::server_languages_map($lang['english_name']);
    }
    if (!$this->icl_account_configured()) {
        $user['create_account'] = 1;
        $user['anon'] = 1;
        $user['platform_kind'] = 2;
        $user['cms_kind'] = 1;
        $user['blogid'] = $wpdb->blogid ? $wpdb->blogid : 1;
        $user['url'] = get_option('siteurl');
        $user['title'] = get_option('blogname');
        $user['description'] = @strval($this->settings['icl_site_description']);
        $user['is_verified'] = 1;
        if (defined('ICL_AFFILIATE_ID') && defined('ICL_AFFILIATE_KEY')) {
            $user['affiliate_id'] = ICL_AFFILIATE_ID;
            $user['affiliate_key'] = ICL_AFFILIATE_KEY;
        }
开发者ID:besimhu,项目名称:LDF-site,代码行数:31,代码来源:icl-reminder-popup.php

示例8: ICanLocalizeQuery

     //break;
 //break;
 case 'icl_cms_id_fix':
     $iclq = new ICanLocalizeQuery($sitepress_settings['site_id'], $sitepress_settings['access_key']);
     $p = $wpdb->get_row("SELECT t.* FROM {$wpdb->prefix}icl_translations t JOIN {$wpdb->prefix}icl_translation_status s ON t.translation_id=s.translation_id\n                WHERE t.element_type LIKE 'post\\_%' AND t.source_language_code IS NOT NULL AND s.translation_service='icanlocalize' LIMIT {$_REQUEST['offset']}, 1");
     if (!empty($p)) {
         $original_id = $wpdb->get_var($wpdb->prepare("SELECT element_id FROM {$wpdb->prefix}icl_translations WHERE trid=%d AND source_language_code IS NULL", $p->trid));
         if ($p->element_type == 'post_page') {
             $permalink = get_option('home') . '?page_id=' . $original_id;
         } else {
             $permalink = get_option('home') . '?p=' . $original_id;
         }
         $_lang_details = $sitepress->get_language_details($p->source_language_code);
         $from_language = ICL_Pro_Translation::server_languages_map($_lang_details['english_name']);
         $_lang_details = $sitepress->get_language_details($p->language_code);
         $to_language = ICL_Pro_Translation::server_languages_map($_lang_details['english_name']);
         $cms_id = sprintf('%s_%d_%s_%s', preg_replace('#^post_#', '', $p->element_type), $original_id, $p->source_language_code, $p->language_code);
         $ret = $iclq->update_cms_id(compact('permalink', 'from_language', 'to_language', 'cms_id'));
         if ($ret != $cms_id && $iclq->error()) {
             echo json_encode(array('errors' => 1, 'message' => $iclq->error(), 'cont' => 0));
         } else {
             echo json_encode(array('errors' => 0, 'message' => 'OK', 'cont' => 1));
         }
     } else {
         echo json_encode(array('errors' => 0, 'message' => __('Done', 'sitepress'), 'cont' => 0));
     }
     exit;
     //break;
 //break;
 case 'icl_cleanup':
     global $sitepress, $wpdb, $wp_post_types;
开发者ID:GaryJones,项目名称:TPWP,代码行数:31,代码来源:troubleshooting.php

示例9: send_translation_snapshots

 /** * Creates and sends translation snapshots.  *
  * Called by the scheduled cron event.
  */
 function send_translation_snapshots()
 {
     if (!defined('ICL_PLUGIN_PATH')) {
         return;
     }
     require_once ICL_PLUGIN_PATH . '/inc/translation-management/pro-translation.class.php';
     global $sitepress, $sitepress_settings;
     if (isset($sitepress_settings['site_id'])) {
         $jobs = $this->get_translation_jobs();
         $total_word_count = $this->get_translation_word_count($jobs);
         // Do not send snapshots when nothing changed
         $icl_settings = $sitepress->get_settings();
         if (isset($icl_settings['snapshot_word_count']) and $icl_settings['snapshot_word_count'] == $total_word_count) {
             return;
         } else {
             $icl_settings['snapshot_word_count'] = $total_word_count;
             $sitepress->save_settings($icl_settings);
         }
         $datetime = new DateTime();
         if (!empty($total_word_count['total'])) {
             foreach ($total_word_count['total'] as $from => $to_list) {
                 foreach ($to_list as $to => $value) {
                     // Convert language names to icanlocalize format
                     $from_language_name = ICL_Pro_Translation::server_languages_map($from);
                     $to_language_name = ICL_Pro_Translation::server_languages_map($to);
                     $params = array('date' => $datetime->format("Y-m-d\\TH:i:s-P"), 'from_language_name' => $from_language_name, 'to_language_name' => $to_language_name, 'words_to_translate' => $value, 'translated_words' => $total_word_count['finished'][$from][$to]);
                     $this->send_translation_snapshot_to_icl($params);
                 }
             }
         }
     }
 }
开发者ID:ascarius,项目名称:wordpress-bootstrap,代码行数:35,代码来源:translation-analytics.class.php

示例10: __

                $sitepress->save_settings(array('quote-get' => $saved));
                echo __('An unknown error has occurred when communicating with the ICanLocalize server. Please try again.', 'sitepress') . '<br /><br />';
                require_once ICL_PLUGIN_PATH . '/inc/quote/quote-get.php';
                exit;
            }
        }
        /**
         * Set URL query
         */
        $language_pairs = array($saved['from'] => $saved['to']);
        $lang_pairs = array();
        $incr = 1;
        $query = '';
        if (isset($language_pairs)) {
            foreach ($language_pairs as $k => $v) {
                $english_from = $wpdb->get_var("SELECT english_name FROM {$wpdb->prefix}icl_languages WHERE code='{$k}' ");
                $query .= '&to_lang_num=' . count($v);
                $query .= '&from_language_name=' . $english_from;
                foreach ($v as $k => $v) {
                    $english_to = $wpdb->get_var("SELECT english_name FROM {$wpdb->prefix}icl_languages WHERE code='{$k}' ");
                    $query .= '&to_language_name_' . $incr . '=' . ICL_Pro_Translation::server_languages_map($english_to);
                    $incr++;
                }
            }
        }
        $url = ICL_API_ENDPOINT . '/websites/' . $site_id . '/quote?accesskey=' . $access_key . '&locale=' . $sitepress->get_default_language() . $query . '&compact=1';
        // Call reopen JS
        echo '<script type="text/javascript">icl_thickbox_reopen(\'' . $url . '\');</script>';
        exit;
    }
}
开发者ID:santikrass,项目名称:apache,代码行数:31,代码来源:quote-get-submit.php

示例11: get_translation_jobs

 function get_translation_jobs($args = array())
 {
     global $wpdb, $sitepress, $wp_query;
     // defaults
     $args_default = array('translator_id' => 0, 'status' => false, 'include_unassigned' => false);
     extract($args_default);
     extract($args, EXTR_OVERWRITE);
     $_exp = explode('-', $translator_id);
     $service = isset($_exp[1]) ? $_exp[1] : 'local';
     $translator_id = $_exp[0];
     $where = " s.status > " . ICL_TM_NOT_TRANSLATED;
     if ($status != '') {
         $where .= " AND s.status=" . intval($status);
     }
     if (!empty($translator_id)) {
         if ($include_unassigned) {
             $where .= " AND (j.translator_id=" . intval($translator_id) . " OR j.translator_id=0) ";
         } else {
             $where .= " AND j.translator_id=" . intval($translator_id);
         }
         if (!empty($service)) {
             $where .= " AND s.translation_service='{$service}'";
         }
     }
     if (!empty($from)) {
         $where .= " AND t.source_language_code='" . $wpdb->escape($from) . "'";
     }
     if (!empty($to)) {
         $where .= " AND t.language_code='" . $wpdb->escape($to) . "'";
     }
     // ORDER BY
     if ($include_unassigned) {
         $orderby[] = 'j.translator_id DESC';
     }
     $orderby[] = ' j.job_id DESC ';
     $orderby = join(', ', $orderby);
     // LIMIT
     if (!isset($_GET['paged'])) {
         $_GET['paged'] = 1;
     }
     $offset = ($_GET['paged'] - 1) * $limit_no;
     $limit = " " . $offset . ',' . $limit_no;
     $jobs = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS \n                j.job_id, t.trid, t.language_code, t.source_language_code, \n                s.translation_id, s.status, s.needs_update, s.translator_id, u.display_name AS translator_name, s.translation_service \n                FROM {$wpdb->prefix}icl_translate_job j\n                    JOIN {$wpdb->prefix}icl_translation_status s ON j.rid = s.rid\n                    JOIN {$wpdb->prefix}icl_translations t ON s.translation_id = t.translation_id\n                    LEFT JOIN {$wpdb->users} u ON s.translator_id = u.ID\n                WHERE {$where} AND revision IS NULL\n                ORDER BY {$orderby}\n                LIMIT {$limit}\n            ");
     $count = $wpdb->get_var("SELECT FOUND_ROWS()");
     $wp_query->found_posts = $count;
     $wp_query->query_vars['posts_per_page'] = $limit_no;
     $wp_query->max_num_pages = ceil($wp_query->found_posts / $limit_no);
     foreach ($jobs as $k => $row) {
         //original
         $post_id = $wpdb->get_var($wpdb->prepare("\n                                                     SELECT field_data\n                                                     FROM {$wpdb->prefix}icl_translate\n                                                     WHERE job_id=%d and field_type='original_id'", $row->job_id));
         $parts = explode('_', $post_id);
         if ($parts[0] == 'external') {
             $jobs[$k]->original_doc_id = $post_id;
             $jobs[$k]->post_title = base64_decode($wpdb->get_var($wpdb->prepare("\n                                                         SELECT field_data\n                                                         FROM {$wpdb->prefix}icl_translate\n                                                         WHERE job_id=%d and field_type='name'", $row->job_id)));
             if ($jobs[$k]->post_title == "") {
                 // try the title field.
                 $jobs[$k]->post_title = base64_decode($wpdb->get_var($wpdb->prepare("\n                                                         SELECT field_data\n                                                         FROM {$wpdb->prefix}icl_translate\n                                                         WHERE job_id=%d and field_type='title'", $row->job_id)));
             }
             $jobs[$k]->edit_link = $this->tm_post_link($post_id);
             $ldf = $sitepress->get_language_details($row->source_language_code);
         } else {
             $doc = $wpdb->get_row($wpdb->prepare("SELECT ID, post_title, post_type FROM {$wpdb->posts} WHERE ID=%d", $post_id));
             if ($doc) {
                 $jobs[$k]->post_title = $doc->post_title;
                 $jobs[$k]->original_doc_id = $doc->ID;
                 $jobs[$k]->edit_link = get_edit_post_link($doc->ID);
                 $ldf = $sitepress->get_language_details($sitepress->get_element_language_details($post_id, 'post_' . $doc->post_type)->language_code);
             } else {
                 $jobs[$k]->post_title = __("The original has been deleted!", "sitepress");
                 $jobs[$k]->original_doc_id = 0;
                 $jobs[$k]->edit_link = "";
                 $ldf['display_name'] = __("Deleted", "sitepress");
             }
         }
         $ldt = $sitepress->get_language_details($row->language_code);
         $jobs[$k]->lang_text = $ldf['display_name'] . ' &raquo; ' . $ldt['display_name'];
         if ($row->translation_service == 'icanlocalize') {
             $row->translator_name = ICL_Pro_Translation::get_translator_name($row->translator_id);
         }
     }
     return $jobs;
 }
开发者ID:bidhanbaral,项目名称:fotodep_store,代码行数:82,代码来源:translation-management.class.php

示例12: get_translation_jobs

 function get_translation_jobs($args = array())
 {
     global $wpdb, $sitepress, $wp_query;
     // defaults
     $args_default = array('translator_id' => 0, 'status' => false, 'include_unassigned' => false);
     extract($args_default);
     extract($args, EXTR_OVERWRITE);
     $_exp = explode('-', $translator_id);
     $service = isset($_exp[1]) ? $_exp[1] : 'local';
     $translator_id = $_exp[0];
     $where = "1";
     if ($status != '') {
         $where .= " AND s.status=" . intval($status);
     }
     if (!empty($translator_id)) {
         if ($include_unassigned) {
             $where .= " AND (j.translator_id=" . intval($translator_id) . " OR j.translator_id=0) ";
         } else {
             $where .= " AND j.translator_id=" . intval($translator_id);
         }
         if (!empty($service)) {
             $where .= " AND s.translation_service='{$service}'";
         }
     }
     if (!empty($from)) {
         $where .= " AND t.source_language_code='" . $wpdb->escape($from) . "'";
     }
     if (!empty($to)) {
         $where .= " AND t.language_code='" . $wpdb->escape($to) . "'";
     }
     // ORDER BY
     if ($include_unassigned) {
         $orderby[] = 'j.translator_id DESC';
     }
     $orderby[] = ' j.job_id DESC ';
     $orderby = join(', ', $orderby);
     // LIMIT
     if (!isset($_GET['paged'])) {
         $_GET['paged'] = 1;
     }
     $offset = ($_GET['paged'] - 1) * $limit_no;
     $limit = " " . $offset . ',' . $limit_no;
     $jobs = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS \r\n                j.job_id, t.trid, t.language_code, t.source_language_code, s.status, s.needs_update, s.translator_id, u.display_name AS translator_name, s.translation_service \r\n                FROM {$wpdb->prefix}icl_translate_job j\r\n                    JOIN {$wpdb->prefix}icl_translation_status s ON j.rid = s.rid\r\n                    JOIN {$wpdb->prefix}icl_translations t ON s.translation_id = t.translation_id\r\n                    LEFT JOIN {$wpdb->users} u ON s.translator_id = u.ID\r\n                WHERE {$where} AND revision IS NULL\r\n                ORDER BY {$orderby}\r\n                LIMIT {$limit}\r\n            ");
     $count = $wpdb->get_var("SELECT FOUND_ROWS()");
     $wp_query->found_posts = $count;
     $wp_query->query_vars['posts_per_page'] = $limit_no;
     $wp_query->max_num_pages = ceil($wp_query->found_posts / $limit_no);
     foreach ($jobs as $k => $row) {
         //original
         $doc = $wpdb->get_row($wpdb->prepare("\r\n                SELECT p.ID, p.post_title \r\n                FROM {$wpdb->prefix}icl_translations t \r\n                    JOIN {$wpdb->posts} p ON p.ID = t.element_id\r\n                WHERE t.trid = %d AND t.language_code = '%s'", $row->trid, $row->source_language_code));
         $jobs[$k]->post_title = $doc->post_title;
         $jobs[$k]->edit_link = get_edit_post_link($doc->ID);
         $ldt = $sitepress->get_language_details($row->language_code);
         $ldf = $sitepress->get_language_details($row->source_language_code);
         $jobs[$k]->lang_text = $ldf['display_name'] . ' &raquo; ' . $ldt['display_name'];
         if ($row->translation_service == 'icanlocalize') {
             $row->translator_name = ICL_Pro_Translation::get_translator_name($row->translator_id);
         }
     }
     return $jobs;
 }
开发者ID:winyatasenjaya,项目名称:sitepress-multilingual-cms,代码行数:61,代码来源:translation-management.class.php

示例13: register_string

 public function register_string($context, $name, $value, $allow_empty_value = false)
 {
     global $wpdb, $sitepress_settings;
     /* cpt slugs - do not register them when scanning themes and plugins
      * if name starting from 'URL slug: '
      * and context is different from 'WordPress'
      */
     if (substr($name, 0, 10) === 'URL slug: ' && 'WordPress' !== $context) {
         return false;
     }
     // if the default language is not set up return without doing anything
     if (!isset($sitepress_settings['existing_content_language_verified']) || !$sitepress_settings['existing_content_language_verified']) {
         return false;
     }
     $translation = $this->string_from_registered($value, $name, $context);
     if ($translation == $value) {
         return false;
     }
     $language = isset($sitepress_settings['st']['strings_language']) ? $sitepress_settings['st']['strings_language'] : 'en';
     $query = $wpdb->prepare("SELECT id, value, status, language FROM {$wpdb->prefix}icl_strings WHERE context=%s AND name=%s", $context, $name);
     $res = $wpdb->get_row($query);
     if ($res) {
         $string_id = $res->id;
         $update_string = array();
         /*
          * If Sticky Links plugin is active and set to change links in Strings,
          * we need to process $value and change links into sticky before comparing
          * with saved in DB $res->value.
          * Otherwise after every String Translation screen refresh status of this string
          * will be changed into 'needs update'
          */
         $alp_settings = get_option('alp_settings');
         if (!empty($alp_settings['sticky_links_strings']) && $alp_settings['sticky_links_strings'] && defined('WPML_STICKY_LINKS_VERSION')) {
             // sticky links plugin is active?
             require_once ICL_PLUGIN_PATH . '/inc/absolute-links/absolute-links.class.php';
             $absolute_links_object = new AbsoluteLinks();
             $alp_broken_links = array();
             $value = $absolute_links_object->_process_generic_text($value, $alp_broken_links);
         }
         if ($value != $res->value) {
             $update_string['value'] = $value;
         }
         if ($language != $res->language) {
             $update_string['language'] = $language;
         }
         if (!empty($update_string)) {
             $wpdb->update($wpdb->prefix . 'icl_strings', $update_string, array('id' => $string_id));
             $wpdb->update($wpdb->prefix . 'icl_string_translations', array('status' => ICL_STRING_TRANSLATION_NEEDS_UPDATE), array('string_id' => $string_id));
             icl_update_string_status($string_id);
         }
     } else {
         $string_id = $this->save_string($value, $allow_empty_value, $language, $context, $name);
     }
     global $WPML_Sticky_Links;
     if (!empty($WPML_Sticky_Links) && $WPML_Sticky_Links->settings['sticky_links_strings']) {
         require_once ICL_PLUGIN_PATH . '/inc/translation-management/pro-translation.class.php';
         ICL_Pro_Translation::_content_make_links_sticky($string_id, 'string', false);
     }
     $this->name_cache[$name . $context] = $value;
     return $string_id;
 }
开发者ID:StudioCreate,项目名称:Uncle-Hummer-WordPress-Theme,代码行数:61,代码来源:wpml-admin-string-filter.class.php


注:本文中的ICL_Pro_Translation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。