array( 'noheader' => True, 'nonavbar' => True, 'currentapp' => 'home', 'noapi' => True )); include('./inc/functions.inc.php'); // Authorize the user to use setup app and load the database // Does not return unless user is authorized if (!$GLOBALS['egw_setup']->auth('Config') || @$_POST['cancel']) { Header('Location: index.php'); exit; } $GLOBALS['egw_setup']->loaddb(); $GLOBALS['egw_setup']->translation->setup_translation_sql(); $translation = &$GLOBALS['egw_setup']->translation->sql; $translation->translation(True); // to get the mbstring warnings $tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup'); $setup_tpl = CreateObject('phpgwapi.Template',$tpl_root); $setup_tpl->set_file(array( 'T_head' => 'head.tpl', 'T_footer' => 'footer.tpl', 'T_system_charset' => 'system_charset.tpl', )); $stage_title = lang('Change system-charset'); $stage_desc = lang('This program will convert your database to a new system-charset.'); if ($diagnostics || !@$_POST['convert']) { $GLOBALS['egw_setup']->html->show_header($stage_title,False,'config',$GLOBALS['egw_setup']->ConfigDomain . '(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')'); } if (@$_POST['convert']) { if (empty($_POST['current_charset'])) { $errors[] = lang('You need to select your current charset!'); $GLOBALS['egw_setup']->html->show_header($stage_title,False,'config',$GLOBALS['egw_setup']->ConfigDomain . '(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')'); } else { convert_db($_POST['current_charset'],$_POST['new_charset'],$diagnostics); if (!$diagnostics) { Header('Location: index.php'); } echo '
'.lang('Click here to return to setup.')."
\n"; exit; } } function convert_db($from,$to,$diagnostics=1) { if ($diagnostics) echo "$app: "; if (!isset($data['tables']) || !count($data['tables']) || !$GLOBALS['egw_setup']->app_registered($app) || !($table_definitions = $db2->get_table_definitions($app))) { if ($diagnostics) echo "skipping (no tables or not installed)
\n"; continue; } foreach($table_definitions as $table => $definition) { if ($diagnostics) { echo "\n";
++$updates;
}
}
if ($diagnostics)
{
$GLOBALS['egw_setup']->db->query("SELECT count(*) FROM $table",__LINE__,__FILE__);
$GLOBALS['egw_setup']->db->next_record();
$total = $GLOBALS['egw_setup']->db->f(0);
echo " done, $updates/$total rows updated";
}
}
}
@$GLOBALS['egw_setup']->db->query("DELETE FROM phpgw_config WHERE config_app='phpgwapi' AND config_name='system_charset'",__LINE__,__FILE__);
$GLOBALS['egw_setup']->db->query("INSERT INTO phpgw_config (config_app,config_name,config_value) VALUES ('phpgwapi','system_charset','$to')",__LINE__,__FILE__);
}
$setup_tpl->set_var('stage_title',$stage_title);
$setup_tpl->set_var('stage_desc',$stage_desc);
$setup_tpl->set_var('error_msg',is_array($errors) ? implode('
',$errors) : ' ');
$setup_tpl->set_var('lang_convert',lang('Convert'));
$setup_tpl->set_var('lang_cancel',lang('Cancel'));
$setup_tpl->set_var('lang_current',lang('Current system-charset'));
$setup_tpl->set_var('lang_convert_to',lang('Charset to convert to'));
$setup_tpl->set_var('lang_warning',''.lang('Setting the system-charset to UTF-8 (unicode) allows the coexistens of data from languages of different charsets.').'
'.
lang('If you use only languages of the same charset (eg. western european ones) you dont need to set a system-charset!'));
$installed_charsets = $translation->get_installed_charsets();
if ($translation->system_charset || count($installed_charsets) == 1)
{
reset($installed_charsets);
list($current_charset) = each($installed_charsets);
if ($translation->system_charset)
{
$current_charset = $translation->system_charset;
}
$setup_tpl->set_var('current_charset',"$current_charset".
"\n");
}
else
{
$options = '\n";
foreach($installed_charsets as $charset => $description)
{
$options .= "\n";
}
$setup_tpl->set_var('current_charset',"\n");
}
if ($translation->system_charset == 'utf-8' || count($installed_charsets) == 1)
{
reset($installed_charsets);
list($other_charset) = each($installed_charsets);
if (!$translation->system_charset || $other_charset == $translation->system_charset)
{
$other_charset = 'utf-8';
}
$setup_tpl->set_var('new_charset',"$other_charset\n");
}
else
{
if ($translation->system_charset != 'utf-8')
{
$options = '\n";
}
foreach($installed_charsets as $charset => $description)
{
if ($charset != $translation->system_charset)
{
$options .= "\n";
}
}
$setup_tpl->set_var('new_charset',"\n");
}
$setup_tpl->pparse('out','T_system_charset');
$GLOBALS['egw_setup']->html->show_footer();
?>