本文整理汇总了PHP中TranslationProxy::get_current_service_batch_name_max_length方法的典型用法代码示例。如果您正苦于以下问题:PHP TranslationProxy::get_current_service_batch_name_max_length方法的具体用法?PHP TranslationProxy::get_current_service_batch_name_max_length怎么用?PHP TranslationProxy::get_current_service_batch_name_max_length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TranslationProxy
的用法示例。
在下文中一共展示了TranslationProxy::get_current_service_batch_name_max_length方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build_translation_options
private function build_translation_options()
{
global $sitepress, $wpdb;
$basket_items_number = TranslationProxy_Basket::get_basket_items_count(true);
$basket_name_max_length = TranslationProxy::get_current_service_batch_name_max_length();
if ($basket_items_number > 0) {
$source_language = TranslationProxy_Basket::get_source_language();
$basket_name_placeholder = sprintf(__("%s|WPML|%s", 'wpml-translation-management'), get_option('blogname'), $source_language);
$basket = new WPML_Translation_Basket($wpdb);
$basket_name_placeholder = esc_attr($basket->get_unique_basket_name($basket_name_placeholder, $basket_name_max_length));
?>
<h3>2. <?php
_e('Choose translation options', 'wpml-translation-management');
?>
</h3>
<form method="post" id="translation-jobs-translators-form" name="translation-jobs-translators" action="">
<input type="hidden" name="icl_tm_action" value="send_all_jobs"/>
<label for="basket_name"><strong><?php
_e('Batch name', 'wpml-translation-management');
?>
:</strong></label>
<input id="basket_name"
name="basket_name"
type="text"
style="width: 40%;"
value="<?php
echo $basket_name_placeholder;
?>
"
maxlength="<?php
echo $basket_name_max_length;
?>
"
placeholder="<?php
echo $basket_name_placeholder;
?>
">
<br/><span class="description"><?php
_e('Give a name to the batch. If omitted, the default name will be applied.', 'wpml-translation-management');
?>
</span>
<table class="widefat fixed" id="icl-translation-translators" cellspacing="0">
<thead>
<tr>
<th scope="col" width="15%"><?php
_e('Language', 'wpml-translation-management');
?>
</th>
<th scope="col"><?php
_e('Translator', 'wpml-translation-management');
?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="col"><?php
_e('Language', 'wpml-translation-management');
?>
</th>
<th scope="col"><?php
_e('Translator', 'wpml-translation-management');
?>
</th>
</tr>
</tfoot>
<?php
$basket_languages = TranslationProxy_Basket::get_target_languages();
if ($basket_languages) {
?>
<tbody>
<?php
$target_languages = $sitepress->get_active_languages();
foreach ($target_languages as $key => $lang) {
if (!in_array($lang['code'], $basket_languages)) {
unset($target_languages[$key]);
}
}
foreach ($target_languages as $lang) {
if ($lang['code'] === TranslationProxy_Basket::get_source_language()) {
continue;
}
?>
<tr>
<td><strong><?php
echo $lang['display_name'];
?>
</strong></td>
<td>
<label for="<?php
echo esc_attr('translator[' . $lang['code'] . ']');
?>
">
<?php
_e('Translate by', 'wpml-translation-management');
?>
</label>
<?php
//.........这里部分代码省略.........
示例2: check_basket_name
/**
* Ajax handler for checking if a current basket/batch name is valid for use with the currently used translation
* service.
*
* @uses \WPML_Translation_Basket::check_basket_name
*/
function check_basket_name()
{
$basket_name = filter_input(INPUT_POST, 'basket_name', FILTER_SANITIZE_STRING);
$basket_name_max_length = TranslationProxy::get_current_service_batch_name_max_length();
wp_send_json_success($this->basket->check_basket_name($basket_name, $basket_name_max_length));
}
示例3: check_basket_name
public function check_basket_name()
{
$basket_name = filter_input(INPUT_POST, 'basket_name', FILTER_SANITIZE_STRING);
$basket_name_max_length = TranslationProxy::get_current_service_batch_name_max_length();
$result = array('modified' => false, 'valid' => true, 'message' => '', 'new_value' => '');
$old_value = $basket_name;
$basket_name = strip_tags($basket_name);
if ($old_value != $basket_name) {
$result['modified'] = true;
$result['new_value'] = $basket_name;
}
if (strlen($basket_name) > $basket_name_max_length) {
$result['valid'] = false;
$result['message'] = sprintf(__('The length of the batch name exceeds the maximum length of %s', 'wpml-translation-management'), $basket_name_max_length);
} elseif (TranslationProxy::get_batch_id_from_name($basket_name)) {
$result['valid'] = true;
$result['modified'] = true;
$result['new_value'] = TranslationProxy_Basket::get_unique_basket_name($basket_name, $basket_name_max_length);
$result['message'] = __('This batch name already exists and was modified to ensure unique naming', 'wpml-translation-management');
} elseif (count($basket_name_array = explode('|', $basket_name)) == 1) {
$result['valid'] = true;
$result['modified'] = true;
$result['new_value'] = TranslationProxy_Basket::get_unique_basket_name($basket_name, $basket_name_max_length);
$result['message'] = __('The batch name was appended with the source language of its elements.', 'wpml-translation-management');
}
wp_send_json_success($result);
}
示例4: get_unique_basket_name
/**
* Returns a unique name derived from an input name for a Translation Proxy Basket
*
* @param bool $basket_name
* @param bool|int $max_length
*
* @return bool|string
*/
public static function get_unique_basket_name($basket_name = false, $max_length = false)
{
if (!$max_length) {
$max_length = TranslationProxy::get_current_service_batch_name_max_length();
}
$basket_name_array = explode('|', $basket_name);
//if we just have some user entered string not in our format we add the information to it
if (count($basket_name_array) == 1) {
$basket_name = $basket_name . '|' . self::get_source_language();
} elseif (!is_numeric($basket_name_array[count($basket_name_array) - 1]) && $basket_name_array[count($basket_name_array) - 1] != self::get_source_language()) {
//if we do not have a numeric suffix and also do not have the source language as the last entry we add it.
$basket_name = $basket_name . '|' . self::get_source_language();
} elseif (is_numeric($basket_name_array[count($basket_name_array) - 1]) && $basket_name_array[count($basket_name_array) - 2] != self::get_source_language()) {
//if we have a possible suffix we check whether the language has been added in the appropriate place if not we dont see it as a suffix and add our language at the end
$basket_name = $basket_name . '|' . self::get_source_language();
}
if (!$basket_name) {
self::get_basket();
if (isset(self::$basket['name'])) {
$basket_name = self::$basket['name'];
}
}
if (strlen($basket_name) > $max_length) {
$basket_name = self::sanitize_basket_name($basket_name, $max_length);
}
if (TranslationProxy::get_batch_id_from_name($basket_name)) {
$suffix = 2;
$basket_name = self::sanitize_basket_name($basket_name, $max_length - strlen((string) $suffix) - 1);
while (TranslationProxy::get_batch_id_from_name($basket_name . '|' . $suffix)) {
$suffix++;
$basket_name = self::sanitize_basket_name($basket_name, $max_length - strlen((string) $suffix) - 1);
}
return $basket_name . '|' . $suffix;
}
return $basket_name;
}