mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 16:44:07 +01:00
limited the length of the message_id to 230 and defined a constant for it
This commit is contained in:
parent
456493f188
commit
6b1cfa855e
@ -161,8 +161,15 @@
|
||||
{
|
||||
$setup_info['depends'][$depkey]['status'] = True;
|
||||
}
|
||||
else
|
||||
else // check if majors are equal and minors greater or equal
|
||||
{
|
||||
$major_depsvalue = $GLOBALS['phpgw_setup']->get_major($depsvalue);
|
||||
list(,,,$minor_depsvalue) = explode('.',$depsvalue);
|
||||
list(,,,$minor) = explode('.',$setup_info[$value['depends'][$depkey]['appname']]['currentver']);
|
||||
if ($major == $major_depsvalue && $minor <= $minor_depsvalue)
|
||||
{
|
||||
$setup_info['depends'][$depkey]['status'] = True;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -330,18 +337,18 @@
|
||||
{
|
||||
$GLOBALS['setup_info'] = $GLOBALS['phpgw_setup']->detection->get_db_versions($GLOBALS['setup_info']);
|
||||
}
|
||||
if($GLOBALS['phpgw_setup']->alessthanb($GLOBALS['setup_info']['phpgwapi']['currentver'], '0.9.15.002'))
|
||||
if($GLOBALS['phpgw_setup']->alessthanb($GLOBALS['setup_info']['phpgwapi']['currentver'], '0.9.14.501') ||
|
||||
ereg('0\.9\.15\.00[01]{1,1}',$GLOBALS['setup_info']['phpgwapi']['currentver']))
|
||||
{
|
||||
$langtbl = 'lang';
|
||||
$langstbl = 'languages';
|
||||
$languagestbl = 'languages';
|
||||
}
|
||||
else
|
||||
{
|
||||
$langtbl = 'phpgw_lang';
|
||||
$langstbl = 'phpgw_languages';
|
||||
$languagestbl = 'phpgw_languages';
|
||||
}
|
||||
|
||||
$GLOBALS['phpgw_setup']->db->query("SELECT DISTINCT lang FROM $langtbl",__LINE__,__FILE__);
|
||||
$GLOBALS['phpgw_setup']->db->query($q = "SELECT DISTINCT lang FROM $langtbl",__LINE__,__FILE__);
|
||||
if($GLOBALS['phpgw_setup']->db->num_rows() == 0)
|
||||
{
|
||||
$GLOBALS['phpgw_info']['setup']['header_msg'] = 'Stage 3 (No languages installed)';
|
||||
@ -356,7 +363,7 @@
|
||||
reset($GLOBALS['phpgw_info']['setup']['installed_langs']);
|
||||
while(list($key, $value) = each($GLOBALS['phpgw_info']['setup']['installed_langs']))
|
||||
{
|
||||
$sql = "SELECT lang_name FROM $langstbl WHERE lang_id = '".$value."'";
|
||||
$sql = "SELECT lang_name FROM $languagestbl WHERE lang_id = '".$value."'";
|
||||
$GLOBALS['phpgw_setup']->db->query($sql);
|
||||
$GLOBALS['phpgw_setup']->db->next_record();
|
||||
$GLOBALS['phpgw_info']['setup']['installed_langs'][$value] = $GLOBALS['phpgw_setup']->db->f('lang_name');
|
||||
|
@ -23,10 +23,14 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
if (!defined('MAX_MESSAGE_ID_LENGTH'))
|
||||
{
|
||||
define('MAX_MESSAGE_ID_LENGTH',230);
|
||||
}
|
||||
|
||||
class setup_translation
|
||||
{
|
||||
var $langarray;
|
||||
var $langtbl = 'phpgw_lang';
|
||||
|
||||
/*!
|
||||
@function setup_lang
|
||||
@ -37,14 +41,6 @@
|
||||
{
|
||||
$ConfigLang = get_var('ConfigLang',Array('POST','COOKIE'));
|
||||
|
||||
/* TODO */
|
||||
/*
|
||||
if(@$GLOBALS['phpgw_setup']->alessthanb(@$GLOBALS['setup_info']['phpgwapi']['currentver'], '0.9.15.002'))
|
||||
{
|
||||
$this->langtbl = 'lang';
|
||||
}
|
||||
*/
|
||||
|
||||
if(!$ConfigLang)
|
||||
{
|
||||
$lang = 'en';
|
||||
@ -77,7 +73,7 @@
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
@function translate
|
||||
@abstract Translate phrase to user selected lang
|
||||
@ -128,7 +124,7 @@
|
||||
{
|
||||
echo '<br>get_langs(): checking db...' . "\n";
|
||||
}
|
||||
$GLOBALS['phpgw_setup']->db->query("SELECT DISTINCT(lang) FROM $this->langtbl",__LINE__,__FILE__);
|
||||
$GLOBALS['phpgw_setup']->db->query("SELECT DISTINCT(lang) FROM phpgw_lang",__LINE__,__FILE__);
|
||||
$langs = array();
|
||||
|
||||
while($GLOBALS['phpgw_setup']->db->next_record())
|
||||
@ -153,11 +149,11 @@
|
||||
{
|
||||
echo '<br>drop_langs(): Working on: ' . $appname;
|
||||
}
|
||||
$GLOBALS['phpgw_setup']->db->query("SELECT COUNT(message_id) FROM $this->langtbl WHERE app_name='$appname'",__LINE__,__FILE__);
|
||||
$GLOBALS['phpgw_setup']->db->query("SELECT COUNT(message_id) FROM phpgw_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 $this->langtbl WHERE app_name='$appname'",__LINE__,__FILE__);
|
||||
$GLOBALS['phpgw_setup']->db->query("DELETE FROM phpgw_lang WHERE app_name='$appname'",__LINE__,__FILE__);
|
||||
return True;
|
||||
}
|
||||
return False;
|
||||
@ -202,13 +198,13 @@
|
||||
while (list($null,$line) = @each($raw_file))
|
||||
{
|
||||
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(substr($message_id,0,MAX_MESSAGE_ID_LENGTH)));
|
||||
/* 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 $this->langtbl WHERE message_id='$message_id' and lang='"
|
||||
$GLOBALS['phpgw_setup']->db->query("SELECT COUNT(*) FROM phpgw_lang WHERE message_id='$message_id' and lang='"
|
||||
. $GLOBALS['phpgw_setup']->db_lang . "'",__LINE__,__FILE__);
|
||||
$GLOBALS['phpgw_setup']->db->next_record();
|
||||
|
||||
@ -218,10 +214,10 @@
|
||||
{
|
||||
if($DEBUG)
|
||||
{
|
||||
echo "<br>add_langs(): adding - INSERT INTO $this->langtbl VALUES ('$message_id','$app_name','"
|
||||
echo "<br>add_langs(): adding - INSERT INTO phpgw_lang VALUES ('$message_id','$app_name','"
|
||||
. $GLOBALS['phpgw_setup']->db_lang . "','$content')";
|
||||
}
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO $this->langtbl VALUES ('$message_id','$app_name','"
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_lang VALUES ('$message_id','$app_name','"
|
||||
. $GLOBALS['phpgw_setup']->db_lang . "','$content')",__LINE__,__FILE__);
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,13 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
// define the maximal length of a message_id, all message_ids have to be unique
|
||||
// in this length, our column is varchar 255, but addslashes might add some length
|
||||
if (!defined('MAX_MESSAGE_ID_LENGTH'))
|
||||
{
|
||||
define('MAX_MESSAGE_ID_LENGTH',230);
|
||||
}
|
||||
|
||||
class translation
|
||||
{
|
||||
var $lang = array();
|
||||
@ -103,7 +110,7 @@
|
||||
$vars = array();
|
||||
}
|
||||
$ret = $key;
|
||||
$_key = strtolower($key);
|
||||
$_key = substr(strtolower($key),0,MAX_MESSAGE_ID_LENGTH);
|
||||
|
||||
if(!@isset($this->lang[$_key]) && !$this->loaded)
|
||||
{
|
||||
@ -140,4 +147,22 @@
|
||||
$GLOBALS['phpgw']->db->next_record();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@function get_installed_langs
|
||||
@returns array of installed langs, in the form eg. 'de' => 'German'
|
||||
*/
|
||||
function get_installed_langs()
|
||||
{
|
||||
$GLOBALS['phpgw']->db->query("SELECT DISTINCT l.lang,ln.lang_name FROM phpgw_lang l,phpgw_languages ln WHERE l.lang = ln.lang_id",__LINE__,__FILE__);
|
||||
if (!$GLOBALS['phpgw']->db->num_rows())
|
||||
{
|
||||
return False;
|
||||
}
|
||||
while ($GLOBALS['phpgw']->db->next_record())
|
||||
{
|
||||
$langs[$GLOBALS['phpgw']->db->f('lang')] = $GLOBALS['phpgw']->db->f('lang_name');
|
||||
}
|
||||
return $langs;
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,11 @@
|
||||
$submit = True;
|
||||
}
|
||||
|
||||
if (!defined('MAX_MESSAGE_ID_LENGTH'))
|
||||
{
|
||||
define('MAX_MESSAGE_ID_LENGTH',230);
|
||||
}
|
||||
|
||||
if (@$GLOBALS['HTTP_POST_VARS']['submit'])
|
||||
{
|
||||
$lang_selected = @$GLOBALS['HTTP_POST_VARS']['lang_selected'];
|
||||
@ -66,7 +71,7 @@
|
||||
//echo '<br>Test: dumpold';
|
||||
$GLOBALS['phpgw_info']['server']['lang_ctimes'] = array();
|
||||
}
|
||||
while (list($null,$lang) = each($lang_selected))
|
||||
foreach($lang_selected as $lang)
|
||||
{
|
||||
//echo '<br>Working on: ' . $lang;
|
||||
$addlang = False;
|
||||
@ -87,8 +92,8 @@
|
||||
//echo '<br>Test: loop above file()';
|
||||
$setup_info = $GLOBALS['phpgw_setup']->detection->get_versions();
|
||||
$setup_info = $GLOBALS['phpgw_setup']->detection->get_db_versions($setup_info);
|
||||
$raw = $raw_file = array();
|
||||
// Visit each app/setup dir, look for a lang file
|
||||
$raw = array();
|
||||
// Visit each app/setup dir, look for a phpgw_lang file
|
||||
while (list($key,$app) = each($setup_info))
|
||||
{
|
||||
$appfile = PHPGW_SERVER_ROOT . SEP . $app['name'] . SEP . 'setup' . SEP . 'phpgw_' . strtolower($lang) . '.lang';
|
||||
@ -96,27 +101,29 @@
|
||||
if($GLOBALS['phpgw_setup']->app_registered($app['name']) && file_exists($appfile))
|
||||
{
|
||||
//echo '<br>Including: ' . $appfile;
|
||||
$raw[] = file($appfile);
|
||||
|
||||
$lines = file($appfile);
|
||||
foreach($lines as $line)
|
||||
{
|
||||
list($message_id,$app_name,,$content) = explode("\t",$line);
|
||||
$message_id = $GLOBALS['phpgw_setup']->db->db_addslashes(substr(chop($message_id),0,MAX_MESSAGE_ID_LENGTH));
|
||||
$app_name = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($app_name));
|
||||
$content = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($content));
|
||||
|
||||
$raw[$app_name][$message_id] = $content;
|
||||
}
|
||||
$GLOBALS['phpgw_info']['server']['lang_ctimes'][$lang][$app['name']] = filectime($appfile);
|
||||
}
|
||||
}
|
||||
@reset($raw);
|
||||
while (list($a,$raw_file) = @each($raw))
|
||||
foreach($raw as $app_name => $ids)
|
||||
{
|
||||
while (list($_null,$line) = @each($raw_file))
|
||||
foreach($ids as $message_id => $content)
|
||||
{
|
||||
$addit = False;
|
||||
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));
|
||||
//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));
|
||||
if ($upgrademethod == 'addmissing')
|
||||
{
|
||||
//echo '<br>Test: addmissing';
|
||||
$GLOBALS['phpgw_setup']->db->query("SELECT COUNT(*) FROM phpgw_lang WHERE message_id='".$message_id."' and lang='".$GLOBALS['phpgw_setup']->db_lang."' and (app_name='".$app_name."' or app_name='common')",__LINE__,__FILE__);
|
||||
$GLOBALS['phpgw_setup']->db->query("SELECT COUNT(*) FROM phpgw_lang WHERE message_id='$message_id' and lang='$lang' and (app_name='$app_name' or app_name='common')",__LINE__,__FILE__);
|
||||
$GLOBALS['phpgw_setup']->db->next_record();
|
||||
|
||||
if ($GLOBALS['phpgw_setup']->db->f(0) == 0)
|
||||
@ -130,11 +137,11 @@
|
||||
{
|
||||
if($message_id && $content)
|
||||
{
|
||||
//echo "<br>adding - insert into lang values ('".$message_id."','".$app_name."','".$GLOBALS['phpgw_setup']->db_lang."','".$content."')";
|
||||
$result = $GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_lang(message_id,app_name,lang,content) VALUES('".$message_id."','".$app_name."','".$GLOBALS['phpgw_setup']->db_lang."','".$content."')",__LINE__,__FILE__);
|
||||
//echo "<br>adding - insert into phpgw_lang values ('$message_id','$app_name','$lang','$content')";
|
||||
$result = $GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_lang (message_id,app_name,lang,content) VALUES('$message_id','$app_name','$lang','$content')",__LINE__,__FILE__);
|
||||
if (intval($result) <= 0)
|
||||
{
|
||||
echo "<br>Error inserting record: phpgw_lang values ('".$message_id."','".$app_name."','".$GLOBALS['phpgw_setup']->db_lang."','".$content."')";
|
||||
echo "<br>Error inserting record: phpgw_lang values ('$message_id','$app_name','$lang','$content')";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -148,7 +155,6 @@
|
||||
$GLOBALS['phpgw_setup']->db->query($query="INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES ('phpgwapi','lang_ctimes','".
|
||||
addslashes(serialize($GLOBALS['phpgw_info']['server']['lang_ctimes']))."')",__LINE__,__FILE__);
|
||||
}
|
||||
|
||||
if(!$included)
|
||||
{
|
||||
Header('Location: index.php');
|
||||
@ -189,7 +195,7 @@
|
||||
}
|
||||
$select_box_desc = lang('Select which languages you would like to use');
|
||||
$select_box = '';
|
||||
$GLOBALS['phpgw_setup']->db->query("select lang_id,lang_name from phpgw_languages where available='Yes'");
|
||||
$GLOBALS['phpgw_setup']->db->query($q="select lang_id,lang_name from phpgw_languages where available='Yes'");
|
||||
while ($GLOBALS['phpgw_setup']->db->next_record())
|
||||
{
|
||||
$id = $GLOBALS['phpgw_setup']->db->f('lang_id');
|
||||
|
Loading…
Reference in New Issue
Block a user