check if the used froxlor version has already iso-codes in the language-table for this will output undefined variables after updating the files before updating the database in the panel

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2013-03-10 10:23:24 +01:00
parent 4b872399ac
commit 47481aab56
2 changed files with 29 additions and 25 deletions

View File

@@ -457,7 +457,8 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version)
if ($settings['system']['webserver'] == 'apache2') { if ($settings['system']['webserver'] == 'apache2') {
$has_preconfig = true; $has_preconfig = true;
$description = 'Froxlor now supports the new Apache 2.4. Please be aware that you need to load additional apache-modules in ordner to use it.<br />'; $description = 'Froxlor now supports the new Apache 2.4. Please be aware that you need to load additional apache-modules in ordner to use it.<br />';
$description.= '<pre>LoadModule authz_core_module modules/mod_authz_core.so LoadModule authz_host_module modules/mod_authz_host.so</pre><br />'; $description.= '<pre>LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_host_module modules/mod_authz_host.so</pre><br />';
$question = '<strong>Do you want to enable the Apache-2.4 modification?:</strong>&nbsp;'; $question = '<strong>Do you want to enable the Apache-2.4 modification?:</strong>&nbsp;';
$question.= makeyesno('update_system_apache24', '1', '0', '0'); $question.= makeyesno('update_system_apache24', '1', '0', '0');
eval("\$return.=\"" . getTemplate("update/preconfigitem") . "\";"); eval("\$return.=\"" . getTemplate("update/preconfigitem") . "\";");

View File

@@ -276,7 +276,13 @@ $result = $db->query($query);
while($row = $db->fetch_array($result)) while($row = $db->fetch_array($result))
{ {
$langs[$row['language']][] = $row; $langs[$row['language']][] = $row;
// check for row[iso] cause older froxlor
// versions didn't have that and it will
// lead to a lot of undfined variables
// before the admin can even update
if (isset($row['iso'])) {
$iso[$row['iso']] = $row['language']; $iso[$row['iso']] = $row['language'];
}
} }
// buildup $languages for the login screen // buildup $languages for the login screen
@@ -285,29 +291,28 @@ foreach($langs as $key => $value)
$languages[$key] = $key; $languages[$key] = $key;
} }
if (isset($userinfo['language']) && isset($languages[$userinfo['language']])) // set default langauge before anything else to
{ // ensure that we can display messages
$language = $settings['panel']['standardlanguage'];
if (isset($userinfo['language']) && isset($languages[$userinfo['language']])) {
// default: use language from session, #277 // default: use language from session, #277
$language = $userinfo['language']; $language = $userinfo['language'];
} } else {
else if (!isset($userinfo['def_language'])
{ || !isset($languages[$userinfo['def_language']]) // this will always evaluat true, since it is the above statement inverted. @todo remove
if(!isset($userinfo['def_language']) ) {
|| !isset($languages[$userinfo['def_language']]))// this will always evaluat true, since it is the above statement inverted. @todo remove if (isset($_GET['language'])
{ && isset($languages[$_GET['language']])
if(isset($_GET['language']) ) {
&& isset($languages[$_GET['language']]))
{
$language = $_GET['language']; $language = $_GET['language'];
} } else {
else
{
$accept_langs = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']); $accept_langs = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
for($i = 0; $i<count($accept_langs); $i++) { for($i = 0; $i<count($accept_langs); $i++) {
# this only works for most common languages. some (uncommon) languages have a 3 letter iso-code. // this only works for most common languages. some (uncommon) languages have a 3 letter iso-code.
# to be able to use these also, we would have to depend on the intl extension for php (using Locale::lookup or similar) // to be able to use these also, we would have to depend on the intl extension for php (using Locale::lookup or similar)
# as long as froxlor does not support any of these languages, we can leave it like that. // as long as froxlor does not support any of these languages, we can leave it like that.
if(isset($iso[substr($accept_langs[$i],0,2)])) { if (isset($iso[substr($accept_langs[$i],0,2)])) {
$language=$iso[substr($accept_langs[$i],0,2)]; $language=$iso[substr($accept_langs[$i],0,2)];
break; break;
} }
@@ -315,13 +320,11 @@ else
unset($iso); unset($iso);
// if HTTP_ACCEPT_LANGUAGES has no valid langs, use default (very unlikely) // if HTTP_ACCEPT_LANGUAGES has no valid langs, use default (very unlikely)
if(!strlen($language)>0) { if (!strlen($language)>0) {
$language = $settings['panel']['standardlanguage']; $language = $settings['panel']['standardlanguage'];
} }
} }
} } else {
else
{
$language = $userinfo['def_language']; $language = $userinfo['def_language'];
} }
} }