modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2024-06-14 19:57:50 +04:00
parent dca04418b7
commit 64e343dd38
3 changed files with 61 additions and 4 deletions

View File

@ -15,6 +15,7 @@ class Bs3IconManager implements IIconManager {
"config" => "cog",
"save" => "floppy-disk",
"download" => "download-alt",
"upload" => "cloud-upload",
"new_window",
"mail" => "enveloppe",
"search",
@ -84,6 +85,7 @@ EOT;
'config' => 'cog',
'save' => 'floppy-disk',
'download' => 'download-alt',
'upload' => 'cloud-upload',
'new_window' => 'new-window',
'mail' => 'enveloppe',
'search' => 'search',
@ -138,6 +140,7 @@ EOT;
const CONFIG = /*autogen*/['<span class="glyphicon glyphicon-cog" aria-hidden="true"></span>'];
const SAVE = /*autogen*/['<span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>'];
const DOWNLOAD = /*autogen*/['<span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span>'];
const UPLOAD = /*autogen*/['<span class="glyphicon glyphicon-cloud-upload" aria-hidden="true"></span>'];
const NEW_WINDOW = /*autogen*/['<span class="glyphicon glyphicon-new-window" aria-hidden="true"></span>'];
const MAIL = /*autogen*/['<span class="glyphicon glyphicon-enveloppe" aria-hidden="true"></span>'];
const SEARCH = /*autogen*/['<span class="glyphicon glyphicon-search" aria-hidden="true"></span>'];

View File

@ -64,7 +64,7 @@ class A {
$dest = cl::mpselect($dest, $merge, $pkeys);
}
static final function append_nn(?array &$dest, $value, $key=null) {
static final function set_nn(?array &$dest, $key, $value) {
if ($value !== null) {
if ($key === null) $dest[] = $value;
else $dest[$key] = $value;
@ -72,7 +72,11 @@ class A {
return $value;
}
static final function append_nz(?array &$dest, $value, $key=null) {
static final function append_nn(?array &$dest, $value, $key=null) {
return self::set_nn($dest, $key, $value);
}
static final function set_nz(?array &$dest, $key, $value) {
if ($value !== null && $value !== false) {
if ($key === null) $dest[] = $value;
else $dest[$key] = $value;
@ -80,6 +84,10 @@ class A {
return $value;
}
static final function append_nz(?array &$dest, $value, $key=null) {
return self::set_nz($dest, $key, $value);
}
static final function prepend_nn(?array &$dest, $value) {
if ($value !== null) {
if ($dest === null) $dest = [];
@ -95,4 +103,43 @@ class A {
}
return $value;
}
static final function replace_nx(?array &$dest, $key, $value) {
if ($dest !== null && !array_key_exists($key, $dest)) {
return $dest[$key] = $value;
} else {
return $dest[$key] ?? null;
}
}
static final function replace_n(?array &$dest, $key, $value) {
$pvalue = $dest[$key] ?? null;
if ($pvalue === null) $dest[$key] = $value;
return $pvalue;
}
static final function replace_z(?array &$dest, $key, $value) {
$pvalue = $dest[$key] ?? null;
if ($pvalue === null || $pvalue === false) $dest[$key] = $value;
return $pvalue;
}
static final function pop(?array $dest, $key, $default=null) {
if ($dest === null) return $default;
if ($key === null) return array_pop($dest);
$value = $dest[$key] ?? $default;
unset($dest[$key]);
return $value;
}
static final function popx(?array $dest, ?array $keys): array {
$values = [];
if ($dest === null) return $values;
if ($keys === null) return $values;
foreach ($keys as $key) {
$values[$key] = self::pop($dest, $key);
}
return $values;
}
}

View File

@ -18,6 +18,7 @@ abstract class AbstractReader implements IReader {
$this->schema = $params["schema"] ?? static::SCHEMA;
$this->headers = $params["headers"] ?? static::HEADERS;
$this->input = $params["input"] ?? static::INPUT;
$this->parseEmptyAsNull = boolval($params["empty_as_null"] ?? true);
}
protected ?array $schema;
@ -26,6 +27,8 @@ abstract class AbstractReader implements IReader {
protected $input;
protected bool $parseEmptyAsNull;
protected int $isrc = 0, $idest = 0;
protected function cook(array &$row): bool {
@ -45,10 +48,14 @@ abstract class AbstractReader implements IReader {
}
protected function verifixCol(&$col): void {
# conversion Date et DateTime
if (DateTime::isa_datetime($col, true)) {
if ($col === "" && $this->parseEmptyAsNull) {
# valeur vide --> null
$col = null;
} elseif (DateTime::isa_datetime($col, true)) {
# datetime
$col = new DateTime($col);
} elseif (DateTime::isa_date($col, true)) {
# date
$col = new Date($col);
}
}