ISO Language Code for the Language you want to insert. (Example: en)', 'qtranslate'); ?>
0){
?>
strftime (use %q for day suffix (st,nd,rd,th)) or date format. This field is optional. (Example: %A %B %e%q, %Y)', 'qtranslate'); ?>
strftime or date format. This field is optional. (Example: %I:%M %p)', 'qtranslate'); ?>
'Flag',
'name' => __('Name', 'qtranslate'),
'status' => __('Action', 'qtranslate'),
'status2' => '',
'status3' => ''
);
}
function qtranslate_conf() {
global $q_config, $wpdb;
// do redirection for dashboard
if(isset($_GET['godashboard'])) {
echo '
'.__('Switching Language', 'qtranslate').'
'.sprintf(__('Switching language to %1$s... If the Dashboard isn\'t loading, use this link.','qtranslate'),$q_config['language_name'][qtrans_getLanguage()],admin_url()).'';
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_BOOLEAN);
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.']","")');
$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.']","")');
$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
?>
qTranslate FAQ and the Support Forum.', 'qtranslate'), 'http://www.qianqin.de/qtranslate/faq/', 'http://www.qianqin.de/qtranslate/forum/viewforum.php?f=3'); ?>