29 lines
817 B
PHP
29 lines
817 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Batch-list style column widths: px from max character count (same formula as batch_list.php).
|
|
*
|
|
* @param array<int, string> $headerLabels
|
|
* @param array<int, int> $maxLenPerCol Same length as $headerLabels
|
|
* @param array<int, int> $minPx
|
|
* @param array<int, int> $maxPx
|
|
* @return array<int, int>
|
|
*/
|
|
function nhance_dt_column_widths_px(array $headerLabels, array $maxLenPerCol, array $minPx, array $maxPx): array
|
|
{
|
|
$n = count($headerLabels);
|
|
$out = [];
|
|
for ($i = 0; $i < $n; $i++) {
|
|
$chars = max($maxLenPerCol[$i] ?? 0, mb_strlen($headerLabels[$i]));
|
|
$px = (int) round($chars * 7.0 + 26);
|
|
$out[] = min(
|
|
(int) ($maxPx[$i] ?? 640),
|
|
max((int) ($minPx[$i] ?? 48), $px)
|
|
);
|
|
}
|
|
|
|
return $out;
|
|
}
|