Ejemplo n.º 1
0
 function widget($args, $instance)
 {
     extract($args);
     echo $before_widget;
     $title = empty($instance['title']) ? __('Language', 'qts') : apply_filters('widget_title', $instance['title']);
     $hide_title = empty($instance['hide-title']) ? false : 'on';
     $type = $instance['type'];
     $short_text = $instance['short_text'] == 'on' ? true : false;
     if ($type != 'text' && $type != 'image' && $type != 'both' && $type != 'dropdown') {
         $type = 'text';
     }
     if ($hide_title != 'on') {
         echo $before_title . $title . $after_title;
     }
     qts_language_menu($type, array('id' => $this->id, 'short' => $short_text));
     echo $after_widget;
 }
 /**
  * cover from function qtrans_generateLanguageSelectCode at mqtranslate_widget.php
  * @param $style: extend param by mqtranslate function qtrans_generateLanguageSelectCode
  * @param $id: extend param by mqtranslate function qtrans_generateLanguageSelectCode
  * @param $tpl: twig template
  */
 public static function qtrans_generateLanguageSelectCode()
 {
     $id = 'mqtranslate';
     $style = hw_option('mqtrans_style');
     //get class name
     switch ($style) {
         case 'image':
             $anchor_class = 'qtrans_flag';
             break;
         case 'both':
             $anchor_class = 'qtrans_flag_and_text';
             break;
         default:
             $anchor_class = '';
     }
     if (function_exists('is_plugin_active') && is_plugin_active('qtranslate-slug/qtranslate-slug.php')) {
         qts_language_menu($style, array('id' => $id, 'short' => ''));
     } else {
         global $q_config;
         if ($style == '') {
             $style = 'text';
         }
         if (is_bool($style) && $style) {
             $style = 'image';
         }
         if (is_404()) {
             $url = get_option('home');
         } else {
             $url = '';
         }
         $id .= '-chooser';
         $data = array();
         $data['wrapper'] = array('id' => $id, 'class' => 'qtrans_language_chooser');
         $data['active_langs'] = array();
         //echo '<ul class="qtrans_language_chooser" id="'.$id.'">';
         //qtrans_getSortedLanguages:    //for mqtranslate & qtranslate-x plugin, note for qtranslate-x enable `Compatibility Functions`
         foreach (self::get_languages() as $language) {
             $item = array();
             //li class
             $classes = array('lang-' . $language);
             if ($language == $q_config['language']) {
                 //$item['class'] = 'active';
                 $classes[] = 'active';
             }
             $item['class'] = implode(' ', $classes);
             $item['url'] = self::convertURL($url, $language);
             $item['anchor_class'] = 'qtrans_flag_' . $language . ' ' . $anchor_class;
             $item['title'] = $q_config['language_name'][$language];
             $item['text'] = $q_config['language_name'][$language];
             $data['active_langs'][] = $item;
             /*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>";
         return $data;
     }
 }
Ejemplo n.º 3
0
function qtrans_generateLanguageSelectCode($style = '', $id = '')
{
    if (function_exists('is_plugin_active') && is_plugin_active('qtranslate-slug/qtranslate-slug.php')) {
        qts_language_menu($style, array('id' => $id, 'short' => ''));
    } else {
        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 = 'mqtranslate';
        }
        $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><div class=\"qtrans_widget_end\"></div>";
                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;
        }
    }
}
Ejemplo n.º 4
0
?>

			<?php 
if (theme_options('header', 'search') == 'on') {
    ?>
				<li class="search">
					<a href="#"><i class="icon icon-search"></i></a>
					<form action="<?php 
    echo home_url('/');
    ?>
"><input type="text" name="s" /></form>
				</li>
			<?php 
}
?>
			
		</ul>

		<?php 
if (function_exists('qts_language_menu')) {
    qts_language_menu('image');
}
?>
	</div>

	<div class="clear"></div>
</div><!-- .container -->
</header>