Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
831f3be1a8 | ||
|
|
f2aba8c466 | ||
|
|
f085ccaa38 | ||
|
|
6c3c1a908d | ||
|
|
388b90913a |
14
4dev/bin/create_mo.sh
Executable file
14
4dev/bin/create_mo.sh
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
base_folder='/var/www/html/developers/clemens/core_data/php_libraries/trunk/www/';
|
||||||
|
|
||||||
|
# locale gettext po to mo translator master
|
||||||
|
for file in $(ls -1 ${base_folder}../4dev/locale/*.po); do
|
||||||
|
file=$(basename $file .po);
|
||||||
|
echo "Translate language ${file}";
|
||||||
|
locale=$(echo "${file}" | cut -d "-" -f 1);
|
||||||
|
domain=$(echo "${file}" | cut -d "-" -f 2);
|
||||||
|
msgfmt -o ${base_folder}/includes/locale/${locale}/LC_MESSAGES/${domain}.mo ${base_folder}../4dev/locale/${locale}-${domain}.po;
|
||||||
|
done;
|
||||||
|
|
||||||
|
# __END__
|
||||||
@@ -1,4 +1,42 @@
|
|||||||
base="/storage/var/www/html/developers/clemens/core_data/php_libraries/trunk/";
|
base="/storage/var/www/html/developers/clemens/core_data/php_libraries/trunk/";
|
||||||
# -c phpunit.xml
|
# -c phpunit.xml
|
||||||
# --testdox
|
# --testdox
|
||||||
${base}www/vendor/bin/phpunit -c ${base}phpunit.xml ${base}4dev/tests/
|
# call with "t" to give verbose testdox output
|
||||||
|
# SUPPORTED: https://www.php.net/supported-versions.php
|
||||||
|
# call with 7.3, 7.4, 8.0, 8.1 to force a certain php version
|
||||||
|
|
||||||
|
opt_testdox="";
|
||||||
|
if [ "${1}" = "t" ] || [ "${2}" = "t" ]; then
|
||||||
|
opt_testdox="--testdox";
|
||||||
|
fi;
|
||||||
|
php_bin="";
|
||||||
|
if [ ! -z "${1}" ]; then
|
||||||
|
case "${1}" in
|
||||||
|
# "7.3") php_bin="/usr/bin/php7.3 "; ;;
|
||||||
|
"7.4") php_bin="/usr/bin/php7.4 "; ;;
|
||||||
|
"8.0") php_bin="/usr/bin/php8.0 "; ;;
|
||||||
|
"8.1") php_bin="/usr/bin/php8.1 "; ;;
|
||||||
|
*) echo "Not support PHP: ${1}"; exit; ;;
|
||||||
|
esac;
|
||||||
|
fi;
|
||||||
|
if [ ! -z "${2}" ] && [ -z "${php_bin}" ]; then
|
||||||
|
case "${2}" in
|
||||||
|
# "7.3") php_bin="/usr/bin/php7.3 "; ;;
|
||||||
|
"7.4") php_bin="/usr/bin/php7.4 "; ;;
|
||||||
|
"8.0") php_bin="/usr/bin/php8.0 "; ;;
|
||||||
|
"8.1") php_bin="/usr/bin/php8.1 "; ;;
|
||||||
|
*) echo "Not support PHP: ${1}"; exit; ;;
|
||||||
|
esac;
|
||||||
|
fi;
|
||||||
|
|
||||||
|
phpunit_call="${php_bin}${base}www/vendor/bin/phpunit ${opt_testdox} -c ${base}phpunit.xml ${base}4dev/tests/";
|
||||||
|
|
||||||
|
${phpunit_call};
|
||||||
|
|
||||||
|
if [ ! -z "${php_bin}" ]; then
|
||||||
|
echo "CALLED WITH PHP: ${php_bin}"$(${php_bin} --version);
|
||||||
|
else
|
||||||
|
echo "Default PHP used: "$(php --version);
|
||||||
|
fi;
|
||||||
|
|
||||||
|
# __END__
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
# AUTHOR: Clemens Schwaighofer
|
# AUTHOR: Clemens Schwaighofer
|
||||||
# CREATED: 2005/08/09
|
# CREATED: 2005/08/09
|
||||||
# SHORT DESCRIPTION:
|
# SHORT DESCRIPTION:
|
||||||
# Backned English Messages file for gettext
|
# Backend English Messages file for gettext
|
||||||
# to craete: msgfmt -o <output.po> <input.mo>
|
|
||||||
# ********************************************************************/
|
# ********************************************************************/
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
# to craete: msgfmt -o <output.po> <input.mo>
|
# ********************************************************************
|
||||||
|
# AUTHOR: Clemens Schwaighofer
|
||||||
|
# CREATED: 2005/08/09
|
||||||
|
# SHORT DESCRIPTION:
|
||||||
|
# Frontend English Messages file for gettext
|
||||||
|
# ********************************************************************/
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
# AUTHOR: Clemens Schwaighofer
|
# AUTHOR: Clemens Schwaighofer
|
||||||
# CREATED: 2018/03/28
|
# CREATED: 2018/03/28
|
||||||
# SHORT DESCRIPTION:
|
# SHORT DESCRIPTION:
|
||||||
# Backend Japanese Messages file for gettext
|
# Backend Japanese Messages file for gettext>
|
||||||
# to craete: msgfmt -o <output.po> <input.mo>
|
|
||||||
# ********************************************************************/
|
# ********************************************************************/
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
# to craete: msgfmt -o <output.po> <input.mo>
|
# ********************************************************************
|
||||||
|
# AUTHOR: Clemens Schwaighofer
|
||||||
|
# CREATED: 2005/08/09
|
||||||
|
# SHORT DESCRIPTION:
|
||||||
|
# Frontend Japanese Messages file for gettext
|
||||||
|
# ********************************************************************/
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
@@ -566,7 +566,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
public function testDbSetDebug(
|
public function testDbSetDebug(
|
||||||
string $connection,
|
string $connection,
|
||||||
?bool $set,
|
?bool $set,
|
||||||
bool $expected,
|
bool $expected
|
||||||
): void {
|
): void {
|
||||||
$db = new \CoreLibs\DB\IO(
|
$db = new \CoreLibs\DB\IO(
|
||||||
self::$db_config[$connection],
|
self::$db_config[$connection],
|
||||||
@@ -599,7 +599,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
public function testDbToggleDebug(
|
public function testDbToggleDebug(
|
||||||
string $connection,
|
string $connection,
|
||||||
?bool $toggle,
|
?bool $toggle,
|
||||||
bool $expected,
|
bool $expected
|
||||||
): void {
|
): void {
|
||||||
$db = new \CoreLibs\DB\IO(
|
$db = new \CoreLibs\DB\IO(
|
||||||
self::$db_config[$connection],
|
self::$db_config[$connection],
|
||||||
@@ -1734,7 +1734,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
$expected,
|
$expected,
|
||||||
string $warning,
|
string $warning,
|
||||||
string $error,
|
string $error,
|
||||||
string $insert_data,
|
string $insert_data
|
||||||
): void {
|
): void {
|
||||||
// self::$log->setLogLevelAll('debug', true);
|
// self::$log->setLogLevelAll('debug', true);
|
||||||
// self::$log->setLogLevelAll('print', true);
|
// self::$log->setLogLevelAll('print', true);
|
||||||
@@ -1871,7 +1871,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
$expected,
|
$expected,
|
||||||
string $warning,
|
string $warning,
|
||||||
string $error,
|
string $error,
|
||||||
string $insert_data,
|
string $insert_data
|
||||||
): void {
|
): void {
|
||||||
// self::$log->setLogLevelAll('debug', true);
|
// self::$log->setLogLevelAll('debug', true);
|
||||||
// self::$log->setLogLevelAll('print', true);
|
// self::$log->setLogLevelAll('print', true);
|
||||||
@@ -2034,7 +2034,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
array $cursor_ext_checks,
|
array $cursor_ext_checks,
|
||||||
string $warning,
|
string $warning,
|
||||||
string $error,
|
string $error,
|
||||||
string $insert_data,
|
string $insert_data
|
||||||
): void {
|
): void {
|
||||||
// self::$log->setLogLevelAll('debug', true);
|
// self::$log->setLogLevelAll('debug', true);
|
||||||
// self::$log->setLogLevelAll('print', true);
|
// self::$log->setLogLevelAll('print', true);
|
||||||
@@ -2356,7 +2356,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
string $error_execute,
|
string $error_execute,
|
||||||
string $expected_data_query,
|
string $expected_data_query,
|
||||||
array $expected_data,
|
array $expected_data,
|
||||||
string $insert_data,
|
string $insert_data
|
||||||
): void {
|
): void {
|
||||||
// self::$log->setLogLevelAll('debug', true);
|
// self::$log->setLogLevelAll('debug', true);
|
||||||
// self::$log->setLogLevelAll('print', true);
|
// self::$log->setLogLevelAll('print', true);
|
||||||
@@ -3010,7 +3010,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
string $insert,
|
string $insert,
|
||||||
?string $pk_name,
|
?string $pk_name,
|
||||||
string $table,
|
string $table,
|
||||||
string $primary_key,
|
string $primary_key
|
||||||
): void {
|
): void {
|
||||||
// self::$log->setLogLevelAll('debug', true);
|
// self::$log->setLogLevelAll('debug', true);
|
||||||
// self::$log->setLogLevelAll('print', true);
|
// self::$log->setLogLevelAll('print', true);
|
||||||
|
|||||||
@@ -730,7 +730,7 @@ final class CoreLibsDebugLoggingTest extends TestCase
|
|||||||
bool $expected_debug,
|
bool $expected_debug,
|
||||||
string $expected_file,
|
string $expected_file,
|
||||||
string $expected_string_start,
|
string $expected_string_start,
|
||||||
string $expected_string_contains,
|
string $expected_string_contains
|
||||||
): void {
|
): void {
|
||||||
// must run with below matrix
|
// must run with below matrix
|
||||||
// level | debug | print | echo | debug() | printErrorMsg() | file
|
// level | debug | print | echo | debug() | printErrorMsg() | file
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase
|
|||||||
?string $path,
|
?string $path,
|
||||||
?string $SESSION_DEFAULT_LOCALE,
|
?string $SESSION_DEFAULT_LOCALE,
|
||||||
?string $SESSION_DEFAULT_CHARSET,
|
?string $SESSION_DEFAULT_CHARSET,
|
||||||
array $expected,
|
array $expected
|
||||||
): void {
|
): void {
|
||||||
$return_lang_settings = [];
|
$return_lang_settings = [];
|
||||||
global $_SESSION;
|
global $_SESSION;
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
string $domain_expected,
|
string $domain_expected,
|
||||||
?string $context,
|
?string $context,
|
||||||
string $original,
|
string $original,
|
||||||
string $translated,
|
string $translated
|
||||||
): void {
|
): void {
|
||||||
if ($locale === null) {
|
if ($locale === null) {
|
||||||
$l10n = new \CoreLibs\Language\L10n();
|
$l10n = new \CoreLibs\Language\L10n();
|
||||||
@@ -385,7 +385,7 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
string $locale_expected_b,
|
string $locale_expected_b,
|
||||||
string $locale_set_expected_b,
|
string $locale_set_expected_b,
|
||||||
string $domain_expected_b,
|
string $domain_expected_b,
|
||||||
string $translated_b,
|
string $translated_b
|
||||||
): void {
|
): void {
|
||||||
if ($locale === null) {
|
if ($locale === null) {
|
||||||
$l10n = new \CoreLibs\Language\L10n();
|
$l10n = new \CoreLibs\Language\L10n();
|
||||||
@@ -763,7 +763,7 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
string $type,
|
string $type,
|
||||||
string $var,
|
string $var,
|
||||||
string $value,
|
string $value,
|
||||||
string $expected,
|
string $expected
|
||||||
): void {
|
): void {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'global':
|
case 'global':
|
||||||
|
|||||||
58
www/admin/class_test.config.direct.php
Normal file
58
www/admin/class_test.config.direct.php
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php // phpcs:ignore warning
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations
|
||||||
|
$DEBUG_ALL = 1;
|
||||||
|
$PRINT_ALL = 1;
|
||||||
|
$DB_DEBUG = 1;
|
||||||
|
|
||||||
|
if ($DEBUG_ALL) {
|
||||||
|
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
|
||||||
|
// basic class test file
|
||||||
|
define('USE_DATABASE', false);
|
||||||
|
// sample config
|
||||||
|
require '../configs/config.php';
|
||||||
|
// define log file id
|
||||||
|
$LOG_FILE_ID = 'classTest-config-direct';
|
||||||
|
ob_end_flush();
|
||||||
|
|
||||||
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
print "<!DOCTYPE html>";
|
||||||
|
print "<html><head><title>TEST CLASS: CONFIG DIRECT</title><head>";
|
||||||
|
print "<body>";
|
||||||
|
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||||
|
print '<div><b>CONFIG DIRECT</b></div>';
|
||||||
|
|
||||||
|
print "DIR: " . DIR . "<br>";
|
||||||
|
print "BASE: " . BASE . "<br>";
|
||||||
|
print "ROOT: " . ROOT . "<br>";
|
||||||
|
print "BASE NAME: " . BASE_NAME . "<br>";
|
||||||
|
echo "Config path prefix: " . $CONFIG_PATH_PREFIX . "<br>";
|
||||||
|
print "DB Name: " . DB_CONFIG_NAME . "<br>";
|
||||||
|
print "DB Config: " . \CoreLibs\Debug\Support::printAr(DB_CONFIG) . "<br>";
|
||||||
|
|
||||||
|
// error message
|
||||||
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
|
print "</body></html>";
|
||||||
|
|
||||||
|
// __END__
|
||||||
58
www/admin/class_test.config.link.php
Normal file
58
www/admin/class_test.config.link.php
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php // phpcs:ignore warning
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations
|
||||||
|
$DEBUG_ALL = 1;
|
||||||
|
$PRINT_ALL = 1;
|
||||||
|
$DB_DEBUG = 1;
|
||||||
|
|
||||||
|
if ($DEBUG_ALL) {
|
||||||
|
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
|
||||||
|
// basic class test file
|
||||||
|
define('USE_DATABASE', false);
|
||||||
|
// sample config
|
||||||
|
require 'config.php';
|
||||||
|
// define log file id
|
||||||
|
$LOG_FILE_ID = 'classTest-config-link';
|
||||||
|
ob_end_flush();
|
||||||
|
|
||||||
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
print "<!DOCTYPE html>";
|
||||||
|
print "<html><head><title>TEST CLASS: CONFIG LINK</title><head>";
|
||||||
|
print "<body>";
|
||||||
|
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||||
|
print '<div><b>CONFIG LINK</b></div>';
|
||||||
|
|
||||||
|
print "DIR: " . DIR . "<br>";
|
||||||
|
print "BASE: " . BASE . "<br>";
|
||||||
|
print "ROOT: " . ROOT . "<br>";
|
||||||
|
print "BASE NAME: " . BASE_NAME . "<br>";
|
||||||
|
echo "Config path prefix: " . $CONFIG_PATH_PREFIX . "<br>";
|
||||||
|
print "DB Name: " . DB_CONFIG_NAME . "<br>";
|
||||||
|
print "DB Config: " . \CoreLibs\Debug\Support::printAr(DB_CONFIG) . "<br>";
|
||||||
|
|
||||||
|
// error message
|
||||||
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
|
print "</body></html>";
|
||||||
|
|
||||||
|
// __END__
|
||||||
@@ -68,6 +68,9 @@ print "S::DEBUSTRING(s): " . DebugSupport::debugString('SET') . "<br>";
|
|||||||
print "S::DEBUSTRING(''): " . DebugSupport::debugString('') . "<br>";
|
print "S::DEBUSTRING(''): " . DebugSupport::debugString('') . "<br>";
|
||||||
print "S::DEBUSTRING(,s): " . DebugSupport::debugString(null, '{-}') . "<br>";
|
print "S::DEBUSTRING(,s): " . DebugSupport::debugString(null, '{-}') . "<br>";
|
||||||
|
|
||||||
|
// get test
|
||||||
|
print "LOG FOLDER: " . $debug->getSetting('log_folder') . "<br>";
|
||||||
|
|
||||||
// debug
|
// debug
|
||||||
print "C->DEBUG: " . $debug->debug('CLASS-TEST-DEBUG', 'Class Test Debug') . "<br>";
|
print "C->DEBUG: " . $debug->debug('CLASS-TEST-DEBUG', 'Class Test Debug') . "<br>";
|
||||||
print "C->DEBUG(html): " . $debug->debug('CLASS-TEST-DEBUG', 'HTML TAG<br><b>BOLD</b>') . "<br>";
|
print "C->DEBUG(html): " . $debug->debug('CLASS-TEST-DEBUG', 'HTML TAG<br><b>BOLD</b>') . "<br>";
|
||||||
|
|||||||
@@ -83,6 +83,9 @@ print '<div><a href="class_test.admin.backend.php">Class Test: BACKEND ADMIN CLA
|
|||||||
print '<div><a href="class_test.lang.php">Class Test: LANG/L10n</a></div>';
|
print '<div><a href="class_test.lang.php">Class Test: LANG/L10n</a></div>';
|
||||||
print '<div><a href="class_test.smarty.php">Class Test: SMARTY</a></div>';
|
print '<div><a href="class_test.smarty.php">Class Test: SMARTY</a></div>';
|
||||||
print '<div><a href="class_test.autoloader.php">Class Test: AUTOLOADER</a></div>';
|
print '<div><a href="class_test.autoloader.php">Class Test: AUTOLOADER</a></div>';
|
||||||
|
print '<div><a href="class_test.config.link.php">Class Test: CONFIG LINK</a></div>';
|
||||||
|
print '<div><a href="class_test.config.direct.php">Class Test: CONFIG DIRECT</a></div>';
|
||||||
|
print '<div><a href="subfolder/class_test.config.direct.php">Class Test: CONFIG DIRECT SUB</a></div>';
|
||||||
|
|
||||||
print "<hr>";
|
print "<hr>";
|
||||||
print "L: " . CoreLibs\Debug\Support::printAr($locale) . "<br>";
|
print "L: " . CoreLibs\Debug\Support::printAr($locale) . "<br>";
|
||||||
|
|||||||
58
www/admin/subfolder/class_test.config.direct.php
Normal file
58
www/admin/subfolder/class_test.config.direct.php
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php // phpcs:ignore warning
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations
|
||||||
|
$DEBUG_ALL = 1;
|
||||||
|
$PRINT_ALL = 1;
|
||||||
|
$DB_DEBUG = 1;
|
||||||
|
|
||||||
|
if ($DEBUG_ALL) {
|
||||||
|
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
|
||||||
|
// basic class test file
|
||||||
|
define('USE_DATABASE', false);
|
||||||
|
// sample config
|
||||||
|
require '../../configs/config.php';
|
||||||
|
// define log file id
|
||||||
|
$LOG_FILE_ID = 'classTest-config-direct';
|
||||||
|
ob_end_flush();
|
||||||
|
|
||||||
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
print "<!DOCTYPE html>";
|
||||||
|
print "<html><head><title>TEST CLASS: CONFIG DIRECT SUB</title><head>";
|
||||||
|
print "<body>";
|
||||||
|
print '<div><a href="../class_test.php">Class Test Master</a></div>';
|
||||||
|
print '<div><b>CONFIG DIRECT SUB</b></div>';
|
||||||
|
|
||||||
|
print "DIR: " . DIR . "<br>";
|
||||||
|
print "BASE: " . BASE . "<br>";
|
||||||
|
print "ROOT: " . ROOT . "<br>";
|
||||||
|
print "BASE NAME: " . BASE_NAME . "<br>";
|
||||||
|
echo "Config path prefix: " . $CONFIG_PATH_PREFIX . "<br>";
|
||||||
|
print "DB Name: " . DB_CONFIG_NAME . "<br>";
|
||||||
|
print "DB Config: " . \CoreLibs\Debug\Support::printAr(DB_CONFIG) . "<br>";
|
||||||
|
|
||||||
|
// error message
|
||||||
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
|
print "</body></html>";
|
||||||
|
|
||||||
|
// __END__
|
||||||
@@ -11,44 +11,56 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
define('CONFIG_PATH', 'configs' . DIRECTORY_SEPARATOR);
|
define('CONFIG_PATH', 'configs' . DIRECTORY_SEPARATOR);
|
||||||
// config path prefix search, start with 0, got down each level __DIR__ has, if nothing found -> bail
|
// config path prefix search, start with 0, got down each level __DIR__ has,
|
||||||
|
// if nothing found -> bail
|
||||||
$CONFIG_PATH_PREFIX = '';
|
$CONFIG_PATH_PREFIX = '';
|
||||||
|
// base path for loads
|
||||||
|
$__DIR__PATH = __DIR__ . DIRECTORY_SEPARATOR;
|
||||||
|
// don't load autoloader twice
|
||||||
$end_autoload = false;
|
$end_autoload = false;
|
||||||
for ($dir_pos = 0, $dir_max = count(explode(DIRECTORY_SEPARATOR, __DIR__)); $dir_pos <= $dir_max; $dir_pos++) {
|
for (
|
||||||
|
$dir_pos = 0, $dir_max = count(explode(DIRECTORY_SEPARATOR, __DIR__));
|
||||||
|
$dir_pos <= $dir_max;
|
||||||
|
$dir_pos++
|
||||||
|
) {
|
||||||
$CONFIG_PATH_PREFIX .= '..' . DIRECTORY_SEPARATOR;
|
$CONFIG_PATH_PREFIX .= '..' . DIRECTORY_SEPARATOR;
|
||||||
if ($end_autoload === false) {
|
if ($end_autoload === false) {
|
||||||
/************* AUTO LOADER *******************/
|
/************* AUTO LOADER *******************/
|
||||||
// read auto loader for lib only
|
// composer auto loader, in composer.json file add classmap for lib/:
|
||||||
// It is recommended to setup basic composer and use just one auto loader
|
|
||||||
// if (is_file($CONFIG_PATH_PREFIX . 'lib' . DIRECTORY_SEPARATOR . 'autoloader.php')) {
|
|
||||||
// require $CONFIG_PATH_PREFIX . 'lib' . DIRECTORY_SEPARATOR . 'autoloader.php';
|
|
||||||
// $end_autoload = true;
|
|
||||||
// }
|
|
||||||
// composer auto loader, IF composer.json file includes classmap for lib/:
|
|
||||||
// "autoload": {
|
// "autoload": {
|
||||||
// "classmap": [
|
// "classmap": [
|
||||||
// "lib/"
|
// "lib/"
|
||||||
// ]
|
// ]
|
||||||
// },
|
// },
|
||||||
// NOTE: MUST RUN composer dump-autoload if file/class names are changed or added
|
// NOTE: MUST RUN composer dump-autoload if file/class names are
|
||||||
// load auto loader
|
// changed or new ones are added
|
||||||
if (is_file($CONFIG_PATH_PREFIX . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php')) {
|
if (
|
||||||
require $CONFIG_PATH_PREFIX . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
is_file(
|
||||||
|
$__DIR__PATH . $CONFIG_PATH_PREFIX
|
||||||
|
. 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
require $__DIR__PATH . $CONFIG_PATH_PREFIX
|
||||||
|
. 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||||
$end_autoload = true;
|
$end_autoload = true;
|
||||||
}
|
}
|
||||||
// load enviorment file if it exists
|
|
||||||
\CoreLibs\Get\ReadEnvFile::readEnvFile($CONFIG_PATH_PREFIX . CONFIG_PATH);
|
|
||||||
}
|
}
|
||||||
/************* MASTER CONFIG *******************/
|
/************* MASTER CONFIG *******************/
|
||||||
if (is_file($CONFIG_PATH_PREFIX . CONFIG_PATH . 'config.master.php')) {
|
if (
|
||||||
|
is_file($__DIR__PATH . $CONFIG_PATH_PREFIX . CONFIG_PATH . 'config.master.php')
|
||||||
|
) {
|
||||||
|
// load enviorment file if it exists
|
||||||
|
\CoreLibs\Get\ReadEnvFile::readEnvFile(
|
||||||
|
$__DIR__PATH . $CONFIG_PATH_PREFIX . CONFIG_PATH
|
||||||
|
);
|
||||||
// load master config file that loads all other config files
|
// load master config file that loads all other config files
|
||||||
require $CONFIG_PATH_PREFIX . CONFIG_PATH . 'config.master.php';
|
require $__DIR__PATH . $CONFIG_PATH_PREFIX . CONFIG_PATH . 'config.master.php';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fail if no base DIR is not set
|
// fail if no base DIR is not set
|
||||||
if (!defined('DIR')) {
|
if (!defined('DIR')) {
|
||||||
exit('Base config unloadable');
|
exit('Base config could not be loaded');
|
||||||
}
|
}
|
||||||
// find trigger name "admin/" or "frontend/" in the getcwd() folder
|
// find trigger name "admin/" or "frontend/" in the getcwd() folder
|
||||||
foreach (['admin', 'frontend'] as $folder) {
|
foreach (['admin', 'frontend'] as $folder) {
|
||||||
|
|||||||
@@ -85,11 +85,13 @@ class Basic
|
|||||||
* main Basic constructor to init and check base settings
|
* main Basic constructor to init and check base settings
|
||||||
* @param \CoreLibs\Debug\Logging|null $log Logging class
|
* @param \CoreLibs\Debug\Logging|null $log Logging class
|
||||||
* @param string|null $session_name Set session name
|
* @param string|null $session_name Set session name
|
||||||
|
* @deprecated DO NOT USE Class\Basic anymore. Use dedicated logger and sub classes
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
\CoreLibs\Debug\Logging $log = null,
|
\CoreLibs\Debug\Logging $log = null,
|
||||||
?string $session_name = null
|
?string $session_name = null
|
||||||
) {
|
) {
|
||||||
|
trigger_error('Class \CoreLibs\Basic is deprected', E_USER_DEPRECATED);
|
||||||
// TODO make check dynamic for entries we MUST have depending on load type
|
// TODO make check dynamic for entries we MUST have depending on load type
|
||||||
// before we start any work, we should check that all MUST constants are defined
|
// before we start any work, we should check that all MUST constants are defined
|
||||||
$abort = false;
|
$abort = false;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class DateTime
|
|||||||
4 => 'Thu',
|
4 => 'Thu',
|
||||||
5 => 'Fri',
|
5 => 'Fri',
|
||||||
6 => 'Sat',
|
6 => 'Sat',
|
||||||
7 => 'Sun'
|
7 => 'Sun',
|
||||||
];
|
];
|
||||||
/** @var array<int,string> */
|
/** @var array<int,string> */
|
||||||
public const DAY_LONG = [
|
public const DAY_LONG = [
|
||||||
@@ -30,7 +30,7 @@ class DateTime
|
|||||||
4 => 'Thursday',
|
4 => 'Thursday',
|
||||||
5 => 'Friday',
|
5 => 'Friday',
|
||||||
6 => 'Saturday',
|
6 => 'Saturday',
|
||||||
7 => 'Sunday'
|
7 => 'Sunday',
|
||||||
];
|
];
|
||||||
/** @var array<int,string> */
|
/** @var array<int,string> */
|
||||||
public const MONTH_LONG = [
|
public const MONTH_LONG = [
|
||||||
@@ -45,7 +45,7 @@ class DateTime
|
|||||||
9 => 'September',
|
9 => 'September',
|
||||||
10 => 'October',
|
10 => 'October',
|
||||||
11 => 'November',
|
11 => 'November',
|
||||||
12 => 'December'
|
12 => 'December',
|
||||||
];
|
];
|
||||||
/** @var array<int,string> */
|
/** @var array<int,string> */
|
||||||
public const MONTH_SHORT = [
|
public const MONTH_SHORT = [
|
||||||
@@ -60,7 +60,7 @@ class DateTime
|
|||||||
9 => 'Sep',
|
9 => 'Sep',
|
||||||
10 => 'Oct',
|
10 => 'Oct',
|
||||||
11 => 'Nov',
|
11 => 'Nov',
|
||||||
12 => 'Dec'
|
12 => 'Dec',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -349,7 +349,7 @@ class DateTime
|
|||||||
try {
|
try {
|
||||||
$start = new \DateTime($start_date);
|
$start = new \DateTime($start_date);
|
||||||
$end = new \DateTime($end_date);
|
$end = new \DateTime($end_date);
|
||||||
} catch (Exception) {
|
} catch (Exception $e) {
|
||||||
if ($return_named === true) {
|
if ($return_named === true) {
|
||||||
return [
|
return [
|
||||||
'overall' => 0,
|
'overall' => 0,
|
||||||
|
|||||||
@@ -401,10 +401,10 @@ class Logging
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Temporary method to read all class variables for testing purpose
|
* Temporary method to read all class variables for testing purpose
|
||||||
* @param string $name
|
* @param string $name what variable to return
|
||||||
* @return mixed can be anything, bool, string, int, array
|
* @return mixed can be anything, bool, string, int, array
|
||||||
*/
|
*/
|
||||||
public function getSetting(string $name): mixed
|
public function getSetting(string $name) //:mixed DOES not work with PHP 7.4
|
||||||
{
|
{
|
||||||
// for debug purpose only
|
// for debug purpose only
|
||||||
return $this->{$name};
|
return $this->{$name};
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class L10n
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
string $locale = '',
|
string $locale = '',
|
||||||
string $domain = '',
|
string $domain = '',
|
||||||
string $path = '',
|
string $path = ''
|
||||||
) {
|
) {
|
||||||
// auto load language only if at least locale and domain is set
|
// auto load language only if at least locale and domain is set
|
||||||
if (!empty($locale) && !empty($domain)) {
|
if (!empty($locale) && !empty($domain)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user