本文整理汇总了PHP中TranslationProxy::translator_selection_available方法的典型用法代码示例。如果您正苦于以下问题:PHP TranslationProxy::translator_selection_available方法的具体用法?PHP TranslationProxy::translator_selection_available怎么用?PHP TranslationProxy::translator_selection_available使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TranslationProxy
的用法示例。
在下文中一共展示了TranslationProxy::translator_selection_available方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_translator_name
public static function get_translator_name($translator_id)
{
if (TranslationProxy::translator_selection_available()) {
$lang_status = self::get_language_pairs();
if ($lang_status) {
foreach ($lang_status as $lp) {
$lp_trans = !empty($lp['translators']) ? $lp['translators'] : array();
foreach ($lp_trans as $tr) {
$translators[$tr['id']] = $tr['nickname'];
}
}
}
}
return isset($translators[$translator_id]) ? $translators[$translator_id] : false;
}
示例2: build_content_translators
public function build_content_translators()
{
global $sitepress, $iclTranslationManagement, $wpdb, $current_user;
$selected_translator = $iclTranslationManagement->get_selected_translator();
$active_service = $this->active_service;
$service_name = $this->service_name;
if (current_user_can('list_users')) {
add_filter('icl_translation_services_button', array($this, 'icl_local_add_translator_button'));
add_filter('icl_translation_services_button', array('TranslationProxy', 'get_current_service_info'));
$only_local_translators = $active_service && (!TranslationProxy_Service::is_authenticated($active_service) || $active_service && !$active_service->has_translator_selection);
?>
<div id="icl-your-translators">
<?php
if ($active_service && TranslationProxy::translator_selection_available()) {
if ($only_local_translators) {
$translation_dashboard_url = "admin.php?page=" . WPML_TM_FOLDER . "/menu/main.php&sm=dashboard";
$translation_dashboard_link = sprintf('<a href="%s">' . __('Translation Dashboard', 'wpml-translation-management') . '</a>', $translation_dashboard_url);
$service_html = '<p>';
$service_html .= sprintf(__('This section is for selecting WPML (local) translators only. If you wish to use %s, please go to %s.'), '<strong>' . $service_name . '</strong>', $translation_dashboard_link);
$service_html .= '</p>';
} else {
$service_html = TranslationProxy::get_service_translators_info();
}
ICL_AdminNotifier::display_instant_message($service_html);
}
if ($selected_translator && $selected_translator->ID) {
// Edit form
echo '<h3>' . __('Edit translator', 'wpml-translation-management') . '</h3>';
echo '<form id="icl_tm_adduser" method="post" action="">' . "\r\n";
echo $this->icl_local_edit_translator_form('edit', $selected_translator) . "\r\n";
echo '</form>' . "\r\n";
} else {
// Services add translator form
// Services hook
$services_buttons = apply_filters('icl_translation_services_button', array());
if (!empty($services_buttons)) {
if (!$only_local_translators) {
// Toggle button
echo '<input type="submit" class="button secondary" id="icl_add_translator_form_toggle" value="' . __('Add Translator', 'wpml-translation-management') . ' »" />' . "\r\n";
}
// Toggle div start
$form_classes = array('translator-form-wrapper');
if (!isset($_GET['service']) && !$only_local_translators) {
$form_classes[] = 'hidden';
}
echo '<div id="icl_add_translator_form_wrapper" class="' . implode(' ', $form_classes) . '">';
// Open form
echo '<form id="icl_tm_adduser" method="post" action="">';
// 'From' and 'To' languages dropdowns
$languages = $sitepress->get_active_languages();
$from = '<label>' . __('From language:', 'wpml-translation-management') . ' <select name="from_lang" id="edit-from">' . "\r\n" . '<option value="0">' . __('Choose', 'wpml-translation-management') . '</option>' . "\r\n";
$to = '<label>' . __('To language:', 'wpml-translation-management') . ' <select name="to_lang" id="edit-to">' . "\r\n" . '<option value="0">' . __('Choose', 'wpml-translation-management') . '</option>' . "\r\n";
foreach ($languages as $language) {
// select language from request
$selected_from = isset($_GET['icl_lng']) && $_GET['icl_lng'] == $language['code'] ? ' selected="selected"' : '';
$from .= '<option ' . $selected_from . ' value="' . $language['code'] . '"' . @strval($selected_from) . '>' . $language['display_name'] . '</option>' . "\r\n";
$to .= '<option value="' . $language['code'] . '"' . '>' . $language['display_name'] . '</option>' . "\r\n";
}
echo $from . '</select></label>' . "\r\n";
echo $to . '</select></label>' . "\r\n";
if (!$only_local_translators) {
// Services radio boxes
echo '<h4 style="margin-bottom:5px;">' . __('Select translation service', 'wpml-translation-management') . '</h4>' . "\r\n";
} else {
echo '<h4 style="margin-bottom:5px;">' . __('Select translators', 'wpml-translation-management') . '</h4>' . "\r\n";
}
foreach ($services_buttons as $service => $button) {
if ($only_local_translators && $service != 'local') {
continue;
}
if (!isset($button['has_translator_selection']) || $button['has_translator_selection']) {
$selected = $only_local_translators && $service == 'local' || isset($_GET['service']) && $_GET['service'] == $service ? ' checked="checked"' : '';
$title = array();
$has_translator_selection = isset($service['has_translator_selection']) ? $service['has_translator_selection'] : false;
echo '<div style="margin-bottom:5px;">';
$display = $only_local_translators && $service == 'local' ? ' style="display:none;"' : '';
echo '<input type="radio"
id="radio-' . $service . '"
name="services"
data-has_translator_selection="' . $has_translator_selection . '"
value="' . $service . '"' . $selected . $display . ' />';
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";
//.........这里部分代码省略.........
示例3: translators_dropdown
public static function translators_dropdown($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();
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', 'sitepress'), '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', 'sitepress'), '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', 'sitepress'));
$translators = array_merge($translators, self::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', 'sitepress');
$dropdown .= ')';
}
$dropdown .= '</option>';
}
$dropdown .= '</select>';
} catch (TranslationProxy_Api_Error $ex) {
$dropdown .= __('Translation Proxy error', 'sitepress') . ': ' . $ex->getMessage();
} catch (Exception $ex) {
$dropdown .= __('Error', 'sitepress') . ': ' . $ex->getMessage();
}
if ($add_label) {
$dropdown = '<label for="' . esc_attr($id) . '">' . __('Translation jobs for:', 'wpml-translation-management') . '</label> ' . $dropdown;
}
if ($echo) {
//.........这里部分代码省略.........
示例4: get_translator_name
public static function get_translator_name($translator_id)
{
static $translators;
if (TranslationProxy::translator_selection_available()) {
$lang_status = self::get_language_pairs();
if (is_null($translators) && $lang_status) {
foreach ($lang_status as $lp) {
if (!empty($lp['translators'])) {
foreach ($lp['translators'] as $tr) {
$translators[$tr['id']] = $tr['nickname'];
}
}
}
}
}
if (isset($translators[$translator_id])) {
return $translators[$translator_id];
} else {
return false;
}
}
示例5: service_requires_authentication
private function service_requires_authentication()
{
$result = false;
$service_has_translators = TranslationProxy::translator_selection_available();
if (!$service_has_translators) {
$has_custom_fields = TranslationProxy::has_custom_fields();
$custom_fields_data = TranslationProxy::get_custom_fields_data();
$result = $has_custom_fields && !$custom_fields_data;
}
return $result;
}
示例6: translation_service_has_translators
/**
* @param $active_service
*
* @return bool
*/
private function translation_service_has_translators($active_service)
{
return $active_service && TranslationProxy::translator_selection_available();
}