Bug fix for translation class, DB IO connection error set fix
- The translation file reader did an isset on a set variable insetad of checking if the variable is zero and so never started the translation system - The DB IO connection not set was wrongly set. If the connection failed it is not TRUE and else FALSE. There is a new internal method getConnectionStatus to query this status it returns TRUE/FALSE depending if the connection failed - Update the l10n test page with proper translation tests - init OK - show current lang/file - translation test - switch language test
This commit is contained in:
@@ -95,6 +95,7 @@ return [
|
||||
'www/media',
|
||||
],
|
||||
'exclude_file_list' => [
|
||||
// ignore all symlink files to edit
|
||||
'www/admin/edit_access.php',
|
||||
'www/admin/edit_groups.php',
|
||||
'www/admin/edit_languages.php',
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#********************************************************************
|
||||
# ********************************************************************
|
||||
# AUTHOR: Clemens Schwaighofer
|
||||
# CREATED: 2005/08/09
|
||||
# SHORT DESCRIPTION:
|
||||
# Backned English Messages file for gettext
|
||||
# to craete: msgfmt -o ja.mo messages_en.po
|
||||
# HISTORY:
|
||||
#********************************************************************/
|
||||
# ********************************************************************/
|
||||
|
||||
msgid ""
|
||||
msgstr ""
|
||||
@@ -24,3 +24,6 @@ msgstr "Year"
|
||||
|
||||
msgid "Month"
|
||||
msgstr "Month"
|
||||
|
||||
msgid "INPUT TEST"
|
||||
msgstr "OUTPUT TEST EN"
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#********************************************************************
|
||||
# ********************************************************************
|
||||
# AUTHOR: Clemens Schwaighofer
|
||||
# CREATED: 2018/03/28
|
||||
# SHORT DESCRIPTION:
|
||||
# Backend Japanese Messages file for gettext
|
||||
# to craete: msgfmt -o ja.mo messages_ja.po
|
||||
# HISTORY:
|
||||
#********************************************************************/
|
||||
# ********************************************************************/
|
||||
|
||||
msgid ""
|
||||
msgstr ""
|
||||
@@ -61,3 +61,6 @@ msgstr "土"
|
||||
|
||||
msgid "Sun"
|
||||
msgstr "日"
|
||||
|
||||
msgid "INPUT TEST"
|
||||
msgstr "OUTPUT TEST JA"
|
||||
|
||||
@@ -5,13 +5,25 @@
|
||||
// namespace test
|
||||
ob_start();
|
||||
|
||||
// init language
|
||||
$lang = 'en_utf8';
|
||||
|
||||
// admin class tests
|
||||
require 'config.php';
|
||||
$l = new CoreLibs\Language\L10n($lang);
|
||||
|
||||
echo "OK<br>";
|
||||
|
||||
ob_end_flush();
|
||||
|
||||
$string = 'INPUT TEST';
|
||||
|
||||
echo "LANGUAGE SET: ".$l->__getLang()."<br>";
|
||||
echo "LANGUAGE FILE: ".$l->__getMoFile()."<br>";
|
||||
echo "INPUT TEST: ".$string." => ".$l->__($string)."<br>";
|
||||
|
||||
// switch to other language
|
||||
$lang = 'ja_utf8';
|
||||
$l->l10nReloadMOfile($lang);
|
||||
|
||||
echo "LANGUAGE SET: ".$l->__getLang()."<br>";
|
||||
echo "LANGUAGE FILE: ".$l->__getMoFile()."<br>";
|
||||
echo "INPUT TEST: ".$string." => ".$l->__($string)."<br>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -17,6 +17,9 @@ echo "DIR: ".DIR."<br>ROOT: ".ROOT."<br>BASE: ".BASE."<br>";
|
||||
$lang = 'ja_utf8';
|
||||
$base = new CoreLibs\Admin\Backend(DB_CONFIG, $lang);
|
||||
ob_end_flush();
|
||||
if ($base->getConnectionStatus()) {
|
||||
die("Cannot connect to database");
|
||||
}
|
||||
|
||||
print "Start time: ".$base->runningTime()."<br>";
|
||||
print "ByteStringFormat: ".$base->ByteStringFormat(1234567.12)."<br>";
|
||||
|
||||
@@ -27,6 +27,8 @@ $SITE_CONFIG = array (
|
||||
'debug_flag' => true,
|
||||
// site language
|
||||
'site_lang' => 'en_utf8',
|
||||
// enable/disable login override
|
||||
'login_enabled' => true
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ DEFINE('DEFAULT_ENCODING', 'UTF-8');
|
||||
// below two can be defined here, but they should be
|
||||
// defined in either the header file or the file itself
|
||||
/************* LOGGING *******************/
|
||||
// DEFINE('LOG_FILE_ID', '');
|
||||
DEFINE('LOG_FILE_ID', '');
|
||||
|
||||
/************* CLASS ERRORS *******************/
|
||||
// 0 = default all OFF
|
||||
@@ -220,7 +220,7 @@ if ((array_key_exists('HTTPS', $_SERVER) && !empty($_SERVER['HTTPS']) && $_SERVE
|
||||
}
|
||||
// define the db config set name, the db config and the db schema
|
||||
DEFINE('DB_CONFIG_NAME', $SITE_CONFIG[$HOST_NAME]['db_host']);
|
||||
DEFINE('DB_CONFIG', $DB_CONFIG[DB_CONFIG_NAME]);
|
||||
DEFINE('DB_CONFIG', isset($DB_CONFIG[DB_CONFIG_NAME]) ? $DB_CONFIG[DB_CONFIG_NAME] : array ());
|
||||
// DEFINE('DB_CONFIG_TARGET', SITE_CONFIG[$HOST_NAME]['db_host_target']);
|
||||
// DEFINE('DB_CONFIG_OTHER', SITE_CONFIG[$HOST_NAME]['db_host_other']);
|
||||
// override for login and global schemas
|
||||
@@ -230,6 +230,7 @@ DEFINE('DB_CONFIG', $DB_CONFIG[DB_CONFIG_NAME]);
|
||||
DEFINE('TARGET', $SITE_CONFIG[$HOST_NAME]['location']);
|
||||
DEFINE('DEBUG', $SITE_CONFIG[$HOST_NAME]['debug_flag']);
|
||||
DEFINE('SITE_LANG', $SITE_CONFIG[$HOST_NAME]['site_lang']);
|
||||
DEFINE('LOGIN_ENABLED', $SITE_CONFIG[$HOST_NAME]['login_enabled']);
|
||||
// paths
|
||||
// DEFINE('CSV_PATH', $PATHS[TARGET]['csv_path']);
|
||||
// DEFINE('EXPORT_SCRIPT', $PATHS[TARGET]['perl_bin']);
|
||||
|
||||
@@ -10,8 +10,12 @@
|
||||
|
||||
// File and Folder paths
|
||||
// ID is TARGET (first array element)
|
||||
// $PATHS['test']['csv_path'] = '';
|
||||
// $PATHS['test']['perl_bin'] = '';
|
||||
// $PATHS['test']['redirect_url'] = '';
|
||||
/*$PATHS = array (
|
||||
'test' => array (
|
||||
'csv_path' => '',
|
||||
'perl_bin' => '',
|
||||
'other_url' => '',
|
||||
)
|
||||
)*/
|
||||
|
||||
// __END__
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -122,7 +122,7 @@ class Login extends \CoreLibs\DB\IO
|
||||
|
||||
// create db connection and init base class
|
||||
parent::__construct($db_config, $set_control_flag);
|
||||
if ($this->db_init_error === false) {
|
||||
if ($this->db_init_error === true) {
|
||||
echo 'Could not connect to DB<br>';
|
||||
// if I can't connect to the DB to auth exit hard. No access allowed
|
||||
exit;
|
||||
|
||||
@@ -376,18 +376,15 @@ class IO extends \CoreLibs\Basic
|
||||
// abort error
|
||||
$this->error_id = 10;
|
||||
$this->__dbError();
|
||||
$this->db_init_error = false;
|
||||
$this->db_init_error = true;
|
||||
}
|
||||
|
||||
// connect to DB
|
||||
if (!$this->__connectToDB()) {
|
||||
$this->error_id = 16;
|
||||
$this->__dbError();
|
||||
$this->db_init_error = false;
|
||||
$this->db_init_error = true;
|
||||
}
|
||||
|
||||
// so we can check that we have a successful DB connection created
|
||||
$this->db_init_error = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -897,6 +894,17 @@ class IO extends \CoreLibs\Basic
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the db init error
|
||||
* if failed to connect it is set to true
|
||||
* else false
|
||||
* @return bool connection failure status
|
||||
*/
|
||||
public function getConnectionStatus(): bool
|
||||
{
|
||||
return $this->db_init_error;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets new db schema
|
||||
* @param string $db_schema schema name, if not given tries internal default db schema
|
||||
|
||||
@@ -106,7 +106,7 @@ class GetTextReader
|
||||
public function __construct($Reader, $enable_cache = true)
|
||||
{
|
||||
// If there isn't a StreamReader, turn on short circuit mode.
|
||||
if (!$Reader || isset($Reader->error)) {
|
||||
if (!$Reader || $Reader->error) {
|
||||
$this->short_circuit = true;
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user