mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-23 07:09:20 +01:00
- phpgw --> egw
- fixed a problem php5 complained about, which is present in php4 too: arrays in $GLOBALS[egw][server] are NOT unserialized. As this seems to be only used for the lang_ctimes, I just took care of it here
This commit is contained in:
parent
a3fb79a6a4
commit
fd5576e3ee
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
if (empty($GLOBALS['phpgw_info']['server']['translation_system']))
|
||||
if (empty($GLOBALS['egw_info']['server']['translation_system']))
|
||||
{
|
||||
$GLOBALS['phpgw_info']['server']['translation_system'] = 'sql';
|
||||
$GLOBALS['egw_info']['server']['translation_system'] = 'sql';
|
||||
}
|
||||
include(PHPGW_API_INC.'/class.translation_' . $GLOBALS['phpgw_info']['server']['translation_system'].'.inc.php');
|
||||
include(EGW_API_INC.'/class.translation_' . $GLOBALS['egw_info']['server']['translation_system'].'.inc.php');
|
||||
?>
|
||||
|
@ -46,6 +46,9 @@
|
||||
var $loaded_apps = array();
|
||||
var $line_rejected = array();
|
||||
|
||||
/**
|
||||
* Constructor, sets up a copy of the db-object, gets the system-charset and tries to load the mbstring extension
|
||||
*/
|
||||
function translation($warnings = False)
|
||||
{
|
||||
for ($i = 1; $i <= 9; $i++)
|
||||
@ -97,9 +100,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@function charset
|
||||
@abstract returns the charset to use (!$lang) or the charset of the lang-files or $lang
|
||||
/**
|
||||
* returns the charset to use (!$lang) or the charset of the lang-files or $lang
|
||||
*
|
||||
* @param string/boolean $lang=False return charset of the active user-lang, or $lang if specified
|
||||
* @return string charset
|
||||
*/
|
||||
function charset($lang=False)
|
||||
{
|
||||
@ -134,6 +139,9 @@
|
||||
return $charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises global lang-array and loads the 'common' and app-spec. translations
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
// post-nuke and php-nuke are using $GLOBALS['lang'] too
|
||||
@ -157,10 +165,13 @@
|
||||
$this->add_app($GLOBALS['egw_info']['flags']['currentapp']);
|
||||
}
|
||||
|
||||
/*!
|
||||
@function translate
|
||||
@abstract translates a phrase and evtl. substitute some variables
|
||||
@returns the translation
|
||||
/**
|
||||
* translates a phrase and evtl. substitute some variables
|
||||
*
|
||||
* @param string $key phrase to translate, may contain placeholders %N (N=1,2,...) for vars
|
||||
* @param array/boolean $vars=false vars to replace the placeholders, or false for none
|
||||
* @param string $not_found='*' what to add to not found phrases, default '*'
|
||||
* @return string with translation
|
||||
*/
|
||||
function translate($key, $vars=false, $not_found='*' )
|
||||
{
|
||||
@ -198,12 +209,11 @@
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/*!
|
||||
@function add_app
|
||||
@abstract adds translations for an application from the database to the lang-array
|
||||
@syntax add_app($app,$lang=False)
|
||||
@param $app name of the application to add (or 'common' for the general translations)
|
||||
@param $lang 2-char code of the language to use or False if the users language should be used
|
||||
/**
|
||||
* adds translations for an application from the database to the lang-array
|
||||
*
|
||||
* @param string $app name of the application to add (or 'common' for the general translations)
|
||||
* @param string/boolean $lang=false 2 or 5 char lang-code or false for the users language
|
||||
*/
|
||||
function add_app($app,$lang=False)
|
||||
{
|
||||
@ -227,13 +237,15 @@
|
||||
|
||||
/**
|
||||
* Adds setup's translations, they are not in the DB!
|
||||
*
|
||||
* @param string $lang 2 or 5 char lang-code
|
||||
*/
|
||||
function add_setup($lang)
|
||||
{
|
||||
$fn = PHPGW_SERVER_ROOT.'/setup/lang/phpgw_' . $lang . '.lang';
|
||||
$fn = EGW_SERVER_ROOT.'/setup/lang/phpgw_' . $lang . '.lang';
|
||||
if (!file_exists($fn))
|
||||
{
|
||||
$fn = PHPGW_SERVER_ROOT.'/setup/lang/phpgw_en.lang';
|
||||
$fn = EGW_SERVER_ROOT.'/setup/lang/phpgw_en.lang';
|
||||
}
|
||||
if (file_exists($fn))
|
||||
{
|
||||
@ -253,10 +265,10 @@
|
||||
}
|
||||
$this->loaded_apps['setup'] = $lang;
|
||||
}
|
||||
/*!
|
||||
@function get_installed_langs
|
||||
@abstract returns a list of installed langs
|
||||
@returns array with 2-character lang-code as key and descriptiv lang-name as data
|
||||
/**
|
||||
* returns a list of installed langs
|
||||
*
|
||||
* @return array with lang-code => descriptiv lang-name pairs
|
||||
*/
|
||||
function get_installed_langs()
|
||||
{
|
||||
@ -279,22 +291,17 @@
|
||||
return $this->langs;
|
||||
}
|
||||
|
||||
/*!
|
||||
@function get_installed_charsets
|
||||
@abstract returns a list of installed charsets
|
||||
@returns array with charset as key and comma-separated list of langs useing the charset as data
|
||||
/**
|
||||
* returns a list of installed charsets
|
||||
*
|
||||
* @return array with charset as key and comma-separated list of langs useing the charset as data
|
||||
*/
|
||||
function get_installed_charsets()
|
||||
{
|
||||
if (!is_array($this->charsets))
|
||||
{
|
||||
$distinct = 'DISTINCT';
|
||||
switch($this->db->Type)
|
||||
{
|
||||
case 'sapdb': case 'maxdb':
|
||||
case 'mssql':
|
||||
$distinct = ''; // cant use distinct on text columns (l.content is text)
|
||||
}
|
||||
$distinct = $this->db->capabilities['distinct_on_text'] ? 'DISTINCT' : '';
|
||||
|
||||
$this->db->query("SELECT $distinct l.lang,lx.lang_name,l.content AS charset FROM phpgw_lang l,phpgw_languages lx WHERE l.lang = lx.lang_id AND l.message_id='charset'",__LINE__,__FILE__);
|
||||
if (!$this->db->num_rows())
|
||||
{
|
||||
@ -313,14 +320,13 @@
|
||||
return $this->charsets;
|
||||
}
|
||||
|
||||
/*!
|
||||
@function convert
|
||||
@abstract converts a string $data from charset $from to charset $to
|
||||
@syntax convert($data,$from=False,$to=False)
|
||||
@param $data string or array of strings to convert
|
||||
@param $from charset $data is in or False if it should be detected
|
||||
@param $to charset to convert to or False for the system-charset
|
||||
@returns the converted string
|
||||
/**
|
||||
* converts a string $data from charset $from to charset $to
|
||||
*
|
||||
* @param string/array $data string(s) to convert
|
||||
* @param string/boolean $from charset $data is in or False if it should be detected
|
||||
* @param string/boolean $to charset to convert to or False for the system-charset the converted string
|
||||
* @return string/array converted string(s) from $data
|
||||
*/
|
||||
function convert($data,$from=False,$to=False)
|
||||
{
|
||||
@ -405,12 +411,12 @@
|
||||
return $data;
|
||||
}
|
||||
|
||||
/*!
|
||||
@function install_langs
|
||||
@abstract installs translations for the selected langs into the database
|
||||
@syntax install_langs($langs,$upgrademethod='dumpold')
|
||||
@param $langs array of langs to install (as data NOT keys (!))
|
||||
@param $upgrademethod 'dumpold' (recommended & fastest), 'addonlynew' languages, 'addmissing' phrases
|
||||
/**
|
||||
* installs translations for the selected langs into the database
|
||||
*
|
||||
* @param array $langs langs to install (as data NOT keys (!))
|
||||
* @param string $upgrademethod='dumpold' 'dumpold' (recommended & fastest), 'addonlynew' languages, 'addmissing' phrases
|
||||
* @param string/boolean $only_app=false app-name to install only one app or default false for all
|
||||
*/
|
||||
function install_langs($langs,$upgrademethod='dumpold',$only_app=False)
|
||||
{
|
||||
@ -464,8 +470,8 @@
|
||||
//echo '<br>Test: loop above file()';
|
||||
if (!is_object($GLOBALS['egw_setup']))
|
||||
{
|
||||
$GLOBALS['egw_setup'] = CreateObject('setup.setup');
|
||||
$GLOBALS['egw_setup']->db = $this->db;
|
||||
$GLOBALS['egw_setup'] =& CreateObject('setup.setup');
|
||||
$GLOBALS['egw_setup']->db = clone($this->db);
|
||||
}
|
||||
$setup_info = $GLOBALS['egw_setup']->detection->get_versions();
|
||||
$setup_info = $GLOBALS['egw_setup']->detection->get_db_versions($setup_info);
|
||||
@ -474,7 +480,7 @@
|
||||
// Visit each app/setup dir, look for a phpgw_lang file
|
||||
foreach($apps as $app)
|
||||
{
|
||||
$appfile = PHPGW_SERVER_ROOT . SEP . $app . SEP . 'setup' . SEP . 'phpgw_' . strtolower($lang) . '.lang';
|
||||
$appfile = EGW_SERVER_ROOT . SEP . $app . SEP . 'setup' . SEP . 'phpgw_' . strtolower($lang) . '.lang';
|
||||
//echo '<br>Checking in: ' . $app;
|
||||
if($GLOBALS['egw_setup']->app_registered($app) && file_exists($appfile))
|
||||
{
|
||||
@ -498,6 +504,10 @@
|
||||
$app_name = chop($app_name);
|
||||
$raw[$app_name][$message_id] = $content;
|
||||
}
|
||||
if ($GLOBALS['egw_info']['server']['lang_ctimes'] && !is_array($GLOBALS['egw_info']['server']['lang_ctimes']))
|
||||
{
|
||||
$GLOBALS['egw_info']['server']['lang_ctimes'] = unserialize($GLOBALS['egw_info']['server']['lang_ctimes']);
|
||||
}
|
||||
$GLOBALS['egw_info']['server']['lang_ctimes'][$lang][$app] = filectime($appfile);
|
||||
}
|
||||
}
|
||||
@ -580,9 +590,8 @@
|
||||
$config->save_value('lang_ctimes',$GLOBALS['egw_info']['server']['lang_ctimes'],'phpgwapi');
|
||||
}
|
||||
|
||||
/*!
|
||||
@function autolaod_changed_langfiles
|
||||
@abstract re-loads all (!) langfiles if one langfile for the an app and the language of the user has changed
|
||||
/**
|
||||
* re-loads all (!) langfiles if one langfile for the an app and the language of the user has changed
|
||||
*/
|
||||
function autoload_changed_langfiles()
|
||||
{
|
||||
@ -598,7 +607,7 @@
|
||||
$apps['phpgwapi'] = True; // check the api too
|
||||
foreach($apps as $app => $data)
|
||||
{
|
||||
$fname = PHPGW_SERVER_ROOT . "/$app/setup/phpgw_$lang.lang";
|
||||
$fname = EGW_SERVER_ROOT . "/$app/setup/phpgw_$lang.lang";
|
||||
|
||||
if (file_exists($fname))
|
||||
{
|
||||
@ -623,9 +632,11 @@
|
||||
|
||||
/* Following functions are called for app (un)install */
|
||||
|
||||
/*!
|
||||
@function get_langs
|
||||
@abstract return array of installed languages, e.g. array('de','en')
|
||||
/**
|
||||
* gets array of installed languages, e.g. array('de','en')
|
||||
*
|
||||
* @param boolean $DEBUG=false debug messages or not, default not
|
||||
* @return array with installed langs
|
||||
*/
|
||||
function get_langs($DEBUG=False)
|
||||
{
|
||||
@ -640,10 +651,12 @@
|
||||
return $this->langs ? array_keys($this->langs) : array();
|
||||
}
|
||||
|
||||
/*!
|
||||
@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
|
||||
/**
|
||||
* delete all lang entries for an application, return True if langs were found
|
||||
*
|
||||
* @param $appname app_name whose translations you want to delete
|
||||
* @param boolean $DEBUG=false debug messages or not, default not
|
||||
* @return boolean true if $appname had translations installed, false otherwise
|
||||
*/
|
||||
function drop_langs($appname,$DEBUG=False)
|
||||
{
|
||||
@ -654,8 +667,8 @@
|
||||
$this->db->select($this->lang_table,'COUNT(message_id)',array(
|
||||
'app_name' => $appname
|
||||
),__LINE__,__FILE__);
|
||||
$this->db->next_record();
|
||||
if($this->db->f(0))
|
||||
|
||||
if($this->db->next_record() && $this->db->f(0))
|
||||
{
|
||||
$this->db->delete($this->lang_table,array(
|
||||
'app_name' => $appname
|
||||
@ -665,10 +678,12 @@
|
||||
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
|
||||
/**
|
||||
* process an application's lang files, calling get_langs() to see what langs the admin installed already
|
||||
*
|
||||
* @param string $appname app_name of application to process
|
||||
* @param boolean $DEBUG=false debug messages or not, default not
|
||||
* @param array/boolean $force_langs=false array with langs to install anyway (beside the allready installed ones), or false for none
|
||||
*/
|
||||
function add_langs($appname,$DEBUG=False,$force_langs=False)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user