本文整理汇总了PHP中qtranxf_get_url_for_language函数的典型用法代码示例。如果您正苦于以下问题:PHP qtranxf_get_url_for_language函数的具体用法?PHP qtranxf_get_url_for_language怎么用?PHP qtranxf_get_url_for_language使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qtranxf_get_url_for_language函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: translate_url
public function translate_url($url, $lang = null)
{
global $q_config;
if ($lang) {
$showLanguage = true;
} else {
$lang = $q_config['language'];
$showLanguage = !$q_config['hide_default_language'] || $lang != $q_config['default_language'];
}
return qtranxf_get_url_for_language($url, $lang, $showLanguage);
}
示例2: qtranxf_test_convertURL
function qtranxf_test_convertURL($url_mode_name, $urls, $lang, $showLanguage)
{
$cnt = 0;
foreach ($urls as $url => $url_expected) {
//$url_converted = qtranxf_convertURL($url, false, true);
$url_converted = qtranxf_get_url_for_language($url, $lang, $showLanguage);
//qtranxf_tst_log('test convertURL('.$url.'): ', $url_converted);
if (!qtranxf_check_url($url_converted, $url_expected)) {
++$cnt;
qtranxf_tst_log('qtranxf_test_convertURL(' . $url_mode_name . '): exit on the first error for url: ', $url);
exit;
}
}
//qtranxf_tst_log('qtranxf_test_convertURL('.$url_mode_name.'): '.($showLanguage?'show':'hide').' language lang='.$lang.'; #errors=', $cnt);
return $cnt;
}
示例3: qtranxf_home_url
function qtranxf_home_url($url, $path, $orig_scheme, $blog_id)
{
global $q_config;
$lang = $q_config['language'];
//qtranxf_dbg_log('qtranxf_home_url: url='.$url.'; path='.$path.'; orig_scheme='.$orig_scheme);
$url = qtranxf_get_url_for_language($url, $lang, !$q_config['hide_default_language'] || $lang != $q_config['default_language']);
//qtranxf_dbg_log('qtranxf_home_url: url='.$url.'; lang='.$lang);
return $url;
}
示例4: qtranxf_convertURL
/**
* Encode URL $url with language $lang.
* @param (string) $url URL to be converted.
* @param (string) $lang two-letter language code of the language to convert $url to.
* @param (bool) $forceadmin $url is not converted on admin side, unless $forceadmin is set to true.
* @param (bool) $showDefaultLanguage When set to true, $url is always encoded with a language, otherwise it senses option "Hide URL language information for default language" to keep $url consistent with the currently active language.
*
* If you need a URL to switch the language, set $showDefaultLanguage=true, if you need a URL to keep the current language, set it to false.
*/
function qtranxf_convertURL($url = '', $lang = '', $forceadmin = false, $showDefaultLanguage = false)
{
global $q_config;
if (empty($lang)) {
$lang = $q_config['language'];
}
if (empty($url)) {
if ($q_config['url_info']['doing_front_end'] && defined('QTS_VERSION') && $q_config['url_mode'] != QTX_URL_QUERY) {
//quick workaround, but need a permanent solution
$url = qts_get_url($lang);
//qtranxf_dbg_log('qtranxf_convertURL: qts_get_url: url=', $url);
if (!empty($url)) {
if ($showDefaultLanguage && $q_config['hide_default_language'] && $lang == $q_config['default_language']) {
$url = qtranxf_convertURL($url, $lang, $forceadmin, true);
}
return $url;
}
}
//$url = esc_url($q_config['url_info']['url']);
}
if (!$q_config['url_info']['doing_front_end'] && !$forceadmin) {
return $url;
}
if (!qtranxf_isEnabled($lang)) {
return '';
}
if (!$showDefaultLanguage) {
$showDefaultLanguage = !$q_config['hide_default_language'];
}
$showLanguage = $showDefaultLanguage || $lang != $q_config['default_language'];
//qtranxf_dbg_log('qtranxf_convertURL('.$url.','.$lang.'): showLanguage=',$showLanguage);
$complete = qtranxf_get_url_for_language($url, $lang, $showLanguage);
//qtranxf_dbg_log('qtranxf_convertURL: complete: ',$complete);
return $complete;
}
示例5: qtranxf_admin_home_url
/**
* Encode front end language on home_url, since, on admin side, it is mostly in use to create links to a preview pages.
* @since 3.4.5
*/
function qtranxf_admin_home_url($url, $path, $orig_scheme, $blog_id)
{
global $q_config;
//qtranxf_dbg_log('qtranxf_admin_home_url: $_COOKIE: ', $_COOKIE);
if (isset($_COOKIE[QTX_COOKIE_NAME_FRONT])) {
$lang = $_COOKIE[QTX_COOKIE_NAME_FRONT];
} else {
$lang = $q_config['default_language'];
}
//qtranxf_dbg_log('qtranxf_admin_home_url: url='.$url.'; path='.$path.'; orig_scheme='.$orig_scheme);
$url = qtranxf_get_url_for_language($url, $lang, !$q_config['hide_default_language'] || $lang != $q_config['default_language']);
//qtranxf_dbg_log('qtranxf_admin_home_url: url='.$url.'; lang='.$lang);
return $url;
}