/**
  * get actived languages
  * @return array
  */
 public static function get_languages()
 {
     $active_langs = array();
     if (function_exists('qtrans_getSortedLanguages')) {
         $active_langs = qtrans_getSortedLanguages();
     }
     return $active_langs;
 }
 /**
  * Get the active language.
  */
 public function get_active_language($language)
 {
     if (empty($_COOKIE['qtrans_edit_language']) === false) {
         $enabledLanguages = qtrans_getSortedLanguages();
         if (in_array($_COOKIE['qtrans_edit_language'], $enabledLanguages)) {
             $language = $_COOKIE['qtrans_edit_language'];
         }
     }
     return $language;
 }
Example #3
0
 function render_field($field)
 {
     global $q_config;
     $languages = qtrans_getSortedLanguages(true);
     $values = qtrans_split($field['value'], $quicktags = true);
     $currentLanguage = $this->plugin->get_active_language();
     // vars
     $o = array('id', 'class', 'name', 'placeholder', 'rows');
     $s = array('readonly', 'disabled');
     $e = '';
     // maxlength
     if ($field['maxlength'] !== '') {
         $o[] = 'maxlength';
     }
     // rows
     if (empty($field['rows'])) {
         $field['rows'] = 8;
     }
     // populate atts
     $atts = array();
     foreach ($o as $k) {
         $atts[$k] = $field[$k];
     }
     // special atts
     foreach ($s as $k) {
         if ($field[$k]) {
             $atts[$k] = $k;
         }
     }
     // render
     $e .= '<div class="acf-input-wrap multi-language-field">';
     foreach ($languages as $language) {
         $class = $language === $currentLanguage ? 'wp-switch-editor current-language' : 'wp-switch-editor';
         $e .= '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
     }
     foreach ($languages as $language) {
         $atts['class'] = $field['class'];
         if ($language === $currentLanguage) {
             $atts['class'] .= ' current-language';
         }
         $atts['name'] = $field['name'] . "[{$language}]";
         $atts['data-language'] = $language;
         $e .= '<textarea ' . acf_esc_attr($atts) . ' >';
         $e .= esc_textarea($values[$language]);
         $e .= '</textarea>';
     }
     $e .= '</div>';
     // return
     echo $e;
 }
Example #4
0
 /**
  * Показывает переключатель языков в виде ненумерованного списка
  *
  * @param        $ulClasses
  * @param string $linkActiveClass
  * @param bool   $echo
  *
  * @return string
  */
 public function showLangSwitcher($ulClasses, $linkActiveClass = 'active', $echo = TRUE)
 {
     $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $result = '<ul class="' . $ulClasses . '">';
     foreach (qtrans_getSortedLanguages() as $lang) {
         $isActive = $lang == $GLOBALS['q_config']['language'] ? ' class="' . $linkActiveClass . '" ' : '';
         $result .= '<li><a href="' . qtrans_convertURL($url, $lang) . '" ' . $isActive . '>' . $lang . '</a></li>';
     }
     $result .= '</ul>';
     if ($echo) {
         echo $result;
         return;
     }
     return $result;
 }
 function create_field($field)
 {
     global $q_config;
     $languages = qtrans_getSortedLanguages(true);
     $values = qtrans_split($field['value'], $quicktags = true);
     $currentLanguage = $this->plugin->get_active_language();
     echo '<div class="multi-language-field">';
     foreach ($languages as $language) {
         $class = $language === $currentLanguage ? 'wp-switch-editor current-language' : 'wp-switch-editor';
         echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
     }
     foreach ($languages as $language) {
         $class = $language === $currentLanguage ? $field['class'] . ' current-language' : $field['class'];
         echo '<textarea data-language="' . esc_attr($language) . '" id="' . esc_attr($field['id']) . '" rows="4" class="' . esc_attr($class) . '" name="' . esc_attr($field['name'] . "[{$language}]") . '">' . esc_textarea($values[$language]) . '</textarea>';
     }
     echo '</div>';
 }
Example #6
0
 function create_field($field)
 {
     if (!acf_qtranslate_enabled()) {
         acf_field_textarea::create_field($field);
         return;
     }
     global $q_config;
     $languages = qtrans_getSortedLanguages(true);
     $values = qtrans_split($field['value'], $quicktags = true);
     echo '<div class="multi-language-field">';
     foreach ($languages as $language) {
         $class = $language === end($languages) ? 'wp-switch-editor current-language' : 'wp-switch-editor';
         echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
     }
     foreach ($languages as $language) {
         $class = $language === end($languages) ? $field['class'] . ' current-language' : $field['class'];
         echo '<textarea data-language="' . esc_attr($language) . '" id="' . esc_attr($field['id']) . '" rows="4" class="' . esc_attr($class) . '" name="' . esc_attr($field['name'] . "[{$language}]") . '">' . esc_textarea($values[$language]) . '</textarea>';
     }
     echo '</div>';
 }
Example #7
0
 /**
  * Get field HTML
  *
  * @param string $html
  * @param mixed  $meta
  * @param array  $field
  *
  * @return string
  */
 static function html($html, $meta, $field)
 {
     $html = '';
     //$getall ='';
     $i = 0;
     if (!is_array($meta)) {
         $meta['default'] = isset($meta['defalut']) ? $meta['defalut'] : '';
         if (function_exists(qtrans_getSortedLanguages)) {
             $languages = qtrans_getSortedLanguages();
             foreach ($languages as $lang) {
                 $meta[$lang] = isset($meta[$lang]) ? $meta[$lang] : '';
             }
         }
     }
     $html .= sprintf('<span style="display: block;">Default</span> <input type="text" name="%s[default]" id="%s[default]" value="%s" size="%s"  class="rwmb-text %s"/>' . '<br />', $field['field_name'], $field['id'], $meta['default'], $field['size'], $field['class']);
     if (function_exists(qtrans_getSortedLanguages)) {
         $languages = qtrans_getSortedLanguages();
         //print_r($languages);
         foreach ($languages as $lang) {
             //$meta = $lang;
             $i++;
             //	$html .= 'jfslfjsldfj '.$i++;
             //	$html .= 'xxx '.$i++;
             $html .= sprintf('<span style="display: block;">' . qtrans_getLanguageName($lang) . '</span> <input type="text" class="rwmb-text" name="%s[' . $lang . ']" id="%s[' . $lang . ']" value="%s" size="%s"  />' . '<br />', $field['field_name'], $field['id'], $meta[$lang], $field['size']);
             //$getall .= '[:'.$lang.']'.$meta[$lang].' ';
             //save( $new, $old, $post_id, $field )
             //save( $new, $old, $post_id, $field );
         }
     }
     //$html .=$field['id'];
     //$html .=$field['field_name'];
     //$field['field_name['translate']'] = 'paijo';
     /* 	$html .= sprintf('<input type="hidden" name="%s['."translate".']" id="%s" value="'.$getall.'"  />',
     					$field['field_name'],
     					$field['id']
     			); */
     //var_dump($getall);
     return $html;
 }
function qtrans_getLanguageLinks($style = '', $id = '')
{
    if (function_exists('qtrans_init')) {
        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';
        switch ($style) {
            case 'image':
            case 'text':
            case 'dropdown':
                echo '<ul class="qtrans_language_chooser" id="' . $id . '">';
                foreach (qtrans_getSortedLanguages() as $language) {
                    echo '<li';
                    if ($language == $q_config['language']) {
                        echo ' class="active"';
                    }
                    echo '><a href="' . qtrans_convertURL($url, $language) . '"';
                    // set hreflang
                    echo ' hreflang="' . $language . '" title="' . $q_config['language_name'][$language] . '"';
                    echo '><span';
                    echo '>' . $q_config['language_name'][$language] . '</span></a></li>';
                }
                echo "</ul><div class=\"qtrans_widget_end\"></div>";
        }
    }
}
Example #9
0
/**
 * Language list Code for non-Widget users
 *
 * @global array $q_config
 * @param string $sep
 */
function qtrans_generate_language_list($sep = " | ")
{
    global $q_config;
    $languages = qtrans_getSortedLanguages();
    $num_langs = count($languages);
    $id = 'qtranslate-chooser';
    $url = is_404() ? get_option('home') : '';
    echo '<div class="qtrans_language_chooser" id="' . $id . '">';
    foreach ($languages as $language) {
        $classes = array('lang-' . $language);
        if ($language == $q_config['language']) {
            $classes[] = 'active';
        }
        echo '<span class="' . implode(' ', $classes) . '"><a href="' . qtrans_convertURL($url, $language) . '"';
        echo ' hreflang="' . $language . '" title="' . $q_config['language_name'][$language] . '"';
        echo '>' . $q_config['language_name'][$language] . '</a></span>';
        if (--$num_langs > 0) {
            echo '<span class="qtrans_separator">' . $sep . '</span>';
        }
    }
    echo "</div>";
}
function qtrans_showAllSeperated($text)
{
    if (empty($text)) {
        return $text;
    }
    global $q_config;
    $result = "";
    foreach (qtrans_getSortedLanguages() as $language) {
        $result .= $q_config['language_name'][$language] . ":\n" . qtrans_use($language, $text) . "\n\n";
    }
    return $result;
}
Example #11
0
 /**
  * Check for qTranslate existance
  * 
  * @return boolean Indicates if the plugin is enabled.
  */
 static function check()
 {
     # Check for qTranslate's existance
     return function_exists('qtrans_getSortedLanguages') && count(qtrans_getSortedLanguages()) > 1;
 }
 function cs_language_defaults()
 {
     $multilang = array();
     if (cs_is_wpml_activated() || cs_is_qtranslate_activated() || cs_is_polylang_activated()) {
         if (cs_is_wpml_activated()) {
             global $sitepress;
             $multilang['default'] = $sitepress->get_default_language();
             $multilang['current'] = $sitepress->get_current_language();
             $multilang['languages'] = $sitepress->get_active_languages();
         } else {
             if (cs_is_polylang_activated()) {
                 global $polylang;
                 $current = pll_current_language();
                 $default = pll_default_language();
                 $current = empty($current) ? $default : $current;
                 $poly_langs = $polylang->model->get_languages_list();
                 $languages = array();
                 foreach ($poly_langs as $p_lang) {
                     $languages[$p_lang->slug] = $p_lang->slug;
                 }
                 $multilang['default'] = $default;
                 $multilang['current'] = $current;
                 $multilang['languages'] = $languages;
             } else {
                 if (cs_is_qtranslate_activated()) {
                     global $q_config;
                     $multilang['default'] = $q_config['default_language'];
                     $multilang['current'] = $q_config['language'];
                     $multilang['languages'] = array_flip(qtrans_getSortedLanguages());
                 }
             }
         }
     }
     $multilang = apply_filters('cs_language_defaults', $multilang);
     return !empty($multilang) ? $multilang : false;
 }
    function render_field($field)
    {
        // enqueue
        acf_enqueue_uploader();
        // vars
        $id = uniqid('acf-editor-');
        //$id = $field['id'] . '-' . uniqid();
        $mode = 'html';
        $show_tabs = true;
        // get height
        $height = acf_get_user_setting('wysiwyg_height', 300);
        $height = max($height, 300);
        // minimum height is 300
        // detect mode
        // case: visual tab only
        if ($field['tabs'] == 'visual') {
            $mode = 'tmce';
            $show_tabs = false;
        } elseif ($field['tabs'] == 'text') {
            $show_tabs = false;
        } elseif (wp_default_editor() == 'tinymce') {
            $mode = 'tmce';
        }
        // mode
        $switch_class = $mode . '-active';
        // filter value for editor
        remove_all_filters('acf_the_editor_content');
        if ($mode == 'tmce') {
            add_filter('acf_the_editor_content', 'wp_richedit_pre');
        } else {
            add_filter('acf_the_editor_content', 'wp_htmledit_pre');
        }
        global $q_config, $wp_version;
        $languages = qtrans_getSortedLanguages(true);
        $values = qtrans_split($field['value'], $quicktags = true);
        $currentLanguage = $this->plugin->get_active_language();
        echo '<div class="multi-language-field multi-language-field-wysiwyg">';
        foreach ($languages as $language) {
            $class = $language === $currentLanguage ? 'wp-switch-editor current-language' : 'wp-switch-editor';
            echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
        }
        $uid = uniqid('acf-editor-');
        foreach ($languages as $language) {
            $value = apply_filters('acf_the_editor_content', $values[$language]);
            $id = $uid . "-{$language}";
            $name = $field['name'] . "[{$language}]";
            $class = $switch_class;
            if ($language === $currentLanguage) {
                $class .= ' current-language';
            }
            ?>
			<div id="wp-<?php 
            echo $id;
            ?>
-wrap" class="acf-editor-wrap wp-core-ui wp-editor-wrap <?php 
            echo $class;
            ?>
" data-toolbar="<?php 
            echo $field['toolbar'];
            ?>
" data-upload="<?php 
            echo $field['media_upload'];
            ?>
" data-language="<?php 
            echo $language;
            ?>
">
				<div id="wp-<?php 
            echo $id;
            ?>
-editor-tools" class="wp-editor-tools hide-if-no-js">
					<?php 
            if ($field['media_upload']) {
                ?>
					<div id="wp-<?php 
                echo $id;
                ?>
-media-buttons" class="wp-media-buttons">
						<?php 
                do_action('media_buttons');
                ?>
					</div>
					<?php 
            }
            ?>
					<?php 
            if (user_can_richedit() && $show_tabs) {
                ?>
						<div class="wp-editor-tabs">
							<button id="<?php 
                echo $id;
                ?>
-tmce" class="wp-switch-editor switch-tmce" onclick="switchEditors.switchto(this);" type="button"><?php 
                echo __('Visual', 'acf');
                ?>
</button>
							<button id="<?php 
                echo $id;
                ?>
-html" class="wp-switch-editor switch-html" onclick="switchEditors.switchto(this);" type="button"><?php 
                echo _x('Text', 'Name for the Text editor tab (formerly HTML)', 'acf');
                ?>
</button>
						</div>
					<?php 
            }
            ?>
				</div>
				<div id="wp-<?php 
            echo $id;
            ?>
-editor-container" class="wp-editor-container">
					<textarea id="<?php 
            echo $id;
            ?>
" class="qtx-wp-editor-area" name="<?php 
            echo $name;
            ?>
" <?php 
            if ($height) {
                ?>
style="height:<?php 
                echo $height;
                ?>
px;"<?php 
            }
            ?>
><?php 
            echo $value;
            ?>
</textarea>
				</div>
			</div>

		<?php 
        }
        echo '</div>';
    }
Example #14
0
?>
</span></a></h2>
		</div>
		<div class="description"><?php 
bloginfo('description');
?>
</div>
		<div id="head-menu">
			<ul id="header-nav">
				<?php 
wp_list_pages('child_of=10&depth=1&title_li=&sort_column=menu_order');
?>
			</ul>
			<ul id="head-idioma">
				<?php 
foreach (qtrans_getSortedLanguages() as $language) {
    ?>
					<li class="flag_<?php 
    echo $language;
    ?>
 <?php 
    if ($language == $q_config['language']) {
        echo ' class="active"';
    }
    ?>
">
						<a href="<?php 
    echo qtrans_convertURL($url, $language);
    ?>
" ><span><?php 
    echo $language;
function qtrans_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';
    switch ($style) {
        case 'image':
        case 'text':
        case 'dropdown':
            echo '<ul class="qtrans_language_chooser" id="' . $id . '">';
            foreach (qtrans_getSortedLanguages() as $language) {
                $classes = array('lang-' . $language);
                if ($language == $q_config['language']) {
                    $classes[] = 'active';
                }
                echo '<li class="' . implode(' ', $classes) . '"><a href="' . qtrans_convertURL($url, $language) . '"';
                // set hreflang
                echo ' hreflang="' . $language . '" title="' . $q_config['language_name'][$language] . '"';
                if ($style == 'image') {
                    echo ' class="qtrans_flag qtrans_flag_' . $language . '"';
                }
                echo '><span';
                if ($style == 'image') {
                    echo ' style="display:none"';
                }
                echo '>' . $q_config['language_name'][$language] . '</span></a></li>';
            }
            echo "</ul>";
            if ($style == 'dropdown') {
                echo "<script type=\"text/javascript\">\n// <![CDATA[\r\n";
                echo "var lc = document.getElementById('" . $id . "');\n";
                echo "var s = document.createElement('select');\n";
                echo "s.id = 'qtrans_select_" . $id . "';\n";
                echo "lc.parentNode.insertBefore(s,lc);";
                // create dropdown fields for each language
                foreach (qtrans_getSortedLanguages() as $language) {
                    echo qtrans_insertDropDownElement($language, qtrans_convertURL($url, $language), $id);
                }
                // hide html language chooser text
                echo "s.onchange = function() { document.location.href = this.value;}\n";
                echo "lc.style.display='none';\n";
                echo "// ]]>\n</script>\n";
            }
            break;
        case 'both':
            echo '<ul class="qtrans_language_chooser" id="' . $id . '">';
            foreach (qtrans_getSortedLanguages() as $language) {
                echo '<li';
                if ($language == $q_config['language']) {
                    echo ' class="active"';
                }
                echo '><a href="' . qtrans_convertURL($url, $language) . '"';
                echo ' class="qtrans_flag_' . $language . ' qtrans_flag_and_text" title="' . $q_config['language_name'][$language] . '"';
                echo '><span>' . $q_config['language_name'][$language] . '</span></a></li>';
            }
            echo "</ul><div class=\"qtrans_widget_end\"></div>";
            break;
    }
}
 /**
  * Prepare languages list if any
  *
  * @access private
  * @return void
  */
 private function prepareLanguages()
 {
     // check if languages list not prepared already
     if (!empty($this->languagesPrepared)) {
         return;
     }
     // get languages
     $langs = qtrans_getSortedLanguages();
     if (!empty($langs)) {
         global $q_config;
         foreach ($langs as $key => $val) {
             if (isset($q_config['locale'][$val])) {
                 $this->languages[$q_config['locale'][$val]] = $val;
             }
         }
     }
     // set languages list as prepared
     $this->languagesPrepared = true;
 }
    function create_field($field)
    {
        global $q_config, $wp_version;
        $languages = qtrans_getSortedLanguages(true);
        $values = qtrans_split($field['value'], $quicktags = true);
        $currentLanguage = $this->plugin->get_active_language();
        echo '<div class="multi-language-field multi-language-field-wysiwyg">';
        foreach ($languages as $language) {
            $class = $language === $currentLanguage ? 'wp-switch-editor current-language' : 'wp-switch-editor';
            echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
        }
        foreach ($languages as $language) {
            $value = $values[$language];
            $id = 'wysiwyg-' . $field['id'] . '-' . uniqid();
            $name = $field['name'] . "[{$language}]";
            $class = $language === $currentLanguage ? 'acf_wysiwyg wp-editor-wrap current-language' : 'acf_wysiwyg wp-editor-wrap';
            ?>
			<div id="wp-<?php 
            echo $id;
            ?>
-wrap" class="<?php 
            echo $class;
            ?>
" data-toolbar="<?php 
            echo $field['toolbar'];
            ?>
" data-upload="<?php 
            echo $field['media_upload'];
            ?>
" data-language="<?php 
            echo $language;
            ?>
">
				<?php 
            if (user_can_richedit() && $field['media_upload'] == 'yes') {
                ?>
					<?php 
                if (version_compare($wp_version, '3.3', '<')) {
                    ?>
						<div id="editor-toolbar">
							<div id="media-buttons" class="hide-if-no-js">
								<?php 
                    do_action('media_buttons');
                    ?>
							</div>
						</div>
					<?php 
                } else {
                    ?>
						<div id="wp-<?php 
                    echo $id;
                    ?>
-editor-tools" class="wp-editor-tools">
							<div id="wp-<?php 
                    echo $id;
                    ?>
-media-buttons" class="hide-if-no-js wp-media-buttons">
								<?php 
                    do_action('media_buttons');
                    ?>
							</div>
						</div>
					<?php 
                }
                ?>
				<?php 
            }
            ?>
				<div id="wp-<?php 
            echo $id;
            ?>
-editor-container" class="wp-editor-container">
					<textarea id="<?php 
            echo $id;
            ?>
" class="qtx-wp-editor-area" name="<?php 
            echo $name;
            ?>
" ><?php 
            if (user_can_richedit()) {
                echo wp_richedit_pre($field['value']);
            } else {
                echo wp_htmledit_pre($field['value']);
            }
            ?>
</textarea>
				</div>
			</div>
		<?php 
        }
        echo '</div>';
    }
function qtranslate_conf()
{
    global $q_config, $wpdb;
    // do redirection for dashboard
    if (isset($_GET['godashboard'])) {
        echo '<h2>' . __('Switching Language', 'qtranslate') . '</h2>' . sprintf(__('Switching language to %1$s... If the Dashboard isn\'t loading, use this <a href="%2$s" title="Dashboard">link</a>.', 'qtranslate'), $q_config['language_name'][qtrans_getLanguage()], admin_url()) . '<script type="text/javascript">document.location="' . admin_url() . '";</script>';
        exit;
    }
    // init some needed variables
    $error = '';
    $original_lang = '';
    $language_code = '';
    $language_name = '';
    $language_locale = '';
    $language_date_format = '';
    $language_time_format = '';
    $language_na_message = '';
    $language_flag = '';
    $language_default = '';
    $altered_table = false;
    $message = apply_filters('qtranslate_configuration_pre', '');
    // check for action
    if (isset($_POST['qtranslate_reset']) && isset($_POST['qtranslate_reset2'])) {
        $message = __('qTranslate has been reset.', 'qtranslate');
    } elseif (isset($_POST['default_language'])) {
        // save settings
        qtrans_checkSetting('default_language', true, QT_LANGUAGE);
        qtrans_checkSetting('flag_location', true, QT_URL);
        qtrans_checkSetting('ignore_file_types', true, QT_STRING);
        qtrans_checkSetting('detect_browser_language', true, QT_BOOLEAN);
        qtrans_checkSetting('hide_untranslated', true, QT_INTEGER);
        qtrans_checkSetting('use_strftime', true, QT_INTEGER);
        qtrans_checkSetting('url_mode', true, QT_INTEGER);
        qtrans_checkSetting('auto_update_mo', true, QT_BOOLEAN);
        qtrans_checkSetting('hide_default_language', true, QT_BOOLEAN);
        if (isset($_POST['update_mo_now']) && $_POST['update_mo_now'] == '1' && qtrans_updateGettextDatabases(true)) {
            $message = __('Gettext databases updated.', 'qtranslate');
        }
    }
    if (isset($_POST['original_lang'])) {
        // validate form input
        if ($_POST['language_na_message'] == '') {
            $error = __('The Language must have a Not-Available Message!', 'qtranslate');
        }
        if (strlen($_POST['language_locale']) < 2) {
            $error = __('The Language must have a Locale!', 'qtranslate');
        }
        if ($_POST['language_name'] == '') {
            $error = __('The Language must have a name!', 'qtranslate');
        }
        if (strlen($_POST['language_code']) != 2) {
            $error = __('Language Code has to be 2 characters long!', 'qtranslate');
        }
        if ($_POST['original_lang'] == '' && $error == '') {
            // new language
            if (isset($q_config['language_name'][$_POST['language_code']])) {
                $error = __('There is already a language with the same Language Code!', 'qtranslate');
            }
        }
        if ($_POST['original_lang'] != '' && $error == '') {
            // language update
            if ($_POST['language_code'] != $_POST['original_lang'] && isset($q_config['language_name'][$_POST['language_code']])) {
                $error = __('There is already a language with the same Language Code!', 'qtranslate');
            } else {
                // remove old language
                unset($q_config['language_name'][$_POST['original_lang']]);
                unset($q_config['flag'][$_POST['original_lang']]);
                unset($q_config['locale'][$_POST['original_lang']]);
                unset($q_config['date_format'][$_POST['original_lang']]);
                unset($q_config['time_format'][$_POST['original_lang']]);
                unset($q_config['not_available'][$_POST['original_lang']]);
                if (in_array($_POST['original_lang'], $q_config['enabled_languages'])) {
                    // was enabled, so set modified one to enabled too
                    for ($i = 0; $i < sizeof($q_config['enabled_languages']); $i++) {
                        if ($q_config['enabled_languages'][$i] == $_POST['original_lang']) {
                            $q_config['enabled_languages'][$i] = $_POST['language_code'];
                        }
                    }
                }
                if ($_POST['original_lang'] == $q_config['default_language']) {
                    // was default, so set modified the default
                    $q_config['default_language'] = $_POST['language_code'];
                }
            }
        }
        if (get_magic_quotes_gpc()) {
            if (isset($_POST['language_date_format'])) {
                $_POST['language_date_format'] = stripslashes($_POST['language_date_format']);
            }
            if (isset($_POST['language_time_format'])) {
                $_POST['language_time_format'] = stripslashes($_POST['language_time_format']);
            }
        }
        if ($error == '') {
            // everything is fine, insert language
            $q_config['language_name'][$_POST['language_code']] = $_POST['language_name'];
            $q_config['flag'][$_POST['language_code']] = $_POST['language_flag'];
            $q_config['locale'][$_POST['language_code']] = $_POST['language_locale'];
            $q_config['date_format'][$_POST['language_code']] = $_POST['language_date_format'];
            $q_config['time_format'][$_POST['language_code']] = $_POST['language_time_format'];
            $q_config['not_available'][$_POST['language_code']] = $_POST['language_na_message'];
        }
        if ($error != '' || isset($_GET['edit'])) {
            // get old values in the form
            $original_lang = $_POST['original_lang'];
            $language_code = $_POST['language_code'];
            $language_name = $_POST['language_name'];
            $language_locale = $_POST['language_locale'];
            $language_date_format = $_POST['language_date_format'];
            $language_time_format = $_POST['language_time_format'];
            $language_na_message = $_POST['language_na_message'];
            $language_flag = $_POST['language_flag'];
            $language_default = $_POST['language_default'];
        }
    } elseif (isset($_GET['convert'])) {
        // update language tags
        global $wpdb;
        $wpdb->show_errors();
        foreach ($q_config['enabled_languages'] as $lang) {
            $wpdb->query('UPDATE ' . $wpdb->posts . ' set post_title = REPLACE(post_title, "[lang_' . $lang . ']","<!--:' . $lang . '-->")');
            $wpdb->query('UPDATE ' . $wpdb->posts . ' set post_title = REPLACE(post_title, "[/lang_' . $lang . ']","<!--:-->")');
            $wpdb->query('UPDATE ' . $wpdb->posts . ' set post_content = REPLACE(post_content, "[lang_' . $lang . ']","<!--:' . $lang . '-->")');
            $wpdb->query('UPDATE ' . $wpdb->posts . ' set post_content = REPLACE(post_content, "[/lang_' . $lang . ']","<!--:-->")');
        }
        $message = "Database Update successful!";
    } elseif (isset($_GET['markdefault'])) {
        // update language tags
        global $wpdb;
        $wpdb->show_errors();
        $result = $wpdb->get_results('SELECT ID, post_title, post_content FROM ' . $wpdb->posts . ' WHERE NOT (post_content LIKE "%<!--:-->%" OR post_title LIKE "%<!--:-->%")');
        foreach ($result as $post) {
            $content = qtrans_split($post->post_content);
            $title = qtrans_split($post->post_title);
            foreach ($q_config['enabled_languages'] as $language) {
                if ($language != $q_config['default_language']) {
                    $content[$language] = "";
                    $title[$language] = "";
                }
            }
            $content = qtrans_join($content);
            $title = qtrans_join($title);
            $wpdb->query('UPDATE ' . $wpdb->posts . ' set post_content = "' . mysql_escape_string($content) . '", post_title = "' . mysql_escape_string($title) . '" WHERE ID=' . $post->ID);
        }
        $message = "All Posts marked as default language!";
    } elseif (isset($_GET['edit'])) {
        $original_lang = $_GET['edit'];
        $language_code = $_GET['edit'];
        $language_name = $q_config['language_name'][$_GET['edit']];
        $language_locale = $q_config['locale'][$_GET['edit']];
        $language_date_format = $q_config['date_format'][$_GET['edit']];
        $language_time_format = $q_config['time_format'][$_GET['edit']];
        $language_na_message = $q_config['not_available'][$_GET['edit']];
        $language_flag = $q_config['flag'][$_GET['edit']];
    } elseif (isset($_GET['delete'])) {
        // validate delete (protect code)
        if ($q_config['default_language'] == $_GET['delete']) {
            $error = 'Cannot delete Default Language!';
        }
        if (!isset($q_config['language_name'][$_GET['delete']]) || strtolower($_GET['delete']) == 'code') {
            $error = 'No such language!';
        }
        if ($error == '') {
            // everything seems fine, delete language
            qtrans_disableLanguage($_GET['delete']);
            unset($q_config['language_name'][$_GET['delete']]);
            unset($q_config['flag'][$_GET['delete']]);
            unset($q_config['locale'][$_GET['delete']]);
            unset($q_config['date_format'][$_GET['delete']]);
            unset($q_config['time_format'][$_GET['delete']]);
            unset($q_config['not_available'][$_GET['delete']]);
        }
    } elseif (isset($_GET['enable'])) {
        // enable validate
        if (!qtrans_enableLanguage($_GET['enable'])) {
            $error = __('Language is already enabled or invalid!', 'qtranslate');
        }
    } elseif (isset($_GET['disable'])) {
        // enable validate
        if ($_GET['disable'] == $q_config['default_language']) {
            $error = __('Cannot disable Default Language!', 'qtranslate');
        }
        if (!qtrans_isEnabled($_GET['disable'])) {
            if (!isset($q_config['language_name'][$_GET['disable']])) {
                $error = __('No such language!', 'qtranslate');
            }
        }
        // everything seems fine, disable language
        if ($error == '' && !qtrans_disableLanguage($_GET['disable'])) {
            $error = __('Language is already disabled!', 'qtranslate');
        }
    } elseif (isset($_GET['moveup'])) {
        $languages = qtrans_getSortedLanguages();
        $message = __('No such language!', 'qtranslate');
        foreach ($languages as $key => $language) {
            if ($language == $_GET['moveup']) {
                if ($key == 0) {
                    $message = __('Language is already first!', 'qtranslate');
                    break;
                }
                $languages[$key] = $languages[$key - 1];
                $languages[$key - 1] = $language;
                $q_config['enabled_languages'] = $languages;
                $message = __('New order saved.', 'qtranslate');
                break;
            }
        }
    } elseif (isset($_GET['movedown'])) {
        $languages = qtrans_getSortedLanguages();
        $message = __('No such language!', 'qtranslate');
        foreach ($languages as $key => $language) {
            if ($language == $_GET['movedown']) {
                if ($key == sizeof($languages) - 1) {
                    $message = __('Language is already last!', 'qtranslate');
                    break;
                }
                $languages[$key] = $languages[$key + 1];
                $languages[$key + 1] = $language;
                $q_config['enabled_languages'] = $languages;
                $message = __('New order saved.', 'qtranslate');
                break;
            }
        }
    }
    $everything_fine = (isset($_POST['submit']) || isset($_GET['delete']) || isset($_GET['enable']) || isset($_GET['disable']) || isset($_GET['moveup']) || isset($_GET['movedown'])) && $error == '';
    if ($everything_fine) {
        // settings might have changed, so save
        qtrans_saveConfig();
        if (empty($message)) {
            $message = __('Options saved.', 'qtranslate');
        }
    }
    if ($q_config['auto_update_mo']) {
        if (!is_dir(WP_LANG_DIR) || !($ll = @fopen(trailingslashit(WP_LANG_DIR) . 'qtranslate.test', 'a'))) {
            $error = 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');
        }
    }
    // don't accidently delete/enable/disable twice
    $clean_uri = preg_replace("/&(delete|enable|disable|convert|markdefault|moveup|movedown)=[^&#]*/i", "", $_SERVER['REQUEST_URI']);
    $clean_uri = apply_filters('qtranslate_clean_uri', $clean_uri);
    // Generate XHTML
    if ($message) {
        ?>
<div id="message" class="updated fade"><p><strong><?php 
        echo $message;
        ?>
</strong></p></div>
<?php 
    }
    if ($error != '') {
        ?>
<div id="message" class="error fade"><p><strong><?php 
        echo $error;
        ?>
</strong></p></div>
<?php 
    }
    ?>

<?php 
    if (isset($_GET['edit'])) {
        ?>
<div class="wrap">
<h2><?php 
        _e('Edit Language', 'qtranslate');
        ?>
</h2>
<form action="" method="post" id="qtranslate-edit-language">
<?php 
        qtranslate_language_form($language_code, $language_code, $language_name, $language_locale, $language_date_format, $language_time_format, $language_flag, $language_na_message, $language_default, $original_lang);
        ?>
<p class="submit"><input type="submit" name="submit" value="<?php 
        _e('Save Changes &raquo;', 'qtranslate');
        ?>
" /></p>
</form>
</div>
<?php 
    } else {
        ?>
<div class="wrap">
<h2><?php 
        _e('Language Management (qTranslate Configuration)', 'qtranslate');
        ?>
</h2> 
<div class="tablenav"><?php 
        printf(__('For help on how to configure qTranslate correctly, take a look at the <a href="%1$s">qTranslate FAQ</a> and the <a href="%2$s">Support Forum</a>.', 'qtranslate'), 'http://www.qianqin.de/qtranslate/faq/', 'http://www.qianqin.de/qtranslate/forum/viewforum.php?f=3');
        ?>
</div>
	<form action="<?php 
        echo $clean_uri;
        ?>
" method="post">
		<h3><?php 
        _e('General Settings', 'qtranslate');
        ?>
</h3>
		<table class="form-table">
			<tr>
				<th scope="row"><?php 
        _e('Default Language / Order', 'qtranslate');
        ?>
</th>
				<td>
					<fieldset><legend class="hidden"><?php 
        _e('Default Language', 'qtranslate');
        ?>
</legend>
				<?php 
        foreach (qtrans_getSortedLanguages() as $key => $language) {
            echo "\t<label title='" . $q_config['language_name'][$language] . "'><input type='radio' name='default_language' value='" . $language . "'";
            if ($language == $q_config['default_language']) {
                echo " checked='checked'";
            }
            echo ' />';
            echo ' <a href="' . add_query_arg('moveup', $language, $clean_uri) . '"><img src="' . WP_PLUGIN_URL . '/' . basename(__DIR__) . '/arrowup.png" alt="up" /></a>';
            echo ' <a href="' . add_query_arg('movedown', $language, $clean_uri) . '"><img src="' . WP_PLUGIN_URL . '/' . basename(__DIR__) . '/arrowdown.png" alt="down" /></a>';
            echo ' <img src="' . trailingslashit(WP_CONTENT_URL) . $q_config['flag_location'] . $q_config['flag'][$language] . '" alt="' . $q_config['language_name'][$language] . '" /> ';
            echo ' ' . $q_config['language_name'][$language] . "</label><br />\n";
        }
        ?>
					</br>
					<?php 
        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'), get_bloginfo('url'));
        ?>
					</fieldset>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row"><?php 
        _e('Untranslated Content', 'qtranslate');
        ?>
</th>
				<td>
					<fieldset><legend class="hidden"><?php 
        _e('URL Modification Mode', 'qtranslate');
        ?>
</legend>
						<label title="Hide untranslated"><input type="radio" name="hide_untranslated" value="<?php 
        echo QT_UNTRANSLATED_HIDE;
        ?>
" <?php 
        echo $q_config['hide_untranslated'] == QT_UNTRANSLATED_HIDE ? "checked=\"checked\"" : "";
        ?>
 /> <?php 
        _e('Hide Content which is not available for the selected language.', 'qtranslate');
        ?>
</label><br />
						<label title="Show messages"><input type="radio" name="hide_untranslated" value="<?php 
        echo QT_UNTRANSLATED_MESSAGE;
        ?>
" <?php 
        echo $q_config['hide_untranslated'] == QT_UNTRANSLATED_MESSAGE ? "checked=\"checked\"" : "";
        ?>
 /> <?php 
        _e('Display a message showing all the languages the content is available in.', 'qtranslate');
        ?>
</label><br />
						<label title="Show default language"><input type="radio" name="hide_untranslated" value="<?php 
        echo QT_UNTRANSLATED_DEFAULT;
        ?>
" <?php 
        echo $q_config['hide_untranslated'] == QT_UNTRANSLATED_DEFAULT ? "checked=\"checked\"" : "";
        ?>
 /> <?php 
        _e('Display the content in default language (or the first available language)', 'qtranslate');
        ?>
</label><br />
					</fieldset><br/>
					<?php 
        _e('This function will not work correctly if you installed qTranslate on a blog with existing entries. In this case you will need to take a look at "Convert Database" under "Advanced Settings".', 'qtranslate');
        ?>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row"><?php 
        _e('Detect Browser Language', 'qtranslate');
        ?>
</th>
				<td>
					<label for="detect_browser_language"><input type="checkbox" name="detect_browser_language" id="detect_browser_language" value="1"<?php 
        echo $q_config['detect_browser_language'] ? ' checked="checked"' : '';
        ?>
/> <?php 
        _e('Detect the language of the browser and redirect accordingly.', 'qtranslate');
        ?>
</label>
					<br/>
					<?php 
        _e('When the frontpage is visited via bookmark/external link/type-in, the visitor will be forwarded to the correct URL for the language specified by his browser.', 'qtranslate');
        ?>
				</td>
			</tr>
		</table>
		<h3><?php 
        _e('Advanced Settings', 'qtranslate');
        ?>
<span id="qtranslate-show-advanced" style="display:none"> (<a name="advanced_settings" href="#advanced_settings" onclick="showAdvanced();"><?php 
        _e('Show', 'qtranslate');
        ?>
</a>)</span></h3>
		<table class="form-table" id="qtranslate-advanced">
			<tr>
				<th scope="row"><?php 
        _e('URL Modification Mode', 'qtranslate');
        ?>
</th>
				<td>
					<fieldset><legend class="hidden"><?php 
        _e('URL Modification Mode', 'qtranslate');
        ?>
</legend>
						<label title="Query Mode"><input type="radio" name="url_mode" value="<?php 
        echo QT_URL_QUERY;
        ?>
" <?php 
        echo $q_config['url_mode'] == QT_URL_QUERY ? "checked=\"checked\"" : "";
        ?>
 /> <?php 
        _e('Use Query Mode (?lang=en)', 'qtranslate');
        ?>
</label><br />
						<label title="Pre-Path Mode"><input type="radio" name="url_mode" value="<?php 
        echo QT_URL_PATH;
        ?>
" <?php 
        echo $q_config['url_mode'] == QT_URL_PATH ? "checked=\"checked\"" : "";
        ?>
 /> <?php 
        _e('Use Pre-Path Mode (Default, puts /en/ in front of URL)', 'qtranslate');
        ?>
</label><br />
						<label title="Pre-Domain Mode"><input type="radio" name="url_mode" value="<?php 
        echo QT_URL_DOMAIN;
        ?>
" <?php 
        echo $q_config['url_mode'] == QT_URL_DOMAIN ? "checked=\"checked\"" : "";
        ?>
 /> <?php 
        _e('Use Pre-Domain Mode (uses http://en.yoursite.com)', 'qtranslate');
        ?>
</label><br />
					</fieldset><br/>
					<?php 
        _e('Pre-Path and Pre-Domain mode will only work with mod_rewrite/pretty permalinks. Additional Configuration is needed for Pre-Domain mode!', 'qtranslate');
        ?>
<br/>
					<label for="hide_default_language"><input type="checkbox" name="hide_default_language" id="hide_default_language" value="1"<?php 
        echo $q_config['hide_default_language'] ? ' checked="checked"' : '';
        ?>
/> <?php 
        _e('Hide URL language information for default language.', 'qtranslate');
        ?>
</label>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row"><?php 
        _e('Flag Image Path', 'qtranslate');
        ?>
</th>
				<td>
					<?php 
        echo trailingslashit(WP_CONTENT_URL);
        ?>
<input type="text" name="flag_location" id="flag_location" value="<?php 
        echo $q_config['flag_location'];
        ?>
" style="width:50%"/>
					<br/>
					<?php 
        _e('Path to the flag images under wp-content, with trailing slash. (Default: plugins/qtranslate/flags/)', 'qtranslate');
        ?>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row"><?php 
        _e('Ignore Links', 'qtranslate');
        ?>
</th>
				<td>
					<input type="text" name="ignore_file_types" id="ignore_file_types" value="<?php 
        echo $q_config['ignore_file_types'];
        ?>
" style="width:100%"/>
					<br/>
					<?php 
        _e('Don\'t convert Links to files of the given file types. (Default: gif,jpg,jpeg,png,pdf,swf,tif,rar,zip,7z,mpg,divx,mpeg,avi,css,js)', 'qtranslate');
        ?>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row"><?php 
        _e('Update Gettext Databases', 'qtranslate');
        ?>
</th>
				<td>
					<label for="auto_update_mo"><input type="checkbox" name="auto_update_mo" id="auto_update_mo" value="1"<?php 
        echo $q_config['auto_update_mo'] ? ' checked="checked"' : '';
        ?>
/> <?php 
        _e('Automatically check for .mo-Database Updates of installed languages.', 'qtranslate');
        ?>
</label>
					<br/>
					<label for="update_mo_now"><input type="checkbox" name="update_mo_now" id="update_mo_now" value="1" /> <?php 
        _e('Update Gettext databases now.', 'qtranslate');
        ?>
</label>
					<br/>
					<?php 
        _e('qTranslate will query the Wordpress Localisation Repository every week and download the latest Gettext Databases (.mo Files).', 'qtranslate');
        ?>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row"><?php 
        _e('Date / Time Conversion', 'qtranslate');
        ?>
</th>
				<td>
					<label><input type="radio" name="use_strftime" value="<?php 
        echo QT_DATE;
        ?>
" <?php 
        echo $q_config['use_strftime'] == QT_DATE ? ' checked="checked"' : '';
        ?>
/> <?php 
        _e('Use emulated date function.', 'qtranslate');
        ?>
</label><br />
					<label><input type="radio" name="use_strftime" value="<?php 
        echo QT_DATE_OVERRIDE;
        ?>
" <?php 
        echo $q_config['use_strftime'] == QT_DATE_OVERRIDE ? ' checked="checked"' : '';
        ?>
/> <?php 
        _e('Use emulated date function and replace formats with the predefined formats for each language.', 'qtranslate');
        ?>
</label><br />
					<label><input type="radio" name="use_strftime" value="<?php 
        echo QT_STRFTIME;
        ?>
" <?php 
        echo $q_config['use_strftime'] == QT_STRFTIME ? ' checked="checked"' : '';
        ?>
/> <?php 
        _e('Use strftime instead of date.', 'qtranslate');
        ?>
</label><br />
					<label><input type="radio" name="use_strftime" value="<?php 
        echo QT_STRFTIME_OVERRIDE;
        ?>
" <?php 
        echo $q_config['use_strftime'] == QT_STRFTIME_OVERRIDE ? ' checked="checked"' : '';
        ?>
/> <?php 
        _e('Use strftime instead of date and replace formats with the predefined formats for each language.', 'qtranslate');
        ?>
</label><br />
					<?php 
        _e('Depending on the mode selected, additional customizations of the theme may be needed.', 'qtranslate');
        ?>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row"><?php 
        _e('Reset qTranslate', 'qtranslate');
        ?>
</th>
				<td>
					<label for="qtranslate_reset"><input type="checkbox" name="qtranslate_reset" id="qtranslate_reset" value="1"/> <?php 
        _e('Check this box and click Save Changes to reset all qTranslate settings.', 'qtranslate');
        ?>
</label>
					<br/>
					<label for="qtranslate_reset2"><input type="checkbox" name="qtranslate_reset2" id="qtranslate_reset2" value="1"/> <?php 
        _e('Yes, I really want to reset qTranslate.', 'qtranslate');
        ?>
</label>
					<br/>
					<label for="qtranslate_reset3"><input type="checkbox" name="qtranslate_reset3" id="qtranslate_reset3" value="1"/> <?php 
        _e('Also delete Translations for Categories/Tags/Link Categories.', 'qtranslate');
        ?>
</label>
					<br/>
					<?php 
        _e('If something isn\'t working correctly, you can always try to reset all qTranslate settings. A Reset won\'t delete any posts but will remove all settings (including all languages added).', 'qtranslate');
        ?>
				</td>
			</tr>
			<tr>
				<th scope="row"><?php 
        _e('Convert Database', 'qtranslate');
        ?>
</th>
				<td>
					<?php 
        printf(__('If you are updating from qTranslate 1.x or Polyglot, <a href="%s">click here</a> to convert posts to the new language tag format.', 'qtranslate'), $clean_uri . '&convert=true');
        ?>
					<?php 
        printf(__('If you have installed qTranslate for the first time on a Wordpress with existing posts, you can either go through all your posts manually and save them in the correct language or <a href="%s">click here</a> to mark all existing posts as written in the default language.', 'qtranslate'), $clean_uri . '&markdefault=true');
        ?>
					<?php 
        _e('Both processes are <b>irreversible</b>! Be sure to make a full database backup before clicking one of the links.', 'qtranslate');
        ?>
				</td>
			</tr>
			<tr>
				<th scope="row"><?php 
        _e('Debugging Information', 'qtranslate');
        ?>
</th>
				<td>
					<p><?php 
        printf(__('If you encounter any problems and you are unable to solve them yourself, you can visit the <a href="%s">Support Forum</a>. Posting the following Content will help other detect any misconfigurations.', 'qtranslate'), 'http://www.qianqin.de/qtranslate/forum/');
        ?>
</p>
					<textarea readonly="readonly" id="qtranslate_debug"><?php 
        $q_config_copy = $q_config;
        // remove information to keep data anonymous and other not needed things
        unset($q_config_copy['url_info']);
        unset($q_config_copy['js']);
        unset($q_config_copy['windows_locale']);
        unset($q_config_copy['pre_domain']);
        unset($q_config_copy['term_name']);
        echo htmlspecialchars(print_r($q_config_copy, true));
        ?>
</textarea>
				</td>
			</tr>
		</table>
		<script type="text/javascript">
		// <![CDATA[
			function showAdvanced() {
				document.getElementById('qtranslate-advanced').style.display='block';
				document.getElementById('qtranslate-show-advanced').style.display='none';
				return false;
			}
			
			if(location.hash!='#advanced_settings') {
					document.getElementById('qtranslate-show-advanced').style.display='inline';
					document.getElementById('qtranslate-advanced').style.display='none';
			}
		// ]]>
		</script>
<?php 
        do_action('qtranslate_configuration', $clean_uri);
        ?>
		<p class="submit">
			<input type="submit" name="submit" class="button-primary" value="<?php 
        _e('Save Changes', 'qtranslate');
        ?>
" />
		</p>
	</form>

</div>
<div class="wrap">

<h2><?php 
        _e('Languages', 'qtranslate');
        ?>
</h2>
<div id="col-container">

<div id="col-right">
<div class="col-wrap">

<table class="widefat">
	<thead>
	<tr>
<?php 
        print_column_headers('language');
        ?>
	</tr>
	</thead>

	<tfoot>
	<tr>
<?php 
        print_column_headers('language', false);
        ?>
	</tr>
	</tfoot>

	<tbody id="the-list" class="list:cat">
<?php 
        foreach ($q_config['language_name'] as $lang => $language) {
            if ($lang != 'code') {
                ?>
	<tr>
		<td><img src="<?php 
                echo trailingslashit(WP_CONTENT_URL) . $q_config['flag_location'] . $q_config['flag'][$lang];
                ?>
" alt="<?php 
                echo $language;
                ?>
 Flag"></td>
		<td><?php 
                echo $language;
                ?>
</td>
		<td><?php 
                if (in_array($lang, $q_config['enabled_languages'])) {
                    ?>
<a class="edit" href="<?php 
                    echo $clean_uri;
                    ?>
&disable=<?php 
                    echo $lang;
                    ?>
"><?php 
                    _e('Disable', 'qtranslate');
                    ?>
</a><?php 
                } else {
                    ?>
<a class="edit" href="<?php 
                    echo $clean_uri;
                    ?>
&enable=<?php 
                    echo $lang;
                    ?>
"><?php 
                    _e('Enable', 'qtranslate');
                    ?>
</a><?php 
                }
                ?>
</td>
		<td><a class="edit" href="<?php 
                echo $clean_uri;
                ?>
&edit=<?php 
                echo $lang;
                ?>
"><?php 
                _e('Edit', 'qtranslate');
                ?>
</a></td>
		<td><?php 
                if ($q_config['default_language'] == $lang) {
                    _e('Default', 'qtranslate');
                } else {
                    ?>
<a class="delete" href="<?php 
                    echo $clean_uri;
                    ?>
&delete=<?php 
                    echo $lang;
                    ?>
"><?php 
                    _e('Delete', 'qtranslate');
                    ?>
</a><?php 
                }
                ?>
</td>
	</tr>
<?php 
            }
        }
        ?>
	</tbody>
</table>
<p><?php 
        _e('Enabling a language will cause qTranslate to update the Gettext-Database for the language, which can take a while depending on your server\'s connection speed.', 'qtranslate');
        ?>
</p>
</div>
</div><!-- /col-right -->

<div id="col-left">
<div class="col-wrap">
<div class="form-wrap">
<h3><?php 
        _e('Add Language', 'qtranslate');
        ?>
</h3>
<form name="addcat" id="addcat" method="post" class="add:the-list: validate">
<?php 
        qtranslate_language_form($language_code, $language_code, $language_name, $language_locale, $language_date_format, $language_time_format, $language_flag, $language_default, $language_na_message);
        ?>
<p class="submit"><input type="submit" name="submit" value="<?php 
        _e('Add Language &raquo;', 'qtranslate');
        ?>
" /></p>
</form></div>
</div>
</div><!-- /col-left -->

</div><!-- /col-container -->
<?php 
    }
}
function mqtrans_userProfile($user)
{
    global $q_config;
    if (empty($q_config['ul_lang_protection'])) {
        return;
    }
    $cu = wp_get_current_user();
    $langs = qtrans_getSortedLanguages();
    echo '<h3>' . __('mqTranslate User Language Settings', 'mqtranslate') . "</h3>\n";
    echo "<table class=\"form-table\">\n<tbody>\n";
    // Editable languages
    $user_meta = get_user_meta($user->ID);
    if (empty($user_meta) || !is_array($user_meta) || !array_key_exists('mqtranslate_language_access', $user_meta)) {
        $user_langs = $q_config['enabled_languages'];
    } else {
        $user_langs = explode(',', get_user_meta($user->ID, 'mqtranslate_language_access', true));
    }
    echo "<tr>\n";
    if ($cu->ID == $user->ID) {
        echo '<th>' . __('You can edit posts in', 'mqtranslate') . "</th>\n";
    } else {
        echo '<th>' . __('This user can edit posts in', 'mqtranslate') . "</th>\n";
    }
    echo "<td>";
    if ($user->has_cap('edit_users')) {
        if (empty($langs)) {
            _e('No language available', 'mqtranslate');
        } else {
            if ($cu->ID == $user->ID) {
                _e('As an Administrator, you can edit posts in all languages.', 'mqtranslate');
            } else {
                _e('As an Administrator, this user can edit posts in all languages.', 'mqtranslate');
            }
        }
    } else {
        if ($cu->has_cap('edit_users')) {
            if (empty($langs)) {
                _e('No language available', 'mqtranslate') . "\n";
            } else {
                $checkboxes = array();
                foreach ($langs as $l) {
                    $name = "mqtrans_user_lang_{$l}";
                    $checked = in_array($l, $user_langs) ? 'checked' : '';
                    $checkboxes[] = "<label for=\"{$name}\"><input type=\"checkbox\" name=\"mqtrans_user_lang[]\" id=\"{$name}\" value=\"{$l}\" {$checked} /> {$q_config['language_name'][$l]}</label>\n";
                }
                echo implode("<br />\n", $checkboxes);
            }
        } else {
            $intersect = array_intersect($langs, $user_langs);
            if (empty($intersect)) {
                _e('No language selected', 'mqtranslate') . "\n";
            } else {
                $languages = array();
                foreach ($intersect as $l) {
                    $languages[] = $q_config['language_name'][$l];
                }
                echo implode(', ', $languages);
            }
        }
    }
    echo "</td>\n";
    echo "</tr>\n";
    // Master language
    $user_master_lang = get_user_meta($user->ID, 'mqtranslate_master_language', true);
    echo "<tr>\n";
    echo '<th>' . __('Master language', 'mqtranslate') . "</th>\n";
    echo "<td>\n";
    if ($user->has_cap('edit_users')) {
        _e('Not applicable to Administrators', 'mqtranslate');
    } else {
        if ($cu->has_cap('edit_users')) {
            echo "<select name=\"mqtrans_master_lang\">\n";
            echo '<option value="">' . __('Default Language', 'mqtranslate') . "</option>\n";
            foreach ($langs as $l) {
                if ($l == $q_config['default_language']) {
                    continue;
                }
                $selected = $user_master_lang == $l ? ' selected' : '';
                echo "<option value=\"{$l}\"{$selected}>{$q_config['language_name'][$l]}</option>\n";
            }
            echo "</select>\n";
            echo '<span class="description">' . __('Language from which texts should be translated by this user', 'mqtranslate') . "</span>\n";
        } else {
            if (empty($langs) || empty($user_master_lang) || !in_array($user_master_lang, $langs)) {
                _e('Default Language', 'mqtranslate');
            } else {
                echo $q_config['language_name'][$user_master_lang];
            }
        }
    }
    echo "</td>\n";
    echo "</tr>\n";
    echo "</tbody>\n</table>\n";
}
 function language_getlanguages()
 {
     if ($this->language_do()) {
         if (function_exists('qtrans_getSortedLanguages')) {
             if ($languages = qtrans_getSortedLanguages()) {
                 return $languages;
             }
         }
     }
     return false;
 }
Example #21
0
    function render_field($field)
    {
        global $q_config;
        $languages = qtrans_getSortedLanguages(true);
        $values = qtrans_split($field['value'], $quicktags = true);
        $currentLanguage = $this->plugin->get_active_language();
        // enqueue
        acf_enqueue_uploader();
        // vars
        $o = array('icon' => '', 'title' => '', 'size' => '', 'url' => '', 'name' => '');
        $div = array('class' => 'acf-file-uploader acf-cf', 'data-library' => $field['library'], 'data-mime_types' => $field['mime_types']);
        $input_atts = array('type' => 'hidden', 'name' => $field['name'], 'value' => $field['value'], 'data-name' => 'value-id');
        $url = '';
        echo '<div class="multi-language-field multi-language-field-image">';
        foreach ($languages as $language) {
            $class = 'wp-switch-editor';
            if ($language === $currentLanguage) {
                $class .= ' current-language';
            }
            echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
        }
        foreach ($languages as $language) {
            $input_atts['name'] = $field['name'] . '[' . $language . ']';
            $field['value'] = $values[$language];
            $div['data-language'] = $language;
            $div['class'] = 'acf-file-uploader acf-cf';
            // has value?
            if ($field['value'] && is_numeric($field['value'])) {
                $file = get_post($field['value']);
                if ($file) {
                    $div['class'] .= ' has-value';
                    $o['icon'] = wp_mime_type_icon($file->ID);
                    $o['title'] = $file->post_title;
                    $o['size'] = @size_format(filesize(get_attached_file($file->ID)));
                    $o['url'] = wp_get_attachment_url($file->ID);
                    $explode = explode('/', $o['url']);
                    $o['name'] = end($explode);
                }
            }
            // basic?
            $basic = !current_user_can('upload_files');
            if ($basic) {
                $div['class'] .= ' basic';
            }
            if ($language === $currentLanguage) {
                $div['class'] .= ' current-language';
            }
            ?>
			<div <?php 
            acf_esc_attr_e($div);
            ?>
>
				<div class="acf-hidden">
					<?php 
            acf_hidden_input(array('name' => $input_atts['name'], 'value' => $field['value'], 'data-name' => 'id'));
            ?>
				</div>
				<div class="show-if-value file-wrap acf-soh">
					<div class="file-icon">
						<img data-name="icon" src="<?php 
            echo $o['icon'];
            ?>
" alt=""/>
					</div>
					<div class="file-info">
						<p>
							<strong data-name="title"><?php 
            echo $o['title'];
            ?>
</strong>
						</p>
						<p>
							<strong><?php 
            _e('File Name', 'acf');
            ?>
:</strong>
							<a data-name="name" href="<?php 
            echo $o['url'];
            ?>
" target="_blank"><?php 
            echo $o['name'];
            ?>
</a>
						</p>
						<p>
							<strong><?php 
            _e('File Size', 'acf');
            ?>
:</strong>
							<span data-name="size"><?php 
            echo $o['size'];
            ?>
</span>
						</p>

						<ul class="acf-hl acf-soh-target">
							<?php 
            if (!$basic) {
                ?>
								<li><a class="acf-icon dark" data-name="edit" href="#"><i class="acf-sprite-edit"></i></a></li>
							<?php 
            }
            ?>
							<li><a class="acf-icon dark" data-name="remove" href="#"><i class="acf-sprite-delete"></i></a></li>
						</ul>
					</div>
				</div>
				<div class="hide-if-value">
					<?php 
            if ($basic) {
                ?>

						<?php 
                if ($field['value'] && !is_numeric($field['value'])) {
                    ?>
							<div class="acf-error-message"><p><?php 
                    echo $field['value'];
                    ?>
</p></div>
						<?php 
                }
                ?>

						<input type="file" name="<?php 
                echo $field['name'];
                ?>
" id="<?php 
                echo $field['id'];
                ?>
" />

					<?php 
            } else {
                ?>

						<p style="margin:0;"><?php 
                _e('No File selected', 'acf');
                ?>
 <a data-name="add" class="acf-button" href="#"><?php 
                _e('Add File', 'acf');
                ?>
</a></p>

					<?php 
            }
            ?>

				</div>
			</div>

		<?php 
        }
        echo '</div>';
    }
function qs_service()
{
    global $q_config, $qs_public_key, $qs_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']);
    $translate_from = '';
    if (isset($_REQUEST['source_language']) && qtrans_isEnabled($_REQUEST['source_language'])) {
        $translate_from = $_REQUEST['source_language'];
    }
    if (isset($_REQUEST['target_language']) && qtrans_isEnabled($_REQUEST['target_language'])) {
        $translate_to = $_REQUEST['target_language'];
    }
    if ($translate_to == $translate_from) {
        $translate_to = '';
    }
    $post =& get_post($post_id);
    if (!$post) {
        printf(__('Post with id "%s" not found!', 'qtranslate'), $post_id);
        return;
    }
    $default_service = intval(get_option('qs_default_service'));
    $service_settings = get_option('qs_service_settings');
    // Detect available Languages and possible target languages
    $available_languages = qtrans_getAvailableLanguages($post->post_content);
    if (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) {
            $translate_to = '';
        }
        $translate_from = $available_languages[0];
    } elseif ($translate_from == '' && sizeof($available_languages) > 1) {
        $languages = qtrans_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 = qtrans_use($translate_from, $post->post_title);
    $post_content = qtrans_use($translate_from, $post->post_content);
    if (isset($translate_from) && isset($translate_to)) {
        $title = sprintf('Translate &quot;%1$s&quot; from %2$s to %3$s', htmlspecialchars($post_title), $q_config['language_name'][$translate_from], $q_config['language_name'][$translate_to]);
    } elseif (isset($translate_from)) {
        $title = sprintf('Translate &quot;%1$s&quot; from %2$s', htmlspecialchars($post_title), $q_config['language_name'][$translate_from]);
    } else {
        $title = sprintf('Translate &quot;%1$s&quot;', htmlspecialchars($post_title));
    }
    // Check data
    if (isset($_POST['service_id'])) {
        $service_id = intval($_POST['service_id']);
        $default_service = $service_id;
        update_option('qs_default_service', $service_id);
        $order_key = substr(md5(time() . AUTH_KEY), 0, 20);
        $request = array('order_service_id' => $service_id, 'order_url' => get_option('home'), 'order_key' => $order_key, 'order_title' => $post_title, 'order_text' => $post_content, 'order_source_language' => $translate_from, 'order_source_locale' => $q_config['locale'][$translate_from], 'order_target_language' => $translate_to, 'order_target_locale' => $q_config['locale'][$translate_to]);
        // check for additional fields
        if (is_array($service_settings[$service_id])) {
            $request['order_required_field'] = array();
            foreach ($service_settings[$service_id] as $setting => $value) {
                $request['order_required_field'][$setting] = $value;
            }
        }
        $answer = qs_queryQS(QS_INIT_TRANSLATION, $request);
        if (isset($answer['error'])) {
            $error = sprintf(__('An error occured: %s', 'qtranslate'), $qs_error_messages[$answer['error']]);
            if ($answer['message'] != '') {
                $error .= '<br />' . sprintf(__('Additional information: %s', 'qtranslate'), qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($answer['message']));
            }
        }
        if (isset($answer['order_id'])) {
            $orders = get_option('qs_orders');
            if (!is_array($orders)) {
                $orders = array();
            }
            $orders[] = array('post_id' => $post_id, 'service_id' => $service_id, 'source_language' => $translate_from, 'target_language' => $translate_to, 'order' => array('order_key' => $order_key, 'order_id' => $answer['order_id']));
            update_option('qs_orders', $orders);
            if (empty($answer['message'])) {
                $order_completed_message = '';
            } else {
                $order_completed_message = htmlspecialchars($answer['message']);
            }
            qs_UpdateOrder($answer['order_id']);
        }
    }
    if (isset($error)) {
        ?>
<div class="wrap">
<h2><?php 
        _e('qTranslate Services', 'qtranslate');
        ?>
</h2>
<div id="message" class="error fade"><p><?php 
        echo $error;
        ?>
</p></div>
<p><?php 
        printf(__('An serious error occured and qTranslate Services cannot proceed. For help, please visit the <a href="%s">Support Forum</a>', 'qtranslate'), 'http://www.qianqin.de/qtranslate/forum/');
        ?>
</p>
</div>
<?php 
        return;
    }
    if (isset($order_completed_message)) {
        ?>
<div class="wrap">
<h2><?php 
        _e('qTranslate Services', 'qtranslate');
        ?>
</h2>
<div id="message" class="updated fade"><p><?php 
        _e('Order successfully sent.', 'qtranslate');
        ?>
</p></div>
<p><?php 
        _e('Your translation order has been successfully transfered to the selected service.', 'qtranslate');
        ?>
</p>
<?php 
        if (!empty($order_completed_message)) {
            ?>
<p><?php 
            printf(__('The service returned this message: %s', 'qtranslate'), $order_completed_message);
            ?>
</p>
<?php 
        }
        ?>
<p><?php 
        _e('Feel free to choose an action:', 'qtranslate');
        ?>
</p>
<ul>
	<li><a href="<?php 
        echo add_query_arg('target_language', null, $url_link);
        ?>
"><?php 
        _e('Translate this post to another language.', 'qtranslate');
        ?>
</a></li>
	<li><a href="edit.php"><?php 
        _e('Translate a different post.', 'qtranslate');
        ?>
</a></li>
	<li><a href="options-general.php?page=qtranslate#qtranslate_service_settings"><?php 
        _e('View all open orders.', 'qtranslate');
        ?>
</a></li>
	<li><a href="options-general.php?page=qtranslate&qs_cron=true#qtranslate_service_settings"><?php 
        _e('Let qTranslate Services check if any open orders are finished.', 'qtranslate');
        ?>
</a></li>
	<li><a href="<?php 
        echo get_permalink($post_id);
        ?>
 "><?php 
        _e('View this post.', 'qtranslate');
        ?>
</a></li>
</ul>
</div>
<?php 
        return;
    }
    ?>
<div class="wrap">
<h2><?php 
    _e('qTranslate Services', 'qtranslate');
    ?>
</h2>
<?php 
    if (!empty($message)) {
        ?>
<div id="message" class="updated fade"><p><?php 
        echo $message;
        ?>
</p></div>
<?php 
    }
    ?>
<h3><?php 
    echo $title;
    ?>
</h3>
<form action="edit.php?page=qtranslate_services" method="post" id="qtranslate-services-translate">
<p><?php 
    if (sizeof($available_languages) > 1) {
        $available_languages_name = array();
        foreach (array_diff($available_languages, array($translate_from)) as $language) {
            $available_languages_name[] = '<a href="' . add_query_arg('source_language', $language, $url_link) . '">' . $q_config['language_name'][$language] . '</a>';
        }
        $available_languages_names = join(", ", $available_languages_name);
        printf(__('Your article is available in multiple languages. If you do not want to translate from %1$s, you can switch to one of the following languages: %2$s', 'qtranslate'), $q_config['language_name'][$translate_from], $available_languages_names);
    }
    ?>
</p>
<input type="hidden" name="post" value="<?php 
    echo $post_id;
    ?>
"/>
<input type="hidden" name="source_language" value="<?php 
    echo $translate_from;
    ?>
"/>
<?php 
    if (empty($translate_to)) {
        ?>
<p><?php 
        _e('Please choose the language you want to translate to:', 'qtranslate');
        ?>
</p>
<ul>
<?php 
        foreach ($q_config['enabled_languages'] as $language) {
            if ($translate_from == $language) {
                continue;
            }
            ?>
	<li><label><input type="radio" name="target_language" value="<?php 
            echo $language;
            ?>
" /> <?php 
            echo $q_config['language_name'][$language];
            ?>
</li>
<?php 
        }
        ?>
</ul>
	<p class="submit">
		<input type="submit" name="submit" class="button-primary" value="<?php 
        _e('Continue', 'qtranslate');
        ?>
" />
	</p>
<?php 
    } else {
        ?>
<p><?php 
        printf(__('Please review your article and <a href="%s">edit</a> it if needed.', 'qtranslate'), 'post.php?action=edit&post=' . $post_id);
        ?>
</p>
<textarea name="qs_content_preview" id="qs_content_preview" readonly="readonly"><?php 
        echo $post_content;
        ?>
</textarea>
<?php 
        $timestamp = time();
        if ($timestamp != qs_queryQS(QS_VERIFY, $timestamp)) {
            ?>
<p class="error"><?php 
            _e('ERROR: Could not connect to qTranslate Services. Please try again later.', 'qtranslate');
            ?>
</p>
<?php 
            return;
        }
        ?>
<h4><?php 
        _e('Use the following Translation Service:', 'qtranslate');
        ?>
</h4>
<ul>
<?php 
        if ($services = qs_queryQS(QS_GET_SERVICES)) {
            foreach ($services as $service_id => $service) {
                // check if we have data for all required fields
                $requirements_matched = true;
                foreach ($service['service_required_fields'] as $field) {
                    if (!isset($service_settings[$service_id][$field['name']]) || $service_settings[$service_id][$field['name']] == '') {
                        $requirements_matched = false;
                    }
                }
                if (!$requirements_matched) {
                    ?>
<li>
	<label><input type="radio" name="service_id" disabled="disabled" /> <b><?php 
                    echo qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($service['service_name']);
                    ?>
</b> ( <a href="<?php 
                    echo $service['service_url'];
                    ?>
" target="_blank"><?php 
                    _e('Website', 'qtranslate');
                    ?>
</a> )</label>
	<p class="error"><?php 
                    printf(__('Cannot use this service, not all <a href="%s">required fields</a> filled in for this service.', 'qtranslate'), 'options-general.php?page=qtranslate#qs_service_' . $service_id);
                    ?>
</p>
	<p class="service_description"><?php 
                    echo qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($service['service_description']);
                    ?>
</p>
</li>
<?php 
                } else {
                    ?>
<li><label><input type="radio" name="service_id" <?php 
                    if ($default_service == $service['service_id']) {
                        echo 'checked="checked"';
                    }
                    ?>
 value="<?php 
                    echo $service['service_id'];
                    ?>
" /> <b><?php 
                    echo qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($service['service_name']);
                    ?>
</b> ( <a href="<?php 
                    echo $service['service_url'];
                    ?>
" target="_blank"><?php 
                    _e('Website', 'qtranslate');
                    ?>
</a> )</label><p class="service_description"><?php 
                    echo qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($service['service_description']);
                    ?>
</p></li>
<?php 
                }
            }
            ?>
</ul>
<p><?php 
            _e('Your article will be SSL encrypted and securly sent to qTranslate Services, which will forward your text to the chosen Translation Service. Once qTranslate Services receives the translated text, it will automatically appear on your blog.', 'qtranslate');
            ?>
</p>
	<p class="submit">
		<input type="hidden" name="target_language" value="<?php 
            echo $translate_to;
            ?>
"/>
		<input type="submit" name="submit" class="button-primary" value="<?php 
            _e('Request Translation', 'qtranslate');
            ?>
" />
	</p>
<?php 
        }
    }
    ?>
</div>
</form>
<?php 
}
Example #23
0
    function create_field($field)
    {
        global $q_config;
        $languages = qtrans_getSortedLanguages(true);
        $values = qtrans_split($field['value'], $quicktags = true);
        $currentLanguage = $this->plugin->get_active_language();
        echo '<div class="multi-language-field multi-language-field-file">';
        foreach ($languages as $language) {
            $class = 'wp-switch-editor';
            if ($language === $currentLanguage) {
                $class .= ' current-language';
            }
            echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
        }
        $base_class = $field['class'];
        $base_name = $field['name'];
        foreach ($languages as $language) {
            $value = $values[$language];
            $o = array('class' => '', 'icon' => '', 'title' => '', 'size' => '', 'url' => '', 'name' => '');
            if ($value && is_numeric($value)) {
                $file = get_post($value);
                if ($file) {
                    $o['class'] = 'active';
                    $o['icon'] = wp_mime_type_icon($file->ID);
                    $o['title'] = $file->post_title;
                    $o['size'] = size_format(filesize(get_attached_file($file->ID)));
                    $o['url'] = wp_get_attachment_url($file->ID);
                    $explode = explode('/', $o['url']);
                    $o['name'] = end($explode);
                }
            }
            $field['class'] = $base_class;
            if ($language === $currentLanguage) {
                $field['class'] .= ' current-language';
                $o['class'] .= ' current-language';
            }
            $field['name'] = $base_name . '[' . $language . ']';
            ?>
			<div class="acf-file-uploader clearfix <?php 
            echo $o['class'];
            ?>
" data-library="<?php 
            echo $field['library'];
            ?>
" data-language="<?php 
            echo $language;
            ?>
">
				<input class="acf-file-value" type="hidden" name="<?php 
            echo $field['name'];
            ?>
" value="<?php 
            echo $value;
            ?>
" />
				<div class="has-file">
					<ul class="hl clearfix">
						<li>
							<img class="acf-file-icon" src="<?php 
            echo $o['icon'];
            ?>
" alt=""/>
							<div class="hover">
								<ul class="bl">
									<li><a href="#" class="acf-button-delete ir">Remove</a></li>
									<li><a href="#" class="acf-button-edit ir">Edit</a></li>
								</ul>
							</div>
						</li>
						<li>
							<p>
								<strong class="acf-file-title"><?php 
            echo $o['title'];
            ?>
</strong>
							</p>
							<p>
								<strong><?php 
            _e('Name', 'acf');
            ?>
:</strong>
								<a class="acf-file-name" href="<?php 
            echo $o['url'];
            ?>
" target="_blank"><?php 
            echo $o['name'];
            ?>
</a>
							</p>
							<p>
								<strong><?php 
            _e('Size', 'acf');
            ?>
:</strong>
								<span class="acf-file-size"><?php 
            echo $o['size'];
            ?>
</span>
							</p>

						</li>
					</ul>
				</div>
				<div class="no-file">
					<ul class="hl clearfix">
						<li>
							<p><?php 
            _e('No File Selected', 'acf');
            ?>
 <a href="#" class="button add-file"><?php 
            _e('Add File', 'acf');
            ?>
</p></a>
						</li>
					</ul>
				</div>
		</div>
		<?php 
        }
        echo '</div>';
    }
Example #24
0
 /**
  * Language select function for templating
  *
  * @param $type (string) choose the type of menu: 'text', 'image', 'both', 'dropdown' 
  * @param $args (array) some args for draw the menu: array( 'id', 'class', 'short' );
  * 
  * @since 1.0
  */
 public function language_menu($type = "text", $args = array())
 {
     global $q_config;
     // default arguments
     $defaults = array('id' => "qts-lang-menu", 'class' => "qts-lang-menu", 'short' => false);
     $args = wp_parse_args($args, $defaults);
     $languages = qtrans_getSortedLanguages();
     // every type
     switch ($type) {
         case 'image':
         case 'text':
         case 'both':
             echo "<ul id=\"{$args['id']}\" class=\"{$args['class']}\">" . PHP_EOL;
             foreach ($languages as $index => $lang) {
                 $url = $this->get_current_url($lang);
                 $item_class = array();
                 if ((string) $q_config['language'] == (string) $lang) {
                     $item_class[] = 'current-menu-item';
                 }
                 if ($index == count($languages) - 1) {
                     $item_class[] = 'last-child';
                 }
                 $item_class = empty($item_class) ? '' : ' class="' . implode(' ', $item_class) . '"';
                 $language_name = $args['short'] ? $lang : $q_config['language_name'][$lang];
                 if ($type == 'image') {
                     $link_class = " class=\"qtrans_flag qtrans_flag_{$lang}\"";
                     $link_content = "<span style=\"display:none\">{$language_name}</span>";
                 } else {
                     if ($type == 'both') {
                         $link_class = " class=\"qtrans_flag qtrans_flag_{$lang}\" style=\"padding-left:25px\"";
                         $link_content = "{$language_name}";
                     } else {
                         $link_class = '';
                         $link_content = $language_name;
                     }
                 }
                 echo "<li{$item_class}><a href=\"{$url}\" hreflang=\"{$lang}\"{$link_class}>{$link_content}</a></li>" . PHP_EOL;
             }
             echo "</ul>" . PHP_EOL;
             break;
         case 'dropdown':
             echo "<select id=\"{$args['id']}\" class=\"{$args['class']}\" onchange=\"window.location.href=this.options[this.selectedIndex].value\">" . PHP_EOL;
             foreach ($languages as $index => $lang) {
                 $url = $this->get_current_url($lang);
                 $item_class = '';
                 if ((string) $q_config['language'] == (string) $lang) {
                     $item_class = 'selected="selected"';
                 }
                 $language_name = $args['short'] ? $lang : $q_config['language_name'][$lang];
                 echo "<option value=\"{$url}\" {$item_class}>{$language_name}</option>" . PHP_EOL;
             }
             echo "</select>" . PHP_EOL;
             break;
     }
 }
    function create_field($field)
    {
        global $q_config;
        $languages = qtrans_getSortedLanguages(true);
        $values = qtrans_split($field['value'], $quicktags = true);
        $currentLanguage = $this->plugin->get_active_language();
        echo '<div class="multi-language-field multi-language-field-image">';
        foreach ($languages as $language) {
            $class = 'wp-switch-editor';
            if ($language === $currentLanguage) {
                $class .= ' current-language';
            }
            echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
        }
        $base_class = $field['class'];
        $base_name = $field['name'];
        foreach ($languages as $language) {
            $value = $values[$language];
            $o = array('class' => '', 'url' => '');
            if ($value && is_numeric($value)) {
                $url = wp_get_attachment_image_src($value, $field['preview_size']);
                $o['class'] = 'active';
                $o['url'] = $url[0];
            }
            $field['class'] = $base_class;
            if ($language === $currentLanguage) {
                $field['class'] .= ' current-language';
                $o['class'] .= ' current-language';
            }
            $field['name'] = $base_name . '[' . $language . ']';
            ?>
			<div class="acf-image-uploader clearfix <?php 
            echo $o['class'];
            ?>
" data-preview_size="<?php 
            echo $field['preview_size'];
            ?>
" data-library="<?php 
            echo $field['library'];
            ?>
" data-language="<?php 
            echo $language;
            ?>
" >
				<input class="acf-image-value" type="hidden" name="<?php 
            echo $field['name'];
            ?>
" value="<?php 
            echo $value;
            ?>
" />
				<div class="has-image">
					<div class="hover">
						<ul class="bl">
							<li><a class="acf-button-delete ir" href="#"><?php 
            _e("Remove", 'acf');
            ?>
</a></li>
							<li><a class="acf-button-edit ir" href="#"><?php 
            _e("Edit", 'acf');
            ?>
</a></li>
						</ul>
					</div>
					<img class="acf-image-image" src="<?php 
            echo $o['url'];
            ?>
" alt="" />
				</div>
				<div class="no-image">
					<p><?php 
            _e('No image selected', 'acf');
            ?>
 <input type="button" class="button add-image" value="<?php 
            _e('Add Image', 'acf');
            ?>
" />
				</div>
			</div>
		<?php 
        }
        echo '</div>';
    }
Example #26
0
</h2>
<!--div class="below-h2"><p>
	<?php 
_e('This table shows the META tags in each language set for each page in the site.', 'qtranslate-meta');
?>
<br/>
	<?php 
_e('Hover the cursor over the flags to view the actual content.', 'qtranslate-meta');
?>
</p></div-->

<?php 
global $qtransMETA;
global $q_config;
//Get languages
$languages = qtrans_getSortedLanguages();
//Check for & set view
if (isset($_REQUEST['qtm_view'])) {
    $_SESSION['qtm_view'] = filter_var($_REQUEST['qtm_view'], FILTER_SANITIZE_STRING);
}
$_view = $_SESSION['qtm_view'] ? $_SESSION['qtm_view'] : 'flags';
//Check for & set lang
if (isset($_REQUEST['qtm_lang'])) {
    $_SESSION['qtm_lang'] = filter_var($_REQUEST['qtm_lang'], FILTER_SANITIZE_STRING);
}
$_lang = $_SESSION['qtm_lang'] ? $_SESSION['qtm_lang'] : qtrans_getLanguage();
?>

<form method="post" action="">
<div class="tablenav">
	<div class="alignleft actions">	
    function render_field($field)
    {
        global $q_config;
        $languages = qtrans_getSortedLanguages(true);
        $values = qtrans_split($field['value'], $quicktags = true);
        $currentLanguage = $this->plugin->get_active_language();
        // enqueue
        acf_enqueue_uploader();
        // vars
        $div = array('class' => 'acf-image-uploader acf-cf', 'data-preview_size' => $field['preview_size'], 'data-library' => $field['library'], 'data-mime_types' => $field['mime_types']);
        $input_atts = array('type' => 'hidden', 'name' => $field['name'], 'value' => $field['value'], 'data-name' => 'value-id');
        $url = '';
        echo '<div class="multi-language-field multi-language-field-image">';
        foreach ($languages as $language) {
            $class = 'wp-switch-editor';
            if ($language === $currentLanguage) {
                $class .= ' current-language';
            }
            echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
        }
        foreach ($languages as $language) {
            $input_atts['name'] = $field['name'] . '[' . $language . ']';
            $field['value'] = $values[$language];
            $div['data-language'] = $language;
            $div['class'] = 'acf-image-uploader acf-cf';
            // has value?
            if ($field['value'] && is_numeric($field['value'])) {
                $url = wp_get_attachment_image_src($field['value'], $field['preview_size']);
                $url = $url[0];
                $div['class'] .= ' has-value';
            }
            // basic?
            $basic = !current_user_can('upload_files');
            if ($basic) {
                $div['class'] .= ' basic';
            }
            if ($language === $currentLanguage) {
                $div['class'] .= ' current-language';
            }
            ?>
			<div <?php 
            acf_esc_attr_e($div);
            ?>
>
				<div class="acf-hidden">
					<?php 
            acf_hidden_input(array('name' => $input_atts['name'], 'value' => $field['value'], 'data-name' => 'id'));
            ?>
				</div>
				<div class="view show-if-value acf-soh">
					<img data-name="image" src="<?php 
            echo $url;
            ?>
" alt=""/>
					<ul class="acf-hl acf-soh-target">
						<?php 
            if (!$basic) {
                ?>
							<li><a class="acf-icon dark" data-name="edit" href="#"><i class="acf-sprite-edit"></i></a></li>
						<?php 
            }
            ?>
						<li><a class="acf-icon dark" data-name="remove" href="#"><i class="acf-sprite-delete"></i></a></li>
					</ul>
				</div>
				<div class="view hide-if-value">
					<?php 
            if ($basic) {
                ?>
						<?php 
                if ($field['value'] && !is_numeric($field['value'])) {
                    ?>
							<div class="acf-error-message"><p><?php 
                    echo $field['value'];
                    ?>
</p></div>
						<?php 
                }
                ?>
						<input type="file" name="<?php 
                echo $field['name'];
                ?>
" id="<?php 
                echo $field['id'];
                ?>
" />
					<?php 
            } else {
                ?>
						<p style="margin:0;"><?php 
                _e('No image selected', 'acf');
                ?>
 <a data-name="add" class="acf-button" href="#"><?php 
                _e('Add Image', 'acf');
                ?>
</a></p>
					<?php 
            }
            ?>
				</div>
			</div>

		<?php 
        }
        echo '</div>';
    }
Example #28
0
function qtrans_modifyExcerpt()
{
    global $q_config;
    echo "<script type=\"text/javascript\">\n// <![CDATA[\n";
    echo "if(jQuery('#excerpt').size()>0) {";
    echo $q_config['js']['qtrans_is_array'];
    echo $q_config['js']['qtrans_xsplit'];
    echo $q_config['js']['qtrans_split'];
    echo $q_config['js']['qtrans_integrate'];
    echo $q_config['js']['qtrans_switch_postbox'];
    echo $q_config['js']['qtrans_use'];
    $el = qtrans_getSortedLanguages();
    foreach ($el as $language) {
        echo qtrans_createTitlebarButton('postexcerpt', $language, 'excerpt', 'qtrans_switcher_postexcerpt_' . $language);
        echo qtrans_createTextArea('postexcerpt', $language, 'excerpt', 'qtrans_switcher_postexcerpt_' . $language);
    }
    echo "qtrans_switch_postbox('postexcerpt','excerpt','" . $q_config['default_language'] . "');";
    echo "jQuery('#excerpt').hide();";
    echo "}";
    echo "// ]]>\n</script>\n";
}
Example #29
0
    function meta_box_generate()
    {
        global $q_config, $post;
        $languages = qtrans_getSortedLanguages();
        $meta = $this->load_meta($post->ID);
        ?>
		<script type="text/javascript">
		//<![CDATA[
			function qtrans_meta_switch_lang(lang) {
				//Hide all
				<?php 
        foreach ($languages as $lang) {
            echo "jQuery('#qtrans_meta_language_{$lang}').hide();";
        }
        ?>
				
				//Show selected, recount chars
				jQuery('#qtrans_meta_language_'+lang).show();
				qtrans_meta_count_chars(lang);
			}
			
			//Count chars & paste into respective box
			function qtrans_meta_count_chars(lang) {
				var chars = jQuery('#qtrans_meta_description_'+lang).val().length;
				jQuery('#qtrans_meta_description-length_'+lang).val(chars);
			}
		//]]>
		</script>
		<div class="qtrans_meta_language-switcher">
		<?php 
        echo "&nbsp;|&nbsp;";
        foreach ($languages as $lang) {
            echo "<a href=\"javascript:qtrans_meta_switch_lang('{$lang}')\" title=\"" . qtrans_getLanguageName($lang) . "\">" . qtrans_getLanguageName($lang) . "</a>&nbsp|&nbsp;";
        }
        ?>
		</div>
		
		<?php 
        foreach ($languages as $lang) {
            ?>
		<table id="qtrans_meta_language_<?php 
            echo $lang;
            ?>
" class="qtrans_meta_table" style="display:none;">
			<tr><td colspan="2" class="heading">
				<img src="<?php 
            echo WP_PLUGIN_URL;
            ?>
/qtranslate/flags/<?php 
            echo $q_config['flag'][$lang];
            ?>
" alt=""/>
				<strong><?php 
            echo qtrans_getLanguageName($lang);
            ?>
</strong>
			</td></tr>
			<tr>
				<th><label for="qtrans_meta_title_<?php 
            echo $lang;
            ?>
"><?php 
            _e('Browser Title', 'qtranslate-meta');
            ?>
:</label> </th>
				<td><input type="text" name="qtrans_meta_title_<?php 
            echo $lang;
            ?>
" id="qtrans_meta_title_<?php 
            echo $lang;
            ?>
" value="<?php 
            echo $meta['title'][$lang];
            ?>
" style="width:50%;" /></td>
			</tr>
			<tr>
				<th><label for="qtrans_meta_keywords_<?php 
            echo $lang;
            ?>
"><?php 
            _e('Keywords', 'qtranslate-meta');
            ?>
:</label> </th>
				<td><input type="text" name="qtrans_meta_keywords_<?php 
            echo $lang;
            ?>
" id="qtrans_meta_keywords_<?php 
            echo $lang;
            ?>
" value="<?php 
            echo $meta['keywords'][$lang];
            ?>
" style="width:100%;" /></td>
			</tr>
			<tr>
				<th><label for="qtrans_meta_description_<?php 
            echo $lang;
            ?>
"><?php 
            _e('Description', 'qtranslate-meta');
            ?>
:</label> </th>
				<td>
					<textarea name="qtrans_meta_description_<?php 
            echo $lang;
            ?>
" id="qtrans_meta_description_<?php 
            echo $lang;
            ?>
" style="width:100%;" rows="3" onkeyup="qtrans_meta_count_chars('<?php 
            echo $lang;
            ?>
')" onkeydown="qtrans_meta_count_chars('<?php 
            echo $lang;
            ?>
')"><?php 
            echo $meta['description'][$lang];
            ?>
</textarea>
					<br/>
					<input type="text" maxlength="3" size="3" id="qtrans_meta_description-length_<?php 
            echo $lang;
            ?>
" readonly="readonly"/>
					<?php 
            _e('characters. Most search engines use a maximum of 160 chars for the description.', 'qtranslate-meta');
            ?>
				</td>
			</tr>
		</table>
		<?php 
        }
        ?>
		
		<script type="text/javascript">
		//<![CDATA[
			qtrans_meta_switch_lang('<?php 
        echo $q_config['default_language'];
        ?>
');
		//]]>
		</script>
		
		<?php 
    }