diff --git a/setup/applications.php b/setup/applications.php
index 3e1481d444..85855d2b7e 100644
--- a/setup/applications.php
+++ b/setup/applications.php
@@ -141,6 +141,13 @@
$phpgw_setup->deregister_hooks($setup_info[$appname]['name']);
echo '
' . $setup_info[$appname]['title'] . ' ' . lang('hooks deregistered') . '.';
}
+
+ $dropped = False;
+ $dropped = $phpgw_setup->drop_langs($appname);
+ if($dropped)
+ {
+ echo '
' . $setup_info[$appname]['title'] . ' ' . lang('Translations removed') . '.';
+ }
}
while (list($appname,$key) = @each($install))
@@ -155,24 +162,25 @@
echo '
' . $setup_info[$appname]['title'] . ' '
. lang('tables installed, unless there are errors printed above') . '.';
}
+
+ if ($phpgw_setup->app_registered($setup_info[$appname]['name']))
+ {
+ $phpgw_setup->update_app($setup_info[$appname]['name']);
+ }
else
{
- if ($phpgw_setup->app_registered($setup_info[$appname]['name']))
- {
- $phpgw_setup->update_app($setup_info[$appname]['name']);
- }
- else
- {
- $phpgw_setup->register_app($setup_info[$appname]['name']);
- }
- echo '
' . $setup_info[$appname]['title'] . ' ' . lang('registered') . '.';
-
- if ($setup_info[$appname]['hooks'])
- {
- $phpgw_setup->register_hooks($setup_info[$appname]['name']);
- echo '
' . $setup_info[$appname]['title'] . ' ' . lang('hooks registered') . '.';
- }
+ $phpgw_setup->register_app($setup_info[$appname]['name']);
}
+ echo '
' . $setup_info[$appname]['title'] . ' ' . lang('registered') . '.';
+
+ if ($setup_info[$appname]['hooks'])
+ {
+ $phpgw_setup->register_hooks($setup_info[$appname]['name']);
+ echo '
' . $setup_info[$appname]['title'] . ' ' . lang('hooks registered') . '.';
+ }
+
+ $phpgw_setup->add_langs($appname);
+ echo '
' . $setup_info[$appname]['title'] . ' ' . lang('Translations added') . '.';
}
while (list($appname,$key) = @each($upgrade))
diff --git a/setup/inc/class.setup_lang.inc.php b/setup/inc/class.setup_lang.inc.php
index 0f5bc617a0..f5794c5744 100644
--- a/setup/inc/class.setup_lang.inc.php
+++ b/setup/inc/class.setup_lang.inc.php
@@ -106,5 +106,89 @@
}
return $ret;
}
+
+ /* Following functions are called for app (un)install in applications.php only */
+
+ /*!
+ @function get_langs
+ @abstract return array of installed languages, e.g. array('de','en')
+ */
+ function get_langs()
+ {
+ $GLOBALS['phpgw_setup']->db->query("SELECT DISTINCT(lang) FROM lang",__LINE__,__FILE__);
+ $langs = array();
+
+ while($GLOBALS['phpgw_setup']->db->next_record())
+ {
+ /* echo 'HELLO: ' . $GLOBALS['phpgw_setup']->db->f(0); */
+ $langs[] = $GLOBALS['phpgw_setup']->db->f(0);
+ }
+ return $langs;
+ }
+
+ /*!
+ @function drop_langs
+ @abstract delete all lang entries for an application, return True if langs were found
+ @param $appname app_name whose translations you want to delete
+ */
+ function drop_langs($appname)
+ {
+ $GLOBALS['phpgw_setup']->db->query("SELECT COUNT(message_id) FROM lang WHERE app_name='$appname'",__LINE__,__FILE__);
+ $GLOBALS['phpgw_setup']->db->next_record();
+ if($GLOBALS['phpgw_setup']->db->f(0))
+ {
+ $GLOBALS['phpgw_setup']->db->query("DELETE FROM lang WHERE app_name='$appname'",__LINE__,__FILE__);
+ return True;
+ }
+ return False;
+ }
+
+ /*!
+ @function add_langs
+ @abstract process an application's lang files, calling get_langs() to see what langs the admin installed already
+ @param $appname app_name of application to process
+ */
+ function add_langs($appname)
+ {
+ $langs = $this->get_langs();
+
+ $GLOBALS['phpgw_setup']->db->transaction_begin();
+
+ while (list($null,$lang) = each($langs))
+ {
+ /* echo '
Working on: ' . $lang; */
+ $appfile = PHPGW_SERVER_ROOT . SEP . $appname . SEP . 'setup' . SEP . 'phpgw_' . strtolower($lang) . '.lang';
+ if(file_exists($appfile))
+ {
+ /* echo '
Including: ' . $appfile; */
+ $raw_file = file($appfile);
+
+ while (list($null,$line) = @each($raw_file))
+ {
+ list($message_id,$app_name,$phpgw_setup->db_lang,$content) = explode("\t",$line);
+ $message_id = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($message_id));
+ /* echo '
APPNAME:' . $app_name . ' PHRASE:' . $message_id; */
+ $app_name = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($app_name));
+ $GLOBALS['phpgw_setup']->db_lang = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($GLOBALS['phpgw_setup']->db_lang));
+ $content = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($content));
+
+ $GLOBALS['phpgw_setup']->db->query("SELECT COUNT(*) FROM lang WHERE message_id='$message_id' and lang='"
+ . $GLOBALS['phpgw_setup']->db_lang . "'",__LINE__,__FILE__);
+ $GLOBALS['phpgw_setup']->db->next_record();
+
+ if ($GLOBALS['phpgw_setup']->db->f(0) == 0)
+ {
+ if($message_id && $content)
+ {
+ /* echo "
adding - INSERT INTO lang VALUES ('$message_id','$app_name','$phpgw_setup->db_lang','$content')"; */
+ $GLOBALS['phpgw_setup']->db->query("INSERT INTO lang VALUES ('$message_id','$app_name','"
+ . $GLOBALS['phpgw_setup']->db_lang . "','$content')",__LINE__,__FILE__);
+ }
+ }
+ }
+ }
+ }
+ $GLOBALS['phpgw_setup']->db->transaction_commit();
+ }
}
?>
diff --git a/setup/inc/functions.inc.php b/setup/inc/functions.inc.php
index c94df06137..9450f12bf3 100644
--- a/setup/inc/functions.inc.php
+++ b/setup/inc/functions.inc.php
@@ -215,6 +215,22 @@
pages from unauthorized use.
*/
+ function _debug_array($array)
+ {
+ if(floor(phpversion()) == 4)
+ {
+ ob_start();
+ echo '
'; print_r($array); echo ''; + $contents = ob_get_contents(); + ob_end_clean(); + echo $contents; + } + else + { + echo '
'; var_dump($array); echo ''; + } + } + if(file_exists(PHPGW_SERVER_ROOT.'/phpgwapi/setup/setup.inc.php')) { include(PHPGW_SERVER_ROOT.'/phpgwapi/setup/setup.inc.php'); // To set the current core version diff --git a/setup/lang/phpgw_en.lang b/setup/lang/phpgw_en.lang index ec4e15b15b..d2741531c4 100644 --- a/setup/lang/phpgw_en.lang +++ b/setup/lang/phpgw_en.lang @@ -199,6 +199,8 @@ this section will help you import users and groups from your ldap tree into phpG this stage is completed