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


PHP qtranxf_getSortedLanguages函数代码示例

本文整理汇总了PHP中qtranxf_getSortedLanguages函数的典型用法代码示例。如果您正苦于以下问题:PHP qtranxf_getSortedLanguages函数的具体用法?PHP qtranxf_getSortedLanguages怎么用?PHP qtranxf_getSortedLanguages使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: qtrans_getSortedLanguages

 function qtrans_getSortedLanguages($reverse = false)
 {
     return qtranxf_getSortedLanguages($reverse);
 }
开发者ID:AndreyLanko,项目名称:perevorot-prozorro-wp,代码行数:4,代码来源:qtranslate_compatibility.php

示例2: qtranxf_conf


//.........这里部分代码省略.........
        $language_na_message = isset($langs['not_available'][$lang]) ? $langs['not_available'][$lang] : '';
        $language_flag = isset($langs['flag'][$lang]) ? $langs['flag'][$lang] : '';
    } elseif (isset($_GET['delete'])) {
        $lang = $_GET['delete'];
        // validate delete (protect code)
        //if($q_config['default_language']==$lang) $error = 'Cannot delete Default Language!';
        //if(!isset($q_config['language_name'][$lang])||strtolower($lang)=='code') $error = __('No such language!', 'qtranslate');
        if (empty($error)) {
            // everything seems fine, delete language
            $error = qtranxf_deleteLanguage($lang);
        }
    } elseif (isset($_GET['enable'])) {
        $lang = $_GET['enable'];
        // enable validate
        if (!qtranxf_enableLanguage($lang)) {
            $error = __('Language is already enabled or invalid!', 'qtranslate');
        }
    } elseif (isset($_GET['disable'])) {
        $lang = $_GET['disable'];
        // enable validate
        if ($lang == $q_config['default_language']) {
            $error = __('Cannot disable Default Language!', 'qtranslate');
        }
        if (!qtranxf_isEnabled($lang)) {
            if (!isset($q_config['language_name'][$lang])) {
                $error = __('No such language!', 'qtranslate');
            }
        }
        // everything seems fine, disable language
        if ($error == '' && !qtranxf_disableLanguage($lang)) {
            $error = __('Language is already disabled!', 'qtranslate');
        }
    } elseif (isset($_GET['moveup'])) {
        $languages = qtranxf_getSortedLanguages();
        $msg = __('No such language!', 'qtranslate');
        foreach ($languages as $key => $language) {
            if ($language != $_GET['moveup']) {
                continue;
            }
            if ($key == 0) {
                $msg = __('Language is already first!', 'qtranslate');
                break;
            }
            $languages[$key] = $languages[$key - 1];
            $languages[$key - 1] = $language;
            $q_config['enabled_languages'] = $languages;
            $msg = __('New order saved.', 'qtranslate');
            break;
        }
        $message[] = $msg;
    } elseif (isset($_GET['movedown'])) {
        $languages = qtranxf_getSortedLanguages();
        $msg = __('No such language!', 'qtranslate');
        foreach ($languages as $key => $language) {
            if ($language != $_GET['movedown']) {
                continue;
            }
            if ($key == sizeof($languages) - 1) {
                $msg = __('Language is already last!', 'qtranslate');
                break;
            }
            $languages[$key] = $languages[$key + 1];
            $languages[$key + 1] = $language;
            $q_config['enabled_languages'] = $languages;
            $msg = __('New order saved.', 'qtranslate');
            break;
开发者ID:ycms,项目名称:framework,代码行数:67,代码来源:qtx_configuration.php

示例3: qtranxf_showAllSeparated

function qtranxf_showAllSeparated($text)
{
    if (empty($text)) {
        return $text;
    }
    global $q_config;
    $result = '';
    foreach (qtranxf_getSortedLanguages() as $language) {
        $result .= $q_config['language_name'][$language] . ':' . PHP_EOL . qtranxf_use($language, $text) . PHP_EOL . PHP_EOL;
    }
    return $result;
}
开发者ID:raxdev,项目名称:qtranslate-x,代码行数:12,代码来源:qtranslate_core.php

示例4: qtranxf_generateLanguageSelectCode

/**
 * Language Select Code for non-Widget users
 * @args is a hash array of options, which accepts the following keys:
 *   ‘type’ – one of the values: ‘text’, ‘image’, ‘both’, ‘dropdown’ and ‘custom’, which match the choices on widget admin page.
 *   ‘format’ – needs to be provided if ‘type’ is ‘custom’. Read help text to this option on widget admin page.
 *   ‘id’ – id of widget, which is used as a distinctive string to create CSS entities.
 * @since 3.4.5 type of argument is changed, compatibility with old way is preserved.
*/
function qtranxf_generateLanguageSelectCode($args = array(), $id = '')
{
    global $q_config;
    if (is_string($args)) {
        $type = $args;
    } elseif (is_bool($args) && $args) {
        $type = 'image';
    } elseif (is_array($args)) {
        if (!empty($args['type'])) {
            $type = $args['type'];
        }
        if (empty($id) && !empty($args['id'])) {
            $id = $args['id'];
        }
    }
    if (empty($type)) {
        $type = 'text';
    } else {
        switch ($type) {
            case 'text':
            case 'image':
            case 'both':
            case 'short':
            case 'css_only':
            case 'custom':
            case 'dropdown':
                break;
            default:
                $type = 'text';
        }
    }
    if (empty($id)) {
        $id = 'qtranslate';
    }
    $id .= '-chooser';
    if (is_404()) {
        $url = get_option('home');
    } else {
        $url = '';
    }
    $flag_location = qtranxf_flag_location();
    echo PHP_EOL . '<ul class="language-chooser language-chooser-' . $type . ' qtranxs_language_chooser" id="' . $id . '">' . PHP_EOL;
    switch ($type) {
        case 'image':
        case 'text':
        case 'css_only':
        case 'dropdown':
            foreach (qtranxf_getSortedLanguages() as $language) {
                $alt = $q_config['language_name'][$language] . ' (' . $language . ')';
                $classes = array('lang-' . $language);
                if ($language == $q_config['language']) {
                    $classes[] = 'active';
                }
                echo '<li class="' . implode(' ', $classes) . '"><a href="' . qtranxf_convertURL($url, $language, false, true) . '"';
                // set hreflang
                echo ' hreflang="' . $language . '"';
                echo ' title="' . $alt . '"';
                if ($type == 'image') {
                    echo ' class="qtranxs_image qtranxs_image_' . $language . '"';
                } elseif ($type == 'text') {
                    echo ' class="qtranxs_text qtranxs_text_' . $language . '"';
                } elseif ($type == 'css_only') {
                    // to be removed
                    echo ' class="qtranxs_css qtranxs_css_' . $language . '"';
                }
                echo '>';
                if ($type == 'image') {
                    echo '<img src="' . $flag_location . $q_config['flag'][$language] . '" alt="' . $alt . '" />';
                }
                echo '<span';
                if ($type == 'image' || $type == 'css_only') {
                    echo ' style="display:none"';
                }
                echo '>' . $q_config['language_name'][$language] . '</span>';
                echo '</a></li>' . PHP_EOL;
            }
            //echo '</ul><div class="qtranxs_widget_end"></div>'.PHP_EOL;
            if ($type == 'dropdown') {
                echo '<script type="text/javascript">' . PHP_EOL . '// <![CDATA[' . PHP_EOL;
                echo "var lc = document.getElementById('" . $id . "');" . PHP_EOL;
                echo "var s = document.createElement('select');" . PHP_EOL;
                echo "s.id = 'qtranxs_select_" . $id . "';" . PHP_EOL;
                echo "lc.parentNode.insertBefore(s,lc);" . PHP_EOL;
                // create dropdown fields for each language
                foreach (qtranxf_getSortedLanguages() as $language) {
                    echo qtranxf_insertDropDownElement($language, qtranxf_convertURL($url, $language, false, true), $id);
                }
                // hide html language chooser text
                echo "s.onchange = function() { document.location.href = this.value;}" . PHP_EOL;
                echo "lc.style.display='none';" . PHP_EOL;
                echo '// ]]>' . PHP_EOL . '</script>' . PHP_EOL;
            }
//.........这里部分代码省略.........
开发者ID:razik440,项目名称:qtranslate-x,代码行数:101,代码来源:qtranslate_widget.php

示例5: qtranxf_editConfig


//.........这里部分代码省略.........
        //$lang_props['locale'] = isset($langs['locale'][$lang])?$langs['locale'][$lang]:'';
        //$lang_props['locale_html'] = isset($langs['locale_html'][$lang])?$langs['locale_html'][$lang]:'';
        //$lang_props['date_format'] = isset($langs['date_format'][$lang])?$langs['date_format'][$lang]:'';
        //$lang_props['time_format'] = isset($langs['time_format'][$lang])?$langs['time_format'][$lang]:'';
        //$lang_props['not_available'] = isset($langs['not_available'][$lang])?$langs['not_available'][$lang]:'';
        //$lang_props['flag'] = isset($langs['flag'][$lang])?$langs['flag'][$lang]:'';
        $langs = qtranxf_langs_config();
        $lang_props = isset($langs[$lang]) ? $langs[$lang] : array();
    } elseif (isset($_GET['delete'])) {
        $lang = sanitize_text_field($_GET['delete']);
        // validate delete (protect code)
        //if($q_config['default_language']==$lang) $errors[] = 'Cannot delete Default Language!';
        //if(!isset($q_config['language_name'][$lang])||strtolower($lang)=='code') $errors[] = __('No such language!', 'qtranslate');
        //if(empty($errors)) {
        //	// everything seems fine, delete language
        $err = qtranxf_deleteLanguage($lang);
        if (!empty($err)) {
            $errors[] = $err;
        }
        //}
    } elseif (isset($_GET['enable'])) {
        $lang = sanitize_text_field($_GET['enable']);
        // enable validate
        if (!qtranxf_enableLanguage($lang)) {
            $errors[] = __('Language is already enabled or invalid!', 'qtranslate');
        }
    } elseif (isset($_GET['disable'])) {
        $lang = sanitize_text_field($_GET['disable']);
        // enable validate
        if ($lang == $q_config['default_language']) {
            $errors[] = __('Cannot disable Default Language!', 'qtranslate');
        }
        if (!qtranxf_isEnabled($lang)) {
            if (!isset($q_config['language_name'][$lang])) {
                $errors[] = __('No such language!', 'qtranslate');
            }
        }
        // everything seems fine, disable language
        if (empty($errors) && !qtranxf_disableLanguage($lang)) {
            $errors[] = __('Language is already disabled!', 'qtranslate');
        }
    } elseif (isset($_GET['moveup'])) {
        $lang = sanitize_text_field($_GET['moveup']);
        $languages = qtranxf_getSortedLanguages();
        $msg = __('No such language!', 'qtranslate');
        foreach ($languages as $key => $language) {
            if ($language != $lang) {
                continue;
            }
            if ($key == 0) {
                $msg = __('Language is already first!', 'qtranslate');
                break;
            }
            $languages[$key] = $languages[$key - 1];
            $languages[$key - 1] = $language;
            $q_config['enabled_languages'] = $languages;
            $msg = __('New order saved.', 'qtranslate');
            qtranxf_update_config_header_css();
            break;
        }
        $messages[] = $msg;
    } elseif (isset($_GET['movedown'])) {
        $lang = sanitize_text_field($_GET['movedown']);
        $languages = qtranxf_getSortedLanguages();
        $msg = __('No such language!', 'qtranslate');
        foreach ($languages as $key => $language) {
            if ($language != $lang) {
                continue;
            }
            if ($key == sizeof($languages) - 1) {
                $msg = __('Language is already last!', 'qtranslate');
                break;
            }
            $languages[$key] = $languages[$key + 1];
            $languages[$key + 1] = $language;
            $q_config['enabled_languages'] = $languages;
            $msg = __('New order saved.', 'qtranslate');
            qtranxf_update_config_header_css();
            break;
        }
        $messages[] = $msg;
    }
    do_action('qtranslate_editConfig');
    $everything_fine = (isset($_POST['submit']) || isset($_GET['delete']) || isset($_GET['enable']) || isset($_GET['disable']) || isset($_GET['moveup']) || isset($_GET['movedown'])) && empty($errors);
    if ($everything_fine) {
        // settings might have changed, so save
        qtranxf_saveConfig();
        if (empty($messages)) {
            $messages[] = __('Options saved.', 'qtranslate');
        }
    }
    if ($q_config['auto_update_mo']) {
        if (!is_dir(WP_LANG_DIR) || !($ll = @fopen(trailingslashit(WP_LANG_DIR) . 'qtranslate.test', 'a'))) {
            $errors[] = sprintf(__('Could not write to "%s", Gettext Databases could not be downloaded!', 'qtranslate'), WP_LANG_DIR);
        } else {
            @fclose($ll);
            @unlink(trailingslashit(WP_LANG_DIR) . 'qtranslate.test');
        }
    }
}
开发者ID:razik440,项目名称:qtranslate-x,代码行数:101,代码来源:qtx_admin_options_update.php

示例6: hocwp_get_qtranslate_x_enabled_languages

function hocwp_get_qtranslate_x_enabled_languages()
{
    return qtranxf_getSortedLanguages();
}
开发者ID:skylarkcob,项目名称:hocwp-projects,代码行数:4,代码来源:language.php

示例7: alo_em_qtranxf_get_all_languages

function alo_em_qtranxf_get_all_languages($langs, $fallback_by_users)
{
    if (function_exists('qtranxf_init')) {
        return qtranxf_getSortedLanguages();
    }
    return $langs;
}
开发者ID:dcotet,项目名称:alo-easymail,代码行数:7,代码来源:alo-easymail-multilingual.php

示例8: qtrans_copy_default_theme_option

 /**
  * from 1.1.7
  */
 function qtrans_copy_default_theme_option()
 {
     if (!$this->check_qtrans) {
         return;
     }
     global $q_config;
     $locale_list = $q_config['locale'];
     $option_name = 'option_tree';
     if ($this->check_qtrans) {
         $options = get_option($option_name);
         //$st_plugin_list_lang = icl_get_languages('skip_missing=0&orderby=custom');
         $st_plugin_list_lang = array();
         $qtrans_list = qtranxf_getSortedLanguages();
         $flags = qtranxf_language_configured('flag');
         if (!empty($qtrans_list) and is_array($qtrans_list)) {
             foreach ($qtrans_list as $key => $value) {
                 $lang_name = $q_config['language_name'][$value];
                 $array = array('id' => $key, 'active' => $value == $q_config['language'] ? 1 : 0, 'encode_url' => 0, 'default_locale' => $locale_list[$value], 'tag' => '', 'native_name' => $lang_name, 'language_code' => $value, 'translated_name' => $lang_name, 'url' => qtranxf_convertURL(admin_url(), $value, true, true), 'country_flag_url' => qtranxf_flag_location() . $flags[$value]);
                 $st_plugin_list_lang[$value] = $array;
             }
         }
         if (is_array($st_plugin_list_lang) && !empty($st_plugin_list_lang)) {
             foreach ($st_plugin_list_lang as $lang) {
                 $lang_option = get_option($option_name . '_' . $lang['language_code']);
                 if ($lang_option == '') {
                     update_option($option_name . '_' . $lang['language_code'], $options);
                 }
             }
         }
     }
 }
开发者ID:DaddyFool,项目名称:travelTest,代码行数:34,代码来源:class.optiontree.php

示例9: qtranxf_conf


//.........这里部分代码省略.........
	<?php 
            wp_nonce_field($nonce_action);
            // Prevent CSRF
            ?>
	<div class="tabs-content"><?php 
            //<!-- tabs-container -->
            ?>
	<?php 
            qtranxf_admin_section_start('general');
            $permalink_is_query = qtranxf_is_permalink_structure_query();
            //qtranxf_dbg_echo('$permalink_is_query: ',$permalink_is_query);
            $url_mode = $q_config['url_mode'];
            ?>
		<table class="form-table">
			<tr valign="top">
				<th scope="row"><?php 
            _e('Default Language / Order', 'qtranslate');
            ?>
</th>
				<td><p class="qtranxs_explanation"><?php 
            echo __('Every multilingual field is expected to have a meaningful content in the "Default Language". Usually, it is the language of your site before it became multilingual.', 'qtranslate');
            echo ' ';
            echo __('Order of languages defines in which order they are listed, when languages need to be listed, otherwise it is not important.', 'qtranslate');
            ?>
</p>
					<fieldset id="qtranxs-languages-menu">
					<legend class="hidden"><?php 
            _e('Default Language', 'qtranslate');
            ?>
</legend>
					<table id="qtranxs-enabled-languages">
				<?php 
            $flag_location = qtranxf_flag_location();
            foreach (qtranxf_getSortedLanguages() as $key => $language) {
                echo '<tr>';
                echo '<td><label title="' . $q_config['language_name'][$language] . '"><input type="radio" name="default_language" value="' . $language . '"';
                checked($language, $q_config['default_language']);
                echo ' />';
                echo ' <a href="' . add_query_arg('moveup', $language, $clean_uri) . '"><img src="' . $pluginurl . 'arrowup.png" alt="up" /></a>';
                echo ' <a href="' . add_query_arg('movedown', $language, $clean_uri) . '"><img src="' . $pluginurl . 'arrowdown.png" alt="down" /></a>';
                echo ' <img src="' . $flag_location . $q_config['flag'][$language] . '" alt="' . $q_config['language_name'][$language] . '" /> ';
                echo ' ' . $q_config['language_name'][$language];
                echo '</label></td>';
                echo '<td>[:' . $language . ']</td><td><a href="' . $clean_uri . '&edit=' . $language . '">' . __('Edit', 'qtranslate') . '</a></td><td><a href="' . $clean_uri . '&disable=' . $language . '">' . __('Disable', 'qtranslate') . '</a></td>';
                echo '</tr>' . PHP_EOL;
            }
            ?>
					</table>
					<p class="qtranxs_notes"><?php 
            $url = get_bloginfo('url');
            $url = qtranxf_convertURL($url, $q_config['default_language'], true);
            printf(__('Choose the default language of your blog. This is the language which will be shown on %s. You can also change the order the languages by clicking on the arrows above.', 'qtranslate'), $url);
            ?>
</p>
					</fieldset>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row"><?php 
            _e('URL Modification Mode', 'qtranslate');
            ?>
</th>
				<td>
					<?php 
            if ($permalink_is_query) {
                ?>
开发者ID:Krishan19,项目名称:qtranslate-x,代码行数:67,代码来源:qtx_configuration.php

示例10: qtranxf_generateLanguageSelectCode

function qtranxf_generateLanguageSelectCode($style = '', $id = '')
{
    global $q_config;
    if ($style == '') {
        $style = 'text';
    }
    if (is_bool($style) && $style) {
        $style = 'image';
    }
    if (is_404()) {
        $url = get_option('home');
    } else {
        $url = '';
    }
    if ($id == '') {
        $id = 'qtranslate';
    }
    $id .= '-chooser';
    $flag_location = qtranxf_flag_location();
    switch ($style) {
        case 'image':
        case 'text':
        case 'dropdown':
            echo PHP_EOL . '<ul class="qtranxs_language_chooser" id="' . $id . '">' . PHP_EOL;
            foreach (qtranxf_getSortedLanguages() as $language) {
                $classes = array('lang-' . $language);
                if ($language == $q_config['language']) {
                    $classes[] = 'active';
                }
                echo '<li class="' . implode(' ', $classes) . '"><a href="' . qtranxf_convertURL($url, $language, false, true) . '"';
                //echo '<li'; if($language == $q_config['language']) echo ' class="active"';
                //echo '><a href="'.qtranxf_convertURL($url, $language, false, true).'"';
                // set hreflang
                echo ' hreflang="' . $language . '"';
                echo ' title="' . $q_config['language_name'][$language] . '"';
                if ($style == 'image') {
                    echo ' class="qtranxs_image qtranxs_image_' . $language . '"';
                } elseif ($style == 'text') {
                    echo ' class="qtranxs_text qtranxs_text_' . $language . '"';
                }
                echo '>';
                if ($style == 'image') {
                    echo '<img src="' . $flag_location . $q_config['flag'][$language] . '" alt="' . $q_config['language_name'][$language] . '" />';
                }
                echo '<span';
                if ($style == 'image') {
                    echo ' style="display:none"';
                }
                echo '>' . $q_config['language_name'][$language] . '</span>';
                echo '</a></li>' . PHP_EOL;
            }
            echo '</ul><div class="qtranxs_widget_end"></div>' . PHP_EOL;
            if ($style == 'dropdown') {
                echo '<script type="text/javascript">' . PHP_EOL . '// <![CDATA[' . PHP_EOL;
                echo "var lc = document.getElementById('" . $id . "');" . PHP_EOL;
                echo "var s = document.createElement('select');" . PHP_EOL;
                echo "s.id = 'qtranxs_select_" . $id . "';" . PHP_EOL;
                echo "lc.parentNode.insertBefore(s,lc);" . PHP_EOL;
                // create dropdown fields for each language
                foreach (qtranxf_getSortedLanguages() as $language) {
                    echo qtranxf_insertDropDownElement($language, qtranxf_convertURL($url, $language, false, true), $id);
                }
                // hide html language chooser text
                echo "s.onchange = function() { document.location.href = this.value;}" . PHP_EOL;
                echo "lc.style.display='none';" . PHP_EOL;
                echo '// ]]>' . PHP_EOL . '</script>' . PHP_EOL;
            }
            break;
        case 'both':
            echo PHP_EOL . '<ul class="qtranxs_language_chooser" id="' . $id . '">' . PHP_EOL;
            foreach (qtranxf_getSortedLanguages() as $language) {
                echo '<li';
                if ($language == $q_config['language']) {
                    echo ' class="active"';
                }
                echo '><a href="' . qtranxf_convertURL($url, $language, false, true) . '"';
                echo ' class="qtranxs_flag_' . $language . ' qtranxs_flag_and_text" title="' . $q_config['language_name'][$language] . '">';
                //echo '<img src="'.$flag_location.$q_config['flag'][$language].'"></img>';
                echo '<span>' . $q_config['language_name'][$language] . '</span></a></li>' . PHP_EOL;
            }
            echo '</ul><div class="qtranxs_widget_end"></div>' . PHP_EOL;
            break;
    }
}
开发者ID:ycms,项目名称:framework,代码行数:84,代码来源:qtranslate_widget.php

示例11: esc_attr

" alt="<?php 
    echo esc_attr($lang_name);
    ?>
" title="<?php 
    echo esc_attr($lang_name);
    ?>
"><?php 
    echo esc_attr($lang_name);
    ?>
<i class="fa fa-angle-down"></i><i class="fa fa-angle-up"></i>
                    
                    <i class="fa fa-angle-down"></i><i class="fa fa-angle-up"></i>
                </a>
                <ul class="list nav-drop-menu" style="min-width:120px">
                    <?php 
    $variable = qtranxf_getSortedLanguages();
    if (!empty($variable) and is_array($variable)) {
        foreach ($variable as $key => $value) {
            $qtrans_link = qtranxf_convertURL('', $value, false, true);
            $lang_name = $q_config['language_name'][$value];
            ?>
                            <li>
                                <a title="<?php 
            echo esc_attr($lang_name);
            ?>
" href="<?php 
            echo esc_attr($qtrans_link);
            ?>
">
                                    <img src="<?php 
            echo esc_attr($flag_dir . $flags[$value]);
开发者ID:DaddyFool,项目名称:travelTest,代码行数:31,代码来源:language_select.php

示例12: qts_service

function qts_service()
{
    global $q_config, $qts_public_key, $qts_error_messages;
    if (!isset($_REQUEST['post'])) {
        echo '<script type="text/javascript">document.location="edit.php";</script>';
        printf(__('To translate a post, please go to the <a href="%s">edit posts overview</a>.', 'qtranslate'), 'edit.php');
        exit;
    }
    $post_id = intval($_REQUEST['post']);
    $confirm = isset($_GET['confirm']) ? true : false;
    $translate_from = '';
    $translate_to = '';
    $translate_from_name = '';
    $translate_to_name = '';
    if (isset($_REQUEST['source_language']) && qtranxf_isEnabled($_REQUEST['source_language'])) {
        $translate_from = $_REQUEST['source_language'];
    }
    if (isset($_REQUEST['target_language']) && qtranxf_isEnabled($_REQUEST['target_language'])) {
        $translate_to = $_REQUEST['target_language'];
    }
    if ($translate_to == $translate_from) {
        $translate_to = '';
    }
    $p = get_post($post_id);
    $post =& $p;
    if (!$post) {
        printf(__('Post with id "%s" not found!', 'qtranslate'), $post_id);
        return;
    }
    $default_service = intval(get_option('qts_default_service'), 5);
    $service_settings = get_option('qts_service_settings');
    // Detect available Languages and possible target languages
    $available_languages = qtranxf_getAvailableLanguages($post->post_content);
    if ($available_languages === FALSE && !empty($post->post_content)) {
        $available_languages = array($q_config['default_language']);
    }
    if ($available_languages === FALSE || sizeof($available_languages) == 0) {
        $error = __('The requested Post has no content, no Translation possible.', 'qtranslate');
    }
    // try to guess source and target language
    if (!in_array($translate_from, $available_languages)) {
        $translate_from = '';
    }
    $missing_languages = array_diff($q_config['enabled_languages'], $available_languages);
    if (empty($translate_from) && in_array($q_config['default_language'], $available_languages) && $translate_to != $q_config['default_language']) {
        $translate_from = $q_config['default_language'];
    }
    if (empty($translate_to) && sizeof($missing_languages) == 1) {
        $translate_to = $missing_languages[0];
    }
    if (in_array($translate_to, $available_languages)) {
        $message = __('The Post already has content for the selected target language. If a translation request is send, the current text for the target language will be overwritten.', 'qtranslate');
    }
    if (sizeof($available_languages) == 1) {
        if ($available_languages[0] == $translate_to) {
            unset($translate_to);
        }
        $translate_from = $available_languages[0];
    } elseif ($translate_from == '' && sizeof($available_languages) > 1) {
        $languages = qtranxf_getSortedLanguages();
        foreach ($languages as $language) {
            if ($language != $translate_to && in_array($language, $available_languages)) {
                $translate_from = $language;
                break;
            }
        }
    }
    // link to current page with get variables
    $url_link = add_query_arg('post', $post_id);
    if (!empty($translate_to)) {
        $url_link = add_query_arg('target_language', $translate_to, $url_link);
    }
    if (!empty($translate_from)) {
        $url_link = add_query_arg('source_language', $translate_from, $url_link);
    }
    // get correct title and content
    $post_title = qtranxf_use($translate_from, $post->post_title);
    $post_content = qtranxf_use($translate_from, $post->post_content);
    $post_excerpt = qtranxf_use($translate_from, $post->post_excerpt);
    if (!empty($translate_from)) {
        $translate_from_name = $q_config['language_name'][$translate_from];
    }
    if (!empty($translate_to)) {
        $translate_to_name = $q_config['language_name'][$translate_to];
    }
    $post_title_html = htmlspecialchars($post_title);
    $permalink = get_permalink($post_id);
    if ($permalink) {
        if ($translate_from_name) {
            $permalink = qtranxf_convertURL($translate_from_name, $permalink);
        }
        $post_title_html = '<a href="' . $permalink . '" target="_blank">' . $post_title_html . '</a>';
    }
    if (!empty($translate_from) && !empty($translate_to)) {
        $title = sprintf('Translate &quot;%1$s&quot; from %2$s to %3$s', $post_title_html, $translate_from_name, $translate_to_name);
    } elseif (!empty($translate_from)) {
        $title = sprintf('Translate &quot;%1$s&quot; from %2$s', $post_title_html, $translate_from_name);
    } else {
        $title = sprintf('Translate &quot;%1$s&quot;', $post_title_html);
    }
//.........这里部分代码省略.........
开发者ID:morovan,项目名称:granitpiestany.sk,代码行数:101,代码来源:qtranslate_services.php

示例13: qtranxf_editConfig


//.........这里部分代码省略.........
        $original_lang = $lang;
        $language_code = $lang;
        //$langs = $q_config;
        $langs = array();
        qtranxf_languages_configured($langs);
        $lang_props['language_name'] = isset($langs['language_name'][$lang]) ? $langs['language_name'][$lang] : '';
        $lang_props['locale'] = isset($langs['locale'][$lang]) ? $langs['locale'][$lang] : '';
        $lang_props['locale_html'] = isset($langs['locale_html'][$lang]) ? $langs['locale_html'][$lang] : '';
        $lang_props['date_format'] = isset($langs['date_format'][$lang]) ? $langs['date_format'][$lang] : '';
        $lang_props['time_format'] = isset($langs['time_format'][$lang]) ? $langs['time_format'][$lang] : '';
        $lang_props['not_available'] = isset($langs['not_available'][$lang]) ? $langs['not_available'][$lang] : '';
        $lang_props['flag'] = isset($langs['flag'][$lang]) ? $langs['flag'][$lang] : '';
    } elseif (isset($_GET['delete'])) {
        $lang = $_GET['delete'];
        // validate delete (protect code)
        //if($q_config['default_language']==$lang) $errors[] = 'Cannot delete Default Language!';
        //if(!isset($q_config['language_name'][$lang])||strtolower($lang)=='code') $errors[] = __('No such language!', 'qtranslate');
        if (empty($errors)) {
            // everything seems fine, delete language
            $err = qtranxf_deleteLanguage($lang);
            if (!empty($err)) {
                $errors[] = $err;
            }
        }
    } elseif (isset($_GET['enable'])) {
        $lang = $_GET['enable'];
        // enable validate
        if (!qtranxf_enableLanguage($lang)) {
            $errors[] = __('Language is already enabled or invalid!', 'qtranslate');
        }
    } elseif (isset($_GET['disable'])) {
        $lang = $_GET['disable'];
        // enable validate
        if ($lang == $q_config['default_language']) {
            $errors[] = __('Cannot disable Default Language!', 'qtranslate');
        }
        if (!qtranxf_isEnabled($lang)) {
            if (!isset($q_config['language_name'][$lang])) {
                $errors[] = __('No such language!', 'qtranslate');
            }
        }
        // everything seems fine, disable language
        if (empty($errors) && !qtranxf_disableLanguage($lang)) {
            $errors[] = __('Language is already disabled!', 'qtranslate');
        }
    } elseif (isset($_GET['moveup'])) {
        $languages = qtranxf_getSortedLanguages();
        $msg = __('No such language!', 'qtranslate');
        foreach ($languages as $key => $language) {
            if ($language != $_GET['moveup']) {
                continue;
            }
            if ($key == 0) {
                $msg = __('Language is already first!', 'qtranslate');
                break;
            }
            $languages[$key] = $languages[$key - 1];
            $languages[$key - 1] = $language;
            $q_config['enabled_languages'] = $languages;
            $msg = __('New order saved.', 'qtranslate');
            break;
        }
        $messages[] = $msg;
    } elseif (isset($_GET['movedown'])) {
        $languages = qtranxf_getSortedLanguages();
        $msg = __('No such language!', 'qtranslate');
        foreach ($languages as $key => $language) {
            if ($language != $_GET['movedown']) {
                continue;
            }
            if ($key == sizeof($languages) - 1) {
                $msg = __('Language is already last!', 'qtranslate');
                break;
            }
            $languages[$key] = $languages[$key + 1];
            $languages[$key + 1] = $language;
            $q_config['enabled_languages'] = $languages;
            $msg = __('New order saved.', 'qtranslate');
            break;
        }
        $messages[] = $msg;
    }
    do_action('qtranslate_editConfig');
    $everything_fine = (isset($_POST['submit']) || isset($_GET['delete']) || isset($_GET['enable']) || isset($_GET['disable']) || isset($_GET['moveup']) || isset($_GET['movedown'])) && empty($errors);
    if ($everything_fine) {
        // settings might have changed, so save
        qtranxf_saveConfig();
        if (empty($messages)) {
            $messages[] = __('Options saved.', 'qtranslate');
        }
    }
    if ($q_config['auto_update_mo']) {
        if (!is_dir(WP_LANG_DIR) || !($ll = @fopen(trailingslashit(WP_LANG_DIR) . 'qtranslate.test', 'a'))) {
            $errors[] = sprintf(__('Could not write to "%s", Gettext Databases could not be downloaded!', 'qtranslate'), WP_LANG_DIR);
        } else {
            @fclose($ll);
            @unlink(trailingslashit(WP_LANG_DIR) . 'qtranslate.test');
        }
    }
}
开发者ID:jmalinens,项目名称:qtranslate-x,代码行数:101,代码来源:qtx_admin_options_update.php

示例14: add_query_arg

$current_url = add_query_arg($wp->query_string, '', home_url($wp->request));
if (is_singular() || is_single() || is_page()) {
    $current_url = get_permalink();
}
// Obtaining from Qtranslate
if (function_exists('qtrans_getSortedLanguages')) {
    $current_lang = qtrans_getLanguage();
    $languages = qtrans_getSortedLanguages();
    foreach ($languages as $lang) {
        $display_languages[$lang] = array('name' => $lang, 'url' => qtrans_convertURL($current_url, $lang, 0, 1));
    }
}
// Obtaining from Qtranslate W
if (function_exists('qtranxf_getSortedLanguages')) {
    $current_lang = qtranxf_getLanguage();
    $languages = qtranxf_getSortedLanguages();
    foreach ($languages as $lang) {
        $display_languages[$lang] = array('name' => $lang, 'url' => qtranxf_convertURL($current_url, $lang, 0, 1));
    }
}
// Obtaining from Polylang
if (function_exists('pll_current_language')) {
    global $polylang;
    $current_lang = pll_current_language();
    $poly_langs = pll_the_languages(array('raw' => 1, 'echo' => 0));
    foreach ($poly_langs as $lang) {
        $display_languages[$lang['slug']] = array('name' => $lang['slug'], 'url' => $lang['url']);
    }
}
if (!empty($display_languages)) {
    echo '<div class="languages">';
开发者ID:xfifix,项目名称:WPUTheme,代码行数:31,代码来源:languages.php

示例15: language_getlanguages

 function language_getlanguages()
 {
     global $slideshow_languageplugin, $slideshow_languagelanguages;
     $languages = false;
     if (!empty($slideshow_languagelanguages)) {
         return $slideshow_languagelanguages;
     }
     switch ($slideshow_languageplugin) {
         case 'qtranslate':
             if (function_exists('qtrans_getSortedLanguages')) {
                 $languages = qtrans_getSortedLanguages();
             }
             break;
         case 'qtranslate-x':
             if (function_exists('qtranxf_getSortedLanguages')) {
                 $languages = qtranxf_getSortedLanguages();
             }
             break;
         case 'wpml':
             if (function_exists('icl_get_languages')) {
                 $icl_languages = icl_get_languages();
                 $languages = array();
                 foreach ($icl_languages as $lang => $icl_language) {
                     $languages[] = $lang;
                 }
             }
             break;
     }
     $slideshow_languagelanguages = $languages;
     return $languages;
 }
开发者ID:andywgarcia,项目名称:campuslifeohs,代码行数:31,代码来源:slideshow-gallery-plugin.php


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