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


PHP TranslationProxy::get_current_project方法代码示例

本文整理汇总了PHP中TranslationProxy::get_current_project方法的典型用法代码示例。如果您正苦于以下问题:PHP TranslationProxy::get_current_project方法的具体用法?PHP TranslationProxy::get_current_project怎么用?PHP TranslationProxy::get_current_project使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TranslationProxy的用法示例。


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

示例1: icl_populate_translations_pickup_box

function icl_populate_translations_pickup_box()
{
    if (!wpml_is_action_authenticated('icl_populate_translations_pickup_box')) {
        die('Wrong Nonce');
    }
    global $sitepress;
    $last_picked_up = $sitepress->get_setting('last_picked_up');
    $translation_offset = strtotime(current_time('mysql')) - @intval($last_picked_up) - 5 * 60;
    if (WP_DEBUG == false && $translation_offset < 0) {
        $time_left = floor(abs($translation_offset) / 60);
        if ($time_left == 0) {
            $time_left = abs($translation_offset);
            $wait_text = '<p><i>' . sprintf(__('You can check again in %s seconds.', 'sitepress'), '<span id="icl_sec_tic">' . $time_left . '</span>') . '</i></p>';
        } else {
            $wait_text = sprintf(__('You can check again in %s minutes.', 'sitepress'), '<span id="icl_sec_tic">' . $time_left . '</span>') . '</i></p>';
        }
        $result = array('wait_text' => $wait_text);
    } else {
        $project = TranslationProxy::get_current_project();
        $cms_id_helper = new WPML_TM_CMS_ID();
        $polling_status = new WPML_TP_Polling_Status($project, $sitepress, $cms_id_helper);
        $result = $polling_status->get_status_array();
    }
    wp_send_json_success($result);
}
开发者ID:aarongillett,项目名称:B22-151217,代码行数:25,代码来源:ajax.php

示例2: send_basket_commit

 public function send_basket_commit()
 {
     $has_remote_translators = false;
     try {
         $response = false;
         $errors = array();
         if (TranslationProxy::is_batch_mode()) {
             $project = TranslationProxy::get_current_project();
             $translators = $_POST['translators'];
             $has_remote_translators = false;
             if (is_array($translators)) {
                 foreach ($translators as $translator) {
                     if (!TranslationProxy_Service::is_local_translator($translator)) {
                         $has_remote_translators = true;
                         break;
                     }
                 }
             } else {
                 $has_remote_translators = true;
             }
             if ($project && $has_remote_translators) {
                 $response = $project->commit_batch_job();
                 if (!empty($project->errors)) {
                     $response = false;
                 }
             } else {
                 //Local translation only: return true
                 $response = true;
             }
         }
         if ($response) {
             $is_error = false;
             TranslationProxy_Basket::delete_all_items_from_basket();
             $service_name = TranslationProxy::get_current_service_name();
             if (isset($has_remote_translators) && $has_remote_translators) {
                 $response->call_to_action = '<strong>' . sprintf(__('You have sent items to %s. Please check if additional steps are required on their end', 'wpml-translation-management'), $service_name) . '</strong>';
             }
         } else {
             $response = false;
             $is_error = true;
             if (isset($project) && $project) {
                 $errors = $project->errors;
             }
         }
     } catch (Exception $e) {
         $response = false;
         $is_error = true;
         $errors[] = $e->getMessage();
     }
     $result = array('result' => $response, 'is_error' => $is_error, 'errors' => $errors);
     if (!empty($errors)) {
         $this->rollback_basket_commit();
         wp_send_json_error($result);
     } else {
         wp_send_json_success($result);
     }
 }
开发者ID:ryuqing,项目名称:cake,代码行数:57,代码来源:wpml-basket-tab-ajax.class.php

示例3: icl_pickup_translations

function icl_pickup_translations()
{
    if (!wpml_is_action_authenticated('icl_pickup_translations')) {
        die('Wrong Nonce');
    }
    global $ICL_Pro_Translation, $wpdb;
    $job_factory = wpml_tm_load_job_factory();
    $wpml_tm_records = new WPML_TM_Records($wpdb);
    $cms_id_helper = new WPML_TM_CMS_ID($wpml_tm_records, $job_factory);
    $project = TranslationProxy::get_current_project();
    $remote_sync_factory = new WPML_TP_Remote_Sync_Factory($project, $ICL_Pro_Translation, $cms_id_helper);
    $pickup = new WPML_TP_Polling_Pickup($ICL_Pro_Translation, $remote_sync_factory);
    wp_send_json_success($pickup->poll_job($_POST));
}
开发者ID:agiper,项目名称:wordpress,代码行数:14,代码来源:ajax.php

示例4: translation_service_details

function translation_service_details($service, $show_project = false)
{
    $service_details = '';
    if (defined('OTG_SANDBOX_DEBUG') && OTG_SANDBOX_DEBUG) {
        $service_details .= '<h3>Service details:</h3>' . PHP_EOL;
        $service_details .= '<pre>' . PHP_EOL;
        $service_details .= print_r($service, true);
        $service_details .= '</pre>' . PHP_EOL;
        if ($show_project) {
            $project = TranslationProxy::get_current_project();
            echo '<pre>$project' . PHP_EOL;
            echo print_r($project, true);
            echo '</pre>';
        }
    }
    return $service_details;
}
开发者ID:agiper,项目名称:wordpress,代码行数:17,代码来源:functions.php

示例5: refresh_language_pairs

 function refresh_language_pairs()
 {
     $project = TranslationProxy::get_current_project();
     $nonce_is_valid = false;
     if (array_key_exists('nonce', $_POST)) {
         $nonce = $_POST['nonce'];
         $nonce_is_valid = wp_verify_nonce($nonce, 'wpml-tp-refresh-language-pairs');
     }
     if ($nonce_is_valid) {
         try {
             $this->wpml_tp_api->refresh_language_pairs($project);
             wp_send_json_success(esc_attr__('Language pairs refreshed.', 'wpml-translation-management'));
         } catch (Exception $e) {
             wp_send_json_error($e);
         }
     }
 }
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:17,代码来源:class-wpml-tp-api-ajax.php

示例6: define

<?php

define('ICL_LANGUAGE_NOT_SUPPORTED', 3);
global $wpdb, $sitepress;
$target = filter_input(INPUT_GET, 'target', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$auto_resize = filter_input(INPUT_GET, 'auto_resize', FILTER_VALIDATE_BOOLEAN | FILTER_NULL_ON_FAILURE);
$unload_cb = filter_input(INPUT_GET, 'unload_cb', FILTER_SANITIZE_FULL_SPECIAL_CHARS | FILTER_NULL_ON_FAILURE);
// Adding a translator
if (preg_match('|^@select-translators;([^;]+);([^;]+)@|', $target, $matches)) {
    $source_language = $matches[1];
    $target_language = $matches[2];
    $project = TranslationProxy::get_current_project();
    try {
        $lp_setting_index = 'language_pairs';
        $language_pairs = $sitepress->get_setting($lp_setting_index, array());
        if (!isset($language_pairs[$source_language][$target_language]) || $language_pairs[$source_language][$target_language] == 0) {
            $language_pairs[$source_language][$target_language] = 1;
            TranslationProxy_Translator::update_language_pairs($project, $language_pairs);
            $sitepress->set_setting($lp_setting_index, $language_pairs, true);
        }
        $target = $project->select_translator_iframe_url($source_language, $target_language);
    } catch (Exception $e) {
        if ($e->getCode() == ICL_LANGUAGE_NOT_SUPPORTED) {
            printf(__('<p>Requested languages are not supported by the translation service (%s). Please <a%s>contact us</a> for support. </p>', 'sitepress'), $e->getMessage(), ' target="_blank" href="http://wpml.org/?page_id=5255"');
        } else {
            printf(__('<p>Could not add the requested languages. Please <a%s>contact us</a> for support. </p><p>Show <a%s>debug information</a>.</p>', 'sitepress'), ' target="_blank" href="http://wpml.org/?page_id=5255"', ' a href="admin.php?page=' . ICL_PLUGIN_FOLDER . '/menu/troubleshooting.php&icl_action=icl-connection-test' . '#icl-connection-test"');
        }
        exit;
    }
}
$target .= strpos($target, '?') === false ? '?' : '&';
开发者ID:aarongillett,项目名称:B22-151217,代码行数:31,代码来源:translationproxy-popup.php

示例7: get_translator_html

 protected function get_translator_html($job)
 {
     $job = (object) $job;
     $current_service_name = TranslationProxy::get_current_service_name();
     $translation_services = array('local', TranslationProxy::get_current_service_id());
     $translator = '';
     if ($job->translation_service && $job->translation_service !== 'local') {
         try {
             $project = TranslationProxy::get_current_project();
             if ($project) {
                 if ($project->service->has_translator_selection) {
                     $translator_contact_iframe_url = $project->translator_contact_iframe_url($job->translator_id);
                     $iframe_args = array('title' => __('Contact the translator', 'wpml-translation-management'), 'unload_cb' => 'icl_thickbox_refresh');
                     $translator .= TranslationProxy_Popup::get_link($translator_contact_iframe_url, $iframe_args);
                     $translator .= esc_html($job->translator_name);
                     $translator .= "</a> (" . $current_service_name . ")";
                 } else {
                     $translator .= $current_service_name;
                 }
             } else {
                 $translator .= esc_html($job->translator_name);
             }
         } catch (Exception $e) {
             // Just doesn't create the output
         }
     } elseif ($job->status == ICL_TM_COMPLETE) {
         $translator_data = get_userdata($job->translator_id);
         $translator_name = $translator_data ? $translator_data->display_name : "";
         $translator = '<span class="icl-finished-local-name">' . $translator_name . '</span>';
     } else {
         $translator .= '<span class="icl_tj_select_translator">';
         $selected_translator = isset($job->translator_id) ? $job->translator_id : false;
         $disabled = false;
         if ($job->translation_service && $job->translation_service !== 'local' && is_numeric($job->translation_service)) {
             $selected_translator = TranslationProxy_Service::get_wpml_translator_id($job->translation_service, $job->translator_id);
             $disabled = true;
         }
         $job_id = isset($job->job_id) ? $job->job_id : $job->id;
         $local_only = isset($job->local_only) ? $job->local_only : true;
         $args = array('id' => 'icl_tj_translator_for_' . $job_id, 'name' => 'icl_tj_translator_for_' . $job_id, 'from' => $job->source_language_code, 'to' => $job->language_code, 'selected' => $selected_translator, 'services' => $translation_services, 'disabled' => $disabled, 'echo' => false, 'local_only' => $local_only);
         $translator .= TranslationManagement::translators_dropdown($args);
         $translator .= '<input type="hidden" id="icl_tj_ov_' . $job_id . '" value="' . (int) $job->translator_id . '" />';
         $translator .= '<input type="hidden" id="icl_tj_ty_' . $job_id . '" value="' . strtolower($this->get_type()) . '" />';
         $translator .= '<span class="icl_tj_select_translator_controls" id="icl_tj_tc_' . $job_id . '">';
         $translator .= '<input type="button" class="button-secondary icl_tj_ok" value="' . __('Send', 'wpml-translation-management') . '" />&nbsp;';
         $translator .= '<input type="button" class="button-secondary icl_tj_cancel" value="' . __('Cancel', 'wpml-translation-management') . '" />';
         $translator .= '</span>';
     }
     return $translator;
 }
开发者ID:Junaid-Farid,项目名称:gocnex,代码行数:50,代码来源:wpml-translation-job.class.php

示例8: sync_cancelled

 static function sync_cancelled()
 {
     global $wpdb, $sitepress;
     $project = TranslationProxy::get_current_project();
     $requests = $project->cancelled_jobs();
     if ($requests === false) {
         echo wp_json_encode(array('errors' => 1, 'message' => 'Failed fetching jobs list from the server.'));
         exit;
     }
     $cms_ids = array();
     if (!empty($requests)) {
         foreach ($requests as $request) {
             $cms_ids[] = $request->cms_id;
         }
     }
     // get jobs that are in progress
     $translations_sql = "\n                SELECT t.element_id, t.element_type, t.language_code, t.source_language_code, t.trid,\n                    s.rid, s._prevstate, s.translation_id\n                FROM {$wpdb->prefix}icl_translation_status s\n                JOIN {$wpdb->prefix}icl_translations t\n                    ON t.translation_id = s.translation_id\n                WHERE s.translation_service=%s\n                AND s.status = %d\n            ";
     $translations_prepared = $wpdb->prepare($translations_sql, array(TranslationProxy::get_current_service_id(), ICL_TM_IN_PROGRESS));
     $translations = $wpdb->get_results($translations_prepared);
     $jobs2delete = array();
     $translations2cancel = array();
     foreach ($translations as $t) {
         $original_id_sql = "SELECT element_id FROM {$wpdb->prefix}icl_translations\n                                     WHERE trid=%d AND source_language_code IS NULL";
         $original_id_prepared = $wpdb->prepare($original_id_sql, $t->trid);
         $original_id = $wpdb->get_var($original_id_prepared);
         $cms_id = sprintf('%s_%d_%s_%s', preg_replace('#^post_#', '', $t->element_type), $original_id, $t->source_language_code, $t->language_code);
         if (in_array($cms_id, $cms_ids)) {
             $_lang_details = $sitepress->get_language_details($t->source_language_code);
             $lang_from = $_lang_details['english_name'];
             $_lang_details = $sitepress->get_language_details($t->language_code);
             $lang_to = $_lang_details['english_name'];
             $jobs2delete[] = '<a href="' . get_permalink($original_id) . '">' . get_the_title($original_id) . '</a>' . sprintf(' - from %s to %s', $lang_from, $lang_to);
             $translations2cancel[] = $t;
         }
     }
     $response_message = '';
     if ($jobs2delete && $translations2cancel) {
         $response_message .= '<div class="error clear" style="padding-top:5px;font-size:11px;">';
         $response_message .= __('About to cancel these jobs:', 'sitepress');
         $response_message .= '<br />';
         $response_message .= '<ul style="margin-left:10px;">';
         $response_message .= '<li>';
         $response_message .= join('</li><li>', $jobs2delete);
         $response_message .= '</li>';
         $response_message .= '</ul>';
         $response_message .= '<br />';
         $response_message .= '<a id="icl_ts_cancel_ok" href="#" class="button-secondary">';
         $response_message .= __('OK', 'sitepress');
         $response_message .= '</a>&nbsp;';
         $response_message .= '<a id="icl_ts_cancel_cancel" href="#" class="button-secondary">';
         $response_message .= __('Cancel', 'sitepress');
         $response_message .= '</a>';
         $response_message .= '</div>';
         $response_errors = 0;
         $response_data = array('t2c' => serialize($translations2cancel));
     } elseif ($project->errors) {
         $response_message = join('<br/>', $project->errors);
         $response_errors = count($project->errors);
         $response_data = false;
     } else {
         $response_message = __('Nothing to cancel.', 'sitepress');
         $response_errors = 0;
         $response_data = false;
     }
     $response = array('errors' => $response_errors, 'message' => $response_message, 'data' => $response_data);
     echo wp_json_encode($response);
     die;
 }
开发者ID:Junaid-Farid,项目名称:gocnex,代码行数:68,代码来源:wpml_tm_troubleshooting.class.php

示例9: process_translated_string

 function process_translated_string($translation_proxy_job_id, $language)
 {
     $project = TranslationProxy::get_current_project();
     $translation = $project->fetch_translation($translation_proxy_job_id);
     $translation = apply_filters('icl_data_from_pro_translation', $translation);
     $ret = false;
     $xliff = new WPML_TM_xliff();
     $translation = $xliff->get_strings_xliff_translation($translation);
     if ($translation) {
         $ret = icl_translation_add_string_translation($translation_proxy_job_id, $translation, $language);
         if ($ret) {
             $project->update_job($translation_proxy_job_id);
         }
     }
     return $ret;
 }
开发者ID:ryuqing,项目名称:cake,代码行数:16,代码来源:wpml-pro-translation.class.php

示例10: check_batch_status_ajax

 function check_batch_status_ajax()
 {
     $batch_id = filter_input(INPUT_POST, 'batch_id', FILTER_SANITIZE_NUMBER_INT);
     $valid_nonce = wp_verify_nonce($_POST['nonce'], $_POST['action']);
     if ($valid_nonce && $batch_id > 0) {
         $project = TranslationProxy::get_current_project();
         $project->check_status($batch_id);
         wp_send_json_success(array('error' => 0));
     } else {
         wp_send_json_error(__('Invalid request', 'wpml-translation-management'));
     }
 }
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:12,代码来源:class-wpml-translation-management.php

示例11: get_current_project

 function get_current_project()
 {
     return TranslationProxy::get_current_project();
 }
开发者ID:tlandn,项目名称:akvo-sites-zz-template,代码行数:4,代码来源:wpml-translation-proxy-networking.class.php

示例12: get_basket_extra_fields_array

 public static function get_basket_extra_fields_array($force_refresh = false)
 {
     if ($force_refresh) {
         $networking = wpml_tm_load_tp_networking();
         $project = TranslationProxy::get_current_project();
         $extra_fields = $networking->get_extra_fields_remote($project);
     } else {
         $extra_fields = TranslationProxy::get_extra_fields_local();
     }
     return TranslationProxy::maybe_convert_extra_fields($extra_fields);
 }
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:11,代码来源:translationproxy-basket.class.php

示例13: process_translated_string

 private function process_translated_string($translation_proxy_job_id, $language)
 {
     $project = TranslationProxy::get_current_project();
     $translation = $project->fetch_translation($translation_proxy_job_id);
     $translation = apply_filters('icl_data_from_pro_translation', $translation);
     $ret = false;
     $translation = $this->xliff_reader_factory->string_xliff_reader()->get_data($translation);
     if ($translation) {
         $ret = icl_translation_add_string_translation($translation_proxy_job_id, $translation, $language);
         if ($ret) {
             $project->update_job($translation_proxy_job_id);
         }
     }
     return $ret;
 }
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:15,代码来源:wpml-pro-translation.class.php

示例14: WPML_Basket_Tab_Ajax

<?php

global $wpdb;
require WPML_TM_PATH . '/menu/basket-tab/wpml-basket-tab-ajax.class.php';
$basket_ajax = new WPML_Basket_Tab_Ajax(TranslationProxy::get_current_project(), wpml_tm_load_basket_networking(), new WPML_Translation_Basket($wpdb));
add_action('init', array($basket_ajax, 'init'));
function icl_get_jobs_table()
{
    require_once WPML_TM_PATH . '/menu/wpml-translation-jobs-table.class.php';
    global $iclTranslationManagement;
    $nonce = filter_input(INPUT_POST, 'icl_get_jobs_table_data_nonce', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
    if (!wp_verify_nonce($nonce, 'icl_get_jobs_table_data_nonce')) {
        die('Wrong Nonce');
    }
    $table = new WPML_Translation_Jobs_Table($iclTranslationManagement);
    $data = $table->get_paginated_jobs();
    wp_send_json_success($data);
}
function icl_get_job_original_field_content()
{
    global $iclTranslationManagement;
    if (!wpml_is_action_authenticated('icl_get_job_original_field_content')) {
        die('Wrong Nonce');
    }
    $job_id = filter_input(INPUT_POST, 'tm_editor_job_id', FILTER_SANITIZE_NUMBER_INT);
    $field = filter_input(INPUT_POST, 'tm_editor_job_field');
    $data = array();
    $job = $job_id !== null && $field !== null ? $job = $iclTranslationManagement->get_translation_job($job_id) : null;
    $elements = $job && isset($job->elements) ? $job->elements : array();
    foreach ($elements as $element) {
        $sanitized_type = sanitize_title($element->field_type);
开发者ID:Junaid-Farid,项目名称:gocnex,代码行数:31,代码来源:ajax.php

示例15: send_strings_to_translation_service

 function send_strings_to_translation_service($string_ids, $target_language, $basket_name, $translator_id)
 {
     global $wpdb;
     // get all the untranslated strings
     $untranslated = array();
     foreach ($string_ids as $st_id) {
         $untranslated[] = $st_id;
     }
     if (sizeof($untranslated) > 0) {
         $project = TranslationProxy::get_current_project();
         $strings = array();
         $word_count = 0;
         $source_language = $this->get_strings_language();
         foreach ($untranslated as $string_id) {
             $string_data_query = "SELECT id, context, name, value FROM {$wpdb->prefix}icl_strings WHERE id=%d";
             $string_data_prepare = $wpdb->prepare($string_data_query, $string_id);
             $string_data = $wpdb->get_row($string_data_prepare);
             $word_count += $this->estimate_word_count($string_data->value, $source_language);
             $strings[] = $string_data;
         }
         $xliff = new WPML_TM_xliff();
         $file = $xliff->get_strings_xliff_file($strings, $source_language, $target_language);
         $title = "String Translations";
         $cms_id = '';
         $url = '';
         $timestamp = date('Y-m-d H:i:s');
         if (TranslationProxy::is_batch_mode()) {
             $res = $project->send_to_translation_batch_mode($file, $title, $cms_id, $url, $source_language, $target_language, $word_count);
         } else {
             $res = $project->send_to_translation($file, $title, $cms_id, $url, $source_language, $target_language, $word_count);
         }
         if ($res) {
             foreach ($strings as $string_data) {
                 $batch_id = TranslationProxy_Batch::update_translation_batch($basket_name);
                 $translation_service = TranslationProxy_Service::get_translator_data_from_wpml($translator_id);
                 $added = icl_add_string_translation($string_data->id, $target_language, null, ICL_TM_WAITING_FOR_TRANSLATOR, $translation_service['translator_id'], $translation_service['translation_service'], $batch_id);
                 if ($added) {
                     $data = array('rid' => $res, 'string_translation_id' => $added, 'timestamp' => $timestamp, 'md5' => md5($string_data->value));
                     $wpdb->insert($wpdb->prefix . 'icl_string_status', $data);
                     //insert rid
                 } else {
                     $this->add_message(sprintf(__('Unable to add "%s" string in tables', 'sitepress'), $string_data->name), 'error');
                     return 0;
                 }
             }
             $wpdb->insert($wpdb->prefix . 'icl_core_status', array('rid' => $res, 'module' => '', 'origin' => $source_language, 'target' => $target_language, 'status' => CMS_REQUEST_WAITING_FOR_PROJECT_CREATION));
             if ($project->errors && count($project->errors)) {
                 $res['errors'] = $project->errors;
             }
             return $res;
         }
     }
     return 0;
 }
开发者ID:crazyyy,项目名称:octagram,代码行数:54,代码来源:wpml-string-translation.class.php


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