96 lines
3.2 KiB
PHP
96 lines
3.2 KiB
PHP
<?php
|
|
|
|
use Core\Db;
|
|
use Helper\Conversion;
|
|
|
|
ini_set('xdebug.var_display_max_depth', 10);
|
|
ini_set('xdebug.var_display_max_children', 256);
|
|
ini_set('xdebug.var_display_max_data', 1024);
|
|
|
|
require_once '../_incl_data/autoload.php';
|
|
|
|
|
|
class ShowPriems
|
|
{
|
|
private array $names = [];
|
|
private array $parameters = [];
|
|
public function __construct() {
|
|
foreach (Db::getRows('select sys_name, name from const_stats') as $nrow) {
|
|
$this->names[$nrow['sys_name']] = $nrow['name'];
|
|
}
|
|
// Несовпадения по именам.
|
|
$this->names['lvl'] = $this->names['level'];
|
|
|
|
$this->printAll();
|
|
$this->printUnknown();
|
|
}
|
|
|
|
private function printer(array $data, string $title): string
|
|
{
|
|
$result = '';
|
|
foreach ($data as $k=>$v) {
|
|
if ($k === array_key_first($data)) {
|
|
$result .= "<br><b>$title</b>: ";
|
|
}
|
|
$result .= $this->namer($k, $v);
|
|
}
|
|
return $result;
|
|
}
|
|
private function printAll(): void
|
|
{
|
|
foreach (Db::getRows('select name, info, date2, date3, id, tr from priems order by name') as $prow) {
|
|
$d2 = Conversion::dataStringToArray($prow['date2']);
|
|
$d3 = Conversion::dataStringToArray($prow['date3']);
|
|
$tr = Conversion::dataStringToArray($prow['tr']);
|
|
|
|
$d2s = $this->printer($d2, 'date2');
|
|
$d3s = $this->printer($d3, 'date3');
|
|
$trs = $this->printer($tr, 'Требуется');
|
|
|
|
$dallk = array_flip(array_keys(array_merge($d2, $d3, $tr)));
|
|
$this->parameters = array_merge($dallk, $this->parameters);
|
|
echo "<div><b>{$prow['name']}</b> id:{$prow['id']}<br><i>{$prow['info']}</i> $trs $d2s $d3s</div>";
|
|
}
|
|
}
|
|
private function namer($k, $v): string
|
|
{
|
|
return match (true) {
|
|
$this->names[$k] => "<br>$this->names[$k] = $v",
|
|
str_starts_with($k, 'add_') && $this->names[str_replace('add_', '', $k)] => "<br>{$this->names[str_replace('add_', '', $k)]} = $v",
|
|
str_starts_with($k, 'tr_') && $this->names[str_replace('tr_', '', $k)] => "<br>{$this->names[str_replace('tr_', '', $k)]} = $v",
|
|
default => "<br><span style='background-color: lavender; color: crimson;'>$k = $v</span>",
|
|
};
|
|
}
|
|
|
|
private function printUnknown(): void
|
|
{
|
|
$sorted = [];
|
|
foreach ($this->parameters as $pa=>$va) {
|
|
if ($this->names[str_replace('add_', '', $pa)] || $this->names[str_replace('tr_', '', $pa)]) {
|
|
continue;
|
|
}
|
|
$sorted[] = $pa;
|
|
}
|
|
|
|
echo '<hr>Неизвестные параметры:<br>';
|
|
foreach (array_chunk($sorted, 10) as $re) {
|
|
echo implode(', ', $re) . '<br>';
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
echo <<<HTML
|
|
<style>
|
|
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap');
|
|
body {font-family: 'JetBrains Mono', monospace; font-size: small; background-color: lavender;}
|
|
hr {border: 1px solid darkgreen;}
|
|
i {color: dimgrey;}
|
|
div {margin: 10px 0; padding: 4px; background-color: ghostwhite;}
|
|
div > b:first-child {margin-left: 5px; color: darkslategrey;}
|
|
div > b:first-child:before {content: '⭕ '}
|
|
</style>
|
|
HTML;
|
|
|
|
$np = new ShowPriems();
|