Mod to (un)install application translations with each app (applications.php only)

This commit is contained in:
Miles Lott 2002-01-05 18:07:11 +00:00
parent d351573139
commit 950b7a8a5c
4 changed files with 125 additions and 15 deletions

View File

@ -141,6 +141,13 @@
$phpgw_setup->deregister_hooks($setup_info[$appname]['name']);
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('hooks deregistered') . '.';
}
$dropped = False;
$dropped = $phpgw_setup->drop_langs($appname);
if($dropped)
{
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('Translations removed') . '.';
}
}
while (list($appname,$key) = @each($install))
@ -155,24 +162,25 @@
echo '<br>' . $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 '<br>' . $setup_info[$appname]['title'] . ' ' . lang('registered') . '.';
if ($setup_info[$appname]['hooks'])
{
$phpgw_setup->register_hooks($setup_info[$appname]['name']);
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('hooks registered') . '.';
}
$phpgw_setup->register_app($setup_info[$appname]['name']);
}
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('registered') . '.';
if ($setup_info[$appname]['hooks'])
{
$phpgw_setup->register_hooks($setup_info[$appname]['name']);
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('hooks registered') . '.';
}
$phpgw_setup->add_langs($appname);
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('Translations added') . '.';
}
while (list($appname,$key) = @each($upgrade))

View File

@ -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 '<br>Working on: ' . $lang; */
$appfile = PHPGW_SERVER_ROOT . SEP . $appname . SEP . 'setup' . SEP . 'phpgw_' . strtolower($lang) . '.lang';
if(file_exists($appfile))
{
/* echo '<br>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 '<br>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 "<br>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();
}
}
?>

View File

@ -215,6 +215,22 @@
pages from unauthorized use.
*/
function _debug_array($array)
{
if(floor(phpversion()) == 4)
{
ob_start();
echo '<pre>'; print_r($array); echo '</pre>';
$contents = ob_get_contents();
ob_end_clean();
echo $contents;
}
else
{
echo '<pre>'; var_dump($array); echo '</pre>';
}
}
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

View File

@ -199,6 +199,8 @@ this section will help you import users and groups from your ldap tree into phpG
this stage is completed<br> setup en This stage is completed<br>
this will create 1 admin account and 3 demo accounts<br>the username/passwords are: demo/guest, demo2/guest and demo3/guest.<br><b>!!!THIS WILL DELETE ALL EXISTING ACCOUNTS!!!</b><br> setup en This will create 1 admin account and 3 demo accounts<br>The username/passwords are: demo/guest, demo2/guest and demo3/guest.<br><b>!!!THIS WILL DELETE ALL EXISTING ACCOUNTS!!!</b><br>
to setup 1 admin account and 3 demo accounts.<br><b>this will delete all existing accounts</b> setup en to setup 1 admin account and 3 demo accounts.<br><b>This will delete all existing accounts</b>
translations added setup en Translations Added
translations removed setup en Translations Removed
uninstall all applications setup en Uninstall all applications
uninstalled setup en uninstalled
upgrade setup en Upgrade