Lang files are now installed as part of the install/upgrade process. For step

one (mass install/upgrade), english is installed by default
This commit is contained in:
Miles Lott 2002-01-05 21:20:52 +00:00
parent a9a325f0f3
commit a012283ba5
4 changed files with 121 additions and 41 deletions

View File

@ -12,10 +12,12 @@
/* $Id$ */ /* $Id$ */
$DEBUG = False; $DEBUG = False;
// TODO: We allow a user to hose their setup here, need to make use /*
// of dependencies so they are warned that they are pulling the rug TODO: We allow a user to hose their setup here, need to make use
// out from under other apps. e.g. if they select to uninstall the api of dependencies so they are warned that they are pulling the rug
// this will happen without further warning. out from under other apps. e.g. if they select to uninstall the api
this will happen without further warning.
*/
$phpgw_info = array(); $phpgw_info = array();
$GLOBALS['phpgw_info']['flags'] = array( $GLOBALS['phpgw_info']['flags'] = array(
@ -142,12 +144,8 @@
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('hooks deregistered') . '.'; echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('hooks deregistered') . '.';
} }
$dropped = False; $terror = $phpgw_setup->process_drop_langs($terror);
$dropped = $phpgw_setup->drop_langs($appname); echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('Translations removed') . '.';
if($dropped)
{
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('Translations removed') . '.';
}
} }
while (list($appname,$key) = @each($install)) while (list($appname,$key) = @each($install))
@ -180,7 +178,7 @@
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('hooks registered') . '.'; echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('hooks registered') . '.';
} }
} }
$phpgw_setup->add_langs($appname); $terror = $phpgw_setup->process_add_langs($terror);
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('Translations added') . '.'; echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('Translations added') . '.';
} }
@ -199,6 +197,9 @@
{ {
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('upgraded') . '.'; echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('upgraded') . '.';
} }
$terror = $phpgw_setup->process_upgrade_langs($terror);
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('Translations upgraded') . '.';
} }
//$setup_tpl->set_var('goback', //$setup_tpl->set_var('goback',

View File

@ -107,7 +107,7 @@
return $ret; return $ret;
} }
/* Following functions are called for app (un)install in applications.php only */ /* Following functions are called for app (un)install */
/*! /*!
@function get_langs @function get_langs
@ -148,9 +148,13 @@
@abstract process an application's lang files, calling get_langs() to see what langs the admin installed already @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 @param $appname app_name of application to process
*/ */
function add_langs($appname) function add_langs($appname,$force_en=False)
{ {
$langs = $this->get_langs(); $langs = $this->get_langs();
if($force_en && !isinarray('en',$langs))
{
$langs[] = 'en';
}
$GLOBALS['phpgw_setup']->db->transaction_begin(); $GLOBALS['phpgw_setup']->db->transaction_begin();
@ -165,7 +169,7 @@
while (list($null,$line) = @each($raw_file)) while (list($null,$line) = @each($raw_file))
{ {
list($message_id,$app_name,$phpgw_setup->db_lang,$content) = explode("\t",$line); list($message_id,$app_name,$GLOBALS['phpgw_setup']->db_lang,$content) = explode("\t",$line);
$message_id = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($message_id)); $message_id = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($message_id));
/* echo '<br>APPNAME:' . $app_name . ' PHRASE:' . $message_id; */ /* echo '<br>APPNAME:' . $app_name . ' PHRASE:' . $message_id; */
$app_name = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($app_name)); $app_name = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($app_name));

View File

@ -54,8 +54,10 @@
@abstract the mother of all multipass upgrade parental loop functions @abstract the mother of all multipass upgrade parental loop functions
@param $setup_info array of application info from setup.inc.php files @param $setup_info array of application info from setup.inc.php files
@param $type optional, defaults to new(install), could also be 'upgrade' @param $type optional, defaults to new(install), could also be 'upgrade'
@param $DEBUG optional, print debugging info
@param $force_en optional, install english language files
*/ */
function process_pass($setup_info,$method='new',$DEBUG=False) function process_pass($setup_info,$method='new',$DEBUG=False,$force_en=False)
{ {
if (!$method) if (!$method)
{ {
@ -76,15 +78,15 @@
{ {
$passing = array(); $passing = array();
if ($DEBUG) { echo '<br>process_pass(): #' . $i . ' for ' . $method . ' processing' . "\n"; } if ($DEBUG) { echo '<br>process_pass(): #' . $i . ' for ' . $method . ' processing' . "\n"; }
// Check current versions and dependencies /* Check current versions and dependencies */
$setup_info = $this->get_db_versions($setup_info); $setup_info = $this->get_db_versions($setup_info);
$setup_info = $this->compare_versions($setup_info); $setup_info = $this->compare_versions($setup_info);
//var_dump($setup_info);exit; // var_dump($setup_info);exit;
$setup_info = $this->check_depends($setup_info); $setup_info = $this->check_depends($setup_info);
//if($i==2) { var_dump($passed);exit; } //if($i==2) { var_dump($passed);exit; }
// stuff the rest of the apps, but only those with available upgrades /* stuff the rest of the apps, but only those with available upgrades */
while(list($key,$value) = each($setup_info)) while(list($key,$value) = @each($setup_info))
{ {
if (($value['name'] != 'phpgwapi') && ($value['status'] == 'U')) if (($value['name'] != 'phpgwapi') && ($value['status'] == 'U'))
{ {
@ -93,34 +95,38 @@
$pass[$value['name']] = $setup_info[$value['name']]; $pass[$value['name']] = $setup_info[$value['name']];
} }
} }
// Now if we are on the 2nd or more passes, add api in /*
//if (!$pass['phpgwapi']) Now if we are on the 2nd or more passes, add api in
//{ if (!$pass['phpgwapi'])
// $pass['phpgwapi'] = $setup_info['phpgwapi']; {
//} $pass['phpgwapi'] = $setup_info['phpgwapi'];
}
*/
} }
switch ($method) switch ($method)
{ {
case 'new': case 'new':
// Create tables and insert new records for each app in this list /* Create tables and insert new records for each app in this list */
$passing = $this->process_current($pass,$DEBUG); $passing = $this->process_current($pass,$DEBUG);
$passing = $this->process_default_records($passing,$DEBUG); $passing = $this->process_default_records($passing,$DEBUG);
$passing = $this->process_add_langs($passing,$DEBUG,$force_en);
break; break;
case 'upgrade': case 'upgrade':
// Run upgrade scripts on each app in the list /* Run upgrade scripts on each app in the list */
$passing = $this->process_upgrade($pass,$DEBUG); $passing = $this->process_upgrade($pass,$DEBUG);
$passing = $this->process_upgrade_langs($passing,$DEBUG);
//echo var_dump($pass);exit; //echo var_dump($pass);exit;
break; break;
default: default:
// What the heck are you doing? /* What the heck are you doing? */
return False; return False;
break; break;
} }
$pass = array(); $pass = array();
reset($passing); @reset($passing);
while(list($key,$value) = each($passing)) while(list($key,$value) = @each($passing))
{ {
if($value['status'] == 'C') if($value['status'] == 'C')
{ {
@ -161,7 +167,7 @@
// now return the list // now return the list
@reset($passed); @reset($passed);
while(list($key,$value) = each($passed)) while(list($key,$value) = @each($passed))
{ {
$setup_info[$value['name']] = $passed[$value['name']]; $setup_info[$value['name']] = $passed[$value['name']];
} }
@ -190,7 +196,7 @@
} }
@reset($setup_info); @reset($setup_info);
while (list($key,$null) = each($setup_info)) while (list($key,$null) = @each($setup_info))
{ {
if ($setup_info[$key]['tables']) if ($setup_info[$key]['tables'])
{ {
@ -227,7 +233,7 @@
$this->oProc->m_bDeltaOnly = False; $this->oProc->m_bDeltaOnly = False;
@reset($setup_info); @reset($setup_info);
while (list($key,$null) = each($setup_info)) while (list($key,$null) = @each($setup_info))
{ {
$enabled = False; $enabled = False;
$appname = $setup_info[$key]['name']; $appname = $setup_info[$key]['name'];
@ -308,7 +314,7 @@
$oProc = $this->oProc; $oProc = $this->oProc;
@reset($setup_info); @reset($setup_info);
while (list($key,$null) = each($setup_info)) while (list($key,$null) = @each($setup_info))
{ {
$appname = $setup_info[$key]['name']; $appname = $setup_info[$key]['name'];
$appdir = PHPGW_SERVER_ROOT . SEP . $appname . SEP . 'setup' . SEP; $appdir = PHPGW_SERVER_ROOT . SEP . $appname . SEP . 'setup' . SEP;
@ -330,6 +336,72 @@
return ($setup_info); return ($setup_info);
} }
/*!
@function process_add_langs
@abstract process application lang files and uninstall
@param $setup_info array of application info from setup.inc.php files, etc.
*/
function process_add_langs($setup_info,$DEBUG=False,$force_en=False)
{
@reset($setup_info);
while (list($key,$null) = @each($setup_info))
{
$appname = $setup_info[$key]['name'];
/* This is in the setup_lang class */
$this->add_langs($appname,$force_en);
if($DEBUG)
{
echo '<br>process_add_langs(): Translations added for ' . $appname . "\n";
}
}
// Done, return current status
return ($setup_info);
}
/*!
@function process_drop_langs
@abstract process application lang files and install
@param $setup_info array of application info from setup.inc.php files, etc.
*/
function process_drop_langs($setup_info,$DEBUG=False)
{
@reset($setup_info);
while (list($key,$null) = @each($setup_info))
{
$appname = $setup_info[$key]['name'];
/* This is in the setup_lang class */
$this->drop_langs($appname);
if($DEBUG)
{
echo '<br>process_drop_langs(): Translations removed for ' . $appname . "\n";
}
}
// Done, return current status
return ($setup_info);
}
/*!
@function process_upgrade_langs
@abstract process application lang files and reinstall
@param $setup_info array of application info from setup.inc.php files, etc.
*/
function process_upgrade_langs($setup_info,$DEBUG=False)
{
@reset($setup_info);
while (list($key,$null) = @each($setup_info))
{
$appname = $setup_info[$key]['name'];
/* These are in the setup_lang class */
$this->drop_langs($appname);
$this->add_langs($appname);
if($DEBUG)
{
echo '<br>process_upgrade_langs(): Translations reinstalled for ' . $appname . "\n";
}
}
// Done, return current status
return ($setup_info);
}
/*! /*!
@function process_test_data @function process_test_data
@abstract process test_data.inc.php in each application/setup dir for developer tests @abstract process test_data.inc.php in each application/setup dir for developer tests
@ -346,7 +418,7 @@
$oProc = $this->oProc; $oProc = $this->oProc;
@reset($setup_info); @reset($setup_info);
while (list($key,$null) = each($setup_info)) while (list($key,$null) = @each($setup_info))
{ {
$appname = $setup_info[$key]['name']; $appname = $setup_info[$key]['name'];
$appdir = PHPGW_SERVER_ROOT . SEP . $appname . SEP . 'setup' . SEP; $appdir = PHPGW_SERVER_ROOT . SEP . $appname . SEP . 'setup' . SEP;
@ -380,7 +452,7 @@
} }
@reset($setup_info); @reset($setup_info);
while (list($key,$null) = each($setup_info)) while (list($key,$null) = @each($setup_info))
{ {
$appname = $setup_info[$key]['name']; $appname = $setup_info[$key]['name'];
$appdir = PHPGW_SERVER_ROOT . SEP . $appname . SEP . 'setup' . SEP; $appdir = PHPGW_SERVER_ROOT . SEP . $appname . SEP . 'setup' . SEP;
@ -428,7 +500,7 @@
@reset($setup_info); @reset($setup_info);
while (list($key,$null) = each($setup_info)) while (list($key,$null) = @each($setup_info))
{ {
// if upgrade required, or if we are running again after an upgrade or dependency failure // if upgrade required, or if we are running again after an upgrade or dependency failure
if ($DEBUG) { echo '<br>process_upgrade(): Incoming : appname: '.$setup_info[$key]['name'] . ' status: ' . $setup_info[$key]['status']; } if ($DEBUG) { echo '<br>process_upgrade(): Incoming : appname: '.$setup_info[$key]['name'] . ' status: ' . $setup_info[$key]['status']; }

View File

@ -10,10 +10,12 @@
\**************************************************************************/ \**************************************************************************/
/* $Id$ */ /* $Id$ */
// Idea: This is so I don't forget. When they are preforming a new install, after config, /*
// forward them right to index.php. Create a session for them and have a nice little intro Idea: This is so I don't forget. When they are preforming a new install, after config,
// page explaining what to do from there (ie, create there own account) forward them right to index.php. Create a session for them and have a nice little intro
page explaining what to do from there (ie, create there own account)
*/
$DEBUG = False; $DEBUG = False;
$phpgw_info = array(); $phpgw_info = array();
@ -246,7 +248,8 @@
$setup_info = $phpgw_setup->process_droptables($setup_info); $setup_info = $phpgw_setup->process_droptables($setup_info);
break; break;
case 'new': case 'new':
$setup_info = $phpgw_setup->process_pass($setup_info,'new',$DEBUG); /* process all apps and langs(last param True) */
$setup_info = $phpgw_setup->process_pass($setup_info,'new',$DEBUG,True);
$included = True; $included = True;
include('lang.php'); include('lang.php');
$GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'oldversion'; $GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'oldversion';