Compare commits

...

17 Commits

Author SHA1 Message Date
cliphouse 6c67ab6259 Update for humanReadableByteFormat, update edit.jq.js
edit.jq.js: remove deprecated function decodeHtmlEntities, use utils.js instead

update for humanReadableByteFormat to return non numeric first and then proceed with
the convert
2026-05-27 09:00:48 +09:00
cliphouse c467ed326c Logger Level returns self 2026-05-20 18:46:57 +09:00
cliphouse 40cd64f667 Update JS Utils to v1.1.0, back add html entities convert to Javascript 2026-05-20 18:45:54 +09:00
Clemens Schwaighofer 05dae1031a Locale files test update, L10n PHPdoc typo fix 2026-05-12 14:49:07 +09:00
Clemens Schwaighofer 82ba2a189a L10n update for PHPdoc array descriptions
Make the PHPdoc array description detailed for the parseLocale method
2026-05-12 11:39:19 +09:00
Clemens Schwaighofer a8755c8c0f phpstan check fixes 2026-05-11 15:31:59 +09:00
Clemens Schwaighofer 85f7e114b0 Add throw exception to get mime info if there is no mime type found
Instead of returning empty
2026-05-11 13:38:17 +09:00
Clemens Schwaighofer 6b1261b157 Update dotenv to v3 2026-04-20 16:19:19 +09:00
Clemens Schwaighofer b695c3ffdc phive updates 2026-04-20 10:36:53 +09:00
Clemens Schwaighofer 90d76bbd6c phpunit coverate checks added with report to HTMl, phpstan check fixes for enum 2026-04-17 18:56:07 +09:00
Clemens Schwaighofer 188f0b57d0 Clean up .gitignore and add coverage option to phpunit.sh 2026-02-27 10:58:05 +09:00
Clemens Schwaighofer b84fb5cef5 Comemit message fix for function param (phpdoc) 2026-02-17 18:16:16 +09:00
Clemens Schwaighofer 9a28c86991 json test file update 2026-01-22 11:51:32 +09:00
Clemens Schwaighofer 38b2ffe82a jsonConvertToArray with JSON_INVALID_UTF8_IGNORE does not work
json_decode JSON_INVALID_UTF8_IGNORE is not honoring any of those flags at the moment
2026-01-22 11:44:11 +09:00
Clemens Schwaighofer 6e547abccb Fix text in check runners 2026-01-22 11:31:01 +09:00
Clemens Schwaighofer 676af5e1a4 Add json validation and update tests
Also add removal of THROW flag for json decode to not throw an exception if if wanted

Add jquery 4.0.0 libs
2026-01-22 11:08:18 +09:00
Clemens Schwaighofer 118aacee28 Bug in RamdomKey::validateRandomKeyData when passing large character sets
The check for stringlength was done on the set key range in the class var and not the variable passed on in the method.
So if we cold call randomKey with a key character list and not the default list it failed with invalid max length
2026-01-14 15:07:38 +09:00
42 changed files with 10091 additions and 139 deletions
+3 -4
View File
@@ -1,10 +1,9 @@
.libs
node_modules/
composer.lock
vendor/
**/composer.lock
**/vendor/
tools/
www/composer.lock
www/vendor
**/.env
**/.target
package-lock.json
build/
+3 -3
View File
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpunit" version="~9.6" installed="9.6.31" location="./tools/phpunit" copy="false"/>
<phar name="phpunit" version="~9.6" installed="9.6.34" location="./tools/phpunit" copy="false"/>
<phar name="phpcbf" version="4" installed="4.0.1" location="./tools/phpcbf" copy="false"/>
<phar name="phpcs" version="4" installed="4.0.1" location="./tools/phpcs" copy="false"/>
<phar name="phpstan" version="^2.0" installed="2.1.33" location="./tools/phpstan" copy="false"/>
<phar name="phpstan" version="^2.0" installed="2.1.54" location="./tools/phpstan" copy="false"/>
<phar name="phan" version="^5.4.3" installed="5.5.2" location="./tools/phan" copy="false"/>
<phar name="psalm" version="^5.26.1" installed="5.26.1" location="./tools/psalm" copy="false"/>
<phar name="phpdox" version="^0.12.0" installed="0.12.0" location="./tools/phpdox" copy="false"/>
<phar name="phpdocumentor" version="^3.4.2" installed="3.9.1" location="./tools/phpDocumentor" copy="false"/>
<phar name="php-cs-fixer" version="^3.34.1" installed="3.92.4" location="./tools/php-cs-fixer" copy="false"/>
<phar name="php-cs-fixer" version="^3.34.1" installed="3.95.1" location="./tools/php-cs-fixer" copy="false"/>
</phive>
+2 -2
View File
@@ -62,9 +62,9 @@ fi;
php_bin="${PHP_BIN_PATH}${php_version}";
echo "Use PHP Version: ${php_version}";
if [ "${use_composer}" -eq 1 ]; then
echo "Use composer installed phan";
echo "Use composer installed";
else
echo "Use phan installed via phives";
echo "Use phive installed";
fi;
if [ ! -f "${php_bin}" ]; then
+2 -2
View File
@@ -62,9 +62,9 @@ fi;
php_bin="${PHP_BIN_PATH}${php_version}";
echo "Use PHP Version: ${php_version}";
if [ "${use_composer}" -eq 1 ]; then
echo "Use composer installed phan";
echo "Use composer installed";
else
echo "Use phan installed via phives";
echo "Use phive installed";
fi;
if [ ! -f "${php_bin}" ]; then
+19 -2
View File
@@ -19,6 +19,7 @@ Available options:
-v, --verbose Enable verbose output for PHPunit
-c, --composer Use composer version and not the default phives bundle
-p, --php VERSION Chose PHP version in the form of "N.N", if not found will exit
-C, --coverage Generate code coverage report in text format (default: disabled)
EOF
exit
}
@@ -47,6 +48,8 @@ opt_verbose="";
php_version="";
no_php_version=0;
use_composer=0;
opt_generate_coverage="";
opt_generate_coverage_html="";
while [ -n "${1-}" ]; do
case "${1}" in
-t | --testdox)
@@ -59,6 +62,14 @@ while [ -n "${1-}" ]; do
use_composer=1;
shift
;;
-C | --coverage)
opt_generate_coverage="--coverage-text";
shift
;;
--coverage-report)
opt_generate_coverage_html="--coverage-html build/coverage-report";
shift
;;
-p | --php)
php_version="${2-}";
shift
@@ -81,9 +92,9 @@ fi;
php_bin="${PHP_BIN_PATH}${php_version}";
echo "Use PHP Version: ${php_version}";
if [ "${use_composer}" -eq 1 ]; then
echo "Use composer installed phan";
echo "Use composer installed";
else
echo "Use phan installed via phives";
echo "Use phive installed";
fi;
if [ ! -f "${php_bin}" ]; then
@@ -100,9 +111,15 @@ if [ "${use_composer}" -eq 1 ]; then
else
PHPUNIT_CALL+=("${BASE_PATH}tools/phpunit");
fi;
if [ -n "${opt_generate_coverage}" ]; then
echo "Will run coverage report";
export XDEBUG_MODE=coverage
fi;
PHPUNIT_CALL+=(
"${opt_testdox}"
"${opt_verbose}"
"${opt_generate_coverage}"
"${opt_generate_coverage_html}"
"-c" "${PHPUNIT_CONFIG}"
"${BASE_PATH}4dev/tests/"
);
+3 -3
View File
@@ -8,11 +8,11 @@
msgid ""
msgstr ""
"Project-Id-Version: en.UTF-8 LC_MESSAGES admin\n"
"Report-Msgid-Bugs-To: clemens.schwaighofer@egplusww.com\n"
"Report-Msgid-Bugs-To: webmaster+corelibs-translation@ocex.jp\n"
"POT-Creation-Date: 2018-03-28 10:40+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: clemens.schwaighofer@egplusww.co\n"
"Language-Team: E-GRAPHICS COMMUNICATIONS Japan <info.jp@egplusww.com>\n"
"Last-Translator: clemens.schwaighofer@omc.com\n"
"Language-Team: Omnicom Content Experiences Japan <webmaster@ocex.jp>\n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
+3 -3
View File
@@ -8,11 +8,11 @@
msgid ""
msgstr ""
"Project-Id-Version: en.UTF-8 LC_MESSAGES frontend\n"
"Report-Msgid-Bugs-To: clemens.schwaighofer@egplusww.com\n"
"Report-Msgid-Bugs-To: webmaster+corelibs-translation@ocex.jp\n"
"POT-Creation-Date: 2018-03-28 10:40+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: clemens.schwaighofer@egplusww.co\n"
"Language-Team: E-GRAPHICS COMMUNICATIONS Japan <info.jp@egplusww.com>\n"
"Last-Translator: clemens.schwaighofer@omc.com\n"
"Language-Team: Omnicom Content Experiences Japan <webmaster@ocex.jp>\n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
+3 -3
View File
@@ -8,11 +8,11 @@
msgid ""
msgstr ""
"Project-Id-Version: ja.UTF-8 LC_MESSAGES admin\n"
"Report-Msgid-Bugs-To: clemens.schwaighofer@egplusww.com\n"
"Report-Msgid-Bugs-To: webmaster+corelibs-translation@ocex.jp\n"
"POT-Creation-Date: 2018-03-28 10:40+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: clemens.schwaighofer@egplusww.com\n"
"Language-Team: E-GRAPHICS COMMUNICATIONS Japan <info.jp@egplusww.com>\n"
"Last-Translator: clemens.schwaighofer@omc.com\n"
"Language-Team: Omnicom Content Experiences Japan <webmaster@ocex.jp>\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
+3 -3
View File
@@ -8,11 +8,11 @@
msgid ""
msgstr ""
"Project-Id-Version: ja.UTF-8 LC_MESSAGES frontend\n"
"Report-Msgid-Bugs-To: clemens.schwaighofer@egplusww.com\n"
"Report-Msgid-Bugs-To: webmaster+corelibs-translation@ocex.jp\n"
"POT-Creation-Date: 2018-03-28 10:40+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: clemens.schwaighofer@egplusww.com\n"
"Language-Team: E-GRAPHICS COMMUNICATIONS Japan <info.jp@egplusww.com>\n"
"Last-Translator: clemens.schwaighofer@omc.com\n"
"Language-Team: Omnicom Content Experiences Japan <webmaster@ocex.jp>\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -164,6 +164,51 @@ final class CoreLibsConvertJsonTest extends TestCase
);
}
/**
* test with flags
*
* @covers ::jsonConvertToArray
* @testdox jsonConvertToArray flag test, if flag is used
*
* @return void
*/
public function testJsonConvertToArrayWithFlags(): void
{
$input = '{"valid":"json","invalid":"\xB1\x31"}';
/* $expected_without_flag = [
'valid' => 'json'
];
$expected_with_flag = [
'valid' => 'json',
'invalid' => "\xB1\x31"
]; */
// no idea why in both it throws an erro
$expected_without_flag = [];
$expected_with_flag = [];
$this->assertEquals(
$expected_without_flag,
\CoreLibs\Convert\Json::jsonConvertToArray($input)
);
$this->assertEquals(
$expected_with_flag,
\CoreLibs\Convert\Json::jsonConvertToArray($input, flags:JSON_INVALID_UTF8_IGNORE)
);
}
public function testJsonConvertToArrayRemoveThrowFlag(): void
{
$input = '{"valid":"json","invalid":"\xB1\x31"}';
// show NOT throw an exception
try {
$this->assertEquals(
[],
\CoreLibs\Convert\Json::jsonConvertToArray($input, flags:JSON_THROW_ON_ERROR)
);
} catch (\Exception $e) {
$this->fail('Exception was thrown despite flag removal');
}
}
/**
* test json error states
*
@@ -189,6 +234,81 @@ final class CoreLibsConvertJsonTest extends TestCase
);
}
/**
* test json error states
*
* @covers ::jsonValidate
* @dataProvider jsonErrorProvider
* @testdox jsonValidate $input will be $expected_i/$expected_s [$_dataName]
*
* @param string|null $input
* @param int $expected_i
* @param string $expected_s
* @return void
*/
public function testJsonValidateGetLastError(?string $input, int $expected_i, string $expected_s): void
{
\CoreLibs\Convert\Json::jsonValidate($input);
$this->assertEquals(
$expected_i,
\CoreLibs\Convert\Json::jsonGetLastError()
);
$this->assertEquals(
$expected_s,
\CoreLibs\Convert\Json::jsonGetLastError(true)
);
}
/**
* test json validation
*
* @covers ::jsonValidate
* @testdox jsonValidate test valid and invalid json
*
* @return void
*/
public function testJsonValidate(): void
{
$this->assertTrue(
\CoreLibs\Convert\Json::jsonValidate('{"valid": "json"}')
);
$this->assertFalse(
\CoreLibs\Convert\Json::jsonValidate('not valid json')
);
}
/**
* Check if invalid flag throws exception
*
* @covers ::jsonValidate
* @testdox jsonValidate test exception thrown on invalid flag
*
* @return void
*/
public function testJsonValidateInvalidFlag(): void
{
$this->expectException("\InvalidArgumentException");
\CoreLibs\Convert\Json::jsonValidate('{"valid": "json"}', 5);
}
/**
* Check if valid flag throws no exception
*
* @covers ::jsonValidate
* @testdox jsonValidate test no exception on valid flag
*
* @return void
*/
public function testJsonValidateValidflag(): void
{
$this->assertTrue(
\CoreLibs\Convert\Json::jsonValidate('{"valid": "json"}', 0)
);
$this->assertTrue(
\CoreLibs\Convert\Json::jsonValidate('{"valid": "json"}', JSON_INVALID_UTF8_IGNORE)
);
}
/**
* Undocumented function
*
-1
View File
@@ -45,7 +45,6 @@ use CoreLibs\DB\Support\ConvertPlaceholder;
* Test class for DB\IO + DB\SQL\PgSQL
* This will only test the PgSQL parts
* @coversDefaultClass \CoreLibs\DB\IO
* @coversDefaultClass \CoreLibs\DB\SQL\PgSQL
* @testdox \CoreLibs\DB\IO method tests for SQL\PgSQL
*/
final class CoreLibsDBIOTest extends TestCase
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
$set = 0;
foreach (['/../../www', '/../www', '/../..', '/..', '/../../src', '/../src'] as $src) {
foreach (['/../../www', '/../www', '/../../src', '/../src', '/../..', '/..'] as $src) {
if (is_file(dirname(__DIR__) . $src . '/vendor/autoload.php')) {
require dirname(__DIR__) . $src . '/vendor/autoload.php';
$set = 1;
+5 -2
View File
@@ -1,8 +1,11 @@
// https://www.typescriptlang.org/tsconfig/#compilerOptions
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Node",
// if "bundler"
// "module": "ESNext",
"module": "NodeNext",
// "bundler" (front), "nodenext" or "node16"
"moduleResolution": "nodenext",
"target": "ES2020",
"jsx": "react",
"checkJs": true,
+13
View File
@@ -10,4 +10,17 @@
<directory>4dev/tests</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./www/lib/CoreLibs</directory>
</include>
<!-- <report>
<html outputDirectory="build/coverage-report"/>
</report> -->
</coverage>
<!-- <source>
<include>
<directory>./www/lib/CoreLibs</directory>
</include>
</source> -->
</phpunit>
+19
View File
@@ -38,6 +38,25 @@ print "GETFILENAMEENDING: $file: " . File::getFilenameEnding($file) . "<br>";
$file = getcwd() . DIRECTORY_SEPARATOR . 'class_test.file.php';
print "GETLINESFROMFILE: $file: " . File::getLinesFromFile($file) . "<br>";
print "MIMEINFO: $file: " . File::getMimeType($file) . "<br>";
try {
print "MIMEINFO: does_not_exists.txt " . File::getMimeType("does_not_exists.txt") . "<br>";
} catch (\Exception $e) {
print "Error: " . get_class($e) . ": " . $e->getMessage() . "<br>";
}
$files = [
'layout/css/edit.css',
'layout/javascript/edit.jq.js',
'class_test.file.php',
getcwd() . DIRECTORY_SEPARATOR . 'class_test.file.php',
];
foreach ($files as $file) {
try {
print "MIMEINFO: $file: " . File::getMimeType($file) . "<br>";
} catch (\Exception $e) {
print "Error: " . get_class($e) . ": " . $e->getMessage() . "<br>";
}
}
print "</body></html>";
+19
View File
@@ -46,6 +46,7 @@ $json = '["f: {b"""ar}]';
$output = Json::jsonConvertToArray($json);
print "S::E-JSON: $json: " . DgS::printAr($output) . "<br>";
print "S::E-JSON ERROR: " . Json::jsonGetLastError() . ": " . Json::jsonGetLastError(true) . "<br>";
print "S::E Validate: " . Json::jsonValidate($json) . ": " . Json::jsonGetLastError(true) . "<br>";
// direct
$json = '{"direct": "static function call"}';
@@ -58,6 +59,24 @@ $output = $json_class::jsonConvertToArray($json);
print "J/S::E-JSON: $json: " . DgS::printAr($output) . "<br>";
print "J/S::E-JSON ERROR: " . $json_class::jsonGetLastError() . ": " . $json_class::jsonGetLastError(true) . "<br>";
echo "<hr>";
$json = '{"valid":"json","invalid":"\xB1\x31"}';
// $json = '{"valid":"json","invalid":"abc\x80def"}';
$output_no_flag = Json::jsonConvertToArray($json);
print "No Flag JSON: $json: " . DgS::printAr($output_no_flag) . "<br>";
print "No Flag JSON ERROR: " . Json::jsonGetLastError() . ": " . Json::jsonGetLastError(true) . "<br>";
$output_flag = Json::jsonConvertToArray($json, flags:JSON_INVALID_UTF8_IGNORE);
print "No Flag JSON: $json: " . DgS::printAr($output_flag) . "<br>";
print "No Flag JSON ERROR: " . Json::jsonGetLastError() . ": " . Json::jsonGetLastError(true) . "<br>";
$output_raw = json_decode($json, true, flags:JSON_INVALID_UTF8_IGNORE);
print "No Flag JSON RAW (F-1): $json: " . DgS::printAr($output_raw) . "<br>";
$output_raw = json_decode($json, true, flags:JSON_INVALID_UTF8_SUBSTITUTE);
print "No Flag JSON RAW (F-2): $json: " . DgS::printAr($output_raw) . "<br>";
$output_raw = json_decode($json, true);
print "No Flag JSON RAW: $json: " . DgS::printAr($output_raw) . "<br>";
echo "<hr>";
// $json = '{"foo": "bar"}';
// $output = Jason::jsonConvertToArray($json);
// print "S::JSON: $json: " . DgS::printAr($output) . "<br>";
+15
View File
@@ -34,6 +34,20 @@ print "<body>";
print '<div><a href="class_test.php">Class Test Master</a></div>';
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
$output = RandomKey::randomKeyGen(
12,
[
0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D', 4 => 'E', 5 => 'F', 6 => 'G', 7 => 'H', 8 => 'I', 9 => 'J', 10 => 'K',
11 => 'L', 12 => 'M', 13 => 'N', 14 => 'O', 15 => 'P', 16 => 'Q', 17 => 'R', 18 => 'S', 19 => 'T', 20 => 'U',
21 => 'V', 22 => 'W', 23 => 'X', 24 => 'Y', 25 => 'Z', 26 => 'a', 27 => 'b', 28 => 'c', 29 => 'd', 30 => 'e',
31 => 'f', 32 => 'g', 33 => 'h', 34 => 'i', 35 => 'j', 36 => 'k', 37 => 'l', 38 => 'm', 39 => 'n', 40 => 'o',
41 => 'p', 42 => 'q', 43 => 'r', 44 => 's', 45 => 't', 46 => 'u', 47 => 'v', 48 => 'w', 49 => 'x', 50 => 'y',
51 => 'z', 52 => '0', 53 => '1', 54 => '2', 55 => '3', 56 => '4', 57 => '5', 58 => '6', 59 => '7', 60 => '8',
61 => '9'
]
);
print "CUSTOM OUTPUT: " . $output . "<br>";
$key_length = 10;
$key_length_b = 5;
$key_lenght_long = 64;
@@ -54,6 +68,7 @@ print "===<Br>";
$_array = new CoreLibs\Create\RandomKey(['A', 'F', 'B'], ['1', '5', '9']);
print "C->RANDOMKEYGEN(pre set): " . $_array->randomKeyGen() . "<br>";
print "</body></html>";
// __END__
+10
View File
@@ -122,6 +122,16 @@ print "Combined strings A: "
. Strings::buildCharStringFromLists(['A', 'B', 'C'], ['0', '1', '2']) . "<br>";
print "Combined strings B: "
. Strings::buildCharStringFromLists([['F'], ['G'], 'H'], [['5', ['6']], ['0'], '1', '2']) . "<br>";
print "Combined strings C: "
. Strings::buildCharStringFromLists([
0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D', 4 => 'E', 5 => 'F', 6 => 'G', 7 => 'H', 8 => 'I', 9 => 'J', 10 => 'K',
11 => 'L', 12 => 'M', 13 => 'N', 14 => 'O', 15 => 'P', 16 => 'Q', 17 => 'R', 18 => 'S', 19 => 'T', 20 => 'U',
21 => 'V', 22 => 'W', 23 => 'X', 24 => 'Y', 25 => 'Z', 26 => 'a', 27 => 'b', 28 => 'c', 29 => 'd', 30 => 'e',
31 => 'f', 32 => 'g', 33 => 'h', 34 => 'i', 35 => 'j', 36 => 'k', 37 => 'l', 38 => 'm', 39 => 'n', 40 => 'o',
41 => 'p', 42 => 'q', 43 => 'r', 44 => 's', 45 => 't', 46 => 'u', 47 => 'v', 48 => 'w', 49 => 'x', 50 => 'y',
51 => 'z', 52 => '0', 53 => '1', 54 => '2', 55 => '3', 56 => '4', 57 => '5', 58 => '6', 59 => '7', 60 => '8',
61 => '9'
]) . "<br>";
$input_string = "AaBbCc";
print "Unique: " . Strings::removeDuplicates($input_string) . "<br>";
+13
View File
@@ -1598,4 +1598,17 @@ function createNavMenu(nav_menu, header_id = 'mainHeader') // eslint-disable-lin
}
}
/**
* HTML decode &something; entrie
* @param {string} str
* @returns string
* @deprecated use utils.js
*/
function decodeHtmlEntities(str) // eslint-disable-line no-unused-vars
{
const parser = new DOMParser();
const doc = parser.parseFromString(str, 'text/html');
return doc.documentElement.textContent;
}
/* END */
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+16 -7
View File
@@ -135,7 +135,7 @@ var HtmlElementCreator = class {
* @param {String} tag must set tag (div, span, etc)
* @param {String} [id=''] optional set for id, if input, select will be used for name
* @param {String} [content=''] text content inside, is skipped if sub elements exist
* @param {Array} [css=[]] array for css tags
* @param {Array<String>} [css=[]] array for css tags
* @param {Object} [options={}] anything else (value, placeholder, OnClick, style)
* @return {Object} created element as an object
*/
@@ -509,6 +509,11 @@ function numberWithCommas(number) {
function convertLBtoBR(string) {
return string.replace(/(?:\r\n|\r|\n)/g, "<br>");
}
function decodeHtmlEntities(str) {
const parser = new DOMParser();
const doc = parser.parseFromString(str, "text/html");
return doc.documentElement.textContent;
}
// src/utils/DateTimeHelpers.mjs
function getTimestamp() {
@@ -660,18 +665,19 @@ function getQueryStringParam(search = "", query = "", single = false) {
if (search) {
let _params = url.searchParams.getAll(search);
if (_params.length == 1 || single === true) {
param = _params[0];
return _params[0];
} else if (_params.length > 1) {
param = _params;
return _params;
}
} else {
param = {};
let param2 = {};
for (const [key] of url.searchParams.entries()) {
if (typeof param[key] === "undefined") {
if (typeof param2[key] === "undefined") {
let _params = url.searchParams.getAll(key);
param[key] = _params.length < 2 || single === true ? _params[0] : _params;
param2[key] = _params.length < 2 || single === true ? _params[0] : _params;
}
}
return param2;
}
return param;
}
@@ -1425,6 +1431,9 @@ function numberWithCommas2(x) {
function convertLBtoBR2(string) {
return convertLBtoBR(string);
}
function decodeHtmlEntities2(string) {
return decodeHtmlEntities(string);
}
function getTimestamp2() {
return getTimestamp();
}
@@ -1549,7 +1558,7 @@ function acssel(_element, css) {
return hec.acssel(_element, css);
}
function scssel(_element, rcss, acss) {
hec.scssel(_element, rcss, acss);
return hec.scssel(_element, rcss, acss);
}
function phfo(tree) {
return hec.phfo(tree);
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -17,13 +17,13 @@
"repositories": {
"git.egplusww.jp.Composer": {
"type": "composer",
"url": "https://git.egplusww.jp/api/packages/Composer/composer"
"url": "https://packages.omnicomproduction.jp/api/packages/Composer/composer"
}
},
"require": {
"egrajp/smarty-extended": "^5.4",
"php": ">=8.1",
"gullevek/dotenv": "^2.0",
"gullevek/dotenv": "^3.0",
"psr/log": "^2.0 || ^3.0",
"php-privacy/openpgp": "^2.1"
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+9 -3
View File
@@ -58,15 +58,21 @@ class File
* else returns '' for any other finfo read problem
*
* @param string $read_file File to read, relative or absolute path
* @return string
* @return string mime type
* @throws \UnexpectedValueException if file cannot be read or is not a file
* @throws \RangeException if we cannot get a mime type and throw exception is on
*/
public static function getMimeType(string $read_file): string
{
$finfo = new \finfo(FILEINFO_MIME_TYPE);
if (!is_file($read_file)) {
if (!is_file($read_file) || !is_readable($read_file)) {
throw new \UnexpectedValueException('[getMimeType] File not found: ' . $read_file);
}
return $finfo->file($read_file) ?: '';
$mime_type = $finfo->file($read_file);
if ($mime_type === false) {
throw new \RangeException('[getMimeType] Cannot get mime type for: ' . $read_file);
}
return $mime_type;
}
}
+2 -2
View File
@@ -133,7 +133,7 @@ class DateTime
} else {
for ($i = 0, $iMax = count($timegroups); $i < $iMax; $i++) {
$output = floor((float)$timestamp / $timegroups[$i]);
$timestamp = (float)$timestamp % $timegroups[$i];
$timestamp = $timestamp % $timegroups[$i];
// output has days|hours|min|sec
if ($output || $time_string) {
$time_string .= $output . $labels[$i] . (($i + 1) != count($timegroups) ? ' ' : '');
@@ -453,7 +453,7 @@ class DateTime
}
if (isset($matches[11]) && is_numeric($matches[11])) {
// for milliseconds, we need to divide by 1000 and add them
$timestamp += (float)($matches[11] / 1000);
$timestamp += ((float)$matches[11] / 1000);
}
if ($negative) {
// cast to float so we can do a negative multiplication
+62 -63
View File
@@ -43,71 +43,70 @@ class Byte
public static function humanReadableByteFormat(string|int|float $bytes, int $flags = 0): string
{
// if not numeric, return as is
if (is_numeric($bytes)) {
// flags bit wise check
// remove space between number and suffix
if ($flags & self::BYTE_FORMAT_NOSPACE) {
$space = false;
} else {
$space = true;
}
// use sprintf instead of round
if ($flags & self::BYTE_FORMAT_ADJUST) {
$adjust = true;
} else {
$adjust = false;
}
// use SI 1000 mod and not 1024 mod
if ($flags & self::BYTE_FORMAT_SI) {
$si = true;
} else {
$si = false;
}
if ($flags > 7) {
throw new \InvalidArgumentException("Invalid flags parameter: $flags", 1);
}
// si or normal
$unit = $si ? 1000 : 1024;
// always positive
$abs_bytes = $bytes == PHP_INT_MIN ? PHP_INT_MAX : abs((float)$bytes);
// smaller than unit is always B
if ($abs_bytes < $unit) {
return $bytes . 'B';
}
// labels in order of size [Y, Z]
$labels = ['', 'K', 'M', 'G', 'T', 'P', 'E'];
// exp position calculation
$exp = (int)floor(log($abs_bytes, $unit));
// avoid printing out anything larger than max labels
if ($exp >= count($labels)) {
$exp = count($labels) - 1;
}
// deviation calculation
$dev = pow($unit, $exp) * ($unit - 0.05);
// shift the exp +1 for on the border units
if (
$exp < 6 &&
$abs_bytes > ($dev - (((int)$dev & 0xfff) == 0xd00 ? 52 : 0))
) {
$exp++;
}
// label name, including leading space if flagged
$pre = ($space ? ' ' : '') . ($labels[$exp] ?? '>E') . ($si ? 'i' : '') . 'B';
$bytes_calc = $abs_bytes / pow($unit, $exp);
// if original is negative, reverse
if ($bytes < 0) {
$bytes_calc *= -1;
}
if ($adjust) {
return sprintf("%.2f%s", $bytes_calc, $pre);
} else {
return round($bytes_calc, 2) . $pre;
}
} else {
if (!is_numeric($bytes)) {
// if anything other return as string
return (string)$bytes;
}
// flags bit wise check
// remove space between number and suffix
if ($flags & self::BYTE_FORMAT_NOSPACE) {
$space = false;
} else {
$space = true;
}
// use sprintf instead of round
if ($flags & self::BYTE_FORMAT_ADJUST) {
$adjust = true;
} else {
$adjust = false;
}
// use SI 1000 mod and not 1024 mod
if ($flags & self::BYTE_FORMAT_SI) {
$si = true;
} else {
$si = false;
}
if ($flags > 7) {
throw new \InvalidArgumentException("Invalid flags parameter: $flags", 1);
}
// si or normal
$unit = $si ? 1000 : 1024;
// always positive
$abs_bytes = $bytes == PHP_INT_MIN ? PHP_INT_MAX : abs((float)$bytes);
// smaller than unit is always B
if ($abs_bytes < $unit) {
return $bytes . 'B';
}
// labels in order of size [Y, Z]
$labels = ['', 'K', 'M', 'G', 'T', 'P', 'E'];
// exp position calculation
$exp = (int)floor(log($abs_bytes, $unit));
// avoid printing out anything larger than max labels
if ($exp >= count($labels)) {
$exp = count($labels) - 1;
}
// deviation calculation
$dev = pow($unit, $exp) * ($unit - 0.05);
// shift the exp +1 for on the border units
if (
$exp < 6 &&
$abs_bytes > ($dev - (((int)$dev & 0xfff) == 0xd00 ? 52 : 0))
) {
$exp++;
}
// label name, including leading space if flagged
$pre = ($space ? ' ' : '') . ($labels[$exp] ?? '>E') . ($si ? 'i' : '') . 'B';
$bytes_calc = $abs_bytes / pow($unit, $exp);
// if original is negative, reverse
if ($bytes < 0) {
$bytes_calc *= -1;
}
if ($adjust) {
return sprintf("%.2f%s", $bytes_calc, $pre);
} else {
return round($bytes_calc, 2) . $pre;
}
}
/**
@@ -154,7 +153,7 @@ class Byte
if (!empty($matches[1])) {
$number_negative = true;
}
if (isset($matches[2]) && isset($matches[3])) {
if (isset($matches[2])) {
// remove all non valid characters from the number
$number = preg_replace('/[^0-9\.]/', '', $matches[2]);
// final clean up and convert to float
+6 -6
View File
@@ -957,9 +957,9 @@ class Color
* Undocumented function
*
* @param HWB $hwb
* @return Lch
* @return LCH
*/
public static function hwbToLch(HWB $hwb): Lch
public static function hwbToLch(HWB $hwb): LCH
{
return self::rgbToLch(
self::hwbToRgb($hwb)
@@ -1078,10 +1078,10 @@ class Color
/**
* OkLab to Lch (CIE)
*
* @param LAB $lab
* @param Lab $lab
* @return LCH
*/
public static function okLabToLch(LAB $lab): LCH
public static function okLabToLch(Lab $lab): LCH
{
return self::labToLch(
self::okLabToLab($lab)
@@ -1092,9 +1092,9 @@ class Color
* Lch (CIE) to OkLab
*
* @param LCH $lch
* @return LAB
* @return Lab
*/
public static function lchToOkLab(LCH $lch): LAB
public static function lchToOkLab(LCH $lch): Lab
{
return self::labToOkLab(
self::lchToLab($lch)
+25 -2
View File
@@ -27,10 +27,14 @@ class Json
* set original value as array
* @return array<mixed> returns an array from the json values
*/
public static function jsonConvertToArray(?string $json, bool $override = false): array
public static function jsonConvertToArray(?string $json, bool $override = false, int $flags = 0): array
{
if ($json !== null) {
$_json = json_decode($json, true);
// if flags has JSON_THROW_ON_ERROR remove it
if ($flags & JSON_THROW_ON_ERROR) {
$flags = $flags & ~JSON_THROW_ON_ERROR;
}
$_json = json_decode($json, true, flags:$flags);
if (self::$json_last_error = json_last_error()) {
if ($override == true) {
// init return as array with original as element
@@ -65,6 +69,25 @@ class Json
return (string)$json_string;
}
/**
* Validate if a json string could be decoded.
* Weill set the internval last error state and info can be read with jsonGetLastError
*
* @param string $json
* @param int $flags only JSON_INVALID_UTF8_IGNORE is currently allowed
* @return bool
* @throws \InvalidArgumentException if flags is invalid
*/
public static function jsonValidate(string $json, int $flags = 0): bool
{
if ($flags != 0 && $flags != JSON_INVALID_UTF8_IGNORE) {
throw new \InvalidArgumentException("For flag only 0 or JSON_INVALID_UTF8_IGNORE is allwed: " . $flags);
}
$json_valid = json_validate($json, flags:$flags);
self::$json_last_error = json_last_error();
return $json_valid;
}
/**
* returns human readable string for json errors thrown in jsonConvertToArray
* Source: https://www.php.net/manual/en/function.json-last-error.php
+1 -1
View File
@@ -49,7 +49,7 @@ class RandomKey
private static function validateRandomKeyData(array ...$key_range): string
{
$key_character_range = Strings::buildCharStringFromLists(...$key_range);
if (strlen(self::$key_character_range) <= 1) {
if (strlen($key_character_range) <= 1) {
return '';
}
return $key_character_range;
+12 -6
View File
@@ -2562,21 +2562,27 @@ class IO
// set field names
$this->cursor_ext[$query_hash]['field_names'] = [];
for ($i = 0; $i < $this->cursor_ext[$query_hash]['num_fields']; $i++) {
$this->cursor_ext[$query_hash]['field_names'][] =
$this->db_functions->__dbFieldName(
if (
($field_name = $this->db_functions->__dbFieldName(
$this->cursor_ext[$query_hash]['cursor'],
$i
);
)) !== false
) {
$this->cursor_ext[$query_hash]['field_names'][] = $field_name;
}
}
$this->field_names = $this->cursor_ext[$query_hash]['field_names'];
// field types
$this->cursor_ext[$query_hash]['field_types'] = [];
for ($i = 0; $i < $this->cursor_ext[$query_hash]['num_fields']; $i++) {
$this->cursor_ext[$query_hash]['field_types'][] =
$this->db_functions->__dbFieldType(
if (
($field_type = $this->db_functions->__dbFieldType(
$this->cursor_ext[$query_hash]['cursor'],
$i
);
)) !== false
) {
$this->cursor_ext[$query_hash]['field_types'][] = $field_type;
}
}
$this->field_types = $this->cursor_ext[$query_hash]['field_types'];
// combined name => type
+1 -1
View File
@@ -51,7 +51,7 @@ enum Convert: int
/**
* Get internal name from int value
*
* @param int $value
* @param int $value
* @return self
*/
public static function fromValue(int $value): self
+2 -2
View File
@@ -134,8 +134,8 @@ class Support
* Convert bool value to string value. Short name alias for printBool
*
* @param bool $bool Bool value to be transformed
* @param string $true [='true'] Override default string 'true'
* @param string $false [=false'] Override default string 'false'
* @param string $true [=true] Override default string 'true'
* @param string $false [=false] Override default string 'false'
* @return string $true or $false string for true/false bool
*/
public static function prBl(
+3 -3
View File
@@ -146,7 +146,7 @@ class L10n
* @param string $locale language name, if not set, try previous set
* @param string $domain set name for mo file, if not set, try previous set
* @param string $path path, if not set try to get from paths array, else self
* @param string $override_encoding if locale does not env encoding set, use this one
* @param string $override_encoding if locale does not have encoding set, use this one
* @return GetTextReader the main gettext reader object
*/
public function getTranslator(
@@ -301,7 +301,7 @@ class L10n
* Get the local as array same to the GetLocale::setLocale return
* This does not set from outside, but only what is set in the l10n class
*
* @return array{locale: string, lang: string, lang_short: string, domain: string, encoding: string, path: string}
* @return array{locale:string,lang:string,lang_short:string,domain:string,encoding:string,path:string}
*/
public function getLocaleAsArray(): array
{
@@ -321,7 +321,7 @@ class L10n
* parse the locale string for further processing
*
* @param string $locale Locale to parse
* @return array<string,string|null> array with lang, country, charset, modifier
* @return array{lang:string|null,country:string|null,charset:string|null,modifier:string|null} parsed locale
*/
public static function parseLocale(string $locale = ''): array
{
+1 -1
View File
@@ -63,7 +63,7 @@ enum Flag: int
/**
* Get internal name from int value
*
* @param int $value
* @param value-of<self::VALUES> $value
* @return self
*/
public static function fromValue(int $value): self
+2 -2
View File
@@ -86,7 +86,7 @@ enum Level: int
/**
* @param value-of<self::NAMES>|LogLevel::*|'Debug'|'Info'|'Notice'|'Warning'|'Error'|'Critical'|'Alert'|'Emergency' $name
* @return static
* @return self
*/
public static function fromName(string $name): self
{
@@ -104,7 +104,7 @@ enum Level: int
/**
* @param value-of<self::VALUES> $value
* @return static
* @return self
*/
public static function fromValue(int $value): self
{
+5 -5
View File
@@ -178,11 +178,11 @@ class Elements
"/(href=\")?(\>)?\b($protRegex)([\w\.\-?&=+%#~,;\/]+)\b([\.\-?&=+%#~,;\/]*)(\|([^\||^#]+)(#([^\|]+))?\|)?/",
function ($matches) {
return self::createUrl(
$matches[1] ?? '',
$matches[2] ?? '',
$matches[3] ?? '',
$matches[4] ?? '',
$matches[5] ?? '',
$matches[1],
$matches[2],
$matches[3],
$matches[4],
$matches[5],
$matches[7] ?? '',
$matches[9] ?? ''
);