- Модуль: ui
- Путь к файлу: ~/bitrix/modules/ui/lib/barcode/barcodegenerator.php
- Класс: BitrixUIBarcodeBarcodeGenerator
- Вызов: BarcodeGenerator::dmtx_place_data
private function dmtx_place_data(&$mtx, $rows, $cols, $data) {
$row = 4;
$col = 0;
$offset = 0;
$length = count($data);
while (($row < $rows || $col < $cols) && $offset < $length) {
/* Corner cases. Literally. */
if ($row == $rows && $col == 0) {
$this->dmtx_place_1($mtx, $rows, $cols, $data[$offset++]);
} else if ($row == $rows - 2 && $col == 0 && $cols % 4 != 0) {
$this->dmtx_place_2($mtx, $rows, $cols, $data[$offset++]);
} else if ($row == $rows - 2 && $col == 0 && $cols % 8 == 4) {
$this->dmtx_place_3($mtx, $rows, $cols, $data[$offset++]);
} else if ($row == $rows + 4 && $col == 2 && $cols % 8 == 0) {
$this->dmtx_place_4($mtx, $rows, $cols, $data[$offset++]);
}
/* Up and to the right. */
while ($row >= 0 && $col < $cols && $offset < $length) {
if ($row < $rows && $col >= 0 && is_null($mtx[$row][$col])) {
$b = $data[$offset++];
$this->dmtx_place_0($mtx, $rows, $cols, $row, $col, $b);
}
$row -= 2;
$col += 2;
}
$row += 1;
$col += 3;
/* Down and to the left. */
while ($row < $rows && $col >= 0 && $offset < $length) {
if ($row >= 0 && $col < $cols && is_null($mtx[$row][$col])) {
$b = $data[$offset++];
$this->dmtx_place_0($mtx, $rows, $cols, $row, $col, $b);
}
$row += 2;
$col -= 2;
}
$row += 3;
$col += 1;
}
}