本文整理汇总了PHP中ICanLocalizeQuery::get_website_details方法的典型用法代码示例。如果您正苦于以下问题:PHP ICanLocalizeQuery::get_website_details方法的具体用法?PHP ICanLocalizeQuery::get_website_details怎么用?PHP ICanLocalizeQuery::get_website_details使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICanLocalizeQuery
的用法示例。
在下文中一共展示了ICanLocalizeQuery::get_website_details方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ICanLocalizeQuery
function get_icl_translator_status(&$iclsettings, $res = null)
{
if ($res == null) {
// check what languages we have translators for.
require_once ICL_PLUGIN_PATH . '/lib/Snoopy.class.php';
require_once ICL_PLUGIN_PATH . '/lib/xml2array.php';
require_once ICL_PLUGIN_PATH . '/lib/icl_api.php';
$icl_query = false;
if (empty($iclsettings['site_id'])) {
// Must be for support
if (!empty($iclsettings['support_site_id'])) {
$icl_query = new ICanLocalizeQuery($iclsettings['support_site_id'], $iclsettings['support_access_key']);
}
} else {
$icl_query = new ICanLocalizeQuery($iclsettings['site_id'], $iclsettings['access_key']);
}
if ($icl_query === false) {
return;
}
$res = $icl_query->get_website_details();
}
if (isset($res['translation_languages']['translation_language'])) {
// reset $this->settings['icl_lang_status']
$iclsettings['icl_lang_status'] = array();
$translation_languages = $res['translation_languages']['translation_language'];
if (!isset($translation_languages[0])) {
$buf = $translation_languages;
$translation_languages = array(0 => $buf);
}
$target = array();
foreach ($translation_languages as $lang) {
$translators = $_tr = array();
$max_rate = false;
if (isset($lang['translators']) && !empty($lang['translators'])) {
if (!isset($lang['translators']['translator'][0])) {
$_tr[0] = $lang['translators']['translator'];
} else {
$_tr = $lang['translators']['translator'];
}
foreach ($_tr as $t) {
if ($max_rate === false || $t['attr']['amount'] > $max_rate) {
$max_rate = $t['attr']['amount'];
}
$translators[] = array('id' => $t['attr']['id'], 'nickname' => $t['attr']['nickname'], 'contract_id' => $t['attr']['contract_id']);
}
}
$target[] = array('from' => $this->get_language_code(ICL_Pro_Translation::server_languages_map($lang['attr']['from_language_name'], true)), 'to' => $this->get_language_code(ICL_Pro_Translation::server_languages_map($lang['attr']['to_language_name'], true)), 'have_translators' => $lang['attr']['have_translators'], 'available_translators' => $lang['attr']['available_translators'], 'applications' => $lang['attr']['applications'], 'contract_id' => $lang['attr']['contract_id'], 'id' => $lang['attr']['id'], 'translators' => $translators, 'max_rate' => $max_rate);
}
$iclsettings['icl_lang_status'] = $target;
}
if (isset($res['client']['attr'])) {
$iclsettings['icl_balance'] = $res['client']['attr']['balance'];
$iclsettings['icl_anonymous_user'] = $res['client']['attr']['anon'];
}
if (isset($res['html_status']['value'])) {
$iclsettings['icl_html_status'] = html_entity_decode($res['html_status']['value']);
$iclsettings['icl_html_status'] = preg_replace_callback('#<a([^>]*)href="([^"]+)"([^>]*)>#i', create_function('$matches', 'global $sitepress; return $sitepress->create_icl_popup_link($matches[2], array(\'unload_cb\'=>\'icl_pt_reload_translation_box\'));'), $iclsettings['icl_html_status']);
}
if (isset($res['translators_management_info']['value'])) {
$iclsettings['translators_management_info'] = html_entity_decode($res['translators_management_info']['value']);
$iclsettings['translators_management_info'] = preg_replace_callback('#<a([^>]*)href="([^"]+)"([^>]*)>#i', create_function('$matches', 'global $sitepress; return $sitepress->create_icl_popup_link($matches[2], array(\'unload_cb\'=>\'icl_pt_reload_translation_box\'));'), $iclsettings['translators_management_info']);
}
$iclsettings['icl_support_ticket_id'] = @intval($res['attr']['support_ticket_id']);
}
示例2: get_website_details
/**
* Sends request to ICL to get website details (including language pairs)
*
* @param TranslationProxy_Project $project
*
* @return array
*/
private static function get_website_details($project)
{
require_once ICL_PLUGIN_PATH . '/lib/Snoopy.class.php';
require_once ICL_PLUGIN_PATH . '/lib/xml2array.php';
require_once ICL_PLUGIN_PATH . '/lib/icl_api.php';
$site_id = $project->ts_id;
$access_key = $project->ts_access_key;
$default = array();
if (empty($site_id)) {
return $default;
}
try {
$icl_query = new ICanLocalizeQuery($site_id, $access_key);
$result = $icl_query->get_website_details();
} catch (Exception $e) {
return $default;
}
return $result;
}
示例3: ICanLocalizeQuery
function create_icl_account()
{
global $sitepress;
$site_id = false;
$access_key = false;
$user = $this->create_user_account();
require_once ICL_PLUGIN_PATH . '/lib/icl_api.php';
$icl_query = new ICanLocalizeQuery();
list($site_id, $access_key) = $icl_query->createAccount($user, TA_URL_ENDPOINT);
if (!$site_id) {
$user['pickup_type'] = ICL_PRO_TRANSLATION_PICKUP_POLLING;
list($site_id, $access_key) = $icl_query->createAccount($user, TA_URL_ENDPOINT);
}
if ($site_id) {
if ($user['pickup_type'] == ICL_PRO_TRANSLATION_PICKUP_POLLING) {
$sitepress->set_setting('translation_pickup_method', ICL_PRO_TRANSLATION_PICKUP_POLLING);
}
$icl_query = new ICanLocalizeQuery($site_id, $access_key);
$website_details = $icl_query->get_website_details(TA_URL_ENDPOINT);
TranslationProxy_Translator::get_icl_translator_status($website_details);
}
return array($site_id, $access_key);
}
示例4: foreach
// update account - add language pair
$incr = 0;
foreach ($this->settings['language_pairs'] as $k => $v) {
foreach ($v as $k2 => $v2) {
$incr++;
$data['from_language' . $incr] = $lang_server[$k];
$data['to_language' . $incr] = $lang_server[$k2];
}
}
$data['site_id'] = $this->settings['site_id'];
$data['accesskey'] = $this->settings['access_key'];
$data['create_account'] = 0;
$icl_query->updateAccount($data);
}
$icl_query = new ICanLocalizeQuery($this->settings['site_id'], $this->settings['access_key']);
$website_details = $icl_query->get_website_details();
if (empty($website_details)) {
echo '<p class="error">';
printf(__('There was a problem connecting to ICanLocalize. Please close this window and try again. If the problem persists please <a%s>contact us</a>.', 'sitepress'), ' target="_blank" href="http://wpml.org/?page_id=5255"');
echo '</p>';
exit;
}
$translation_languages = $website_details['translation_languages']['translation_language'];
if (isset($translation_languages['attr'])) {
$buff = $translation_languages;
unset($translation_languages);
$translation_languages[0] = $buff;
unset($buff);
}
foreach ((array) $translation_languages as $lpair) {
if ($lpair['attr']['from_language_name'] == $lang_server[$from_lang] && $lpair['attr']['to_language_name'] == $lang_server[$to_lang]) {
示例5: get_website_details
/**
* Sends request to ICL to get website details (including language pairs)
*
* @param TranslationProxy_Project $project
* @param bool $force
*
* @return array
*/
private static function get_website_details($project, $force = false)
{
require_once ICL_PLUGIN_PATH . '/lib/Snoopy.class.php';
require_once ICL_PLUGIN_PATH . '/inc/utilities/xml2array.php';
require_once ICL_PLUGIN_PATH . '/lib/icl_api.php';
$site_id = $project->ts_id;
$access_key = $project->ts_access_key;
$default = array();
if (!$site_id) {
return $default;
}
$icl_query = new ICanLocalizeQuery($site_id, $access_key);
return $icl_query->get_website_details($force);
}