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


PHP ICanLocalizeQuery::cms_requests方法代码示例

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


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

示例1: strtotime

 function poll_for_translations($force = false)
 {
     global $sitepress_settings, $sitepress, $wpdb;
     if (!$force) {
         // Limit to once per hour
         $toffset = strtotime(current_time('mysql')) - @intval($sitepress_settings['last_picked_up']) - 3600;
         if ($toffset < 0 || $force) {
             return 0;
         }
     }
     $iclq = new ICanLocalizeQuery($sitepress_settings['site_id'], $sitepress_settings['access_key']);
     $pending = $iclq->cms_requests();
     $fetched = 0;
     if (!empty($pending)) {
         foreach ($pending as $doc) {
             if (empty($doc['cms_id'])) {
                 // it's a string
                 $target = $wpdb->get_var($wpdb->prepare("SELECT target FROM {$wpdb->prefix}icl_core_status WHERE rid=%d", $doc['id']));
                 $__ld = $sitepress->get_language_details($target);
                 $language = $this->server_languages_map($__ld['english_name']);
                 $ret = $this->process_translated_string($doc['id'], $language);
                 if ($ret) {
                     $fetched++;
                 }
             } else {
                 // decode cms_id
                 $int = preg_match('#(.+)_([0-9]+)_([^_]+)_([^_]+)#', $doc['cms_id'], $matches);
                 $_element_type = $matches[1];
                 $_element_id = $matches[2];
                 $_original_lang = $matches[3];
                 $_lang = $matches[4];
                 $trid = $sitepress->get_element_trid($_element_id, 'post_' . $_element_type);
                 $translation = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}icl_translations WHERE trid=%d AND language_code=%s", $trid, $_lang));
                 $ret = $this->add_translated_document($translation->translation_id, $doc['id']);
                 if ($ret) {
                     $fetched++;
                 }
             }
         }
     }
     $iclsettings['last_picked_up'] = strtotime(current_time('mysql'));
     $sitepress->save_settings($iclsettings);
     return $fetched;
 }
开发者ID:bidhanbaral,项目名称:fotodep_store,代码行数:44,代码来源:pro-translation.class.php


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