Compare commits
8 Commits
v9.32.1
...
426afdc1ff
| Author | SHA1 | Date | |
|---|---|---|---|
| 426afdc1ff | |||
| ffff65a76d | |||
|
|
c22e68f19a | ||
|
|
074d5bed4c | ||
|
|
93cb7e0cab | ||
|
|
7fbce6529b | ||
|
|
6e086fe7b3 | ||
|
|
0ec19d5b75 |
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phive xmlns="https://phar.io/phive">
|
||||
<phar name="phpunit" version="^10.3.5" installed="10.3.5" location="./tools/phpunit" copy="false"/>
|
||||
<phar name="phpcbf" version="^3.7.2" installed="3.10.3" location="./tools/phpcbf" copy="false"/>
|
||||
<phar name="phpcs" version="^3.10.3" installed="3.10.3" location="./tools/phpcs" copy="false"/>
|
||||
<phar name="phpstan" version="^2.0" installed="2.0.4" location="./tools/phpstan" copy="false"/>
|
||||
<phar name="phpunit" version="^10.3.5" installed="10.5.46" location="./tools/phpunit" copy="false"/>
|
||||
<phar name="phpcbf" version="^3.7.2" installed="3.13.0" location="./tools/phpcbf" copy="false"/>
|
||||
<phar name="phpcs" version="^3.10.3" installed="3.13.0" location="./tools/phpcs" copy="false"/>
|
||||
<phar name="phpstan" version="^2.0" installed="2.1.16" location="./tools/phpstan" copy="false"/>
|
||||
<phar name="phan" version="^5.4.3" installed="5.4.3" location="./tools/phan" copy="false"/>
|
||||
<phar name="psalm" version="^5.15.0" installed="5.24.0" location="./tools/psalm" copy="false"/>
|
||||
<phar name="phpdox" version="^0.12.0" installed="0.12.0" location="./tools/phpdox" copy="false"/>
|
||||
|
||||
@@ -1286,6 +1286,118 @@ final class CoreLibsCombinedArrayHandlerTest extends TestCase
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* provider for arrayModifyKey
|
||||
*
|
||||
* @return array<string,array<mixed>>
|
||||
*/
|
||||
public function providerArrayModifyKey(): array
|
||||
{
|
||||
return [
|
||||
'prefix and suffix add' => [
|
||||
'array' => [
|
||||
'a' => 'foo',
|
||||
'b' => 'bar',
|
||||
'c' => 'foobar',
|
||||
],
|
||||
'prefix' => 'Prefix: ',
|
||||
'suffix' => '.suffix',
|
||||
'expected' => [
|
||||
'Prefix: a.suffix' => 'foo',
|
||||
'Prefix: b.suffix' => 'bar',
|
||||
'Prefix: c.suffix' => 'foobar',
|
||||
],
|
||||
],
|
||||
'prefix add only' => [
|
||||
'array' => [
|
||||
'a' => 'foo',
|
||||
'b' => 'bar',
|
||||
'c' => 'foobar',
|
||||
],
|
||||
'prefix' => 'Prefix: ',
|
||||
'suffix' => '',
|
||||
'expected' => [
|
||||
'Prefix: a' => 'foo',
|
||||
'Prefix: b' => 'bar',
|
||||
'Prefix: c' => 'foobar',
|
||||
],
|
||||
],
|
||||
'suffix add only' => [
|
||||
'array' => [
|
||||
'a' => 'foo',
|
||||
'b' => 'bar',
|
||||
'c' => 'foobar',
|
||||
],
|
||||
'prefix' => '',
|
||||
'suffix' => '.suffix',
|
||||
'expected' => [
|
||||
'a.suffix' => 'foo',
|
||||
'b.suffix' => 'bar',
|
||||
'c.suffix' => 'foobar',
|
||||
],
|
||||
],
|
||||
'empty array' => [
|
||||
'array' => [],
|
||||
'prefix' => '',
|
||||
'suffix' => '.suffix',
|
||||
'expected' => [],
|
||||
],
|
||||
'no suffix or prefix' => [
|
||||
'array' => [
|
||||
'a' => 'foo',
|
||||
'b' => 'bar',
|
||||
'c' => 'foobar',
|
||||
],
|
||||
'prefix' => '',
|
||||
'suffix' => '',
|
||||
'expected' => [
|
||||
'a' => 'foo',
|
||||
'b' => 'bar',
|
||||
'c' => 'foobar',
|
||||
],
|
||||
],
|
||||
'integer index mixed' => [
|
||||
'array' => [
|
||||
'a' => 'foo',
|
||||
'b' => 'bar',
|
||||
3 => 'foobar',
|
||||
],
|
||||
'prefix' => '',
|
||||
'suffix' => '.suffix',
|
||||
'expected' => [
|
||||
'a.suffix' => 'foo',
|
||||
'b.suffix' => 'bar',
|
||||
'3.suffix' => 'foobar',
|
||||
],
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @covers ::arrayModifyKey
|
||||
* @dataProvider providerArrayModifyKey
|
||||
* @testdox arrayModifyKey check that key is correctly modified with $key_mod_prefix and $key_mod_suffix [$_dataName]
|
||||
*
|
||||
* @param array<mixed> $in_array
|
||||
* @param string $key_mod_prefix
|
||||
* @param string $key_mod_suffix
|
||||
* @param array<mixed> $expected
|
||||
* @return void
|
||||
*/
|
||||
public function testArrayModifyKey(
|
||||
array $in_array,
|
||||
string $key_mod_prefix,
|
||||
string $key_mod_suffix,
|
||||
array $expected
|
||||
): void {
|
||||
$this->assertEquals(
|
||||
\CoreLibs\Combined\ArrayHandler::arrayModifyKey($in_array, $key_mod_prefix, $key_mod_suffix),
|
||||
$expected
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -60,6 +60,8 @@ echo "ARRAYSEARCHRECURSIVE(email, [array], type): "
|
||||
. DgS::printAr(ArrayHandler::arraySearchRecursive('email', $test_array, 'type')) . "<br>";
|
||||
echo "ARRAYSEARCHRECURSIVE(email, [array]['input'], type): "
|
||||
. DgS::printAr(ArrayHandler::arraySearchRecursive('email', $test_array['input'], 'type')) . "<br>";
|
||||
echo "ARRAYSEARCHRECURSIVE(email, [array]['input'], wrong): "
|
||||
. DgS::printAr(ArrayHandler::arraySearchRecursive('email', $test_array['input'], 'wrong')) . "<br>";
|
||||
// all return
|
||||
echo "ARRAYSEARCHRECURSIVEALL(email, [array], type): "
|
||||
. Dgs::printAr((array)ArrayHandler::arraySearchRecursiveAll('email', $test_array, 'type')) . "<br>";
|
||||
@@ -168,6 +170,31 @@ $data = [
|
||||
$search = ['image', 'result_image', 'nothing', 'EMPTY'];
|
||||
$result = ArrayHandler::arraySearchKey($data, $search);
|
||||
print "ARRAYSEARCHKEY: Search: " . DgS::printAr($search) . ", Found: " . DgS::printAr($result) . "<br>";
|
||||
$result = ArrayHandler::arraySearchKey($data, $search, true);
|
||||
print "ARRAYSEARCHKEY: FLAT: Search: " . DgS::printAr($search) . ", Found: " . DgS::printAr($result) . "<br>";
|
||||
$result = ArrayHandler::arraySearchKey($data, $search, true, true);
|
||||
print "ARRAYSEARCHKEY: FLAT:PREFIX: Search: " . DgS::printAr($search) . ", Found: " . DgS::printAr($result) . "<br>";
|
||||
$result = ArrayHandler::arraySearchKey($data, ["EMPTY"], true);
|
||||
print "ARRAYSEARCHKEY: FLAT:PREFIX: Search: " . DgS::printAr(["EMPTY"]) . ", Found: " . DgS::printAr($result) . "<br>";
|
||||
|
||||
// $data = [
|
||||
// [
|
||||
// [name] => qrc_apcd,
|
||||
// [value] => 5834367225,
|
||||
// ],
|
||||
// [
|
||||
// [name] => qrc_other,
|
||||
// [value] => test,
|
||||
// ],
|
||||
// [
|
||||
// [name] => qrc_car_type,
|
||||
// [value] => T33P17,
|
||||
// ],
|
||||
// [
|
||||
// [name] => qrc_deaer_store,
|
||||
// [value] => 9990:001,
|
||||
// ]
|
||||
// ]
|
||||
|
||||
// $test = [
|
||||
// 'A' => [
|
||||
@@ -263,6 +290,8 @@ $out = array_intersect_key(
|
||||
);
|
||||
print "array intersect key: " . DgS::printAr($keys) . ": " . DgS::printAr($out) . "<br>";
|
||||
|
||||
print "array + suffix: " . DgS::printAr(ArrayHandler::arrayModifyKey($array, key_mod_suffix:'_attached')) . "<br>";
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -31,6 +31,7 @@ $log = new CoreLibs\Logging\Logging([
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||
$log->setLogFileId('classTest-login-override');
|
||||
$login = new CoreLibs\ACL\Login(
|
||||
$db,
|
||||
$log,
|
||||
@@ -45,6 +46,7 @@ $login = new CoreLibs\ACL\Login(
|
||||
'locale_path' => BASE . INCLUDES . LOCALE,
|
||||
]
|
||||
);
|
||||
$log->setLogFileId($LOG_FILE_ID);
|
||||
ob_end_flush();
|
||||
$login->loginMainCall();
|
||||
|
||||
@@ -158,5 +160,6 @@ if (is_string($edit_access_cuid)) {
|
||||
print "EA ID: " . $edit_access_id . "<br>";
|
||||
print "EA CUID: " . $log->prAr($edit_access_cuid) . "<br>";
|
||||
print "REV EA CUID: " . $log->prAr($edit_access_id_rev) . "<br>";
|
||||
$log->info('This is a test');
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
@@ -34,6 +34,17 @@ function executeFunctionByName(functionName, context) {
|
||||
}
|
||||
return context[func].apply(context, args);
|
||||
}
|
||||
function runFunction(name) {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
runFunctionArgsArray(name, args);
|
||||
}
|
||||
function runFunctionArgsArray(name, args) {
|
||||
var fn = window[name];
|
||||
if (typeof fn !== "function") {
|
||||
return;
|
||||
}
|
||||
fn.apply(window, args);
|
||||
}
|
||||
function isObject(val) {
|
||||
if (val === null) {
|
||||
return false;
|
||||
@@ -659,6 +670,31 @@ function getQueryStringParam(search = "", query = "", single = false) {
|
||||
}
|
||||
return param;
|
||||
}
|
||||
function hasUrlParameter(key) {
|
||||
var urlParams = new URLSearchParams(window.location.search);
|
||||
return urlParams.has(key);
|
||||
}
|
||||
function getUrlParameter(key) {
|
||||
var urlParams = new URLSearchParams(window.location.search);
|
||||
return urlParams.get(key);
|
||||
}
|
||||
function updateUrlParameter(key, value, reload = false) {
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.set(key, value);
|
||||
const newUrl = url.toString();
|
||||
window.history.pushState({ path: newUrl }, "", newUrl);
|
||||
if (reload) {
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
function removeUrlParameter(key, reload = false) {
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.delete(key);
|
||||
window.history.pushState({}, "", url.toString());
|
||||
if (reload) {
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
// src/utils/LoginLogout.mjs
|
||||
function loginLogout() {
|
||||
@@ -979,7 +1015,7 @@ var ActionBox = class {
|
||||
$("#overlayBox").css("zIndex", this.zIndex.base);
|
||||
}
|
||||
$("#overlayBox").show();
|
||||
if (!keyInObject(target_id, this.zIndex.boxes)) {
|
||||
if (!objectKeyExists(this.zIndex.boxes, target_id)) {
|
||||
this.zIndex.boxes[target_id] = this.zIndex.max;
|
||||
this.zIndex.max += 10;
|
||||
} else if (this.zIndex.boxes[target_id] + 10 < this.zIndex.max) {
|
||||
@@ -1005,7 +1041,7 @@ var ActionBox = class {
|
||||
if (!exists(target_id)) {
|
||||
return;
|
||||
}
|
||||
if (keyInObject(target_id, this.action_box_storage) && clean === true) {
|
||||
if (objectKeyExists(this.action_box_storage, target_id) && clean === true) {
|
||||
this.action_box_storage[target_id] = {};
|
||||
}
|
||||
if (clean === true) {
|
||||
@@ -1043,15 +1079,15 @@ var ActionBox = class {
|
||||
* @param {Object} [settings={}] Optional settings, eg style sheets
|
||||
*/
|
||||
createActionBox(target_id = "actionBox", title = "", contents = {}, headers = {}, settings = {}, show_close = true) {
|
||||
if (!keyInObject(target_id, this.action_box_storage)) {
|
||||
if (!objectKeyExists(this.action_box_storage, target_id)) {
|
||||
this.action_box_storage[target_id] = {};
|
||||
}
|
||||
let header_css = [];
|
||||
if (keyInObject("header_css", settings)) {
|
||||
if (objectKeyExists(settings, "header_css")) {
|
||||
header_css = settings.header_css;
|
||||
}
|
||||
let action_box_css = [];
|
||||
if (keyInObject("action_box_css", settings)) {
|
||||
if (objectKeyExists(settings, "action_box_css")) {
|
||||
action_box_css = settings.action_box_css;
|
||||
}
|
||||
let elements = [];
|
||||
@@ -1082,14 +1118,14 @@ var ActionBox = class {
|
||||
)
|
||||
));
|
||||
if (getObjectCount(headers) > 0) {
|
||||
if (keyInObject("raw_string", headers)) {
|
||||
if (objectKeyExists(headers, "raw_string")) {
|
||||
elements.push(headers.raw_string);
|
||||
} else {
|
||||
elements.push(this.hec.phfo(headers));
|
||||
}
|
||||
}
|
||||
if (getObjectCount(contents) > 0) {
|
||||
if (keyInObject("raw_string", contents)) {
|
||||
if (objectKeyExists(contents, "raw_string")) {
|
||||
elements.push(contents.raw_string);
|
||||
} else {
|
||||
elements.push(this.hec.phfo(contents));
|
||||
@@ -1517,12 +1553,24 @@ function html_options_block2(name, data, selected = "", multiple = 0, options_on
|
||||
function html_options_refill2(name, data, sort = "") {
|
||||
html_options_refill(name, data, sort);
|
||||
}
|
||||
function parseQueryString2(query = "", return_key = "") {
|
||||
return parseQueryString(query, return_key);
|
||||
function parseQueryString2(query = "", return_key = "", single = false) {
|
||||
return parseQueryString(query, return_key, single);
|
||||
}
|
||||
function getQueryStringParam2(search = "", query = "", single = false) {
|
||||
return getQueryStringParam(search, query, single);
|
||||
}
|
||||
function updateUrlParameter2(key, value, reload = false) {
|
||||
return updateUrlParameter(key, value, reload);
|
||||
}
|
||||
function removeUrlParameter2(key, reload = false) {
|
||||
return removeUrlParameter(key, reload);
|
||||
}
|
||||
function hasUrlParameter2(key) {
|
||||
return hasUrlParameter(key);
|
||||
}
|
||||
function getUrlParameter2(key) {
|
||||
return getUrlParameter(key);
|
||||
}
|
||||
function loginLogout2() {
|
||||
loginLogout();
|
||||
}
|
||||
|
||||
4
www/admin/layout/javascript/utils.min.js
vendored
4
www/admin/layout/javascript/utils.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -551,6 +551,36 @@ class ArrayHandler
|
||||
ARRAY_FILTER_USE_KEY
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifieds the key of an array with a prefix and/or suffix and returns it with the original value
|
||||
* does not change order in array
|
||||
*
|
||||
* @param array<string|int,mixed> $in_array
|
||||
* @param string $key_mod_prefix [default=''] key prefix string
|
||||
* @param string $key_mod_suffix [default=''] key suffix string
|
||||
* @return array<string|int,mixed>
|
||||
*/
|
||||
public static function arrayModifyKey(
|
||||
array $in_array,
|
||||
string $key_mod_prefix = '',
|
||||
string $key_mod_suffix = ''
|
||||
): array {
|
||||
// skip if array is empty or neither prefix or suffix are set
|
||||
if (
|
||||
$in_array == [] ||
|
||||
($key_mod_prefix == '' && $key_mod_suffix == '')
|
||||
) {
|
||||
return $in_array;
|
||||
}
|
||||
return array_combine(
|
||||
array_map(
|
||||
fn($key) => $key_mod_prefix . $key . $key_mod_suffix,
|
||||
array_keys($in_array)
|
||||
),
|
||||
array_values($in_array)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -39,9 +39,9 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
{
|
||||
// main calss variables
|
||||
/** @var array<mixed> */
|
||||
private array $table_array; // the array from the table to work on
|
||||
private array $table_array = []; // the array from the table to work on
|
||||
/** @var string */
|
||||
private string $table_name; // the table_name
|
||||
private string $table_name = ''; // the table_name
|
||||
/** @var string */
|
||||
private string $pk_name = ''; // the primary key from this table
|
||||
/** @var int|string|null */
|
||||
@@ -127,9 +127,9 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
public function getTableArray(bool $reset = false): array
|
||||
{
|
||||
if (!$reset) {
|
||||
return $this->table_array ?? [];
|
||||
return $this->table_array;
|
||||
}
|
||||
$table_array = $this->table_array ?? [];
|
||||
$table_array = $this->table_array;
|
||||
reset($table_array);
|
||||
return $table_array;
|
||||
}
|
||||
@@ -194,7 +194,7 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
*/
|
||||
public function getTableName(): string
|
||||
{
|
||||
return $this->table_name ?? '';
|
||||
return $this->table_name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2544,7 +2544,10 @@ class IO
|
||||
} // only go if NO cursor exists
|
||||
|
||||
// if cursor exists ...
|
||||
if ($this->cursor_ext[$query_hash]['cursor']) {
|
||||
if (
|
||||
$this->cursor_ext[$query_hash]['cursor'] instanceof \PgSql\Result ||
|
||||
$this->cursor_ext[$query_hash]['cursor'] == 1
|
||||
) {
|
||||
if ($first_call === true) {
|
||||
$this->cursor_ext[$query_hash]['log'][] = 'First call';
|
||||
// count the rows returned (if select)
|
||||
|
||||
Reference in New Issue
Block a user