當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。