本文整理汇总了PHP中TranslationManagement::get_blog_translators方法的典型用法代码示例。如果您正苦于以下问题:PHP TranslationManagement::get_blog_translators方法的具体用法?PHP TranslationManagement::get_blog_translators怎么用?PHP TranslationManagement::get_blog_translators使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TranslationManagement
的用法示例。
在下文中一共展示了TranslationManagement::get_blog_translators方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: translation_send_strings_local
public static function translation_send_strings_local($string_ids, $target, $translator = null, $basket_name = null)
{
global $wpdb;
static $site_translators;
if (!isset($site_translators)) {
$site_translators = TranslationManagement::get_blog_translators();
}
$mkey = $wpdb->prefix . 'strings_notification';
$lkey = $wpdb->prefix . 'language_pairs';
$slang = TranslationProxy_Basket::get_source_language();
foreach ($string_ids as $string_id) {
$batch_id = TranslationProxy_Batch::update_translation_batch($basket_name);
$added = icl_add_string_translation($string_id, $target, null, ICL_TM_WAITING_FOR_TRANSLATOR, $translator, 'local', $batch_id);
if ($added) {
foreach ($site_translators as $key => $st) {
$ulangs = isset($st->{$lkey}) ? $st->{$lkey} : false;
if (!empty($ulangs) && !empty($ulangs[$slang][$target])) {
$enot = isset($st->{$mkey}) ? $st->{$mkey} : false;
if (empty($enot[$slang][$target])) {
self::translator_notification($st, $slang, $target);
$enot[$slang][$target] = 1;
$site_translators[$key]->{$mkey} = $enot;
update_option($wpdb->prefix . 'icl_translators_cached', $site_translators);
}
}
}
}
}
return 1;
}
示例2: new_job_any
function new_job_any($job_id)
{
global $iclTranslationManagement, $sitepress, $wpdb;
$job = $iclTranslationManagement->get_translation_job($job_id);
$translators = TranslationManagement::get_blog_translators(array('to' => $job->language_code));
$edit_url = apply_filters('icl_job_edit_url', admin_url('admin.php?page=' . WPML_TM_FOLDER . '/menu/translations-queue.php&job_id=' . $job_id), $job_id);
foreach ($translators as $t) {
if ($job->manager_id == $t->ID) {
continue;
}
// get current user admin language
$user_language = $sitepress->get_user_admin_language($t->ID);
// override locale
$sitepress->switch_locale($user_language);
$lang_from = $wpdb->get_var($wpdb->prepare("SELECT name FROM {$wpdb->prefix}icl_languages_translations WHERE language_code='%s' AND display_language_code='%s'", $job->source_language_code, $user_language));
$lang_to = $wpdb->get_var($wpdb->prepare("SELECT name FROM {$wpdb->prefix}icl_languages_translations WHERE language_code='%s' AND display_language_code='%s'", $job->language_code, $user_language));
$post_link = $iclTranslationManagement->tm_post_permalink($job->original_doc_id);
if ($post_link != "") {
$post_link = sprintf(__("\nView the original document in %s here: %s\n", 'sitepress'), $lang_from, $post_link);
}
$mail['to'] = $t->display_name . ' <' . $t->user_email . '>';
//$mail['to'] = $t->user_email;
$mail['subject'] = sprintf(__('New translation job from %s', 'sitepress'), get_bloginfo('name'));
$mail['body'] = sprintf(__("New job available from %s to %s.\n%s\nStart editing: %s", 'sitepress'), $lang_from, $lang_to, $post_link, $edit_url);
$mail['type'] = 'translator';
$this->send_mail($mail, $user_language);
//restore locale
$sitepress->switch_locale();
}
}
示例3: get_blog_translators
/**
* @param array $args
*
* @return array
*/
function get_blog_translators($args = array())
{
$translators = TranslationManagement::get_blog_translators($args);
foreach ($translators as $key => $user) {
$translators[$key] = isset($user->data) ? $user->data : $user;
}
return $translators;
}
示例4: new_job_notification_mail
public function new_job_notification_mail($job_id)
{
global $iclTranslationManagement, $sitepress, $wpdb;
$job = $iclTranslationManagement->get_translation_job(array($job_id));
if (isset($job->language_code)) {
$translators = TranslationManagement::get_blog_translators(array('to' => $job->language_code));
} else {
$translators = array();
}
$edit_url = apply_filters('icl_job_edit_url', admin_url('admin.php?page=' . WPML_TM_FOLDER . '/menu/translations-queue.php&job_id=' . $job_id), $job_id);
foreach ($translators as $t) {
if (isset($job->manager_id) && isset($t->ID) && $job->manager_id == $t->ID) {
continue;
}
if (!isset($job->source_language_code) || !isset($job->language_code) || !isset($t->language_pairs) || !isset($t->language_pairs[$job->source_language_code][$job->language_code])) {
continue;
}
// get current user admin language
$user_language = $sitepress->get_user_admin_language($t->ID);
// override locale
$sitepress->switch_locale($user_language);
list($lang_from, $lang_to) = $this->get_lang_to_from($job, $user_language);
$post_link = $iclTranslationManagement->tm_post_permalink($job->original_doc_id);
if ($post_link != "") {
$post_link = sprintf(__("\nView the original document in %s here: %s\n", 'sitepress'), $lang_from, $post_link);
}
$mail['to'] = $t->display_name . ' <' . $t->user_email . '>';
//$mail['to'] = $t->user_email;
$mail['subject'] = sprintf(__('New translation job from %s', 'sitepress'), get_bloginfo('name'));
$mail['body'] = sprintf(__("New job available from %s to %s.\n%s\nStart editing: %s", 'sitepress'), $lang_from, $lang_to, $post_link, $edit_url);
$mail['type'] = 'translator';
$this->enqueue_mail($mail, $user_language);
//restore locale
$sitepress->switch_locale();
}
}
示例5: _e
<?php
// shows only when translation polling is on and there are translations in progress
$ICL_Pro_Translation->get_icl_manually_tranlations_box('icl_cyan_box');
?>
<?php
if (count($active_languages = $sitepress->get_active_languages()) > 1) {
?>
<div><a href="javascript:void(0)" onclick="jQuery(this).parent().next('.wrapper').slideToggle();"
style="display:block; padding:5px; border: 1px solid #eee; margin-bottom:2px; background-color: #F7F7F7;"><?php
_e('Content translation', 'wpml-translation-management');
?>
</a>
</div>
<div class="wrapper" style="display:none; padding: 5px 10px; border: 1px solid #eee; border-top: 0px; margin:-11px 0 2px 0;">
<?php
$your_translators = TranslationManagement::get_blog_translators();
$other_service_translators = TranslationManagement::icanlocalize_translators_list();
if (!empty($your_translators) || !empty($other_service_translators)) {
echo '<p><strong>' . __('Your translators', 'wpml-translation-management') . '</strong></p><ul>';
if (!empty($your_translators)) {
foreach ($your_translators as $your_translator) {
echo '<li>';
if ($current_user->ID == $your_translator->ID) {
$edit_link = 'profile.php';
} else {
$edit_link = esc_url(add_query_arg('wp_http_referer', urlencode(esc_url(stripslashes($_SERVER['REQUEST_URI']))), "user-edit.php?user_id={$your_translator->ID}"));
}
echo '<a href="' . $edit_link . '"><strong>' . $your_translator->display_name . '</strong></a> - ';
foreach ($your_translator->language_pairs as $from => $lp) {
$tos = array();
foreach ($lp as $to => $null) {
示例6: _icl_translation_send_strings_local
function _icl_translation_send_strings_local($string_ids, $target)
{
global $wpdb, $sitepress_settings;
static $site_translators;
$site_translators = TranslationManagement::get_blog_translators();
$mkey = $wpdb->prefix . 'strings_notification';
$lkey = $wpdb->prefix . 'language_pairs';
$slang =& $sitepress_settings['st']['strings_language'];
foreach ($string_ids as $string_id) {
$added = icl_add_string_translation($string_id, $target, NULL, ICL_STRING_TRANSLATION_WAITING_FOR_TRANSLATOR);
if ($added) {
foreach ($site_translators as $key => $st) {
$ulangs = isset($st->{$lkey}) ? $st->{$lkey} : false;
if (!empty($ulangs) && !empty($ulangs[$slang][$target])) {
$enot = isset($st->{$mkey}) ? $st->{$mkey} : false;
if (empty($enot[$sitepress_settings['st']['strings_language']][$target])) {
_icl_st_translator_notification($st, $sitepress_settings['st']['strings_language'], $target);
$enot[$sitepress_settings['st']['strings_language']][$target] = 1;
$site_translators[$key]->{$mkey} = $enot;
update_option($wpdb->prefix . 'icl_translators_cached', $site_translators);
//printf("Notify %d for %s -> %s <br />", $st->ID, $sitepress_settings['st']['strings_language'], $target);
} else {
//printf("Already notified %d for %s -> %s <br />", $st->ID, $sitepress_settings['st']['strings_language'], $target);
}
}
}
}
}
return 1;
}
示例7: icl_local_edit_translator_form
/**
* Add/edit local translator form
*
* @global object $sitepress
* @param string $action add|edit
* @param object $selected_translator
* @return mixed
*/
function icl_local_edit_translator_form($action = 'add', $selected_translator = 0)
{
global $sitepress, $iclTranslationManagement;
$blog_users_nt = TranslationManagement::get_blog_not_translators();
$blog_users_t = TranslationManagement::get_blog_translators();
$output = '';
$return['name'] = __('Local', 'wpml-translation-management');
$return['description'] = __('Your own translators', 'wpml-translation-management');
if ($action == 'add' && empty($blog_users_nt)) {
$output .= '<span class="updated fade" style="padding:4px">' . __('All WordPress users are already translators. To add more translators, first create accounts for them.', 'wpml-translation-management') . '</span>';
$return['content'] = $output;
return $return;
}
$output .= '<div id="icl_tm_add_user_errors">
<span class="icl_tm_no_to">' . __('Select user.', 'wpml-translation-management') . '</span>
</div>
<input type="hidden" name="icl_tm_action" value="' . $action . '_translator" />' . wp_nonce_field($action . '_translator', $action . '_translator_nonce', true, false);
if (!$selected_translator) {
$output .= '<input type="hidden" id="icl_tm_selected_user" name="user_id" />';
$output .= '<input type="text" id="icl_quick_src_users" placeholder="' . esc_attr__('search', 'sitepress') . '" />';
$output .= '<img style="display:none;margin-left:3px;" src="' . esc_url(admin_url('images/wpspin_light.gif')) . '" class="waiting" alt="" />';
if (count($blog_users_nt) <= 10) {
$cssheight = 20 * count($blog_users_nt) + 5;
$output .= '<select size="10" class="icl_tm_auto_suggest_dd" style="visibility:hidden;height:' . $cssheight . 'px">';
foreach ($blog_users_nt as $u) {
$output .= '<option value="' . $u->ID . '|' . esc_attr($u->display_name) . '">' . $u->display_name . ' (' . $u->user_login . ')' . '</option>';
}
$output .= '</select>';
}
$output .= '<p>' . __('To add translators, they must first have accounts in WordPress. Translators can have any editing privileges, including subscriber.') . '</p>';
} else {
$output .= '<span class="updated fade" style="padding:4px">' . sprintf(__('Editing language pairs for <strong>%s</strong>', 'wpml-translation-management'), esc_html($selected_translator->display_name) . ' (' . $selected_translator->user_login . ')') . '</span>';
$output .= '<input type="hidden" name="user_id" value="' . $selected_translator->ID . '" />';
}
if ($selected_translator) {
$output .= '<br />
<div class="icl_tm_lang_pairs"';
if ($selected_translator) {
$output .= ' style="display:block"';
}
$output .= '>
<ul>';
foreach ($sitepress->get_active_languages() as $from_lang) {
$output .= '<li>
<label><input class="icl_tm_from_lang" type="checkbox"';
if ($selected_translator && 0 < @count($selected_translator->language_pairs[$from_lang['code']])) {
$output .= ' checked="checked"';
}
$output .= ' /> ';
$output .= sprintf(__('From %s', 'wpml-translation-management'), $from_lang['display_name']) . '</label>
<div class="icl_tm_lang_pairs_to"';
if ($selected_translator && 0 < @count($selected_translator->language_pairs[$from_lang['code']])) {
$output .= ' style="display:block"';
}
$output .= '>
<small>' . __('to', 'wpml-translation-management') . '</small>
<ul>';
foreach ($sitepress->get_active_languages() as $to_lang) {
if ($from_lang['code'] == $to_lang['code']) {
continue;
}
$output .= '<li>
<label><input class="icl_tm_to_lang" type="checkbox" name="lang_pairs[' . $from_lang['code'] . '][' . $to_lang['code'] . ']" value="1"';
if ($selected_translator->ID && isset($selected_translator->language_pairs[$from_lang['code']][$to_lang['code']])) {
$output .= ' checked="checked"';
}
$output .= ' /> ';
$output .= $to_lang['display_name'] . '</label>
</li>';
}
$output .= '</ul>
</div>
</li>';
}
$output .= '</ul>';
$output .= '
<input class="button-primary" type="submit" value="';
$output .= $selected_translator ? esc_attr(__('Update', 'wpml-translation-management')) : esc_attr(__('Add as translator', 'wpml-translation-management'));
$output .= '" /> <input type="submit" value="' . __('Cancel', 'wpml-translation-management') . '" name="cancel" class="button-secondary" onclick="history.go(-1); return false;" />';
}
$return['content'] = $output;
return $action == 'edit' ? $output : $return;
}
示例8: build_content_translators
//.........这里部分代码省略.........
if (isset($button['name']) && $button['name']) {
$title[] = '<label for="radio-' . $service . '"' . $display . '> ' . $button['name'];
}
if (isset($button['description']) && $button['description']) {
$title[] = $button['description'];
}
if (isset($button['more_link']) && $button['more_link']) {
$title[] = $button['more_link'];
}
echo implode(' - ', $title) . "\r\n";
echo '</label>';
echo isset($button['content']) && $button['content'] ? $button['content'] . "\r\n" : '';
echo isset($button['messages']) && $button['messages'] ? $button['messages'] . "\r\n" : '';
if (isset($button['setup_url']) && $button['setup_url']) {
echo '<input type="hidden"
id="' . $service . '_setup_url"
name="' . $service . '_setup_url"
value="' . $button['setup_url'] . '"
/>' . "\r\n";
}
echo '</div>';
}
}
echo '<br style="clear:both;" />';
echo '<input id="icl_add_translator_submit" class="button-primary" type="submit" value="' . esc_attr(__('Add translator', 'wpml-translation-management')) . '" />' . "\r\n";
echo '</form>' . "\r\n";
echo '</div>' . "\r\n";
} else {
_e('No add translator interface available', 'wpml-translation-management');
}
}
// Translators lists
// Local translators
$blog_users_t = TranslationManagement::get_blog_translators();
if (TranslationProxy::translator_selection_available()) {
$other_service_translators = TranslationProxy_Translator::translation_service_translators_list();
}
?>
<?php
if (!empty($blog_users_t) || !empty($other_service_translators)) {
?>
<h3><?php
_e('Current translators', 'wpml-translation-management');
?>
</h3>
<table class="widefat fixed" cellspacing="0">
<thead>
<?php
$this->translators_head_foot_row();
?>
</thead>
<tfoot>
<?php
$this->translators_head_foot_row();
?>
</tfoot>
<tbody class="list:user user-list">
<?php
if (!empty($blog_users_t)) {
foreach ($blog_users_t as $bu) {
?>
<?php
if (!isset($trstyle) || $trstyle) {
$trstyle = '';
示例9: esc_attr
echo '<input type="hidden" id="' . $service . '_setup_url" name="' . $service . '_setup_url" value="' . $button['setup_url'] . '" />' . "\r\n";
}
echo '</div>';
}
echo '<br style="clear:both;" />';
echo '<input id="icl_add_translator_submit" class="button-primary" type="submit" value="' . esc_attr(__('Add translator', 'wpml-translation-management')) . '" />' . "\r\n";
echo '</form>' . "\r\n";
echo '</div>' . "\r\n";
} else {
_e('No add translator interface available', 'wpml-translation-management');
}
}
// Translators lists
// Local translators
$blog_users_nt = TranslationManagement::get_blog_not_translators();
$blog_users_t = TranslationManagement::get_blog_translators();
$other_service_translators = TranslationManagement::icanlocalize_translators_list();
?>
<?php
if (!empty($blog_users_t) || !empty($other_service_translators)) {
?>
<h3><?php
_e('Current translators', 'wpml-translation-management');
?>
</h3>
<table class="widefat fixed" cellspacing="0">
<thead>
<tr class="thead">
<th><?php
_e('Name', 'wpml-translation-management');
示例10: render
/**
* @param array $args
*
* @return string
*/
public function render($args = array())
{
$dropdown = '';
/** @var $from string|false */
/** @var $to string|false */
/** @var $classes string|false */
/** @var $id string|false */
/** @var $name string|false */
/** @var $selected bool */
/** @var $echo bool */
/** @var $add_label bool */
/** @var $services array */
/** @var $show_service bool */
/** @var $disabled bool */
/** @var $default_name bool|string */
/** @var $local_only bool */
//set default value for variables
$from = false;
$to = false;
$id = 'translator_id';
$name = 'translator_id';
$selected = 0;
$echo = true;
$add_label = false;
$services = array('local');
$show_service = true;
$disabled = false;
$default_name = false;
$local_only = false;
extract($args, EXTR_OVERWRITE);
$translators = array();
$id .= $from ? '_' . $from . ($to ? '_' . $to : '') : '';
try {
$translation_service = TranslationProxy::get_current_service();
$translation_service_id = TranslationProxy::get_current_service_id();
$translation_service_name = TranslationProxy::get_current_service_name();
$is_service_authenticated = TranslationProxy::is_service_authenticated();
//if translation service does not support translators choice, always shows first available
if (isset($translation_service->id) && !TranslationProxy::translator_selection_available() && $is_service_authenticated) {
$translators[] = (object) array('ID' => TranslationProxy_Service::get_wpml_translator_id($translation_service->id), 'display_name' => __('First available', 'wpml-translation-management'), 'service' => $translation_service_name);
} elseif (in_array($translation_service_id, $services) && $is_service_authenticated) {
$lang_status = TranslationProxy_Translator::get_language_pairs();
if (empty($lang_status)) {
$lang_status = array();
}
foreach ((array) $lang_status as $language_pair) {
if ($from && $from != $language_pair['from']) {
continue;
}
if ($to && $to != $language_pair['to']) {
continue;
}
if (!empty($language_pair['translators'])) {
if (1 < count($language_pair['translators'])) {
$translators[] = (object) array('ID' => TranslationProxy_Service::get_wpml_translator_id($translation_service->id), 'display_name' => __('First available', 'wpml-translation-management'), 'service' => $translation_service_name);
}
foreach ($language_pair['translators'] as $tr) {
if (!isset($_icl_translators[$tr['id']])) {
$translators[] = $_icl_translators[$tr['id']] = (object) array('ID' => TranslationProxy_Service::get_wpml_translator_id($translation_service->id, $tr['id']), 'display_name' => $tr['nickname'], 'service' => $translation_service_name);
}
}
}
}
}
if (in_array('local', $services)) {
$translators[] = (object) array('ID' => 0, 'display_name' => __('First available', 'wpml-translation-management'));
$translators = array_merge($translators, TranslationManagement::get_blog_translators(array('from' => $from, 'to' => $to)));
}
$translators = apply_filters('wpml_tm_translators_list', $translators);
$dropdown .= '<select id="' . esc_attr($id) . '" name="' . esc_attr($name) . '" ' . ($disabled ? 'disabled="disabled"' : '') . '>';
if ($default_name) {
$dropdown_selected = selected($selected, false, false);
$dropdown .= '<option value="" ' . $dropdown_selected . '>';
$dropdown .= esc_html($default_name);
$dropdown .= '</option>';
}
foreach ($translators as $t) {
if ($local_only && isset($t->service)) {
continue;
}
$current_translator = $t->ID;
$dropdown_selected = selected($selected, $current_translator, false);
$dropdown .= '<option value="' . $current_translator . '" ' . $dropdown_selected . '>';
$dropdown .= esc_html($t->display_name);
if ($show_service) {
$dropdown .= ' (';
$dropdown .= isset($t->service) ? $t->service : __('Local', 'wpml-translation-management');
$dropdown .= ')';
}
$dropdown .= '</option>';
}
$dropdown .= '</select>';
} catch (TranslationProxy_Api_Error $ex) {
$dropdown .= __('Translation Proxy error', 'wpml-translation-management') . ': ' . $ex->getMessage();
} catch (Exception $ex) {
//.........这里部分代码省略.........
示例11: regenerate_wrong_service_data
private function regenerate_wrong_service_data()
{
global $wpdb;
remove_filter('otgs_translation_get_services', 'filter_tp_services');
TranslationProxy::services(true);
$translators = $this->get_icl_translators();
$local_translators = TranslationManagement::get_blog_translators();
$icl_translator_ids = array();
$local_translator_ids = array();
foreach ($translators as $translator) {
$icl_translator_ids[] = $translator['id'];
}
foreach ($local_translators as $translator) {
$local_translator_ids[] = $translator->ID;
}
if ((bool) $icl_translator_ids === true) {
$icl_translators_snippet = " AND translator_id IN (" . wpml_prepare_in($icl_translator_ids) . ") ";
$local_translators_snippet = (bool) $local_translator_ids === true ? " AND translator_id NOT IN (" . wpml_prepare_in($local_translator_ids) . ') ' : '';
$wpdb->query($wpdb->prepare("\tUPDATE {$wpdb->prefix}icl_translation_status s\n\t\t\t\t\t\t\t\t\t\tSET s.translation_service = 'icl'\n\t\t\t\t\t\t\t\t\t\tWHERE s.status = %d\n\t\t\t\t\t\t\t\t\t\t\tAND s.translation_service != %d\n\t\t\t\t\t\t\t\t\t\t\t{$icl_translators_snippet}\n\t\t\t\t\t\t\t\t\t\t\t{$local_translators_snippet}", ICL_TM_IN_PROGRESS, $this->get_icl_service_id()));
}
}