function qtrans_join($texts)
 {
     if (!is_array($texts)) {
         $texts = qtranxf_split($texts);
     }
     return qtranxf_join_b($texts);
 }
 function qtrans_join($texts)
 {
     if (!is_array($texts)) {
         $texts = qtranxf_split($texts);
     }
     $char = qtransx_getTagCharacter();
     if ($char == '{') {
         return qtranxf_join_s($texts);
     }
     return qtranxf_join_b($texts);
 }
Пример #3
0
function qtranxf_slug_multilingual($name)
{
    global $q_config;
    $results = qtranxf_slug_get_translations($name);
    if (empty($results)) {
        return $name;
    }
    $slugs = array();
    foreach ($results as $row) {
        $slugs[$row->lang] = $row->slug;
    }
    foreach ($q_config['enabled_languages'] as $lang) {
        if (isset($slugs[$lang])) {
            continue;
        }
        $slugs[$lang] = $name;
    }
    return qtranxf_join_b($slugs);
}
Пример #4
0
/**
 * Prepare multilingal text leaving new line outside of language tags '[:]'.
*/
function qtranxf_join_byline($texts)
{
    $text = qtranxf_allthesame($texts);
    if (!is_null($text)) {
        return $text;
    }
    $lines = array();
    foreach ($texts as $lang => $text) {
        $lines[$lang] = preg_split('/\\r?\\n\\r?/', $text);
    }
    $text = '';
    for ($i = 0; true; ++$i) {
        $done = true;
        $ln = array();
        foreach ($lines as $lang => $txts) {
            if (sizeof($txts) <= $i) {
                continue;
            }
            $done = false;
            $t = $txts[$i];
            if (!$t || $t == '') {
                continue;
            }
            $ln[$lang] = $t;
        }
        if ($done) {
            break;
        }
        $char = qtransx_getTagCharacter();
        if ($char == '{') {
            $text .= qtranxf_join_b($ln) . PHP_EOL;
        } else {
            $text .= qtranxf_join_s($ln) . PHP_EOL;
        }
    }
    return $text;
}
Пример #5
0
function qtranxf_trim_words($text, $num_words, $more, $original_text)
{
    global $q_config;
    //qtranxf_dbg_log('qtranxf_trim_words: $text: ',$text);
    //qtranxf_dbg_log('qtranxf_trim_words: $original_text: ',$original_text);
    $blocks = qtranxf_get_language_blocks($original_text);
    //qtranxf_dbg_log('qtranxf_trim_words: $blocks: ',$blocks);
    if (count($blocks) <= 1) {
        return $text;
    }
    $lang = $q_config['language'];
    $texts = qtranxf_split_blocks($blocks);
    foreach ($texts as $key => $txt) {
        $texts[$key] = wp_trim_words($txt, $num_words, $more);
    }
    return qtranxf_join_b($texts);
    //has to be 'b', because 'c' gets stripped in /wp-admin/includes/nav-menu.php:182: esc_html( $item->description )
}
Пример #6
0
/**
 * @param (string) $name - rawurlencoded post name or other slug (not permastruct).
 * @return string - multilingual urldecoded value for post name or other slug.
 */
function qtranxf_slug_multilingual($name)
{
    global $q_config;
    $name = urldecode($name);
    $slugs = qtranxf_slug_get_translations(qtranxf_slug_encode($name));
    if (empty($slugs)) {
        return $name;
    }
    foreach ($q_config['enabled_languages'] as $lang) {
        if (isset($slugs[$lang])) {
            //$slugs[$lang] = urldecode($slugs[$lang]);
        } else {
            $slugs[$lang] = $name;
        }
    }
    return urldecode(qtranxf_join_b($slugs));
}
Пример #7
0
/**
 * @param string   $format Format to display the date or time https://codex.wordpress.org/Formatting_Date_and_Time.
 * @param bool|int $i Optional. Unix timestamp. Default false.
 * @param bool     $gmt Optional. Whether to use GMT timezone. Default false.
 *
 * @return string multilingual string with date/time formatted for each language.
 */
function qtranxf_date_i18n_multilinual($fmt, $i = false, $gmt = false)
{
    global $q_config;
    if (!$i) {
        $i = time();
    }
    $t = array();
    $d = date_i18n($fmt, $i, $gmt);
    foreach ($q_config['enabled_languages'] as $lang) {
        $t[$lang] = empty($q_config['date_i18n'][$fmt][$lang]) ? $d : date_i18n($q_config['date_i18n'][$fmt][$lang], $i, $gmt);
    }
    return qtranxf_join_b($t);
}
function qts_UpdateOrder($order_id)
{
    global $wpdb;
    $orders = get_option('qts_orders');
    if (!is_array($orders)) {
        return false;
    }
    foreach ($orders as $key => $order) {
        // search for wanted order
        if ($order['order']['order_id'] != $order_id) {
            continue;
        }
        // query server for updates
        $order['order']['order_url'] = get_option('home');
        $result = qts_queryQS(QTS_RETRIEVE_TRANSLATION, $order['order']);
        if (isset($result['order_comment'])) {
            $orders[$key]['status'] = $result['order_comment'];
        }
        // update db if post is updated
        if (isset($result['order_status']) && $result['order_status'] == QTS_STATE_CLOSED) {
            $order['post_id'] = intval($order['post_id']);
            $p = get_post($order['post_id']);
            $post =& $p;
            $title = qtranxf_split($post->post_title);
            $content = qtranxf_split($post->post_content);
            $title[$order['target_language']] = $result['order_translated_title'];
            $content[$order['target_language']] = $result['order_translated_text'];
            $post->post_title = qtranxf_join_b($title);
            $post->post_content = qtranxf_join_b($content);
            $wpdb->show_errors();
            $wpdb->query($wpdb->prepare('UPDATE ' . $wpdb->posts . ' SET post_title = %s, post_content = %s WHERE ID = %d', $post->post_title, $post->post_content, $post->ID));
            wp_cache_add($post->ID, $post, 'posts');
            unset($orders[$key]);
        }
        update_option('qts_orders', $orders);
        return true;
    }
    return false;
}