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


PHP ICanLocalizeQuery::cms_create_message方法代码示例

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


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

示例1: ICanLocalizeQuery

 function send_comment_to_translation($comment_id, $to_language)
 {
     global $wpdb, $sitepress_settings, $sitepress;
     $iclq = new ICanLocalizeQuery($sitepress_settings['site_id'], $sitepress_settings['access_key']);
     $from_lang = $sitepress->get_language_details($this->user_language);
     $to_lang = $sitepress->get_language_details($to_language);
     $from_lang_server = ICL_Pro_Translation::server_languages_map($from_lang['english_name']);
     $to_lang_server = ICL_Pro_Translation::server_languages_map($to_lang['english_name']);
     $body = $wpdb->get_var("SELECT comment_content FROM {$wpdb->comments} WHERE comment_ID={$comment_id}");
     $rid = $iclq->cms_create_message($body, $from_lang_server, $to_lang_server);
     if ($rid > 0) {
         // does this comment already exist in the messages status queue?
         $msid = $wpdb->get_var("SELECT id FROM {$wpdb->prefix}icl_message_status WHERE object_type='comment' AND object_id={$comment_id}");
         if ($msid) {
             $wpdb->update($wpdb->prefix . 'icl_message_status', array('rid' => $rid, 'md5' => md5($body), 'status' => MESSAGE_TRANSLATION_IN_PROGRESS), array('id' => $msid));
         } else {
             $wpdb->insert($wpdb->prefix . 'icl_message_status', array('rid' => $rid, 'object_id' => $comment_id, 'from_language' => $this->user_language, 'to_language' => $to_language, 'md5' => md5($body), 'object_type' => 'comment', 'status' => MESSAGE_TRANSLATION_IN_PROGRESS));
         }
     }
 }
开发者ID:batruji,项目名称:metareading,代码行数:20,代码来源:functions.php

示例2: wpml_send_content_to_translation

/**
 *  Sends piece of content (string) to professional translation @ ICanLocalize
 *
 * @since 1.3
 * @package WPML
 * @subpackage WPML API
 *
 * @param string $string String
 * @param string $from_language Language to translate from
 * @param int $content_id Content ID
 * @param string $content_type Content Type
 * @param string $to_language Language to translate into
 *
 * @return int request id
 *  */
function wpml_send_content_to_translation($string, $content_id, $content_type, $from_language, $to_language)
{
    global $sitepress, $sitepress_settings, $wpdb;
    if (!_wpml_api_allowed_content_type($content_type)) {
        return 0;
        //WPML_API_INVALID_CONTENT_TYPE
    }
    if (!$sitepress->get_language_details($from_language) || !$sitepress->get_language_details($to_language)) {
        return 0;
        // WPML_API_INVALID_LANGUAGE_CODE
    }
    $from_lang = $sitepress->get_language_details($from_language);
    $to_lang = $sitepress->get_language_details($to_language);
    $from_lang_server = apply_filters('icl_server_languages_map', $from_lang['english_name']);
    $to_lang_server = apply_filters('icl_server_languages_map', $to_lang['english_name']);
    $iclq = new ICanLocalizeQuery($sitepress_settings['site_id'], $sitepress_settings['access_key']);
    $rid = $iclq->cms_create_message($string, $from_lang_server, $to_lang_server);
    if ($rid > 0) {
        // does this comment already exist in the messages status queue?
        $msid = $wpdb->get_var($wpdb->prepare(" SELECT id\n                                                FROM {$wpdb->prefix}icl_message_status\n                                                WHERE object_type = %s\n                                                  AND object_id = %d", $content_type, $content_id));
        if ($msid) {
            $wpdb->update($wpdb->prefix . 'icl_message_status', array('rid' => $rid, 'md5' => md5($string), 'status' => MESSAGE_TRANSLATION_IN_PROGRESS), array('id' => $msid));
        } else {
            $wpdb->insert($wpdb->prefix . 'icl_message_status', array('rid' => $rid, 'object_id' => $content_id, 'from_language' => $from_language, 'to_language' => $to_language, 'md5' => md5($string), 'object_type' => $content_type, 'status' => MESSAGE_TRANSLATION_IN_PROGRESS));
        }
    }
    return $rid;
}
开发者ID:Junaid-Farid,项目名称:gocnex,代码行数:43,代码来源:wpml-api.php


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