";
break;
}
}
function qtrans_widget_init() {
// Check to see required Widget API functions are defined...
if ( !function_exists('register_sidebar_widget') || !function_exists('register_widget_control') )
return; // ...and if not, exit gracefully from the script.
function qtrans_widget_switch($args) {
global $q_config;
extract($args);
// Collect our widget's options, or define their defaults.
$options = get_option('qtranslate_switch');
$title = empty($options['qtrans-switch-title']) ? __('Language', 'qtranslate') : $options['qtrans-switch-title'];
// It's important to use the $before_widget, $before_title,
// $after_title and $after_widget variables in your output.
echo $before_widget;
if($options['qtrans-switch-hide-title']!='on')
echo $before_title . qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($title) . $after_title;
qtrans_generateLanguageSelectCode($options['qtrans-switch-type']);
echo $after_widget;
}
function qtrans_widget_switch_control() {
// Collect our widget's options.
$options = get_option('qtranslate_switch');
// This is for handing the control form submission.
if ( $_POST['qtrans-switch-submit'] ) {
// Clean up control form submission options
$options['qtrans-switch-title'] = strip_tags(stripslashes($_POST['qtrans-switch-title']));
$options['qtrans-switch-hide-title'] = strip_tags(stripslashes($_POST['qtrans-switch-hide-title']));
$options['qtrans-switch-type'] = strip_tags(stripslashes($_POST['qtrans-switch-type']));
update_option('qtranslate_switch', $options);
}
// Format options as valid HTML. Hey, why not.
$title = htmlspecialchars($options['qtrans-switch-title'], ENT_QUOTES);
$hide_title = htmlspecialchars($options['qtrans-switch-hide-title'], ENT_QUOTES);
$type = $options['qtrans-switch-type'];
if($type!='text'&&$type!='image'&&$type!='both'&&$type!='dropdown') $type='text';
// The HTML below is the control form for editing options.
?>