Initial commit with barely functional code.
This commit is contained in:
17
README.md
17
README.md
@@ -1,3 +1,18 @@
|
|||||||
# Databrae
|
# Databrae
|
||||||
|
|
||||||
Inexpensive, direct, high speed item access without RFID
|
---
|
||||||
|
|
||||||
|
## The Short Story
|
||||||
|
|
||||||
|
RFID is expensive and requires expensive equipment to make it work in a library. So instead, this project uses a small data matrix barcode added to the spine label, or to the spine of the item. This barcode is simply another way of accessing the item's barcode you'd normally find on the cover, the one that would be scanned at a circulation desk or by a self-check machine. This allows the item to be scannable while sitting on the shelf.
|
||||||
|
|
||||||
|
Using an inexpensive 2D barcode scanner -- something that a library might already have on hand -- library staff can act upon individual items or work with them in bulk. This allows for inventory, shelf-reading, weeding, and other library tasks that can be performed in a manner similar to what is done with RFID, but at a fraction of the cost.
|
||||||
|
|
||||||
|
## IUG Speaking Proposal
|
||||||
|
|
||||||
|
One of the dreams of the Circulation Librarian is the ability to access and evaluate the items on the shelves without touching every single item. If you're running an inventory, or checking last circ dates for a weeding project, or checking for errant item statuses, the process is the same: Scan the item into your ILS and move on from there. RFID promised a solution for this, with handheld wands that are supposed to read the tags and you never have to touch the items.
|
||||||
|
|
||||||
|
Except for two problems: One, everything about RFID is expensive and two, wands don't always work. Sooner or later, you'll run into an issue where you cannot scan an RFID tag and need to pull the item off the shelf. And for some libraries, the expensive nature of RFID, from the price of tags to the price of equipment, hampers their ability to improve their workflows and make their jobs easier.
|
||||||
|
|
||||||
|
I have an idea. I admit, it's a crazy idea, but it's everything RFID isn't. It's inexpensive, the software is free and open source, your library won't need to buy a lot of special equipment, the price of conversion is pennies on the dollar compared to RFID, it doesn't matter what ILS you're running, and there's a good chance you already have everything you need.
|
||||||
|
|
||||||
|
|||||||
5
composer.json
Normal file
5
composer.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"require": {
|
||||||
|
"tecnickcom/tc-lib-barcode": "^2.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
188
composer.lock
generated
Normal file
188
composer.lock
generated
Normal file
@@ -0,0 +1,188 @@
|
|||||||
|
{
|
||||||
|
"_readme": [
|
||||||
|
"This file locks the dependencies of your project to a known state",
|
||||||
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
|
"This file is @generated automatically"
|
||||||
|
],
|
||||||
|
"content-hash": "fec1884528cfb2fb28b4e18390c129bc",
|
||||||
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "tecnickcom/tc-lib-barcode",
|
||||||
|
"version": "2.4.8",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/tecnickcom/tc-lib-barcode.git",
|
||||||
|
"reference": "f238ffd120d98a34df6573590e7ed02f766a91c4"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/tecnickcom/tc-lib-barcode/zipball/f238ffd120d98a34df6573590e7ed02f766a91c4",
|
||||||
|
"reference": "f238ffd120d98a34df6573590e7ed02f766a91c4",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-bcmath": "*",
|
||||||
|
"ext-date": "*",
|
||||||
|
"ext-gd": "*",
|
||||||
|
"ext-pcre": "*",
|
||||||
|
"php": ">=8.1",
|
||||||
|
"tecnickcom/tc-lib-color": "^2.2"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"pdepend/pdepend": "2.16.2",
|
||||||
|
"phpmd/phpmd": "2.15.0",
|
||||||
|
"phpunit/phpunit": "12.2.0 || 11.5.7 || 10.5.40",
|
||||||
|
"squizlabs/php_codesniffer": "3.13.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Com\\Tecnick\\Barcode\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"LGPL-3.0-or-later"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nicola Asuni",
|
||||||
|
"email": "info@tecnick.com",
|
||||||
|
"role": "lead"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PHP library to generate linear and bidimensional barcodes",
|
||||||
|
"homepage": "http://www.tecnick.com",
|
||||||
|
"keywords": [
|
||||||
|
"3 of 9",
|
||||||
|
"ANSI MH10.8M-1983",
|
||||||
|
"CBC",
|
||||||
|
"CODABAR",
|
||||||
|
"CODE 11",
|
||||||
|
"CODE 128 A B C",
|
||||||
|
"CODE 39",
|
||||||
|
"CODE 93",
|
||||||
|
"EAN 13",
|
||||||
|
"EAN 8",
|
||||||
|
"ECC200",
|
||||||
|
"ISO IEC 15438 2006",
|
||||||
|
"ISO IEC 16022",
|
||||||
|
"ISO IEC 24778 2008",
|
||||||
|
"Intelligent Mail Barcode",
|
||||||
|
"Interleaved 2 of 5",
|
||||||
|
"KIX",
|
||||||
|
"Klant",
|
||||||
|
"MSI",
|
||||||
|
"Onecode",
|
||||||
|
"PHARMACODE",
|
||||||
|
"PHARMACODE TWO-TRACKS",
|
||||||
|
"POSTNET",
|
||||||
|
"RMS4CC",
|
||||||
|
"Standard 2 of 5",
|
||||||
|
"UPC-A",
|
||||||
|
"UPC-E",
|
||||||
|
"USD-3",
|
||||||
|
"USPS-B-3200",
|
||||||
|
"USS-93",
|
||||||
|
"aztec",
|
||||||
|
"barcode",
|
||||||
|
"datamatrix",
|
||||||
|
"pdf417",
|
||||||
|
"planet",
|
||||||
|
"qr-code",
|
||||||
|
"royal mail",
|
||||||
|
"tc-lib-barcode",
|
||||||
|
"upc"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/tecnickcom/tc-lib-barcode/issues",
|
||||||
|
"source": "https://github.com/tecnickcom/tc-lib-barcode/tree/2.4.8"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://www.paypal.com/donate/?hosted_button_id=NZUEC5XS8MFBJ",
|
||||||
|
"type": "custom"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2025-06-06T11:35:02+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tecnickcom/tc-lib-color",
|
||||||
|
"version": "2.2.13",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/tecnickcom/tc-lib-color.git",
|
||||||
|
"reference": "85d1366fb33813aa521d30e3d7c7d7d82a8103a6"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/tecnickcom/tc-lib-color/zipball/85d1366fb33813aa521d30e3d7c7d7d82a8103a6",
|
||||||
|
"reference": "85d1366fb33813aa521d30e3d7c7d7d82a8103a6",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-pcre": "*",
|
||||||
|
"php": ">=8.1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"pdepend/pdepend": "2.16.2",
|
||||||
|
"phpmd/phpmd": "2.15.0",
|
||||||
|
"phpunit/phpunit": "12.2.0 || 11.5.7 || 10.5.40",
|
||||||
|
"squizlabs/php_codesniffer": "3.13.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Com\\Tecnick\\Color\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"LGPL-3.0-or-later"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nicola Asuni",
|
||||||
|
"email": "info@tecnick.com",
|
||||||
|
"role": "lead"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PHP library to manipulate various color representations",
|
||||||
|
"homepage": "http://www.tecnick.com",
|
||||||
|
"keywords": [
|
||||||
|
"cmyk",
|
||||||
|
"color",
|
||||||
|
"colors",
|
||||||
|
"colour",
|
||||||
|
"colours",
|
||||||
|
"hsl",
|
||||||
|
"hsla",
|
||||||
|
"javascript",
|
||||||
|
"rgb",
|
||||||
|
"rgba",
|
||||||
|
"tc-lib-color",
|
||||||
|
"web"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/tecnickcom/tc-lib-color/issues",
|
||||||
|
"source": "https://github.com/tecnickcom/tc-lib-color/tree/2.2.13"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://www.paypal.com/donate/?hosted_button_id=NZUEC5XS8MFBJ",
|
||||||
|
"type": "custom"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2025-06-06T11:33:19+00:00"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"packages-dev": [],
|
||||||
|
"aliases": [],
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"stability-flags": [],
|
||||||
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
|
"platform": [],
|
||||||
|
"platform-dev": [],
|
||||||
|
"plugin-api-version": "2.6.0"
|
||||||
|
}
|
||||||
499
index-csv.php
Normal file
499
index-csv.php
Normal file
@@ -0,0 +1,499 @@
|
|||||||
|
<?php
|
||||||
|
// index.php — Spine/Item Label Generator with CSV + Sheet Template (Demco 1.5"x1.0")
|
||||||
|
// Prints to exact physical size using CSS inches and @page rules.
|
||||||
|
// Preset defaults can be adjusted from the UI without code changes.
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
$autoloadOk = file_exists(__DIR__ . '/vendor/autoload.php');
|
||||||
|
if ($autoloadOk) {
|
||||||
|
require __DIR__ . '/vendor/autoload.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Barcode;
|
||||||
|
|
||||||
|
function safe($s) { return htmlspecialchars(trim((string)($s ?? '')), ENT_QUOTES, 'UTF-8'); }
|
||||||
|
function strip_bom(string $s): string {
|
||||||
|
if (substr($s, 0, 3) === "\xEF\xBB\xBF") return substr($s, 3);
|
||||||
|
return $s;
|
||||||
|
}
|
||||||
|
function detect_delimiter(string $headerLine): string {
|
||||||
|
$candidates = [",", "\t", ";", "|"];
|
||||||
|
$counts = [];
|
||||||
|
foreach ($candidates as $d) $counts[$d] = substr_count($headerLine, $d);
|
||||||
|
arsort($counts);
|
||||||
|
return array_key_first($counts) ?: ",";
|
||||||
|
}
|
||||||
|
function read_csv_assoc(string $tmpPath, array &$errors): array {
|
||||||
|
$rows = [];
|
||||||
|
$required = ['data1','data2','data3','data4','barcode'];
|
||||||
|
$raw = file_get_contents($tmpPath);
|
||||||
|
if ($raw === false || $raw === '') { $errors[] = "Uploaded CSV is empty or unreadable."; return []; }
|
||||||
|
$raw = strip_bom($raw);
|
||||||
|
$lines = preg_split('/\r\n|\r|\n/', $raw);
|
||||||
|
if (!$lines || count($lines) < 1) { $errors[] = "CSV appears to have no lines."; return []; }
|
||||||
|
$headerLine = '';
|
||||||
|
foreach ($lines as $ln) { if (trim($ln) !== '') { $headerLine = $ln; break; } }
|
||||||
|
if ($headerLine === '') { $errors[] = "CSV header line is missing."; return []; }
|
||||||
|
$delimiter = detect_delimiter($headerLine);
|
||||||
|
|
||||||
|
$fh = fopen($tmpPath, 'r'); if (!$fh) { $errors[] = "Unable to open uploaded CSV."; return []; }
|
||||||
|
|
||||||
|
// Read header
|
||||||
|
$hdr = [];
|
||||||
|
while (($line = fgets($fh)) !== false) {
|
||||||
|
$line = strip_bom($line);
|
||||||
|
if (trim($line) === '') continue;
|
||||||
|
$hdr = str_getcsv($line, $delimiter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!$hdr) { $errors[] = "Could not read header row."; fclose($fh); return []; }
|
||||||
|
$headers = array_map(fn($h) => strtolower(trim((string)$h)), $hdr);
|
||||||
|
|
||||||
|
foreach (['data1','data2','data3','data4','barcode'] as $req) {
|
||||||
|
if (!in_array($req, $headers, true)) $errors[] = "Missing required header: <code>{$req}</code>.";
|
||||||
|
}
|
||||||
|
if ($errors) { fclose($fh); return []; }
|
||||||
|
|
||||||
|
while (($row = fgetcsv($fh, 0, $delimiter)) !== false) {
|
||||||
|
if ($row === [null] || $row === false) continue;
|
||||||
|
if (count(array_filter($row, fn($v) => trim((string)$v) !== '')) === 0) continue; // skip blank line
|
||||||
|
$assoc = [];
|
||||||
|
foreach ($required as $key) {
|
||||||
|
$idx = array_search($key, $headers, true);
|
||||||
|
$assoc[$key] = $idx !== false && isset($row[$idx]) ? trim((string)$row[$idx]) : '';
|
||||||
|
}
|
||||||
|
if (implode('', $assoc) === '') continue;
|
||||||
|
$rows[] = $assoc;
|
||||||
|
}
|
||||||
|
fclose($fh);
|
||||||
|
if (empty($rows)) $errors[] = "CSV contained no usable rows after the header.";
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
function render_datamatrix_svg(string $content): string {
|
||||||
|
global $autoloadOk;
|
||||||
|
if (!$autoloadOk) return '<!-- Barcode library not installed -->';
|
||||||
|
$barcode = new Barcode();
|
||||||
|
$obj = $barcode->getBarcodeObj(
|
||||||
|
'DATAMATRIX',
|
||||||
|
$content,
|
||||||
|
-1, -1, 'black', [0,0,0,0]
|
||||||
|
);
|
||||||
|
$obj->setBackgroundColor('white');
|
||||||
|
return $obj->getSvgCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------- Sheet Template System ---------------- */
|
||||||
|
// Default preset: Demco 1.5" x 1.0" on Letter (guess: 5x8 grid, 0.5" margins, 0.125" gaps).
|
||||||
|
// You can adjust these in the UI and re-preview until alignment is perfect.
|
||||||
|
$defaults = [
|
||||||
|
'page_width_in' => 8.5,
|
||||||
|
'page_height_in' => 11.0,
|
||||||
|
'margin_top_in' => 0.5,
|
||||||
|
'margin_right_in' => 0.5,
|
||||||
|
'margin_bottom_in' => 0.5,
|
||||||
|
'margin_left_in' => 0.5,
|
||||||
|
'cols' => 5,
|
||||||
|
'rows' => 8,
|
||||||
|
'label_w_in' => 1.5,
|
||||||
|
'label_h_in' => 1.0,
|
||||||
|
'gap_h_in' => 0.125, // horizontal gap between columns
|
||||||
|
'gap_v_in' => 0.125, // vertical gap between rows
|
||||||
|
'barcode_h_in' => 0.30, // barcode height inside 1.0" label
|
||||||
|
'font_in' => 0.12, // approx 8.6pt
|
||||||
|
'show_outlines' => '1'
|
||||||
|
];
|
||||||
|
|
||||||
|
// Pull current template params from POST (template form) or keep defaults
|
||||||
|
function valf($name, $def) {
|
||||||
|
return isset($_POST[$name]) && $_POST[$name] !== '' ? $_POST[$name] : $def;
|
||||||
|
}
|
||||||
|
$page_width_in = (float) valf('page_width_in', $defaults['page_width_in']);
|
||||||
|
$page_height_in = (float) valf('page_height_in', $defaults['page_height_in']);
|
||||||
|
$margin_top_in = (float) valf('margin_top_in', $defaults['margin_top_in']);
|
||||||
|
$margin_right_in = (float) valf('margin_right_in', $defaults['margin_right_in']);
|
||||||
|
$margin_bottom_in = (float) valf('margin_bottom_in', $defaults['margin_bottom_in']);
|
||||||
|
$margin_left_in = (float) valf('margin_left_in', $defaults['margin_left_in']);
|
||||||
|
$cols = max(1, (int) valf('cols', $defaults['cols']));
|
||||||
|
$rows = max(1, (int) valf('rows', $defaults['rows']));
|
||||||
|
$label_w_in = (float) valf('label_w_in', $defaults['label_w_in']);
|
||||||
|
$label_h_in = (float) valf('label_h_in', $defaults['label_h_in']);
|
||||||
|
$gap_h_in = (float) valf('gap_h_in', $defaults['gap_h_in']);
|
||||||
|
$gap_v_in = (float) valf('gap_v_in', $defaults['gap_v_in']);
|
||||||
|
$barcode_h_in = (float) valf('barcode_h_in', $defaults['barcode_h_in']);
|
||||||
|
$font_in = (float) valf('font_in', $defaults['font_in']);
|
||||||
|
$show_outlines = isset($_POST['show_outlines']) ? '1' : $defaults['show_outlines'];
|
||||||
|
|
||||||
|
// Records pipeline (single or CSV)
|
||||||
|
$errors = [];
|
||||||
|
$records = [];
|
||||||
|
$isPosted = ($_SERVER['REQUEST_METHOD'] === 'POST');
|
||||||
|
|
||||||
|
$data1 = $_POST['data1'] ?? '';
|
||||||
|
$data2 = $_POST['data2'] ?? '';
|
||||||
|
$data3 = $_POST['data3'] ?? '';
|
||||||
|
$data4 = $_POST['data4'] ?? '';
|
||||||
|
$barcodeText = $_POST['barcode'] ?? '';
|
||||||
|
|
||||||
|
$mode = $_POST['mode'] ?? '';
|
||||||
|
|
||||||
|
if ($isPosted && $mode === 'csv') {
|
||||||
|
if (!isset($_FILES['csvfile']) || !is_uploaded_file($_FILES['csvfile']['tmp_name'])) {
|
||||||
|
$errors[] = "Please choose a CSV file to upload.";
|
||||||
|
} else {
|
||||||
|
$size = $_FILES['csvfile']['size'] ?? 0;
|
||||||
|
if ($size > 10 * 1024 * 1024) { $errors[] = "CSV too large (max 10MB)."; }
|
||||||
|
else { $records = read_csv_assoc($_FILES['csvfile']['tmp_name'], $errors); }
|
||||||
|
}
|
||||||
|
} elseif ($isPosted && $mode === 'single') {
|
||||||
|
if ($barcodeText === '') $errors[] = "Please provide a Barcode value.";
|
||||||
|
else {
|
||||||
|
$records[] = ['data1'=>$data1,'data2'=>$data2,'data3'=>$data3,'data4'=>$data4,'barcode'=>$barcodeText];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute pagination
|
||||||
|
$perPage = $cols * $rows;
|
||||||
|
$pages = [];
|
||||||
|
if ($records) {
|
||||||
|
$pages = array_chunk($records, $perPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Label Generator — CSV + Sheet Template</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--font: "Helvetica Neue", Arial, sans-serif;
|
||||||
|
|
||||||
|
/* These CSS variables are set from PHP inline below to match your template */
|
||||||
|
--page-w: <?= $page_width_in ?>in;
|
||||||
|
--page-h: <?= $page_height_in ?>in;
|
||||||
|
--m-top: <?= $margin_top_in ?>in;
|
||||||
|
--m-right: <?= $margin_right_in ?>in;
|
||||||
|
--m-bottom: <?= $margin_bottom_in ?>in;
|
||||||
|
--m-left: <?= $margin_left_in ?>in;
|
||||||
|
|
||||||
|
--cols: <?= $cols ?>;
|
||||||
|
--rows: <?= $rows ?>;
|
||||||
|
|
||||||
|
--label-w: <?= $label_w_in ?>in;
|
||||||
|
--label-h: <?= $label_h_in ?>in;
|
||||||
|
|
||||||
|
--gap-h: <?= $gap_h_in ?>in;
|
||||||
|
--gap-v: <?= $gap_v_in ?>in;
|
||||||
|
|
||||||
|
--barcode-h: <?= $barcode_h_in ?>in;
|
||||||
|
--font-in: <?= $font_in ?>in;
|
||||||
|
|
||||||
|
--show-outlines: <?= $show_outlines === '1' ? 1 : 0 ?>;
|
||||||
|
}
|
||||||
|
|
||||||
|
@page {
|
||||||
|
size: var(--page-w) var(--page-h);
|
||||||
|
margin: 0; /* we handle margins inside the .sheet via padding */
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: var(--font);
|
||||||
|
margin: 1.5rem;
|
||||||
|
color: #222;
|
||||||
|
line-height: 1.35;
|
||||||
|
}
|
||||||
|
h1 { margin-bottom: .25rem; }
|
||||||
|
.subtle { color: #666; margin-top: 0; }
|
||||||
|
|
||||||
|
.wrap {
|
||||||
|
display: grid;
|
||||||
|
gap: 1.25rem;
|
||||||
|
max-width: 1200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pane {
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
.pane h2 { margin: 0 0 .75rem; font-size: 1.1rem; }
|
||||||
|
|
||||||
|
form { display: grid; gap: .75rem; }
|
||||||
|
.grid2 {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: .75rem 1rem;
|
||||||
|
}
|
||||||
|
label { font-weight: 600; }
|
||||||
|
input[type="text"], input[type="number"], input[type="file"] {
|
||||||
|
padding: .5rem .6rem;
|
||||||
|
border: 1px solid #bbb;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 1rem;
|
||||||
|
width: 100%;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
|
||||||
|
button {
|
||||||
|
padding: .6rem .9rem;
|
||||||
|
border: 1px solid #444;
|
||||||
|
background: #111; color: #fff;
|
||||||
|
border-radius: 8px; cursor: pointer; font-weight: 600;
|
||||||
|
}
|
||||||
|
.ghost { background: #f7f7f7; color: #222; border-color: #ccc; }
|
||||||
|
.info { font-size: .9rem; color: #555; }
|
||||||
|
.error {
|
||||||
|
padding: .75rem 1rem; border: 1px solid #d33; background: #fee; color: #a00;
|
||||||
|
border-radius: 8px; margin-bottom: .75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ====== SHEET LAYOUT ====== */
|
||||||
|
.sheets { display: grid; gap: 1rem; }
|
||||||
|
.sheet {
|
||||||
|
width: var(--page-w);
|
||||||
|
height: var(--page-h);
|
||||||
|
padding: var(--m-top) var(--m-right) var(--m-bottom) var(--m-left);
|
||||||
|
box-sizing: border-box;
|
||||||
|
background: white;
|
||||||
|
position: relative;
|
||||||
|
page-break-after: always;
|
||||||
|
}
|
||||||
|
.grid {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(<?= $cols ?>, var(--label-w));
|
||||||
|
grid-template-rows: repeat(<?= $rows ?>, var(--label-h));
|
||||||
|
column-gap: var(--gap-h);
|
||||||
|
row-gap: var(--gap-v);
|
||||||
|
justify-content: start; /* no stretching */
|
||||||
|
align-content: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cell {
|
||||||
|
width: var(--label-w);
|
||||||
|
height: var(--label-h);
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 0.06in; /* small inner padding for aesthetics; adjust if needed */
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
background: #fff;
|
||||||
|
border: calc(var(--show-outlines) * 1px) dashed #999; /* outline toggle for test prints */
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-text {
|
||||||
|
display: grid;
|
||||||
|
gap: 0.04in;
|
||||||
|
text-align: center;
|
||||||
|
margin: 0;
|
||||||
|
line-height: 1.2;
|
||||||
|
font-size: var(--font-in);
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
.label-text-line { white-space: pre-wrap; }
|
||||||
|
|
||||||
|
.barcode-block { display: flex; justify-content: center; align-items: flex-end; margin-top: 0.02in; }
|
||||||
|
.barcode-block svg { display: block; height: var(--barcode-h); width: auto; }
|
||||||
|
|
||||||
|
.controls { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
.pane, .controls, .error, .info, .subtle, h1 { display: none !important; }
|
||||||
|
body { margin: 0; background: white; }
|
||||||
|
.sheet { border: none; }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
function goPrint(){ window.print(); }
|
||||||
|
function jump(id){ document.getElementById(id)?.scrollIntoView({behavior:'smooth'}); }
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1>Label Generator</h1>
|
||||||
|
<p class="subtle">Import CSV and print to a **1.5" × 1.0"** template (Demco) at <strong>100% / Actual size</strong>.</p>
|
||||||
|
|
||||||
|
<div class="wrap">
|
||||||
|
|
||||||
|
<!-- Single label form -->
|
||||||
|
<div class="pane">
|
||||||
|
<h2>Single Label</h2>
|
||||||
|
<form method="post">
|
||||||
|
<input type="hidden" name="mode" value="single">
|
||||||
|
<!-- Preserve template params across submissions -->
|
||||||
|
<?php foreach ([
|
||||||
|
'page_width_in','page_height_in','margin_top_in','margin_right_in','margin_bottom_in','margin_left_in',
|
||||||
|
'cols','rows','label_w_in','label_h_in','gap_h_in','gap_v_in','barcode_h_in','font_in'
|
||||||
|
] as $p): ?>
|
||||||
|
<input type="hidden" name="<?= $p ?>" value="<?= safe($_POST[$p] ?? $defaults[$p] ?? '') ?>">
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php if ($show_outlines === '1'): ?><input type="hidden" name="show_outlines" value="1"><?php endif; ?>
|
||||||
|
|
||||||
|
<div class="grid2">
|
||||||
|
<div>
|
||||||
|
<label for="data1">Data 1</label>
|
||||||
|
<input type="text" id="data1" name="data1" value="<?= safe($data1) ?>" placeholder="e.g., QA76.73.P224">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="data2">Data 2</label>
|
||||||
|
<input type="text" id="data2" name="data2" value="<?= safe($data2) ?>" placeholder="e.g., 2025">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="data3">Data 3</label>
|
||||||
|
<input type="text" id="data3" name="data3" value="<?= safe($data3) ?>" placeholder="e.g., v.2">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="data4">Data 4</label>
|
||||||
|
<input type="text" id="data4" name="data4" value="<?= safe($data4) ?>" placeholder="e.g., Copy 1">
|
||||||
|
</div>
|
||||||
|
<div style="grid-column: 1 / -1;">
|
||||||
|
<label for="barcode">Barcode (alphanumeric)</label>
|
||||||
|
<input type="text" id="barcode" name="barcode" value="<?= safe($barcodeText) ?>" placeholder="e.g., 1230004231819">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="actions">
|
||||||
|
<button type="submit">Preview Single Label</button>
|
||||||
|
<button type="button" class="ghost" onclick="jump('csvpane')">Or Import CSV…</button>
|
||||||
|
</div>
|
||||||
|
<p class="info">Data Matrix prints as SVG at <strong><?= number_format($barcode_h_in, 2) ?> in</strong> height.</p>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- CSV import -->
|
||||||
|
<div class="pane" id="csvpane">
|
||||||
|
<h2>Import CSV (data1,data2,data3,data4,barcode)</h2>
|
||||||
|
<form method="post" enctype="multipart/form-data">
|
||||||
|
<input type="hidden" name="mode" value="csv">
|
||||||
|
<!-- persist template params -->
|
||||||
|
<div class="grid2">
|
||||||
|
<div style="grid-column: 1 / -1;">
|
||||||
|
<label for="csvfile">Choose CSV file</label>
|
||||||
|
<input type="file" id="csvfile" name="csvfile" accept=".csv,text/csv">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php foreach ([
|
||||||
|
'page_width_in','page_height_in','margin_top_in','margin_right_in','margin_bottom_in','margin_left_in',
|
||||||
|
'cols','rows','label_w_in','label_h_in','gap_h_in','gap_v_in','barcode_h_in','font_in'
|
||||||
|
] as $p): ?>
|
||||||
|
<input type="hidden" name="<?= $p ?>" value="<?= safe($_POST[$p] ?? $defaults[$p] ?? '') ?>">
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php if ($show_outlines === '1'): ?><input type="hidden" name="show_outlines" value="1"><?php endif; ?>
|
||||||
|
|
||||||
|
<div class="actions">
|
||||||
|
<button type="submit">Upload & Preview Labels</button>
|
||||||
|
<button type="reset" class="ghost">Reset</button>
|
||||||
|
</div>
|
||||||
|
<p class="info">Delimiters (comma, tab, semicolon) auto-detected. Headers must match exactly.</p>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Template settings -->
|
||||||
|
<div class="pane">
|
||||||
|
<h2>Template (Demco 1.5" × 1.0")</h2>
|
||||||
|
<form method="post">
|
||||||
|
<div class="grid2">
|
||||||
|
<div><label>Page width (in)</label><input type="number" step="0.01" name="page_width_in" value="<?= safe($page_width_in) ?>"></div>
|
||||||
|
<div><label>Page height (in)</label><input type="number" step="0.01" name="page_height_in" value="<?= safe($page_height_in) ?>"></div>
|
||||||
|
|
||||||
|
<div><label>Margin top (in)</label><input type="number" step="0.01" name="margin_top_in" value="<?= safe($margin_top_in) ?>"></div>
|
||||||
|
<div><label>Margin right (in)</label><input type="number" step="0.01" name="margin_right_in" value="<?= safe($margin_right_in) ?>"></div>
|
||||||
|
<div><label>Margin bottom (in)</label><input type="number" step="0.01" name="margin_bottom_in" value="<?= safe($margin_bottom_in) ?>"></div>
|
||||||
|
<div><label>Margin left (in)</label><input type="number" step="0.01" name="margin_left_in" value="<?= safe($margin_left_in) ?>"></div>
|
||||||
|
|
||||||
|
<div><label>Columns</label><input type="number" step="1" min="1" name="cols" value="<?= safe($cols) ?>"></div>
|
||||||
|
<div><label>Rows</label><input type="number" step="1" min="1" name="rows" value="<?= safe($rows) ?>"></div>
|
||||||
|
|
||||||
|
<div><label>Label width (in)</label><input type="number" step="0.01" name="label_w_in" value="<?= safe($label_w_in) ?>"></div>
|
||||||
|
<div><label>Label height (in)</label><input type="number" step="0.01" name="label_h_in" value="<?= safe($label_h_in) ?>"></div>
|
||||||
|
|
||||||
|
<div><label>Horizontal gap (in)</label><input type="number" step="0.01" name="gap_h_in" value="<?= safe($gap_h_in) ?>"></div>
|
||||||
|
<div><label>Vertical gap (in)</label><input type="number" step="0.01" name="gap_v_in" value="<?= safe($gap_v_in) ?>"></div>
|
||||||
|
|
||||||
|
<div><label>Barcode height (in)</label><input type="number" step="0.01" name="barcode_h_in" value="<?= safe($barcode_h_in) ?>"></div>
|
||||||
|
<div><label>Font size (in)</label><input type="number" step="0.01" name="font_in" value="<?= safe($font_in) ?>"></div>
|
||||||
|
|
||||||
|
<div style="grid-column: 1 / -1; display:flex; align-items:center; gap:.5rem;">
|
||||||
|
<input type="checkbox" id="show_outlines" name="show_outlines" value="1" <?= $show_outlines==='1'?'checked':'' ?>>
|
||||||
|
<label for="show_outlines">Show label outlines (for alignment/test prints)</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Keep any uploaded/entered data visible on re-submit by passing the last single entry (optional) -->
|
||||||
|
<input type="hidden" name="mode" value="<?= safe($mode ?: 'single') ?>">
|
||||||
|
<input type="hidden" name="data1" value="<?= safe($data1) ?>">
|
||||||
|
<input type="hidden" name="data2" value="<?= safe($data2) ?>">
|
||||||
|
<input type="hidden" name="data3" value="<?= safe($data3) ?>">
|
||||||
|
<input type="hidden" name="data4" value="<?= safe($data4) ?>">
|
||||||
|
<input type="hidden" name="barcode" value="<?= safe($barcodeText) ?>">
|
||||||
|
|
||||||
|
<div class="actions">
|
||||||
|
<button type="submit">Apply Template Settings</button>
|
||||||
|
<button type="button" class="ghost" onclick="goPrint()">Print</button>
|
||||||
|
</div>
|
||||||
|
<p class="info">
|
||||||
|
<strong>Tip:</strong> Do a test print on plain paper with “Show label outlines” checked.
|
||||||
|
Hold it behind a real sheet to check alignment, then tweak margins/gaps as needed.
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Errors -->
|
||||||
|
<?php if (!empty($errors)): ?>
|
||||||
|
<div class="error">
|
||||||
|
<strong>Issues:</strong>
|
||||||
|
<ul><?php foreach ($errors as $e): ?><li><?= $e ?></li><?php endforeach; ?></ul>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<!-- Preview / Sheets -->
|
||||||
|
<?php if ($records && !$errors): ?>
|
||||||
|
<div class="controls">
|
||||||
|
<button onclick="goPrint()">Print</button>
|
||||||
|
<span class="info"><?= count($records) ?> label(s), <?= count($pages) ?> sheet(s) @ <?= $cols ?>×<?= $rows ?>.</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="sheets">
|
||||||
|
<?php foreach ($pages as $pageIndex => $pageRecs): ?>
|
||||||
|
<div class="sheet">
|
||||||
|
<div class="grid">
|
||||||
|
<?php
|
||||||
|
// Fill cells row-major: put records first, blank cells if fewer than capacity.
|
||||||
|
$count = count($pageRecs);
|
||||||
|
$capacity = $cols * $rows;
|
||||||
|
for ($i = 0; $i < $capacity; $i++):
|
||||||
|
$rec = $pageRecs[$i] ?? null;
|
||||||
|
?>
|
||||||
|
<div class="cell">
|
||||||
|
<?php if ($rec): ?>
|
||||||
|
<div class="label-text">
|
||||||
|
<div class="label-text-line"><?= nl2br(safe($rec['data1'] ?? '')) ?></div>
|
||||||
|
<div class="label-text-line"><?= nl2br(safe($rec['data2'] ?? '')) ?></div>
|
||||||
|
<div class="label-text-line"><?= nl2br(safe($rec['data3'] ?? '')) ?></div>
|
||||||
|
<div class="label-text-line"><?= nl2br(safe($rec['data4'] ?? '')) ?></div>
|
||||||
|
</div>
|
||||||
|
<div class="barcode-block">
|
||||||
|
<?= render_datamatrix_svg((string)($rec['barcode'] ?? '')) ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
<?php endfor; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if (!$autoloadOk): ?>
|
||||||
|
<div class="error">
|
||||||
|
Composer autoload not found. Install the barcode library with:<br>
|
||||||
|
<code>composer require tecnickcom/tc-lib-barcode</code><br>
|
||||||
|
(Make sure BCMath is enabled.)
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
216
index.php
Normal file
216
index.php
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
<?php
|
||||||
|
// Databrae (working name)
|
||||||
|
// Proof of concept
|
||||||
|
|
||||||
|
$autoloadOk = file_exists(__DIR__ . '/vendor/autoload.php');
|
||||||
|
if ($autoloadOk) {
|
||||||
|
require __DIR__ . '/vendor/autoload.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Using Tecnick's barcode library to generate data matrix barcodes
|
||||||
|
use Com\Tecnick\Barcode\Barcode;
|
||||||
|
|
||||||
|
function safe($s) {
|
||||||
|
return htmlspecialchars(trim($s ?? ''), ENT_QUOTES, 'UTF-8');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set up the form input
|
||||||
|
$data1 = $_POST['data1'] ?? '';
|
||||||
|
$data2 = $_POST['data2'] ?? '';
|
||||||
|
$data3 = $_POST['data3'] ?? '';
|
||||||
|
$data4 = $_POST['data4'] ?? '';
|
||||||
|
$barcodeText = $_POST['barcode'] ?? '';
|
||||||
|
$isPosted = ($_SERVER['REQUEST_METHOD'] === 'POST');
|
||||||
|
|
||||||
|
// Declare some variables
|
||||||
|
$svgBarcode = '';
|
||||||
|
$errorMsg = '';
|
||||||
|
|
||||||
|
// Generate the data matrix barcode and handle some common errors where I've already screwed up
|
||||||
|
if ($isPosted) {
|
||||||
|
if (!$autoloadOk) {
|
||||||
|
$errorMsg = 'Composer autoload not found. Run <code>composer require tecnickcom/tc-lib-barcode</code> in this folder.';
|
||||||
|
} elseif ($barcodeText === '') {
|
||||||
|
$errorMsg = 'Please provide a Barcode value.';
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
$barcode = new Barcode();
|
||||||
|
|
||||||
|
// Create the data matrix as an SVG
|
||||||
|
$bobj = $barcode->getBarcodeObj(
|
||||||
|
'DATAMATRIX',
|
||||||
|
$barcodeText,
|
||||||
|
-1, // width auto
|
||||||
|
-1, // height auto
|
||||||
|
'black',
|
||||||
|
[0, 0, 0, 0]
|
||||||
|
);
|
||||||
|
$bobj->setBackgroundColor('white');
|
||||||
|
$svgBarcode = $bobj->getSvgCode();
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
$errorMsg = 'Barcode generation error: ' . safe($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Spine Label Generator</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--font: "Helvetica Neue", Arial, sans-serif;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
font-family: var(--font);
|
||||||
|
margin: 1.5rem;
|
||||||
|
color: #222;
|
||||||
|
line-height: 1.35;
|
||||||
|
}
|
||||||
|
form {
|
||||||
|
display: grid;
|
||||||
|
gap: .75rem;
|
||||||
|
max-width: 520px;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
||||||
|
label { font-weight: 600; }
|
||||||
|
input[type="text"] {
|
||||||
|
padding: .5rem .6rem;
|
||||||
|
border: 1px solid #bbb;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 1rem;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.row { display: grid; gap: .35rem; }
|
||||||
|
.actions { margin-top: .5rem; }
|
||||||
|
button {
|
||||||
|
padding: .6rem .9rem;
|
||||||
|
border: 1px solid #444;
|
||||||
|
background: #111;
|
||||||
|
color: #fff;
|
||||||
|
border-radius: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
button:hover { filter: brightness(1.05); }
|
||||||
|
|
||||||
|
.note {
|
||||||
|
font-size: .9rem;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
.error {
|
||||||
|
padding: .75rem 1rem;
|
||||||
|
border: 1px solid #d33;
|
||||||
|
background: #fee;
|
||||||
|
color: #a00;
|
||||||
|
border-radius: 8px;
|
||||||
|
max-width: 520px;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== Label (exact print size) ===== */
|
||||||
|
.preview-wrap {
|
||||||
|
display: grid;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
.label-card {
|
||||||
|
width: 2.5cm; /* fixed physical width */
|
||||||
|
height: 3.5cm; /* fixed physical height */
|
||||||
|
box-sizing: border-box; /* include padding in the fixed size */
|
||||||
|
border: 1px dashed #aaa;/* guide border (hidden on print) */
|
||||||
|
padding: 0.2cm; /* compact padding to fit content */
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between; /* push barcode to bottom */
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-text {
|
||||||
|
display: grid;
|
||||||
|
gap: 0.1cm; /* tight vertical spacing between Data 1–3 */
|
||||||
|
text-align: center; /* center the three lines */
|
||||||
|
margin: .2cm;
|
||||||
|
line-height: 1.2;
|
||||||
|
font-size: 0.35cm; /* ~8pt—adjust as needed */
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
.label-text-line { white-space: pre-wrap; }
|
||||||
|
|
||||||
|
.barcode-block {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center; /* center code horizontally */
|
||||||
|
align-items: flex-end;
|
||||||
|
margin-top: 0.05cm; /* tiny breathing room under Data 3 */
|
||||||
|
}
|
||||||
|
/* Keep the Data Matrix exactly 1.5 cm in height; width auto to keep it square */
|
||||||
|
.barcode-block svg {
|
||||||
|
display: block;
|
||||||
|
height: .5cm; /* requested fixed height */
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
form, .note, .error, h1 { display: none !important; }
|
||||||
|
body { margin: 0; }
|
||||||
|
.label-card { border: none; } /* remove guide border on print */
|
||||||
|
/* Ensure the browser doesn't scale */
|
||||||
|
@page { margin: 0; }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1>Spine Label Generator</h1>
|
||||||
|
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<label for="data1">Data 1</label>
|
||||||
|
<input type="text" id="data1" name="data1" value="<?= safe($data1) ?>" placeholder="e.g., QA76.73.P224">
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label for="data2">Data 2</label>
|
||||||
|
<input type="text" id="data2" name="data2" value="<?= safe($data2) ?>" placeholder="e.g., 2025">
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label for="data3">Data 3</label>
|
||||||
|
<input type="text" id="data3" name="data3" value="<?= safe($data3) ?>" placeholder="e.g., v.2">
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label for="data4">Data 4</label>
|
||||||
|
<input type="text" id="data4" name="data4" value="<?= safe($_POST['data4'] ?? '') ?>" placeholder="e.g., Copy 1">
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label for="barcode">Barcode (alphanumeric)</label>
|
||||||
|
<input type="text" id="barcode" name="barcode" value="<?= safe($barcodeText) ?>" placeholder="e.g., 1230004231819">
|
||||||
|
</div>
|
||||||
|
<div class="actions">
|
||||||
|
<button type="submit">Build Label</button>
|
||||||
|
</div>
|
||||||
|
<p class="note">Tip: In the browser print dialog, set scale to <strong>100% / Actual size</strong>.</p>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php if ($errorMsg): ?>
|
||||||
|
<div class="error"><?= $errorMsg ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($isPosted && !$errorMsg): ?>
|
||||||
|
<div class="preview-wrap">
|
||||||
|
<div class="label-card">
|
||||||
|
<div class="label-text">
|
||||||
|
<div class="label-text-line"><?= nl2br(safe($data1)) ?></div>
|
||||||
|
<div class="label-text-line"><?= nl2br(safe($data2)) ?></div>
|
||||||
|
<div class="label-text-line"><?= nl2br(safe($data3)) ?></div>
|
||||||
|
<div class="label-text-line"><?= nl2br(safe($_POST['data4'] ?? '')) ?></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="barcode-block">
|
||||||
|
<?= $svgBarcode /* Inline SVG keeps print quality high */ ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
25
vendor/autoload.php
vendored
Normal file
25
vendor/autoload.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload.php @generated by Composer
|
||||||
|
|
||||||
|
if (PHP_VERSION_ID < 50600) {
|
||||||
|
if (!headers_sent()) {
|
||||||
|
header('HTTP/1.1 500 Internal Server Error');
|
||||||
|
}
|
||||||
|
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
|
||||||
|
if (!ini_get('display_errors')) {
|
||||||
|
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||||
|
fwrite(STDERR, $err);
|
||||||
|
} elseif (!headers_sent()) {
|
||||||
|
echo $err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
trigger_error(
|
||||||
|
$err,
|
||||||
|
E_USER_ERROR
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once __DIR__ . '/composer/autoload_real.php';
|
||||||
|
|
||||||
|
return ComposerAutoloaderInitd5ed540bdb8bd184c88ae0e4cb8f041f::getLoader();
|
||||||
579
vendor/composer/ClassLoader.php
vendored
Normal file
579
vendor/composer/ClassLoader.php
vendored
Normal file
@@ -0,0 +1,579 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Composer.
|
||||||
|
*
|
||||||
|
* (c) Nils Adermann <naderman@naderman.de>
|
||||||
|
* Jordi Boggiano <j.boggiano@seld.be>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Composer\Autoload;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
||||||
|
*
|
||||||
|
* $loader = new \Composer\Autoload\ClassLoader();
|
||||||
|
*
|
||||||
|
* // register classes with namespaces
|
||||||
|
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||||
|
* $loader->add('Symfony', __DIR__.'/framework');
|
||||||
|
*
|
||||||
|
* // activate the autoloader
|
||||||
|
* $loader->register();
|
||||||
|
*
|
||||||
|
* // to enable searching the include path (eg. for PEAR packages)
|
||||||
|
* $loader->setUseIncludePath(true);
|
||||||
|
*
|
||||||
|
* In this example, if you try to use a class in the Symfony\Component
|
||||||
|
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||||
|
* the autoloader will first look for the class under the component/
|
||||||
|
* directory, and it will then fallback to the framework/ directory if not
|
||||||
|
* found before giving up.
|
||||||
|
*
|
||||||
|
* This class is loosely based on the Symfony UniversalClassLoader.
|
||||||
|
*
|
||||||
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||||
|
* @see https://www.php-fig.org/psr/psr-0/
|
||||||
|
* @see https://www.php-fig.org/psr/psr-4/
|
||||||
|
*/
|
||||||
|
class ClassLoader
|
||||||
|
{
|
||||||
|
/** @var \Closure(string):void */
|
||||||
|
private static $includeFile;
|
||||||
|
|
||||||
|
/** @var string|null */
|
||||||
|
private $vendorDir;
|
||||||
|
|
||||||
|
// PSR-4
|
||||||
|
/**
|
||||||
|
* @var array<string, array<string, int>>
|
||||||
|
*/
|
||||||
|
private $prefixLengthsPsr4 = array();
|
||||||
|
/**
|
||||||
|
* @var array<string, list<string>>
|
||||||
|
*/
|
||||||
|
private $prefixDirsPsr4 = array();
|
||||||
|
/**
|
||||||
|
* @var list<string>
|
||||||
|
*/
|
||||||
|
private $fallbackDirsPsr4 = array();
|
||||||
|
|
||||||
|
// PSR-0
|
||||||
|
/**
|
||||||
|
* List of PSR-0 prefixes
|
||||||
|
*
|
||||||
|
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
|
||||||
|
*
|
||||||
|
* @var array<string, array<string, list<string>>>
|
||||||
|
*/
|
||||||
|
private $prefixesPsr0 = array();
|
||||||
|
/**
|
||||||
|
* @var list<string>
|
||||||
|
*/
|
||||||
|
private $fallbackDirsPsr0 = array();
|
||||||
|
|
||||||
|
/** @var bool */
|
||||||
|
private $useIncludePath = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
private $classMap = array();
|
||||||
|
|
||||||
|
/** @var bool */
|
||||||
|
private $classMapAuthoritative = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array<string, bool>
|
||||||
|
*/
|
||||||
|
private $missingClasses = array();
|
||||||
|
|
||||||
|
/** @var string|null */
|
||||||
|
private $apcuPrefix;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array<string, self>
|
||||||
|
*/
|
||||||
|
private static $registeredLoaders = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string|null $vendorDir
|
||||||
|
*/
|
||||||
|
public function __construct($vendorDir = null)
|
||||||
|
{
|
||||||
|
$this->vendorDir = $vendorDir;
|
||||||
|
self::initializeIncludeClosure();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, list<string>>
|
||||||
|
*/
|
||||||
|
public function getPrefixes()
|
||||||
|
{
|
||||||
|
if (!empty($this->prefixesPsr0)) {
|
||||||
|
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
|
||||||
|
}
|
||||||
|
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, list<string>>
|
||||||
|
*/
|
||||||
|
public function getPrefixesPsr4()
|
||||||
|
{
|
||||||
|
return $this->prefixDirsPsr4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public function getFallbackDirs()
|
||||||
|
{
|
||||||
|
return $this->fallbackDirsPsr0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public function getFallbackDirsPsr4()
|
||||||
|
{
|
||||||
|
return $this->fallbackDirsPsr4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string> Array of classname => path
|
||||||
|
*/
|
||||||
|
public function getClassMap()
|
||||||
|
{
|
||||||
|
return $this->classMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, string> $classMap Class to filename map
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function addClassMap(array $classMap)
|
||||||
|
{
|
||||||
|
if ($this->classMap) {
|
||||||
|
$this->classMap = array_merge($this->classMap, $classMap);
|
||||||
|
} else {
|
||||||
|
$this->classMap = $classMap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a set of PSR-0 directories for a given prefix, either
|
||||||
|
* appending or prepending to the ones previously set for this prefix.
|
||||||
|
*
|
||||||
|
* @param string $prefix The prefix
|
||||||
|
* @param list<string>|string $paths The PSR-0 root directories
|
||||||
|
* @param bool $prepend Whether to prepend the directories
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function add($prefix, $paths, $prepend = false)
|
||||||
|
{
|
||||||
|
$paths = (array) $paths;
|
||||||
|
if (!$prefix) {
|
||||||
|
if ($prepend) {
|
||||||
|
$this->fallbackDirsPsr0 = array_merge(
|
||||||
|
$paths,
|
||||||
|
$this->fallbackDirsPsr0
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->fallbackDirsPsr0 = array_merge(
|
||||||
|
$this->fallbackDirsPsr0,
|
||||||
|
$paths
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$first = $prefix[0];
|
||||||
|
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||||
|
$this->prefixesPsr0[$first][$prefix] = $paths;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($prepend) {
|
||||||
|
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||||
|
$paths,
|
||||||
|
$this->prefixesPsr0[$first][$prefix]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||||
|
$this->prefixesPsr0[$first][$prefix],
|
||||||
|
$paths
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a set of PSR-4 directories for a given namespace, either
|
||||||
|
* appending or prepending to the ones previously set for this namespace.
|
||||||
|
*
|
||||||
|
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||||
|
* @param list<string>|string $paths The PSR-4 base directories
|
||||||
|
* @param bool $prepend Whether to prepend the directories
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function addPsr4($prefix, $paths, $prepend = false)
|
||||||
|
{
|
||||||
|
$paths = (array) $paths;
|
||||||
|
if (!$prefix) {
|
||||||
|
// Register directories for the root namespace.
|
||||||
|
if ($prepend) {
|
||||||
|
$this->fallbackDirsPsr4 = array_merge(
|
||||||
|
$paths,
|
||||||
|
$this->fallbackDirsPsr4
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->fallbackDirsPsr4 = array_merge(
|
||||||
|
$this->fallbackDirsPsr4,
|
||||||
|
$paths
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||||
|
// Register directories for a new namespace.
|
||||||
|
$length = strlen($prefix);
|
||||||
|
if ('\\' !== $prefix[$length - 1]) {
|
||||||
|
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||||
|
}
|
||||||
|
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||||
|
$this->prefixDirsPsr4[$prefix] = $paths;
|
||||||
|
} elseif ($prepend) {
|
||||||
|
// Prepend directories for an already registered namespace.
|
||||||
|
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||||
|
$paths,
|
||||||
|
$this->prefixDirsPsr4[$prefix]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Append directories for an already registered namespace.
|
||||||
|
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||||
|
$this->prefixDirsPsr4[$prefix],
|
||||||
|
$paths
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a set of PSR-0 directories for a given prefix,
|
||||||
|
* replacing any others previously set for this prefix.
|
||||||
|
*
|
||||||
|
* @param string $prefix The prefix
|
||||||
|
* @param list<string>|string $paths The PSR-0 base directories
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function set($prefix, $paths)
|
||||||
|
{
|
||||||
|
if (!$prefix) {
|
||||||
|
$this->fallbackDirsPsr0 = (array) $paths;
|
||||||
|
} else {
|
||||||
|
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a set of PSR-4 directories for a given namespace,
|
||||||
|
* replacing any others previously set for this namespace.
|
||||||
|
*
|
||||||
|
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||||
|
* @param list<string>|string $paths The PSR-4 base directories
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setPsr4($prefix, $paths)
|
||||||
|
{
|
||||||
|
if (!$prefix) {
|
||||||
|
$this->fallbackDirsPsr4 = (array) $paths;
|
||||||
|
} else {
|
||||||
|
$length = strlen($prefix);
|
||||||
|
if ('\\' !== $prefix[$length - 1]) {
|
||||||
|
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||||
|
}
|
||||||
|
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||||
|
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns on searching the include path for class files.
|
||||||
|
*
|
||||||
|
* @param bool $useIncludePath
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setUseIncludePath($useIncludePath)
|
||||||
|
{
|
||||||
|
$this->useIncludePath = $useIncludePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can be used to check if the autoloader uses the include path to check
|
||||||
|
* for classes.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getUseIncludePath()
|
||||||
|
{
|
||||||
|
return $this->useIncludePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns off searching the prefix and fallback directories for classes
|
||||||
|
* that have not been registered with the class map.
|
||||||
|
*
|
||||||
|
* @param bool $classMapAuthoritative
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setClassMapAuthoritative($classMapAuthoritative)
|
||||||
|
{
|
||||||
|
$this->classMapAuthoritative = $classMapAuthoritative;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should class lookup fail if not found in the current class map?
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isClassMapAuthoritative()
|
||||||
|
{
|
||||||
|
return $this->classMapAuthoritative;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
||||||
|
*
|
||||||
|
* @param string|null $apcuPrefix
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setApcuPrefix($apcuPrefix)
|
||||||
|
{
|
||||||
|
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The APCu prefix in use, or null if APCu caching is not enabled.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getApcuPrefix()
|
||||||
|
{
|
||||||
|
return $this->apcuPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers this instance as an autoloader.
|
||||||
|
*
|
||||||
|
* @param bool $prepend Whether to prepend the autoloader or not
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register($prepend = false)
|
||||||
|
{
|
||||||
|
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||||
|
|
||||||
|
if (null === $this->vendorDir) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($prepend) {
|
||||||
|
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
|
||||||
|
} else {
|
||||||
|
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||||
|
self::$registeredLoaders[$this->vendorDir] = $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregisters this instance as an autoloader.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function unregister()
|
||||||
|
{
|
||||||
|
spl_autoload_unregister(array($this, 'loadClass'));
|
||||||
|
|
||||||
|
if (null !== $this->vendorDir) {
|
||||||
|
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the given class or interface.
|
||||||
|
*
|
||||||
|
* @param string $class The name of the class
|
||||||
|
* @return true|null True if loaded, null otherwise
|
||||||
|
*/
|
||||||
|
public function loadClass($class)
|
||||||
|
{
|
||||||
|
if ($file = $this->findFile($class)) {
|
||||||
|
$includeFile = self::$includeFile;
|
||||||
|
$includeFile($file);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the path to the file where the class is defined.
|
||||||
|
*
|
||||||
|
* @param string $class The name of the class
|
||||||
|
*
|
||||||
|
* @return string|false The path if found, false otherwise
|
||||||
|
*/
|
||||||
|
public function findFile($class)
|
||||||
|
{
|
||||||
|
// class map lookup
|
||||||
|
if (isset($this->classMap[$class])) {
|
||||||
|
return $this->classMap[$class];
|
||||||
|
}
|
||||||
|
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (null !== $this->apcuPrefix) {
|
||||||
|
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
||||||
|
if ($hit) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = $this->findFileWithExtension($class, '.php');
|
||||||
|
|
||||||
|
// Search for Hack files if we are running on HHVM
|
||||||
|
if (false === $file && defined('HHVM_VERSION')) {
|
||||||
|
$file = $this->findFileWithExtension($class, '.hh');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== $this->apcuPrefix) {
|
||||||
|
apcu_add($this->apcuPrefix.$class, $file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (false === $file) {
|
||||||
|
// Remember that this class does not exist.
|
||||||
|
$this->missingClasses[$class] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the currently registered loaders keyed by their corresponding vendor directories.
|
||||||
|
*
|
||||||
|
* @return array<string, self>
|
||||||
|
*/
|
||||||
|
public static function getRegisteredLoaders()
|
||||||
|
{
|
||||||
|
return self::$registeredLoaders;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $class
|
||||||
|
* @param string $ext
|
||||||
|
* @return string|false
|
||||||
|
*/
|
||||||
|
private function findFileWithExtension($class, $ext)
|
||||||
|
{
|
||||||
|
// PSR-4 lookup
|
||||||
|
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||||
|
|
||||||
|
$first = $class[0];
|
||||||
|
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||||
|
$subPath = $class;
|
||||||
|
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
||||||
|
$subPath = substr($subPath, 0, $lastPos);
|
||||||
|
$search = $subPath . '\\';
|
||||||
|
if (isset($this->prefixDirsPsr4[$search])) {
|
||||||
|
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
||||||
|
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
||||||
|
if (file_exists($file = $dir . $pathEnd)) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PSR-4 fallback dirs
|
||||||
|
foreach ($this->fallbackDirsPsr4 as $dir) {
|
||||||
|
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PSR-0 lookup
|
||||||
|
if (false !== $pos = strrpos($class, '\\')) {
|
||||||
|
// namespaced class name
|
||||||
|
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
||||||
|
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
||||||
|
} else {
|
||||||
|
// PEAR-like class name
|
||||||
|
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($this->prefixesPsr0[$first])) {
|
||||||
|
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
||||||
|
if (0 === strpos($class, $prefix)) {
|
||||||
|
foreach ($dirs as $dir) {
|
||||||
|
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PSR-0 fallback dirs
|
||||||
|
foreach ($this->fallbackDirsPsr0 as $dir) {
|
||||||
|
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PSR-0 include paths.
|
||||||
|
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private static function initializeIncludeClosure()
|
||||||
|
{
|
||||||
|
if (self::$includeFile !== null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope isolated include.
|
||||||
|
*
|
||||||
|
* Prevents access to $this/self from included files.
|
||||||
|
*
|
||||||
|
* @param string $file
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
self::$includeFile = \Closure::bind(static function($file) {
|
||||||
|
include $file;
|
||||||
|
}, null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
359
vendor/composer/InstalledVersions.php
vendored
Normal file
359
vendor/composer/InstalledVersions.php
vendored
Normal file
@@ -0,0 +1,359 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Composer.
|
||||||
|
*
|
||||||
|
* (c) Nils Adermann <naderman@naderman.de>
|
||||||
|
* Jordi Boggiano <j.boggiano@seld.be>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Composer;
|
||||||
|
|
||||||
|
use Composer\Autoload\ClassLoader;
|
||||||
|
use Composer\Semver\VersionParser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is copied in every Composer installed project and available to all
|
||||||
|
*
|
||||||
|
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
||||||
|
*
|
||||||
|
* To require its presence, you can require `composer-runtime-api ^2.0`
|
||||||
|
*
|
||||||
|
* @final
|
||||||
|
*/
|
||||||
|
class InstalledVersions
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var mixed[]|null
|
||||||
|
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
|
||||||
|
*/
|
||||||
|
private static $installed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool|null
|
||||||
|
*/
|
||||||
|
private static $canGetVendors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array[]
|
||||||
|
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||||
|
*/
|
||||||
|
private static $installedByVendor = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of all package names which are present, either by being installed, replaced or provided
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
|
* @psalm-return list<string>
|
||||||
|
*/
|
||||||
|
public static function getInstalledPackages()
|
||||||
|
{
|
||||||
|
$packages = array();
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
$packages[] = array_keys($installed['versions']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (1 === \count($packages)) {
|
||||||
|
return $packages[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of all package names with a specific type e.g. 'library'
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @return string[]
|
||||||
|
* @psalm-return list<string>
|
||||||
|
*/
|
||||||
|
public static function getInstalledPackagesByType($type)
|
||||||
|
{
|
||||||
|
$packagesByType = array();
|
||||||
|
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
foreach ($installed['versions'] as $name => $package) {
|
||||||
|
if (isset($package['type']) && $package['type'] === $type) {
|
||||||
|
$packagesByType[] = $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $packagesByType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the given package is installed
|
||||||
|
*
|
||||||
|
* This also returns true if the package name is provided or replaced by another package
|
||||||
|
*
|
||||||
|
* @param string $packageName
|
||||||
|
* @param bool $includeDevRequirements
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function isInstalled($packageName, $includeDevRequirements = true)
|
||||||
|
{
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
if (isset($installed['versions'][$packageName])) {
|
||||||
|
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the given package satisfies a version constraint
|
||||||
|
*
|
||||||
|
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
|
||||||
|
*
|
||||||
|
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
|
||||||
|
*
|
||||||
|
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
|
||||||
|
* @param string $packageName
|
||||||
|
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
||||||
|
{
|
||||||
|
$constraint = $parser->parseConstraints((string) $constraint);
|
||||||
|
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
||||||
|
|
||||||
|
return $provided->matches($constraint);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a version constraint representing all the range(s) which are installed for a given package
|
||||||
|
*
|
||||||
|
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
|
||||||
|
* whether a given version of a package is installed, and not just whether it exists
|
||||||
|
*
|
||||||
|
* @param string $packageName
|
||||||
|
* @return string Version constraint usable with composer/semver
|
||||||
|
*/
|
||||||
|
public static function getVersionRanges($packageName)
|
||||||
|
{
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
if (!isset($installed['versions'][$packageName])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ranges = array();
|
||||||
|
if (isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||||
|
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
|
||||||
|
}
|
||||||
|
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
|
||||||
|
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
|
||||||
|
}
|
||||||
|
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
|
||||||
|
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
|
||||||
|
}
|
||||||
|
if (array_key_exists('provided', $installed['versions'][$packageName])) {
|
||||||
|
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode(' || ', $ranges);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $packageName
|
||||||
|
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
||||||
|
*/
|
||||||
|
public static function getVersion($packageName)
|
||||||
|
{
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
if (!isset($installed['versions'][$packageName])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($installed['versions'][$packageName]['version'])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $installed['versions'][$packageName]['version'];
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $packageName
|
||||||
|
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
||||||
|
*/
|
||||||
|
public static function getPrettyVersion($packageName)
|
||||||
|
{
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
if (!isset($installed['versions'][$packageName])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $installed['versions'][$packageName]['pretty_version'];
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $packageName
|
||||||
|
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
|
||||||
|
*/
|
||||||
|
public static function getReference($packageName)
|
||||||
|
{
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
if (!isset($installed['versions'][$packageName])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($installed['versions'][$packageName]['reference'])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $installed['versions'][$packageName]['reference'];
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $packageName
|
||||||
|
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
|
||||||
|
*/
|
||||||
|
public static function getInstallPath($packageName)
|
||||||
|
{
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
if (!isset($installed['versions'][$packageName])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
* @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
|
||||||
|
*/
|
||||||
|
public static function getRootPackage()
|
||||||
|
{
|
||||||
|
$installed = self::getInstalled();
|
||||||
|
|
||||||
|
return $installed[0]['root'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the raw installed.php data for custom implementations
|
||||||
|
*
|
||||||
|
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
||||||
|
* @return array[]
|
||||||
|
* @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
|
||||||
|
*/
|
||||||
|
public static function getRawData()
|
||||||
|
{
|
||||||
|
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
if (null === self::$installed) {
|
||||||
|
// only require the installed.php file if this file is loaded from its dumped location,
|
||||||
|
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||||
|
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||||
|
self::$installed = include __DIR__ . '/installed.php';
|
||||||
|
} else {
|
||||||
|
self::$installed = array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$installed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
||||||
|
*
|
||||||
|
* @return array[]
|
||||||
|
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||||
|
*/
|
||||||
|
public static function getAllRawData()
|
||||||
|
{
|
||||||
|
return self::getInstalled();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lets you reload the static array from another file
|
||||||
|
*
|
||||||
|
* This is only useful for complex integrations in which a project needs to use
|
||||||
|
* this class but then also needs to execute another project's autoloader in process,
|
||||||
|
* and wants to ensure both projects have access to their version of installed.php.
|
||||||
|
*
|
||||||
|
* A typical case would be PHPUnit, where it would need to make sure it reads all
|
||||||
|
* the data it needs from this class, then call reload() with
|
||||||
|
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
|
||||||
|
* the project in which it runs can then also use this class safely, without
|
||||||
|
* interference between PHPUnit's dependencies and the project's dependencies.
|
||||||
|
*
|
||||||
|
* @param array[] $data A vendor/composer/installed.php data set
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
|
||||||
|
*/
|
||||||
|
public static function reload($data)
|
||||||
|
{
|
||||||
|
self::$installed = $data;
|
||||||
|
self::$installedByVendor = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array[]
|
||||||
|
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||||
|
*/
|
||||||
|
private static function getInstalled()
|
||||||
|
{
|
||||||
|
if (null === self::$canGetVendors) {
|
||||||
|
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
|
||||||
|
}
|
||||||
|
|
||||||
|
$installed = array();
|
||||||
|
|
||||||
|
if (self::$canGetVendors) {
|
||||||
|
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
||||||
|
if (isset(self::$installedByVendor[$vendorDir])) {
|
||||||
|
$installed[] = self::$installedByVendor[$vendorDir];
|
||||||
|
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
||||||
|
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||||
|
$required = require $vendorDir.'/composer/installed.php';
|
||||||
|
$installed[] = self::$installedByVendor[$vendorDir] = $required;
|
||||||
|
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
||||||
|
self::$installed = $installed[count($installed) - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === self::$installed) {
|
||||||
|
// only require the installed.php file if this file is loaded from its dumped location,
|
||||||
|
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||||
|
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||||
|
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||||
|
$required = require __DIR__ . '/installed.php';
|
||||||
|
self::$installed = $required;
|
||||||
|
} else {
|
||||||
|
self::$installed = array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self::$installed !== array()) {
|
||||||
|
$installed[] = self::$installed;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $installed;
|
||||||
|
}
|
||||||
|
}
|
||||||
19
vendor/composer/LICENSE
vendored
Normal file
19
vendor/composer/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
Copyright (c) Nils Adermann, Jordi Boggiano
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is furnished
|
||||||
|
to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
10
vendor/composer/autoload_classmap.php
vendored
Normal file
10
vendor/composer/autoload_classmap.php
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_classmap.php @generated by Composer
|
||||||
|
|
||||||
|
$vendorDir = dirname(__DIR__);
|
||||||
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||||
|
);
|
||||||
9
vendor/composer/autoload_namespaces.php
vendored
Normal file
9
vendor/composer/autoload_namespaces.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_namespaces.php @generated by Composer
|
||||||
|
|
||||||
|
$vendorDir = dirname(__DIR__);
|
||||||
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
);
|
||||||
11
vendor/composer/autoload_psr4.php
vendored
Normal file
11
vendor/composer/autoload_psr4.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_psr4.php @generated by Composer
|
||||||
|
|
||||||
|
$vendorDir = dirname(__DIR__);
|
||||||
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'Com\\Tecnick\\Color\\' => array($vendorDir . '/tecnickcom/tc-lib-color/src'),
|
||||||
|
'Com\\Tecnick\\Barcode\\' => array($vendorDir . '/tecnickcom/tc-lib-barcode/src'),
|
||||||
|
);
|
||||||
38
vendor/composer/autoload_real.php
vendored
Normal file
38
vendor/composer/autoload_real.php
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_real.php @generated by Composer
|
||||||
|
|
||||||
|
class ComposerAutoloaderInitd5ed540bdb8bd184c88ae0e4cb8f041f
|
||||||
|
{
|
||||||
|
private static $loader;
|
||||||
|
|
||||||
|
public static function loadClassLoader($class)
|
||||||
|
{
|
||||||
|
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||||
|
require __DIR__ . '/ClassLoader.php';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Composer\Autoload\ClassLoader
|
||||||
|
*/
|
||||||
|
public static function getLoader()
|
||||||
|
{
|
||||||
|
if (null !== self::$loader) {
|
||||||
|
return self::$loader;
|
||||||
|
}
|
||||||
|
|
||||||
|
require __DIR__ . '/platform_check.php';
|
||||||
|
|
||||||
|
spl_autoload_register(array('ComposerAutoloaderInitd5ed540bdb8bd184c88ae0e4cb8f041f', 'loadClassLoader'), true, true);
|
||||||
|
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||||
|
spl_autoload_unregister(array('ComposerAutoloaderInitd5ed540bdb8bd184c88ae0e4cb8f041f', 'loadClassLoader'));
|
||||||
|
|
||||||
|
require __DIR__ . '/autoload_static.php';
|
||||||
|
call_user_func(\Composer\Autoload\ComposerStaticInitd5ed540bdb8bd184c88ae0e4cb8f041f::getInitializer($loader));
|
||||||
|
|
||||||
|
$loader->register(true);
|
||||||
|
|
||||||
|
return $loader;
|
||||||
|
}
|
||||||
|
}
|
||||||
41
vendor/composer/autoload_static.php
vendored
Normal file
41
vendor/composer/autoload_static.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_static.php @generated by Composer
|
||||||
|
|
||||||
|
namespace Composer\Autoload;
|
||||||
|
|
||||||
|
class ComposerStaticInitd5ed540bdb8bd184c88ae0e4cb8f041f
|
||||||
|
{
|
||||||
|
public static $prefixLengthsPsr4 = array (
|
||||||
|
'C' =>
|
||||||
|
array (
|
||||||
|
'Com\\Tecnick\\Color\\' => 18,
|
||||||
|
'Com\\Tecnick\\Barcode\\' => 20,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
public static $prefixDirsPsr4 = array (
|
||||||
|
'Com\\Tecnick\\Color\\' =>
|
||||||
|
array (
|
||||||
|
0 => __DIR__ . '/..' . '/tecnickcom/tc-lib-color/src',
|
||||||
|
),
|
||||||
|
'Com\\Tecnick\\Barcode\\' =>
|
||||||
|
array (
|
||||||
|
0 => __DIR__ . '/..' . '/tecnickcom/tc-lib-barcode/src',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
public static $classMap = array (
|
||||||
|
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
||||||
|
);
|
||||||
|
|
||||||
|
public static function getInitializer(ClassLoader $loader)
|
||||||
|
{
|
||||||
|
return \Closure::bind(function () use ($loader) {
|
||||||
|
$loader->prefixLengthsPsr4 = ComposerStaticInitd5ed540bdb8bd184c88ae0e4cb8f041f::$prefixLengthsPsr4;
|
||||||
|
$loader->prefixDirsPsr4 = ComposerStaticInitd5ed540bdb8bd184c88ae0e4cb8f041f::$prefixDirsPsr4;
|
||||||
|
$loader->classMap = ComposerStaticInitd5ed540bdb8bd184c88ae0e4cb8f041f::$classMap;
|
||||||
|
|
||||||
|
}, null, ClassLoader::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
181
vendor/composer/installed.json
vendored
Normal file
181
vendor/composer/installed.json
vendored
Normal file
@@ -0,0 +1,181 @@
|
|||||||
|
{
|
||||||
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "tecnickcom/tc-lib-barcode",
|
||||||
|
"version": "2.4.8",
|
||||||
|
"version_normalized": "2.4.8.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/tecnickcom/tc-lib-barcode.git",
|
||||||
|
"reference": "f238ffd120d98a34df6573590e7ed02f766a91c4"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/tecnickcom/tc-lib-barcode/zipball/f238ffd120d98a34df6573590e7ed02f766a91c4",
|
||||||
|
"reference": "f238ffd120d98a34df6573590e7ed02f766a91c4",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-bcmath": "*",
|
||||||
|
"ext-date": "*",
|
||||||
|
"ext-gd": "*",
|
||||||
|
"ext-pcre": "*",
|
||||||
|
"php": ">=8.1",
|
||||||
|
"tecnickcom/tc-lib-color": "^2.2"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"pdepend/pdepend": "2.16.2",
|
||||||
|
"phpmd/phpmd": "2.15.0",
|
||||||
|
"phpunit/phpunit": "12.2.0 || 11.5.7 || 10.5.40",
|
||||||
|
"squizlabs/php_codesniffer": "3.13.0"
|
||||||
|
},
|
||||||
|
"time": "2025-06-06T11:35:02+00:00",
|
||||||
|
"type": "library",
|
||||||
|
"installation-source": "dist",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Com\\Tecnick\\Barcode\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"LGPL-3.0-or-later"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nicola Asuni",
|
||||||
|
"email": "info@tecnick.com",
|
||||||
|
"role": "lead"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PHP library to generate linear and bidimensional barcodes",
|
||||||
|
"homepage": "http://www.tecnick.com",
|
||||||
|
"keywords": [
|
||||||
|
"3 of 9",
|
||||||
|
"ANSI MH10.8M-1983",
|
||||||
|
"CBC",
|
||||||
|
"CODABAR",
|
||||||
|
"CODE 11",
|
||||||
|
"CODE 128 A B C",
|
||||||
|
"CODE 39",
|
||||||
|
"CODE 93",
|
||||||
|
"EAN 13",
|
||||||
|
"EAN 8",
|
||||||
|
"ECC200",
|
||||||
|
"ISO IEC 15438 2006",
|
||||||
|
"ISO IEC 16022",
|
||||||
|
"ISO IEC 24778 2008",
|
||||||
|
"Intelligent Mail Barcode",
|
||||||
|
"Interleaved 2 of 5",
|
||||||
|
"KIX",
|
||||||
|
"Klant",
|
||||||
|
"MSI",
|
||||||
|
"Onecode",
|
||||||
|
"PHARMACODE",
|
||||||
|
"PHARMACODE TWO-TRACKS",
|
||||||
|
"POSTNET",
|
||||||
|
"RMS4CC",
|
||||||
|
"Standard 2 of 5",
|
||||||
|
"UPC-A",
|
||||||
|
"UPC-E",
|
||||||
|
"USD-3",
|
||||||
|
"USPS-B-3200",
|
||||||
|
"USS-93",
|
||||||
|
"aztec",
|
||||||
|
"barcode",
|
||||||
|
"datamatrix",
|
||||||
|
"pdf417",
|
||||||
|
"planet",
|
||||||
|
"qr-code",
|
||||||
|
"royal mail",
|
||||||
|
"tc-lib-barcode",
|
||||||
|
"upc"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/tecnickcom/tc-lib-barcode/issues",
|
||||||
|
"source": "https://github.com/tecnickcom/tc-lib-barcode/tree/2.4.8"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://www.paypal.com/donate/?hosted_button_id=NZUEC5XS8MFBJ",
|
||||||
|
"type": "custom"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"install-path": "../tecnickcom/tc-lib-barcode"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tecnickcom/tc-lib-color",
|
||||||
|
"version": "2.2.13",
|
||||||
|
"version_normalized": "2.2.13.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/tecnickcom/tc-lib-color.git",
|
||||||
|
"reference": "85d1366fb33813aa521d30e3d7c7d7d82a8103a6"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/tecnickcom/tc-lib-color/zipball/85d1366fb33813aa521d30e3d7c7d7d82a8103a6",
|
||||||
|
"reference": "85d1366fb33813aa521d30e3d7c7d7d82a8103a6",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-pcre": "*",
|
||||||
|
"php": ">=8.1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"pdepend/pdepend": "2.16.2",
|
||||||
|
"phpmd/phpmd": "2.15.0",
|
||||||
|
"phpunit/phpunit": "12.2.0 || 11.5.7 || 10.5.40",
|
||||||
|
"squizlabs/php_codesniffer": "3.13.0"
|
||||||
|
},
|
||||||
|
"time": "2025-06-06T11:33:19+00:00",
|
||||||
|
"type": "library",
|
||||||
|
"installation-source": "dist",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Com\\Tecnick\\Color\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"LGPL-3.0-or-later"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nicola Asuni",
|
||||||
|
"email": "info@tecnick.com",
|
||||||
|
"role": "lead"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PHP library to manipulate various color representations",
|
||||||
|
"homepage": "http://www.tecnick.com",
|
||||||
|
"keywords": [
|
||||||
|
"cmyk",
|
||||||
|
"color",
|
||||||
|
"colors",
|
||||||
|
"colour",
|
||||||
|
"colours",
|
||||||
|
"hsl",
|
||||||
|
"hsla",
|
||||||
|
"javascript",
|
||||||
|
"rgb",
|
||||||
|
"rgba",
|
||||||
|
"tc-lib-color",
|
||||||
|
"web"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/tecnickcom/tc-lib-color/issues",
|
||||||
|
"source": "https://github.com/tecnickcom/tc-lib-color/tree/2.2.13"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://www.paypal.com/donate/?hosted_button_id=NZUEC5XS8MFBJ",
|
||||||
|
"type": "custom"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"install-path": "../tecnickcom/tc-lib-color"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"dev-package-names": []
|
||||||
|
}
|
||||||
41
vendor/composer/installed.php
vendored
Normal file
41
vendor/composer/installed.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php return array(
|
||||||
|
'root' => array(
|
||||||
|
'name' => '__root__',
|
||||||
|
'pretty_version' => '1.0.0+no-version-set',
|
||||||
|
'version' => '1.0.0.0',
|
||||||
|
'reference' => null,
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../../',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev' => true,
|
||||||
|
),
|
||||||
|
'versions' => array(
|
||||||
|
'__root__' => array(
|
||||||
|
'pretty_version' => '1.0.0+no-version-set',
|
||||||
|
'version' => '1.0.0.0',
|
||||||
|
'reference' => null,
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../../',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'tecnickcom/tc-lib-barcode' => array(
|
||||||
|
'pretty_version' => '2.4.8',
|
||||||
|
'version' => '2.4.8.0',
|
||||||
|
'reference' => 'f238ffd120d98a34df6573590e7ed02f766a91c4',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../tecnickcom/tc-lib-barcode',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'tecnickcom/tc-lib-color' => array(
|
||||||
|
'pretty_version' => '2.2.13',
|
||||||
|
'version' => '2.2.13.0',
|
||||||
|
'reference' => '85d1366fb33813aa521d30e3d7c7d7d82a8103a6',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../tecnickcom/tc-lib-color',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
26
vendor/composer/platform_check.php
vendored
Normal file
26
vendor/composer/platform_check.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// platform_check.php @generated by Composer
|
||||||
|
|
||||||
|
$issues = array();
|
||||||
|
|
||||||
|
if (!(PHP_VERSION_ID >= 80100)) {
|
||||||
|
$issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($issues) {
|
||||||
|
if (!headers_sent()) {
|
||||||
|
header('HTTP/1.1 500 Internal Server Error');
|
||||||
|
}
|
||||||
|
if (!ini_get('display_errors')) {
|
||||||
|
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||||
|
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
|
||||||
|
} elseif (!headers_sent()) {
|
||||||
|
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
trigger_error(
|
||||||
|
'Composer detected issues in your platform: ' . implode(' ', $issues),
|
||||||
|
E_USER_ERROR
|
||||||
|
);
|
||||||
|
}
|
||||||
20
vendor/tecnickcom/tc-lib-barcode/.editorconfig
vendored
Normal file
20
vendor/tecnickcom/tc-lib-barcode/.editorconfig
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Ref: https://EditorConfig.org
|
||||||
|
|
||||||
|
# top-most EditorConfig file
|
||||||
|
root = true
|
||||||
|
|
||||||
|
# Unix-style end of lines and a blank line at the end of the file
|
||||||
|
[*]
|
||||||
|
indent_style = tab
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.php]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[*.{js,json,scss,css,yml,vue}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
1
vendor/tecnickcom/tc-lib-barcode/.github/FUNDING.yml
vendored
Normal file
1
vendor/tecnickcom/tc-lib-barcode/.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
custom: ['https://www.paypal.com/donate/?hosted_button_id=NZUEC5XS8MFBJ']
|
||||||
29
vendor/tecnickcom/tc-lib-barcode/.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
29
vendor/tecnickcom/tc-lib-barcode/.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Steps to reproduce the behavior:
|
||||||
|
1. ...
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Logs**
|
||||||
|
If applicable, copy the relevant logs to help explain your problem.
|
||||||
|
|
||||||
|
**Environment:**
|
||||||
|
- OS:
|
||||||
|
- PHP version:
|
||||||
|
- Version:
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
||||||
20
vendor/tecnickcom/tc-lib-barcode/.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
vendor/tecnickcom/tc-lib-barcode/.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
||||||
25
vendor/tecnickcom/tc-lib-barcode/.github/pull_request_template.md
vendored
Normal file
25
vendor/tecnickcom/tc-lib-barcode/.github/pull_request_template.md
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Description
|
||||||
|
|
||||||
|
Please include a summary of the change and include relevant motivation and context.
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
## Checklist:
|
||||||
|
|
||||||
|
- [ ] The `make buildall` command has been run successfully without any error or warning.
|
||||||
|
- [ ] Any new code line is covered by unit tests and the coverage has not dropped.
|
||||||
|
- [ ] Any new code follows the style guidelines of this project.
|
||||||
|
- [ ] The code changes have been self-reviewed.
|
||||||
|
- [ ] Corresponding changes to the documentation have been made.
|
||||||
|
- [ ] The version has been updated in the VERSION file.
|
||||||
|
|
||||||
|
## Type of change:
|
||||||
|
|
||||||
|
- [ ] Bug fix (non-breaking change which fixes an issue) → The patch number in the VERSION file has been increased.
|
||||||
|
- [ ] New feature (non-breaking change which adds functionality) → The minor number in the VERSION file has been increased.
|
||||||
|
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) → The major number in the VERSION file has been increased.
|
||||||
|
- [ ] Automation.
|
||||||
|
- [ ] Documentation.
|
||||||
|
- [ ] Example.
|
||||||
|
- [ ] Testing.
|
||||||
56
vendor/tecnickcom/tc-lib-barcode/.github/workflows/check.yml
vendored
Normal file
56
vendor/tecnickcom/tc-lib-barcode/.github/workflows/check.yml
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
name: check
|
||||||
|
|
||||||
|
env:
|
||||||
|
XDEBUG_MODE: coverage
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'main'
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize, reopened]
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-php:
|
||||||
|
name: Test on php ${{ matrix.php-version }} and ${{ matrix.os }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
continue-on-error: ${{ matrix.experimental }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
php-version: ["8.1", "8.2", "8.3", "8.4"]
|
||||||
|
experimental: [false]
|
||||||
|
os: [ubuntu-latest]
|
||||||
|
coverage-extension: [xdebug]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Use php ${{ matrix.php-version }}
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-version }}
|
||||||
|
coverage: ${{ matrix.coverage-extension }}
|
||||||
|
extensions: xdebug, bcmath, curl, date, gd, hash, imagick, json, mbstring, openssl, pcre, zlib
|
||||||
|
ini-values: display_errors=on, error_reporting=-1, zend.assertions=1
|
||||||
|
- name: List php modules
|
||||||
|
run: php -m
|
||||||
|
- name: List php modules using "no php ini" mode
|
||||||
|
run: php -m -n
|
||||||
|
- name: Cache module
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ~/.composer/cache/
|
||||||
|
key: composer-cache
|
||||||
|
- name: Install dependencies
|
||||||
|
run: make deps
|
||||||
|
- name: Run all tests
|
||||||
|
run: make qa
|
||||||
|
- name: Send coverage
|
||||||
|
uses: codecov/codecov-action@v5
|
||||||
|
with:
|
||||||
|
flags: php-${{ matrix.php-version }}-${{ matrix.os }}
|
||||||
|
name: php-${{ matrix.php-version }}-${{ matrix.os }}
|
||||||
20
vendor/tecnickcom/tc-lib-barcode/.gitignore
vendored
Normal file
20
vendor/tecnickcom/tc-lib-barcode/.gitignore
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
**/*.bak
|
||||||
|
**/*.tmp
|
||||||
|
**/.#*
|
||||||
|
**/.DS_Store
|
||||||
|
**/._*
|
||||||
|
**/.idea
|
||||||
|
**/.vagrant
|
||||||
|
**/auth.json
|
||||||
|
**/nbproject
|
||||||
|
**/temp.php
|
||||||
|
**/test.php
|
||||||
|
.phpdoc
|
||||||
|
.phpunit.cache
|
||||||
|
.phpunit.result.cache
|
||||||
|
composer.lock
|
||||||
|
ecs.php
|
||||||
|
phpunit.xml
|
||||||
|
rector.php
|
||||||
|
target
|
||||||
|
vendor
|
||||||
1
vendor/tecnickcom/tc-lib-barcode/CODEOWNERS
vendored
Normal file
1
vendor/tecnickcom/tc-lib-barcode/CODEOWNERS
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
* @nicolaasuni
|
||||||
128
vendor/tecnickcom/tc-lib-barcode/CODE_OF_CONDUCT.md
vendored
Normal file
128
vendor/tecnickcom/tc-lib-barcode/CODE_OF_CONDUCT.md
vendored
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
We as members, contributors, and leaders pledge to make participation in our
|
||||||
|
community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||||
|
identity and expression, level of experience, education, socio-economic status,
|
||||||
|
nationality, personal appearance, race, religion, or sexual identity
|
||||||
|
and orientation.
|
||||||
|
|
||||||
|
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||||
|
diverse, inclusive, and healthy community.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to a positive environment for our
|
||||||
|
community include:
|
||||||
|
|
||||||
|
* Demonstrating empathy and kindness toward other people
|
||||||
|
* Being respectful of differing opinions, viewpoints, and experiences
|
||||||
|
* Giving and gracefully accepting constructive feedback
|
||||||
|
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||||
|
and learning from the experience
|
||||||
|
* Focusing on what is best not just for us as individuals, but for the
|
||||||
|
overall community
|
||||||
|
|
||||||
|
Examples of unacceptable behavior include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery, and sexual attention or
|
||||||
|
advances of any kind
|
||||||
|
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or email
|
||||||
|
address, without their explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
## Enforcement Responsibilities
|
||||||
|
|
||||||
|
Community leaders are responsible for clarifying and enforcing our standards of
|
||||||
|
acceptable behavior and will take appropriate and fair corrective action in
|
||||||
|
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||||
|
or harmful.
|
||||||
|
|
||||||
|
Community leaders have the right and responsibility to remove, edit, or reject
|
||||||
|
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||||
|
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||||
|
decisions when appropriate.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies within all community spaces, and also applies when
|
||||||
|
an individual is officially representing the community in public spaces.
|
||||||
|
Examples of representing our community include using an official e-mail address,
|
||||||
|
posting via an official social media account, or acting as an appointed
|
||||||
|
representative at an online or offline event.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported to the community leaders responsible for enforcement at
|
||||||
|
.
|
||||||
|
All complaints will be reviewed and investigated promptly and fairly.
|
||||||
|
|
||||||
|
All community leaders are obligated to respect the privacy and security of the
|
||||||
|
reporter of any incident.
|
||||||
|
|
||||||
|
## Enforcement Guidelines
|
||||||
|
|
||||||
|
Community leaders will follow these Community Impact Guidelines in determining
|
||||||
|
the consequences for any action they deem in violation of this Code of Conduct:
|
||||||
|
|
||||||
|
### 1. Correction
|
||||||
|
|
||||||
|
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||||
|
unprofessional or unwelcome in the community.
|
||||||
|
|
||||||
|
**Consequence**: A private, written warning from community leaders, providing
|
||||||
|
clarity around the nature of the violation and an explanation of why the
|
||||||
|
behavior was inappropriate. A public apology may be requested.
|
||||||
|
|
||||||
|
### 2. Warning
|
||||||
|
|
||||||
|
**Community Impact**: A violation through a single incident or series
|
||||||
|
of actions.
|
||||||
|
|
||||||
|
**Consequence**: A warning with consequences for continued behavior. No
|
||||||
|
interaction with the people involved, including unsolicited interaction with
|
||||||
|
those enforcing the Code of Conduct, for a specified period of time. This
|
||||||
|
includes avoiding interactions in community spaces as well as external channels
|
||||||
|
like social media. Violating these terms may lead to a temporary or
|
||||||
|
permanent ban.
|
||||||
|
|
||||||
|
### 3. Temporary Ban
|
||||||
|
|
||||||
|
**Community Impact**: A serious violation of community standards, including
|
||||||
|
sustained inappropriate behavior.
|
||||||
|
|
||||||
|
**Consequence**: A temporary ban from any sort of interaction or public
|
||||||
|
communication with the community for a specified period of time. No public or
|
||||||
|
private interaction with the people involved, including unsolicited interaction
|
||||||
|
with those enforcing the Code of Conduct, is allowed during this period.
|
||||||
|
Violating these terms may lead to a permanent ban.
|
||||||
|
|
||||||
|
### 4. Permanent Ban
|
||||||
|
|
||||||
|
**Community Impact**: Demonstrating a pattern of violation of community
|
||||||
|
standards, including sustained inappropriate behavior, harassment of an
|
||||||
|
individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
|
||||||
|
**Consequence**: A permanent ban from any sort of public interaction within
|
||||||
|
the community.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||||
|
version 2.0, available at
|
||||||
|
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||||
|
|
||||||
|
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||||
|
enforcement ladder](https://github.com/mozilla/diversity).
|
||||||
|
|
||||||
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see the FAQ at
|
||||||
|
https://www.contributor-covenant.org/faq. Translations are available at
|
||||||
|
https://www.contributor-covenant.org/translations.
|
||||||
26
vendor/tecnickcom/tc-lib-barcode/CONTRIBUTING.md
vendored
Normal file
26
vendor/tecnickcom/tc-lib-barcode/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# How to Contribute
|
||||||
|
|
||||||
|
|
||||||
|
## Reporting a bug
|
||||||
|
|
||||||
|
* **Do not open up a GitHub issue if the bug is a security vulnerability**, and instead to refer to our [Security policy](SECURITY.md).
|
||||||
|
|
||||||
|
* Ensure the bug was not already reported by searching on GitHub Issues.
|
||||||
|
|
||||||
|
* If you're unable to find an open issue addressing the problem, open a new one. Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
|
||||||
|
|
||||||
|
|
||||||
|
## Submitting a bug fix
|
||||||
|
|
||||||
|
* Open a new GitHub pull request with the patch.
|
||||||
|
|
||||||
|
* Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
|
||||||
|
|
||||||
|
* Ensure the new code is following the existing conventions and the unit test coverage is 100%.
|
||||||
|
|
||||||
|
* Before submitting, please run the following command locally to ensure the code is passing the automatic checks: `make buildall`.
|
||||||
|
|
||||||
|
|
||||||
|
## Add a new feature or change an existing one
|
||||||
|
|
||||||
|
* Before writing any code please suggest the change by opening a new Feature Request on Issues.
|
||||||
862
vendor/tecnickcom/tc-lib-barcode/LICENSE
vendored
Normal file
862
vendor/tecnickcom/tc-lib-barcode/LICENSE
vendored
Normal file
@@ -0,0 +1,862 @@
|
|||||||
|
**********************************************************************
|
||||||
|
* LICENSE
|
||||||
|
*
|
||||||
|
* SOFTWARE : tc-lib-barcode
|
||||||
|
* AUTHOR : Nicola Asuni <info@tecnick.com>
|
||||||
|
* COPYRIGHT : 2001-2025 Nicola Asuni - Tecnick.com LTD
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
This is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
|
||||||
|
This version of the GNU Lesser General Public License incorporates
|
||||||
|
the terms and conditions of version 3 of the GNU General Public
|
||||||
|
License, supplemented by the additional permissions listed below.
|
||||||
|
|
||||||
|
0. Additional Definitions.
|
||||||
|
|
||||||
|
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||||
|
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||||
|
General Public License.
|
||||||
|
|
||||||
|
"The Library" refers to a covered work governed by this License,
|
||||||
|
other than an Application or a Combined Work as defined below.
|
||||||
|
|
||||||
|
An "Application" is any work that makes use of an interface provided
|
||||||
|
by the Library, but which is not otherwise based on the Library.
|
||||||
|
Defining a subclass of a class defined by the Library is deemed a mode
|
||||||
|
of using an interface provided by the Library.
|
||||||
|
|
||||||
|
A "Combined Work" is a work produced by combining or linking an
|
||||||
|
Application with the Library. The particular version of the Library
|
||||||
|
with which the Combined Work was made is also called the "Linked
|
||||||
|
Version".
|
||||||
|
|
||||||
|
The "Minimal Corresponding Source" for a Combined Work means the
|
||||||
|
Corresponding Source for the Combined Work, excluding any source code
|
||||||
|
for portions of the Combined Work that, considered in isolation, are
|
||||||
|
based on the Application, and not on the Linked Version.
|
||||||
|
|
||||||
|
The "Corresponding Application Code" for a Combined Work means the
|
||||||
|
object code and/or source code for the Application, including any data
|
||||||
|
and utility programs needed for reproducing the Combined Work from the
|
||||||
|
Application, but excluding the System Libraries of the Combined Work.
|
||||||
|
|
||||||
|
1. Exception to Section 3 of the GNU GPL.
|
||||||
|
|
||||||
|
You may convey a covered work under sections 3 and 4 of this License
|
||||||
|
without being bound by section 3 of the GNU GPL.
|
||||||
|
|
||||||
|
2. Conveying Modified Versions.
|
||||||
|
|
||||||
|
If you modify a copy of the Library, and, in your modifications, a
|
||||||
|
facility refers to a function or data to be supplied by an Application
|
||||||
|
that uses the facility (other than as an argument passed when the
|
||||||
|
facility is invoked), then you may convey a copy of the modified
|
||||||
|
version:
|
||||||
|
|
||||||
|
a) under this License, provided that you make a good faith effort to
|
||||||
|
ensure that, in the event an Application does not supply the
|
||||||
|
function or data, the facility still operates, and performs
|
||||||
|
whatever part of its purpose remains meaningful, or
|
||||||
|
|
||||||
|
b) under the GNU GPL, with none of the additional permissions of
|
||||||
|
this License applicable to that copy.
|
||||||
|
|
||||||
|
3. Object Code Incorporating Material from Library Header Files.
|
||||||
|
|
||||||
|
The object code form of an Application may incorporate material from
|
||||||
|
a header file that is part of the Library. You may convey such object
|
||||||
|
code under terms of your choice, provided that, if the incorporated
|
||||||
|
material is not limited to numerical parameters, data structure
|
||||||
|
layouts and accessors, or small macros, inline functions and templates
|
||||||
|
(ten or fewer lines in length), you do both of the following:
|
||||||
|
|
||||||
|
a) Give prominent notice with each copy of the object code that the
|
||||||
|
Library is used in it and that the Library and its use are
|
||||||
|
covered by this License.
|
||||||
|
|
||||||
|
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||||
|
document.
|
||||||
|
|
||||||
|
4. Combined Works.
|
||||||
|
|
||||||
|
You may convey a Combined Work under terms of your choice that,
|
||||||
|
taken together, effectively do not restrict modification of the
|
||||||
|
portions of the Library contained in the Combined Work and reverse
|
||||||
|
engineering for debugging such modifications, if you also do each of
|
||||||
|
the following:
|
||||||
|
|
||||||
|
a) Give prominent notice with each copy of the Combined Work that
|
||||||
|
the Library is used in it and that the Library and its use are
|
||||||
|
covered by this License.
|
||||||
|
|
||||||
|
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||||
|
document.
|
||||||
|
|
||||||
|
c) For a Combined Work that displays copyright notices during
|
||||||
|
execution, include the copyright notice for the Library among
|
||||||
|
these notices, as well as a reference directing the user to the
|
||||||
|
copies of the GNU GPL and this license document.
|
||||||
|
|
||||||
|
d) Do one of the following:
|
||||||
|
|
||||||
|
0) Convey the Minimal Corresponding Source under the terms of this
|
||||||
|
License, and the Corresponding Application Code in a form
|
||||||
|
suitable for, and under terms that permit, the user to
|
||||||
|
recombine or relink the Application with a modified version of
|
||||||
|
the Linked Version to produce a modified Combined Work, in the
|
||||||
|
manner specified by section 6 of the GNU GPL for conveying
|
||||||
|
Corresponding Source.
|
||||||
|
|
||||||
|
1) Use a suitable shared library mechanism for linking with the
|
||||||
|
Library. A suitable mechanism is one that (a) uses at run time
|
||||||
|
a copy of the Library already present on the user's computer
|
||||||
|
system, and (b) will operate properly with a modified version
|
||||||
|
of the Library that is interface-compatible with the Linked
|
||||||
|
Version.
|
||||||
|
|
||||||
|
e) Provide Installation Information, but only if you would otherwise
|
||||||
|
be required to provide such information under section 6 of the
|
||||||
|
GNU GPL, and only to the extent that such information is
|
||||||
|
necessary to install and execute a modified version of the
|
||||||
|
Combined Work produced by recombining or relinking the
|
||||||
|
Application with a modified version of the Linked Version. (If
|
||||||
|
you use option 4d0, the Installation Information must accompany
|
||||||
|
the Minimal Corresponding Source and Corresponding Application
|
||||||
|
Code. If you use option 4d1, you must provide the Installation
|
||||||
|
Information in the manner specified by section 6 of the GNU GPL
|
||||||
|
for conveying Corresponding Source.)
|
||||||
|
|
||||||
|
5. Combined Libraries.
|
||||||
|
|
||||||
|
You may place library facilities that are a work based on the
|
||||||
|
Library side by side in a single library together with other library
|
||||||
|
facilities that are not Applications and are not covered by this
|
||||||
|
License, and convey such a combined library under terms of your
|
||||||
|
choice, if you do both of the following:
|
||||||
|
|
||||||
|
a) Accompany the combined library with a copy of the same work based
|
||||||
|
on the Library, uncombined with any other library facilities,
|
||||||
|
conveyed under the terms of this License.
|
||||||
|
|
||||||
|
b) Give prominent notice with the combined library that part of it
|
||||||
|
is a work based on the Library, and explaining where to find the
|
||||||
|
accompanying uncombined form of the same work.
|
||||||
|
|
||||||
|
6. Revised Versions of the GNU Lesser General Public License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the GNU Lesser General Public License from time to time. Such new
|
||||||
|
versions will be similar in spirit to the present version, but may
|
||||||
|
differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Library as you received it specifies that a certain numbered version
|
||||||
|
of the GNU Lesser General Public License "or any later version"
|
||||||
|
applies to it, you have the option of following the terms and
|
||||||
|
conditions either of that published version or of any later version
|
||||||
|
published by the Free Software Foundation. If the Library as you
|
||||||
|
received it does not specify a version number of the GNU Lesser
|
||||||
|
General Public License, you may choose any version of the GNU Lesser
|
||||||
|
General Public License ever published by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Library as you received it specifies that a proxy can decide
|
||||||
|
whether future versions of the GNU Lesser General Public License shall
|
||||||
|
apply, that proxy's public statement of acceptance of any version is
|
||||||
|
permanent authorization for you to choose that version for the
|
||||||
|
Library.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
**********************************************************************
|
||||||
275
vendor/tecnickcom/tc-lib-barcode/Makefile
vendored
Normal file
275
vendor/tecnickcom/tc-lib-barcode/Makefile
vendored
Normal file
@@ -0,0 +1,275 @@
|
|||||||
|
# makefile
|
||||||
|
#
|
||||||
|
# @since 2015-02-21
|
||||||
|
# @category Library
|
||||||
|
# @package Barcode
|
||||||
|
# @author Nicola Asuni <info@tecnick.com>
|
||||||
|
# @copyright 2015-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
# @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||||
|
# @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
#
|
||||||
|
# This file is part of tc-lib-barcode software library.
|
||||||
|
# ----------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SHELL=/bin/bash
|
||||||
|
.SHELLFLAGS=-o pipefail -c
|
||||||
|
|
||||||
|
# Project owner
|
||||||
|
OWNER=tecnickcom
|
||||||
|
|
||||||
|
# Project vendor
|
||||||
|
VENDOR=${OWNER}
|
||||||
|
|
||||||
|
# Project name
|
||||||
|
PROJECT=tc-lib-barcode
|
||||||
|
|
||||||
|
# Project version
|
||||||
|
VERSION=$(shell cat VERSION)
|
||||||
|
|
||||||
|
# Project release number (packaging build number)
|
||||||
|
RELEASE=$(shell cat RELEASE)
|
||||||
|
|
||||||
|
# Name of RPM or DEB package
|
||||||
|
PKGNAME=php-${OWNER}-${PROJECT}
|
||||||
|
|
||||||
|
# Data dir
|
||||||
|
DATADIR=usr/share
|
||||||
|
|
||||||
|
# PHP home folder
|
||||||
|
PHPHOME=${DATADIR}/php/Com/Tecnick
|
||||||
|
|
||||||
|
# Default installation path for code
|
||||||
|
LIBPATH=${PHPHOME}/Barcode/
|
||||||
|
|
||||||
|
# Path for configuration files (etc/$(PKGNAME)/)
|
||||||
|
CONFIGPATH=
|
||||||
|
|
||||||
|
# Default installation path for documentation
|
||||||
|
DOCPATH=${DATADIR}/doc/$(PKGNAME)/
|
||||||
|
|
||||||
|
# Installation path for the code
|
||||||
|
PATHINSTBIN=$(DESTDIR)/$(LIBPATH)
|
||||||
|
|
||||||
|
# Installation path for the configuration files
|
||||||
|
PATHINSTCFG=$(DESTDIR)/$(CONFIGPATH)
|
||||||
|
|
||||||
|
# Installation path for documentation
|
||||||
|
PATHINSTDOC=$(DESTDIR)/$(DOCPATH)
|
||||||
|
|
||||||
|
# Current directory
|
||||||
|
CURRENTDIR=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||||
|
|
||||||
|
# Target directory
|
||||||
|
TARGETDIR=$(CURRENTDIR)target
|
||||||
|
|
||||||
|
# RPM Packaging path (where RPMs will be stored)
|
||||||
|
PATHRPMPKG=$(TARGETDIR)/RPM
|
||||||
|
|
||||||
|
# DEB Packaging path (where DEBs will be stored)
|
||||||
|
PATHDEBPKG=$(TARGETDIR)/DEB
|
||||||
|
|
||||||
|
# BZ2 Packaging path (where BZ2s will be stored)
|
||||||
|
PATHBZ2PKG=$(TARGETDIR)/BZ2
|
||||||
|
|
||||||
|
# Default port number for the example server
|
||||||
|
PORT?=8000
|
||||||
|
|
||||||
|
# PHP binary
|
||||||
|
PHP=$(shell which php)
|
||||||
|
|
||||||
|
# Composer executable (disable APC to as a work-around of a bug)
|
||||||
|
COMPOSER=$(PHP) -d "apc.enable_cli=0" $(shell which composer)
|
||||||
|
|
||||||
|
# phpDocumentor executable file
|
||||||
|
PHPDOC=$(shell which phpDocumentor)
|
||||||
|
|
||||||
|
# --- MAKE TARGETS ---
|
||||||
|
|
||||||
|
# Display general help about this command
|
||||||
|
.PHONY: help
|
||||||
|
help:
|
||||||
|
@echo ""
|
||||||
|
@echo "$(PROJECT) Makefile."
|
||||||
|
@echo "The following commands are available:"
|
||||||
|
@echo ""
|
||||||
|
@echo " make buildall : Build and test everything from scratch"
|
||||||
|
@echo " make bz2 : Package the library in a compressed bz2 archive"
|
||||||
|
@echo " make clean : Delete the vendor and target directories"
|
||||||
|
@echo " make codefix : Fix code style violations"
|
||||||
|
@echo " make deb : Build a DEB package for Debian-like Linux distributions"
|
||||||
|
@echo " make deps : Download all dependencies"
|
||||||
|
@echo " make doc : Generate source code documentation"
|
||||||
|
@echo " make lint : Test source code for coding standard violations"
|
||||||
|
@echo " make qa : Run all tests and reports"
|
||||||
|
@echo " make report : Generate various reports"
|
||||||
|
@echo " make rpm : Build an RPM package for RedHat-like Linux distributions"
|
||||||
|
@echo " make server : Start the development server"
|
||||||
|
@echo " make test : Run unit tests"
|
||||||
|
@echo ""
|
||||||
|
@echo "To test and build everything from scratch:"
|
||||||
|
@echo "make buildall"
|
||||||
|
@echo ""
|
||||||
|
|
||||||
|
# alias for help target
|
||||||
|
.PHONY: all
|
||||||
|
all: help
|
||||||
|
|
||||||
|
# Full build and test sequence
|
||||||
|
.PHONY: x
|
||||||
|
x: buildall
|
||||||
|
|
||||||
|
# Full build and test sequence
|
||||||
|
.PHONY: buildall
|
||||||
|
buildall: deps codefix qa bz2 rpm deb
|
||||||
|
|
||||||
|
# Package the library in a compressed bz2 archive
|
||||||
|
.PHONY: bz2
|
||||||
|
bz2:
|
||||||
|
rm -rf $(PATHBZ2PKG)
|
||||||
|
make install DESTDIR=$(PATHBZ2PKG)
|
||||||
|
tar -jcvf $(PATHBZ2PKG)/$(PKGNAME)-$(VERSION)-$(RELEASE).tbz2 -C $(PATHBZ2PKG) $(DATADIR)
|
||||||
|
|
||||||
|
# Delete the vendor and target directories
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
rm -rf ./vendor $(TARGETDIR)
|
||||||
|
|
||||||
|
# Fix code style violations
|
||||||
|
.PHONY: codefix
|
||||||
|
codefix:
|
||||||
|
./vendor/bin/phpcbf --ignore="./vendor/" --standard=psr12 src test
|
||||||
|
|
||||||
|
# Build a DEB package for Debian-like Linux distributions
|
||||||
|
.PHONY: deb
|
||||||
|
deb:
|
||||||
|
rm -rf $(PATHDEBPKG)
|
||||||
|
make install DESTDIR=$(PATHDEBPKG)/$(PKGNAME)-$(VERSION)
|
||||||
|
rm -f $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/$(DOCPATH)LICENSE
|
||||||
|
tar -zcvf $(PATHDEBPKG)/$(PKGNAME)_$(VERSION).orig.tar.gz -C $(PATHDEBPKG)/ $(PKGNAME)-$(VERSION)
|
||||||
|
cp -rf ./resources/debian $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian
|
||||||
|
find $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/ -type f -exec sed -i "s/~#DATE#~/`date -R`/" {} \;
|
||||||
|
find $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/ -type f -exec sed -i "s/~#VENDOR#~/$(VENDOR)/" {} \;
|
||||||
|
find $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/ -type f -exec sed -i "s/~#PROJECT#~/$(PROJECT)/" {} \;
|
||||||
|
find $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/ -type f -exec sed -i "s/~#PKGNAME#~/$(PKGNAME)/" {} \;
|
||||||
|
find $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/ -type f -exec sed -i "s/~#VERSION#~/$(VERSION)/" {} \;
|
||||||
|
find $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/ -type f -exec sed -i "s/~#RELEASE#~/$(RELEASE)/" {} \;
|
||||||
|
echo $(LIBPATH) > $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/$(PKGNAME).dirs
|
||||||
|
echo "$(LIBPATH)* $(LIBPATH)" > $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/install
|
||||||
|
echo $(DOCPATH) >> $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/$(PKGNAME).dirs
|
||||||
|
echo "$(DOCPATH)* $(DOCPATH)" >> $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/install
|
||||||
|
ifneq ($(strip $(CONFIGPATH)),)
|
||||||
|
echo $(CONFIGPATH) >> $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/$(PKGNAME).dirs
|
||||||
|
echo "$(CONFIGPATH)* $(CONFIGPATH)" >> $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/install
|
||||||
|
endif
|
||||||
|
echo "new-package-should-close-itp-bug" > $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/$(PKGNAME).lintian-overrides
|
||||||
|
cd $(PATHDEBPKG)/$(PKGNAME)-$(VERSION) && debuild -us -uc
|
||||||
|
|
||||||
|
# Clean all artifacts and download all dependencies
|
||||||
|
.PHONY: deps
|
||||||
|
deps: ensuretarget
|
||||||
|
rm -rf ./vendor/*
|
||||||
|
($(COMPOSER) install -vvv --no-interaction)
|
||||||
|
curl --silent --show-error --fail --location --output ./vendor/phpstan.phar https://github.com/phpstan/phpstan/releases/download/2.1.2/phpstan.phar \
|
||||||
|
&& chmod +x ./vendor/phpstan.phar
|
||||||
|
|
||||||
|
# Generate source code documentation
|
||||||
|
.PHONY: doc
|
||||||
|
doc: ensuretarget
|
||||||
|
rm -rf $(TARGETDIR)/doc
|
||||||
|
$(PHPDOC) -d ./src -t $(TARGETDIR)/doc/
|
||||||
|
|
||||||
|
# Create missing target directories for test and build artifacts
|
||||||
|
.PHONY: ensuretarget
|
||||||
|
ensuretarget:
|
||||||
|
mkdir -p $(TARGETDIR)/test
|
||||||
|
mkdir -p $(TARGETDIR)/report
|
||||||
|
mkdir -p $(TARGETDIR)/doc
|
||||||
|
|
||||||
|
# Install this application
|
||||||
|
.PHONY: install
|
||||||
|
install: uninstall
|
||||||
|
mkdir -p $(PATHINSTBIN)
|
||||||
|
cp -rf ./src/* $(PATHINSTBIN)
|
||||||
|
cp -f ./resources/autoload.php $(PATHINSTBIN)
|
||||||
|
find $(PATHINSTBIN) -type d -exec chmod 755 {} \;
|
||||||
|
find $(PATHINSTBIN) -type f -exec chmod 644 {} \;
|
||||||
|
mkdir -p $(PATHINSTDOC)
|
||||||
|
cp -f ./LICENSE $(PATHINSTDOC)
|
||||||
|
cp -f ./README.md $(PATHINSTDOC)
|
||||||
|
cp -f ./VERSION $(PATHINSTDOC)
|
||||||
|
cp -f ./RELEASE $(PATHINSTDOC)
|
||||||
|
chmod -R 644 $(PATHINSTDOC)*
|
||||||
|
ifneq ($(strip $(CONFIGPATH)),)
|
||||||
|
mkdir -p $(PATHINSTCFG)
|
||||||
|
touch -c $(PATHINSTCFG)*
|
||||||
|
cp -ru ./resources/${CONFIGPATH}* $(PATHINSTCFG)
|
||||||
|
find $(PATHINSTCFG) -type d -exec chmod 755 {} \;
|
||||||
|
find $(PATHINSTCFG) -type f -exec chmod 644 {} \;
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Test source code for coding standard violations
|
||||||
|
.PHONY: lint
|
||||||
|
lint:
|
||||||
|
./vendor/bin/phpcs --ignore="./vendor/" --standard=phpcs.xml src test
|
||||||
|
./vendor/bin/phpmd src text codesize,unusedcode,naming,design --exclude */vendor/*
|
||||||
|
./vendor/bin/phpmd test text unusedcode,naming,design --exclude */vendor/*
|
||||||
|
php -r 'exit((int)version_compare(PHP_MAJOR_VERSION, "7", ">"));' || ./vendor/phpstan.phar analyse
|
||||||
|
|
||||||
|
# Run all tests and reports
|
||||||
|
.PHONY: qa
|
||||||
|
qa: ensuretarget lint test report
|
||||||
|
|
||||||
|
# Generate various reports
|
||||||
|
.PHONY: report
|
||||||
|
report: ensuretarget
|
||||||
|
./vendor/bin/pdepend --jdepend-xml=$(TARGETDIR)/report/dependencies.xml --summary-xml=$(TARGETDIR)/report/metrics.xml --jdepend-chart=$(TARGETDIR)/report/dependecies.svg --overview-pyramid=$(TARGETDIR)/report/overview-pyramid.svg --ignore=vendor ./src
|
||||||
|
#./vendor/bartlett/php-compatinfo/bin/phpcompatinfo --no-ansi analyser:run src/ > $(TARGETDIR)/report/phpcompatinfo.txt
|
||||||
|
|
||||||
|
# Build the RPM package for RedHat-like Linux distributions
|
||||||
|
.PHONY: rpm
|
||||||
|
rpm:
|
||||||
|
rm -rf $(PATHRPMPKG)
|
||||||
|
rpmbuild \
|
||||||
|
--define "_topdir $(PATHRPMPKG)" \
|
||||||
|
--define "_vendor $(VENDOR)" \
|
||||||
|
--define "_owner $(OWNER)" \
|
||||||
|
--define "_project $(PROJECT)" \
|
||||||
|
--define "_package $(PKGNAME)" \
|
||||||
|
--define "_version $(VERSION)" \
|
||||||
|
--define "_release $(RELEASE)" \
|
||||||
|
--define "_current_directory $(CURRENTDIR)" \
|
||||||
|
--define "_libpath /$(LIBPATH)" \
|
||||||
|
--define "_docpath /$(DOCPATH)" \
|
||||||
|
--define "_configpath /$(CONFIGPATH)" \
|
||||||
|
-bb resources/rpm/rpm.spec
|
||||||
|
|
||||||
|
# Start the development server
|
||||||
|
.PHONY: server
|
||||||
|
server:
|
||||||
|
$(PHP) -t example -S localhost:$(PORT)
|
||||||
|
|
||||||
|
# Tag this GIT version
|
||||||
|
.PHONY: tag
|
||||||
|
tag:
|
||||||
|
git checkout main && \
|
||||||
|
git tag -a ${VERSION} -m "Release ${VERSION}" && \
|
||||||
|
git push origin --tags && \
|
||||||
|
git pull
|
||||||
|
|
||||||
|
# Run unit tests
|
||||||
|
.PHONY: test
|
||||||
|
test:
|
||||||
|
cp phpunit.xml.dist phpunit.xml
|
||||||
|
#./vendor/bin/phpunit --migrate-configuration || true
|
||||||
|
XDEBUG_MODE=coverage ./vendor/bin/phpunit --stderr test
|
||||||
|
|
||||||
|
# Remove all installed files
|
||||||
|
.PHONY: uninstall
|
||||||
|
uninstall:
|
||||||
|
rm -rf $(PATHINSTBIN)
|
||||||
|
rm -rf $(PATHINSTDOC)
|
||||||
|
|
||||||
|
# Increase the version patch number
|
||||||
|
.PHONY: versionup
|
||||||
|
versionup:
|
||||||
|
echo ${VERSION} | gawk -F. '{printf("%d.%d.%d\n",$$1,$$2,(($$3+1)));}' > VERSION
|
||||||
176
vendor/tecnickcom/tc-lib-barcode/README.md
vendored
Normal file
176
vendor/tecnickcom/tc-lib-barcode/README.md
vendored
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
# tc-lib-barcode
|
||||||
|
*PHP barcode library*
|
||||||
|
|
||||||
|
[](https://packagist.org/packages/tecnickcom/tc-lib-barcode)
|
||||||
|

|
||||||
|
[](https://codecov.io/gh/tecnickcom/tc-lib-barcode)
|
||||||
|
[](https://packagist.org/packages/tecnickcom/tc-lib-barcode)
|
||||||
|
[](https://packagist.org/packages/tecnickcom/tc-lib-barcode)
|
||||||
|
|
||||||
|
[](https://www.paypal.com/donate/?hosted_button_id=NZUEC5XS8MFBJ)
|
||||||
|
*Please consider supporting this project by making a donation via [PayPal](https://www.paypal.com/donate/?hosted_button_id=NZUEC5XS8MFBJ)*
|
||||||
|
|
||||||
|
* **category** Library
|
||||||
|
* **package** \Com\Tecnick\Barcode
|
||||||
|
* **author** Nicola Asuni <info@tecnick.com>
|
||||||
|
* **copyright** 2001-2025 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* **license** http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* **link** https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
* **SRC DOC** https://tcpdf.org/docs/srcdoc/tc-lib-barcode
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
This library includes utility PHP classes to generate linear and bidimensional barcodes:
|
||||||
|
|
||||||
|
* C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9
|
||||||
|
* C39+ : CODE 39 with checksum
|
||||||
|
* C39E : CODE 39 EXTENDED
|
||||||
|
* C39E+ : CODE 39 EXTENDED + CHECKSUM
|
||||||
|
* C93 : CODE 93 - USS-93
|
||||||
|
* S25 : Standard 2 of 5
|
||||||
|
* S25+ : Standard 2 of 5 + CHECKSUM
|
||||||
|
* I25 : Interleaved 2 of 5
|
||||||
|
* I25+ : Interleaved 2 of 5 + CHECKSUM
|
||||||
|
* C128 : CODE 128
|
||||||
|
* C128A : CODE 128 A
|
||||||
|
* C128B : CODE 128 B
|
||||||
|
* C128C : CODE 128 C
|
||||||
|
* EAN2 : 2-Digits UPC-Based Extension
|
||||||
|
* EAN5 : 5-Digits UPC-Based Extension
|
||||||
|
* EAN8 : EAN 8
|
||||||
|
* EAN13 : EAN 13
|
||||||
|
* UPCA : UPC-A
|
||||||
|
* UPCE : UPC-E
|
||||||
|
* MSI : MSI (Variation of Plessey code)
|
||||||
|
* MSI+ : MSI + CHECKSUM (modulo 11)
|
||||||
|
* POSTNET : POSTNET
|
||||||
|
* PLANET : PLANET
|
||||||
|
* RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)
|
||||||
|
* KIX : KIX (Klant index - Customer index)
|
||||||
|
* IMB : IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
|
||||||
|
* IMBPRE : IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200- pre-processed
|
||||||
|
* CODABAR : CODABAR
|
||||||
|
* CODE11 : CODE 11
|
||||||
|
* PHARMA : PHARMACODE
|
||||||
|
* PHARMA2T : PHARMACODE TWO-TRACKS
|
||||||
|
* AZTEC : AZTEC Code (ISO/IEC 24778:2008)
|
||||||
|
* DATAMATRIX : DATAMATRIX (ISO/IEC 16022)
|
||||||
|
* PDF417 : PDF417 (ISO/IEC 15438:2006)
|
||||||
|
* QRCODE : QR-CODE
|
||||||
|
* RAW : 2D RAW MODE comma-separated rows
|
||||||
|
* RAW2 : 2D RAW MODE rows enclosed in square parentheses
|
||||||
|
|
||||||
|
### Output Formats
|
||||||
|
|
||||||
|
* PNG Image
|
||||||
|
* SVG Image
|
||||||
|
* HTML DIV
|
||||||
|
* Unicode String
|
||||||
|
* Binary String
|
||||||
|
|
||||||
|
The initial source code has been derived from [TCPDF](<http://www.tcpdf.org>).
|
||||||
|
|
||||||
|
|
||||||
|
## Getting started
|
||||||
|
|
||||||
|
First, you need to install all development dependencies using [Composer](https://getcomposer.org/):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ curl -sS https://getcomposer.org/installer | php
|
||||||
|
$ mv composer.phar /usr/local/bin/composer
|
||||||
|
```
|
||||||
|
|
||||||
|
This project include a Makefile that allows you to test and build the project with simple commands.
|
||||||
|
To see all available options:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make help
|
||||||
|
```
|
||||||
|
|
||||||
|
To install all the development dependencies:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make deps
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running all tests
|
||||||
|
|
||||||
|
Before committing the code, please check if it passes all tests using
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make qa
|
||||||
|
```
|
||||||
|
|
||||||
|
All artifacts are generated in the target directory.
|
||||||
|
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
Examples are located in the `example` directory.
|
||||||
|
|
||||||
|
Start a development server (requires PHP 8.0+) using the command:
|
||||||
|
|
||||||
|
```
|
||||||
|
make server
|
||||||
|
```
|
||||||
|
|
||||||
|
and point your browser to <http://localhost:8000/index.php>
|
||||||
|
|
||||||
|
|
||||||
|
### Simple Code Example
|
||||||
|
|
||||||
|
Please check example/index.php for a full example.
|
||||||
|
|
||||||
|
```
|
||||||
|
// instantiate the barcode class
|
||||||
|
$barcode = new \Com\Tecnick\Barcode\Barcode();
|
||||||
|
|
||||||
|
// generate a barcode
|
||||||
|
$bobj = $barcode->getBarcodeObj(
|
||||||
|
'QRCODE,H', // barcode type and additional comma-separated parameters
|
||||||
|
'https://tecnick.com', // data string to encode
|
||||||
|
-4, // bar width (use absolute or negative value as multiplication factor)
|
||||||
|
-4, // bar height (use absolute or negative value as multiplication factor)
|
||||||
|
'black', // foreground color
|
||||||
|
array(-2, -2, -2, -2) // padding (use absolute or negative values as multiplication factors)
|
||||||
|
)->setBackgroundColor('white'); // background color
|
||||||
|
|
||||||
|
// output the barcode as HTML div (see other output formats in the documentation and examples)
|
||||||
|
echo $bobj->getHtmlDiv();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Create a composer.json in your projects root-directory:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"require": {
|
||||||
|
"tecnickcom/tc-lib-barcode": "^2.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Or add to an existing project with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer require tecnickcom/tc-lib-barcode ^2.3
|
||||||
|
```
|
||||||
|
|
||||||
|
## Packaging
|
||||||
|
|
||||||
|
This library is mainly intended to be used and included in other PHP projects using Composer.
|
||||||
|
However, since some production environments dictates the installation of any application as RPM or DEB packages,
|
||||||
|
this library includes make targets for building these packages (`make rpm` and `make deb`).
|
||||||
|
The packages are generated under the `target` directory.
|
||||||
|
|
||||||
|
When this library is installed using an RPM or DEB package, you can use it your code by including the autoloader:
|
||||||
|
```php
|
||||||
|
require_once ('/usr/share/php/Com/Tecnick/Barcode/autoload.php');
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Developer(s) Contact
|
||||||
|
|
||||||
|
* Nicola Asuni <info@tecnick.com>
|
||||||
1
vendor/tecnickcom/tc-lib-barcode/RELEASE
vendored
Normal file
1
vendor/tecnickcom/tc-lib-barcode/RELEASE
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
5
vendor/tecnickcom/tc-lib-barcode/SECURITY.md
vendored
Normal file
5
vendor/tecnickcom/tc-lib-barcode/SECURITY.md
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
Please report (suspected) security vulnerabilities to info@tecnick.com.
|
||||||
1
vendor/tecnickcom/tc-lib-barcode/VERSION
vendored
Normal file
1
vendor/tecnickcom/tc-lib-barcode/VERSION
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
2.4.8
|
||||||
79
vendor/tecnickcom/tc-lib-barcode/composer.json
vendored
Normal file
79
vendor/tecnickcom/tc-lib-barcode/composer.json
vendored
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
{
|
||||||
|
"name": "tecnickcom/tc-lib-barcode",
|
||||||
|
"description": "PHP library to generate linear and bidimensional barcodes",
|
||||||
|
"type": "library",
|
||||||
|
"homepage": "http://www.tecnick.com",
|
||||||
|
"license": "LGPL-3.0-or-later",
|
||||||
|
"keywords": [
|
||||||
|
"3 of 9",
|
||||||
|
"ANSI MH10.8M-1983",
|
||||||
|
"AZTEC",
|
||||||
|
"barcode",
|
||||||
|
"CBC",
|
||||||
|
"CODABAR",
|
||||||
|
"CODE 11",
|
||||||
|
"CODE 128 A B C",
|
||||||
|
"CODE 39",
|
||||||
|
"CODE 93",
|
||||||
|
"Datamatrix",
|
||||||
|
"EAN 13",
|
||||||
|
"EAN 8",
|
||||||
|
"ECC200",
|
||||||
|
"Intelligent Mail Barcode",
|
||||||
|
"Interleaved 2 of 5",
|
||||||
|
"ISO IEC 15438 2006",
|
||||||
|
"ISO IEC 16022",
|
||||||
|
"ISO IEC 24778 2008",
|
||||||
|
"KIX",
|
||||||
|
"Klant",
|
||||||
|
"MSI",
|
||||||
|
"Onecode",
|
||||||
|
"PDF417",
|
||||||
|
"PHARMACODE TWO-TRACKS",
|
||||||
|
"PHARMACODE",
|
||||||
|
"PLANET",
|
||||||
|
"POSTNET",
|
||||||
|
"QR-Code",
|
||||||
|
"RMS4CC",
|
||||||
|
"Royal Mail",
|
||||||
|
"Standard 2 of 5",
|
||||||
|
"tc-lib-barcode",
|
||||||
|
"UPC-A",
|
||||||
|
"UPC-E",
|
||||||
|
"UPC",
|
||||||
|
"USD-3",
|
||||||
|
"USPS-B-3200",
|
||||||
|
"USS-93"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nicola Asuni",
|
||||||
|
"email": "info@tecnick.com",
|
||||||
|
"role": "lead"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"php": ">=8.1",
|
||||||
|
"ext-bcmath": "*",
|
||||||
|
"ext-date": "*",
|
||||||
|
"ext-gd": "*",
|
||||||
|
"ext-pcre": "*",
|
||||||
|
"tecnickcom/tc-lib-color": "^2.2"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"pdepend/pdepend": "2.16.2",
|
||||||
|
"phpmd/phpmd": "2.15.0",
|
||||||
|
"phpunit/phpunit": "12.2.0 || 11.5.7 || 10.5.40",
|
||||||
|
"squizlabs/php_codesniffer": "3.13.0"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Com\\Tecnick\\Barcode\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"Test\\": "test"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
121
vendor/tecnickcom/tc-lib-barcode/example/index.php
vendored
Normal file
121
vendor/tecnickcom/tc-lib-barcode/example/index.php
vendored
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* index.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2015-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// autoloader when using Composer
|
||||||
|
require(__DIR__ . '/../vendor/autoload.php');
|
||||||
|
|
||||||
|
// autoloader when using RPM or DEB package installation
|
||||||
|
//require ('/usr/share/php/Com/Tecnick/Barcode/autoload.php');
|
||||||
|
|
||||||
|
// data to generate for each barcode type
|
||||||
|
$linear = [
|
||||||
|
'C128A' => ['0123456789', 'CODE 128 A'],
|
||||||
|
'C128B' => ['0123456789', 'CODE 128 B'],
|
||||||
|
'C128C' => ['0123456789', 'CODE 128 C'],
|
||||||
|
'C128' => ['0123456789', 'CODE 128'],
|
||||||
|
'C39E+' => ['0123456789', 'CODE 39 EXTENDED + CHECKSUM'],
|
||||||
|
'C39E' => ['0123456789', 'CODE 39 EXTENDED'],
|
||||||
|
'C39+' => ['0123456789', 'CODE 39 + CHECKSUM'],
|
||||||
|
'C39' => ['0123456789', 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9'],
|
||||||
|
'C93' => ['0123456789', 'CODE 93 - USS-93'],
|
||||||
|
'CODABAR' => ['0123456789', 'CODABAR'],
|
||||||
|
'CODE11' => ['0123456789', 'CODE 11'],
|
||||||
|
'EAN13' => ['0123456789', 'EAN 13'],
|
||||||
|
'EAN2' => ['12', 'EAN 2-Digits UPC-Based Extension'],
|
||||||
|
'EAN5' => ['12345', 'EAN 5-Digits UPC-Based Extension'],
|
||||||
|
'EAN8' => ['1234567', 'EAN 8'],
|
||||||
|
'I25+' => ['0123456789', 'Interleaved 2 of 5 + CHECKSUM'],
|
||||||
|
'I25' => ['0123456789', 'Interleaved 2 of 5'],
|
||||||
|
'IMB' => ['01234567094987654321-01234567891', 'IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200'],
|
||||||
|
'IMBPRE' => ['AADTFFDFTDADTAADAATFDTDDAAADDTDTTDAFADADDDTFFFDDTTTADFAAADFTDAADA', 'IMB pre-processed'],
|
||||||
|
'KIX' => ['0123456789', 'KIX (Klant index - Customer index)'],
|
||||||
|
'MSI+' => ['0123456789', 'MSI + CHECKSUM (modulo 11)'],
|
||||||
|
'MSI' => ['0123456789', 'MSI (Variation of Plessey code)'],
|
||||||
|
'PHARMA2T' => ['0123456789', 'PHARMACODE TWO-TRACKS'],
|
||||||
|
'PHARMA' => ['0123456789', 'PHARMACODE'],
|
||||||
|
'PLANET' => ['0123456789', 'PLANET'],
|
||||||
|
'POSTNET' => ['0123456789', 'POSTNET'],
|
||||||
|
'RMS4CC' => ['0123456789', 'RMS4CC (Royal Mail 4-state Customer Bar Code)'],
|
||||||
|
'S25+' => ['0123456789', 'Standard 2 of 5 + CHECKSUM'],
|
||||||
|
'S25' => ['0123456789', 'Standard 2 of 5'],
|
||||||
|
'UPCA' => ['72527273070', 'UPC-A'],
|
||||||
|
'UPCE' => ['725277', 'UPC-E'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$square = [
|
||||||
|
'LRAW' => ['0101010101', '1D RAW MODE (comma-separated rows of 01 strings)'],
|
||||||
|
'SRAW' => ['0101,1010', '2D RAW MODE (comma-separated rows of 01 strings)'],
|
||||||
|
'AZTEC' => ['ABCDabcd01234', 'AZTEC (ISO/IEC 24778:2008)'],
|
||||||
|
'AZTEC,50,A,A' => ['ABCDabcd01234', 'AZTEC (ISO/IEC 24778:2008)'],
|
||||||
|
'PDF417' => ['0123456789', 'PDF417 (ISO/IEC 15438:2006)'],
|
||||||
|
'QRCODE' => ['0123456789', 'QR-CODE'],
|
||||||
|
'QRCODE,H,ST,0,0' => ['abcdefghijklmnopqrstuvwxy0123456789', 'QR-CODE WITH PARAMETERS'],
|
||||||
|
'DATAMATRIX' => ['0123456789', 'DATAMATRIX (ISO/IEC 16022) SQUARE'],
|
||||||
|
'DATAMATRIX,R' => ['0123456789012345678901234567890123456789', 'DATAMATRIX Rectangular (ISO/IEC 16022) RECTANGULAR'],
|
||||||
|
'DATAMATRIX,S,GS1' => [chr(232) . '01095011010209171719050810ABCD1234' . chr(232) . '2110', 'GS1 DATAMATRIX (ISO/IEC 16022) SQUARE GS1'],
|
||||||
|
'DATAMATRIX,R,GS1' => [chr(232) . '01095011010209171719050810ABCD1234' . chr(232) . '2110', 'GS1 DATAMATRIX (ISO/IEC 16022) RECTANGULAR GS1'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$barcode = new \Com\Tecnick\Barcode\Barcode();
|
||||||
|
|
||||||
|
$examples = '<h3>Linear</h3>' . "\n";
|
||||||
|
foreach ($linear as $type => $code) {
|
||||||
|
$bobj = $barcode->getBarcodeObj($type, $code[0], -3, -30, 'black', [0, 0, 0, 0]);
|
||||||
|
$examples .= '<h4>[<span>' . $type . '</span>] ' . $code[1] . '</h4><p style="font-family:monospace;">' . $bobj->getHtmlDiv() . '</p>' . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$examples .= '<h3>Square</h3>' . "\n";
|
||||||
|
foreach ($square as $type => $code) {
|
||||||
|
$bobj = $barcode->getBarcodeObj($type, $code[0], -4, -4, 'black', [0, 0, 0, 0]);
|
||||||
|
$examples .= '<h4>[<span>' . $type . '</span>] ' . $code[1] . '</h4><p style="font-family:monospace;">' . $bobj->getHtmlDiv() . '</p>' . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$bobj = $barcode->getBarcodeObj('QRCODE,H', 'https://tecnick.com', -4, -4, 'black', [-2, -2, -2, -2])->setBackgroundColor('#f0f0f0');
|
||||||
|
|
||||||
|
echo "
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Usage example of tc-lib-barcode library</title>
|
||||||
|
<meta charset=\"utf-8\">
|
||||||
|
<style>
|
||||||
|
body {font-family:Arial, Helvetica, sans-serif;margin:30px;}
|
||||||
|
table {border: 1px solid black;}
|
||||||
|
th {border: 1px solid black;padding:4px;background-barcode:cornsilk;}
|
||||||
|
td {border: 1px solid black;padding:4px;}
|
||||||
|
h3 {color:darkblue;}
|
||||||
|
h4 {color:darkgreen;}
|
||||||
|
h4 span {color:firebrick;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Usage example of tc-lib-barcode library</h1>
|
||||||
|
<p>This is an usage example of <a href=\"https://github.com/tecnickcom/tc-lib-barcode\" title=\"tc-lib-barcode: PHP library to generate linear and bidimensional barcodes\">tc-lib-barcode</a> library.</p>
|
||||||
|
<h2>Output Formats</h2>
|
||||||
|
<h3>PNG Image</h3>
|
||||||
|
<p><img alt=\"Embedded Image\" src=\"data:image/png;base64," . base64_encode($bobj->getPngData()) . "\" /></p>
|
||||||
|
<h3>SVG Image</h3>
|
||||||
|
<p style=\"font-family:monospace;\">" . $bobj->getSvgCode() . "</p>
|
||||||
|
<h3>HTML DIV</h3>
|
||||||
|
<p style=\"font-family:monospace;\">" . $bobj->getHtmlDiv() . "</p>
|
||||||
|
<h3>Unicode String</h3>
|
||||||
|
<pre style=\"font-family:monospace;line-height:0.61em;font-size:6px;\">" . $bobj->getGrid(json_decode('"\u00A0"'), json_decode('"\u2584"')) . "</pre>
|
||||||
|
<h3>Binary String</h3>
|
||||||
|
<pre style=\"font-family:monospace;\">" . $bobj->getGrid() . "</pre>
|
||||||
|
<h2>Barcode Types</h2>
|
||||||
|
" . $examples . "
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
";
|
||||||
15
vendor/tecnickcom/tc-lib-barcode/phpcompatinfo.json
vendored
Normal file
15
vendor/tecnickcom/tc-lib-barcode/phpcompatinfo.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"source-providers": [
|
||||||
|
{
|
||||||
|
"in": "src as source",
|
||||||
|
"exclude": "vendor",
|
||||||
|
"name": "/\\.(php)$/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
],
|
||||||
|
"analysers": [
|
||||||
|
],
|
||||||
|
"services": [
|
||||||
|
]
|
||||||
|
}
|
||||||
7
vendor/tecnickcom/tc-lib-barcode/phpcs.xml
vendored
Normal file
7
vendor/tecnickcom/tc-lib-barcode/phpcs.xml
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<ruleset name="backward-compatibility">
|
||||||
|
<description>PSR-12 for PHP less than 7.1</description>
|
||||||
|
<rule ref="PSR12">
|
||||||
|
<exclude name="PSR12.Properties.ConstantVisibility"/>
|
||||||
|
</rule>
|
||||||
|
</ruleset>
|
||||||
10
vendor/tecnickcom/tc-lib-barcode/phpstan.neon
vendored
Normal file
10
vendor/tecnickcom/tc-lib-barcode/phpstan.neon
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
parameters:
|
||||||
|
level: max
|
||||||
|
paths:
|
||||||
|
- src
|
||||||
|
- test
|
||||||
|
excludePaths:
|
||||||
|
- vendor
|
||||||
|
ignoreErrors:
|
||||||
|
reportUnmatchedIgnoredErrors: false
|
||||||
|
treatPhpDocTypesAsCertain: false
|
||||||
31
vendor/tecnickcom/tc-lib-barcode/phpunit.xml.dist
vendored
Normal file
31
vendor/tecnickcom/tc-lib-barcode/phpunit.xml.dist
vendored
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<phpunit backupGlobals="false"
|
||||||
|
bootstrap="vendor/autoload.php"
|
||||||
|
colors="true"
|
||||||
|
displayDetailsOnTestsThatTriggerDeprecations="true"
|
||||||
|
displayDetailsOnTestsThatTriggerErrors="true"
|
||||||
|
displayDetailsOnTestsThatTriggerNotices="true"
|
||||||
|
displayDetailsOnTestsThatTriggerWarnings="true"
|
||||||
|
displayDetailsOnPhpunitDeprecations="true"
|
||||||
|
processIsolation="false"
|
||||||
|
stopOnFailure="false">
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="tc-lib-barcode Test Suite">
|
||||||
|
<directory>./test</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
<source>
|
||||||
|
<include>
|
||||||
|
<directory suffix=".php">src</directory>
|
||||||
|
</include>
|
||||||
|
</source>
|
||||||
|
<coverage>
|
||||||
|
<report>
|
||||||
|
<clover outputFile="target/coverage/coverage.xml"/>
|
||||||
|
<html outputDirectory="target/coverage" lowUpperBound="50" highLowerBound="90"/>
|
||||||
|
</report>
|
||||||
|
</coverage>
|
||||||
|
<logging>
|
||||||
|
<junit outputFile="target/logs/junit.xml"/>
|
||||||
|
</logging>
|
||||||
|
</phpunit>
|
||||||
30
vendor/tecnickcom/tc-lib-barcode/resources/autoload.php
vendored
Normal file
30
vendor/tecnickcom/tc-lib-barcode/resources/autoload.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* autoload.php
|
||||||
|
*
|
||||||
|
* Autoloader for Tecnick.com libraries
|
||||||
|
*
|
||||||
|
* @since 2015-03-04
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2015-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
spl_autoload_register(
|
||||||
|
function ($class) {
|
||||||
|
$prefix = 'Com\\Tecnick\\';
|
||||||
|
$len = strlen($prefix);
|
||||||
|
if (strncmp($prefix, $class, $len) !== 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$relative_class = substr($class, $len);
|
||||||
|
$file = dirname(__DIR__).'/'.str_replace('\\', '/', $relative_class).'.php';
|
||||||
|
if (file_exists($file)) {
|
||||||
|
require $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
7
vendor/tecnickcom/tc-lib-barcode/resources/debian/changelog
vendored
Normal file
7
vendor/tecnickcom/tc-lib-barcode/resources/debian/changelog
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
~#PKGNAME#~ (~#VERSION#~-~#RELEASE#~) UNRELEASED; urgency=low
|
||||||
|
|
||||||
|
* Please check the
|
||||||
|
https://github.com/~#VENDOR#~/~#PROJECT#~
|
||||||
|
commit history
|
||||||
|
|
||||||
|
-- Nicola Asuni <info@tecnick.com> ~#DATE#~
|
||||||
1
vendor/tecnickcom/tc-lib-barcode/resources/debian/compat
vendored
Normal file
1
vendor/tecnickcom/tc-lib-barcode/resources/debian/compat
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
10
|
||||||
23
vendor/tecnickcom/tc-lib-barcode/resources/debian/control
vendored
Normal file
23
vendor/tecnickcom/tc-lib-barcode/resources/debian/control
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
Source: ~#PKGNAME#~
|
||||||
|
Maintainer: Nicola Asuni <info@tecnick.com>
|
||||||
|
Section: php
|
||||||
|
Priority: optional
|
||||||
|
Build-Depends: debhelper (>= 9)
|
||||||
|
Standards-Version: 3.9.7
|
||||||
|
Homepage: https://github.com/~#VENDOR#~/~#PROJECT#~
|
||||||
|
Vcs-Git: https://github.com/~#VENDOR#~/~#PROJECT#~.git
|
||||||
|
|
||||||
|
Package: ~#PKGNAME#~
|
||||||
|
Provides: php-~#PROJECT#~
|
||||||
|
Architecture: all
|
||||||
|
Depends: php (>= 8.1.0), php-bcmath, php-date, php-gd, php-tecnickcom-tc-lib-color (<< 3.0.0), php-tecnickcom-tc-lib-color (>= 2.2.13), ${misc:Depends}
|
||||||
|
Description: PHP Barcode library
|
||||||
|
This library includes PHP classes to generate linear
|
||||||
|
and bidimensional barcodes:
|
||||||
|
CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93,
|
||||||
|
USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C,
|
||||||
|
2 and 5 Digits UPC-Based Extension, EAN 8, EAN 13, UPC-A,
|
||||||
|
UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code),
|
||||||
|
CBC (Customer Bar Code), KIX (Klant index - Customer index),
|
||||||
|
Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11,
|
||||||
|
PHARMACODE, PHARMACODE TWO-TRACKS, AZTEC, Datamatrix ECC200, QR-Code, PDF417.
|
||||||
20
vendor/tecnickcom/tc-lib-barcode/resources/debian/copyright
vendored
Normal file
20
vendor/tecnickcom/tc-lib-barcode/resources/debian/copyright
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||||
|
Upstream-Name: ~#PROJECT#~
|
||||||
|
Source: https://github.com/~#VENDOR#~/~#PROJECT#~
|
||||||
|
|
||||||
|
Files: *
|
||||||
|
Copyright: Copyright 2001-2024 Nicola Asuni <info@tecnick.com>
|
||||||
|
License: LGPL-3
|
||||||
|
|
||||||
|
License: LGPL-3
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/> or
|
||||||
|
/usr/share/common-licenses/LGPL-3
|
||||||
3
vendor/tecnickcom/tc-lib-barcode/resources/debian/rules
vendored
Normal file
3
vendor/tecnickcom/tc-lib-barcode/resources/debian/rules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/make -f
|
||||||
|
%:
|
||||||
|
dh $@
|
||||||
1
vendor/tecnickcom/tc-lib-barcode/resources/debian/source/format
vendored
Normal file
1
vendor/tecnickcom/tc-lib-barcode/resources/debian/source/format
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
3.0 (quilt)
|
||||||
22
vendor/tecnickcom/tc-lib-barcode/resources/phpmd/codesize.xml
vendored
Normal file
22
vendor/tecnickcom/tc-lib-barcode/resources/phpmd/codesize.xml
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ruleset name="pcsg-generated-ruleset"
|
||||||
|
xmlns="http://pmd.sf.net/ruleset/1.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
|
||||||
|
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
|
||||||
|
<description>Created with the PHP Coding Standard Generator. http://edorian.github.com/php-coding-standard-generator/
|
||||||
|
</description>
|
||||||
|
<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>
|
||||||
|
<rule ref="rulesets/codesize.xml/NPathComplexity"/>
|
||||||
|
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>
|
||||||
|
<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>
|
||||||
|
<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>
|
||||||
|
<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>
|
||||||
|
<rule ref="rulesets/codesize.xml/TooManyFields"/>
|
||||||
|
<rule ref="rulesets/codesize.xml/TooManyMethods"/>
|
||||||
|
<rule ref="rulesets/codesize.xml/ExcessiveClassComplexity">
|
||||||
|
<properties>
|
||||||
|
<property name="maximum" value="60"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
</ruleset>
|
||||||
18
vendor/tecnickcom/tc-lib-barcode/resources/phpmd/design.xml
vendored
Normal file
18
vendor/tecnickcom/tc-lib-barcode/resources/phpmd/design.xml
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ruleset name="pcsg-generated-ruleset"
|
||||||
|
xmlns="http://pmd.sf.net/ruleset/1.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
|
||||||
|
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
|
||||||
|
<description>Created with the PHP Coding Standard Generator. http://edorian.github.com/php-coding-standard-generator/
|
||||||
|
</description>
|
||||||
|
<rule ref="rulesets/design.xml/ExitExpression"/>
|
||||||
|
<rule ref="rulesets/design.xml/EvalExpression"/>
|
||||||
|
<rule ref="rulesets/design.xml/GotoStatement"/>
|
||||||
|
<rule ref="rulesets/design.xml/DepthOfInheritance">
|
||||||
|
<properties>
|
||||||
|
<property name="minimum" value="7"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
<rule ref="rulesets/design.xml/CouplingBetweenObjects"/>
|
||||||
|
</ruleset>
|
||||||
63
vendor/tecnickcom/tc-lib-barcode/resources/rpm/rpm.spec
vendored
Normal file
63
vendor/tecnickcom/tc-lib-barcode/resources/rpm/rpm.spec
vendored
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
# SPEC file
|
||||||
|
|
||||||
|
%global c_vendor %{_vendor}
|
||||||
|
%global gh_owner %{_owner}
|
||||||
|
%global gh_project %{_project}
|
||||||
|
|
||||||
|
Name: %{_package}
|
||||||
|
Version: %{_version}
|
||||||
|
Release: %{_release}%{?dist}
|
||||||
|
Summary: PHP library to generate linear and bidimensional barcodes
|
||||||
|
|
||||||
|
Group: Development/Libraries
|
||||||
|
License: LGPLv3+
|
||||||
|
URL: https://github.com/%{gh_owner}/%{gh_project}
|
||||||
|
|
||||||
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
|
||||||
|
BuildArch: noarch
|
||||||
|
|
||||||
|
Requires: php(language) >= 8.1.0
|
||||||
|
Requires: php-composer(%{c_vendor}/tc-lib-color) < 3.0.0
|
||||||
|
Requires: php-composer(%{c_vendor}/tc-lib-color) >= 2.2.13
|
||||||
|
Requires: php-bcmath
|
||||||
|
Requires: php-date
|
||||||
|
Requires: php-gd
|
||||||
|
Requires: php-pcre
|
||||||
|
|
||||||
|
Provides: php-composer(%{c_vendor}/%{gh_project}) = %{version}
|
||||||
|
Provides: php-%{gh_project} = %{version}
|
||||||
|
|
||||||
|
%description
|
||||||
|
PHP classes to generate linear and bidimensional barcodes:
|
||||||
|
CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93,
|
||||||
|
Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C,
|
||||||
|
2 and 5 Digits UPC-Based Extension, EAN 8, EAN 13, UPC-A,
|
||||||
|
UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code),
|
||||||
|
CBC (Customer Bar Code), KIX (Klant index - Customer index),
|
||||||
|
Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11,
|
||||||
|
PHARMACODE, PHARMACODE TWO-TRACKS, AZTEC, Datamatrix ECC200, QR-Code, PDF417.
|
||||||
|
|
||||||
|
Optional dependency: php-pecl-imagick
|
||||||
|
|
||||||
|
%build
|
||||||
|
#(cd %{_current_directory} && make build)
|
||||||
|
|
||||||
|
%install
|
||||||
|
rm -rf $RPM_BUILD_ROOT
|
||||||
|
(cd %{_current_directory} && make install DESTDIR=$RPM_BUILD_ROOT)
|
||||||
|
|
||||||
|
%clean
|
||||||
|
rm -rf $RPM_BUILD_ROOT
|
||||||
|
#(cd %{_current_directory} && make clean)
|
||||||
|
|
||||||
|
%files
|
||||||
|
%attr(-,root,root) %{_libpath}
|
||||||
|
%attr(-,root,root) %{_docpath}
|
||||||
|
%docdir %{_docpath}
|
||||||
|
#%config(noreplace) %{_configpath}*
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
* Thu Jul 02 2024 Nicola Asuni <info@tecnick.com> 1.2.0-1
|
||||||
|
- Changed package name, add provides section
|
||||||
|
* Tue Feb 24 2024 Nicola Asuni <info@tecnick.com> 1.0.0-1
|
||||||
|
- Initial Commit
|
||||||
158
vendor/tecnickcom/tc-lib-barcode/src/Barcode.php
vendored
Normal file
158
vendor/tecnickcom/tc-lib-barcode/src/Barcode.php
vendored
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Barcode.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2015-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Barcode
|
||||||
|
*
|
||||||
|
* Barcode Barcode class
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class Barcode
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* List of supported Barcode Types with description.
|
||||||
|
*
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
public const BARCODETYPES = [
|
||||||
|
'C128' => 'CODE 128',
|
||||||
|
'C128A' => 'CODE 128 A',
|
||||||
|
'C128B' => 'CODE 128 B',
|
||||||
|
'C128C' => 'CODE 128 C',
|
||||||
|
'C39' => 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.',
|
||||||
|
'C39+' => 'CODE 39 + CHECKSUM',
|
||||||
|
'C39E' => 'CODE 39 EXTENDED',
|
||||||
|
'C39E+' => 'CODE 39 EXTENDED + CHECKSUM',
|
||||||
|
'C93' => 'CODE 93 - USS-93',
|
||||||
|
'CODABAR' => 'CODABAR',
|
||||||
|
'CODE11' => 'CODE 11',
|
||||||
|
'EAN13' => 'EAN 13',
|
||||||
|
'EAN2' => 'EAN 2-Digits UPC-Based Extension',
|
||||||
|
'EAN5' => 'EAN 5-Digits UPC-Based Extension',
|
||||||
|
'EAN8' => 'EAN 8',
|
||||||
|
'I25' => 'Interleaved 2 of 5',
|
||||||
|
'I25+' => 'Interleaved 2 of 5 + CHECKSUM',
|
||||||
|
'IMB' => 'IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200',
|
||||||
|
'IMBPRE' => 'IMB - Intelligent Mail Barcode pre-processed',
|
||||||
|
'KIX' => 'KIX (Klant index - Customer index)',
|
||||||
|
'LRAW' => '1D RAW MODE (comma-separated rows of 01 strings)',
|
||||||
|
'MSI' => 'MSI (Variation of Plessey code)',
|
||||||
|
'MSI+' => 'MSI + CHECKSUM (modulo 11)',
|
||||||
|
'PHARMA' => 'PHARMACODE',
|
||||||
|
'PHARMA2T' => 'PHARMACODE TWO-TRACKS',
|
||||||
|
'PLANET' => 'PLANET',
|
||||||
|
'POSTNET' => 'POSTNET',
|
||||||
|
'RMS4CC' => 'RMS4CC (Royal Mail 4-state Customer Bar Code)',
|
||||||
|
'S25' => 'Standard 2 of 5',
|
||||||
|
'S25+' => 'Standard 2 of 5 + CHECKSUM',
|
||||||
|
'UPCA' => 'UPC-A',
|
||||||
|
'UPCE' => 'UPC-E',
|
||||||
|
'AZTEC' => 'AZTEC Code (ISO/IEC 24778:2008)',
|
||||||
|
'DATAMATRIX' => 'DATAMATRIX (ISO/IEC 16022)',
|
||||||
|
'PDF417' => 'PDF417 (ISO/IEC 15438:2006)',
|
||||||
|
'QRCODE' => 'QR-CODE',
|
||||||
|
'SRAW' => '2D RAW MODE (comma-separated rows of 01 strings)',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the barcode object
|
||||||
|
*
|
||||||
|
* @param string $type Barcode type
|
||||||
|
* @param string $code Barcode content
|
||||||
|
* @param int $width Barcode width in user units (excluding padding).
|
||||||
|
* A negative value indicates the multiplication
|
||||||
|
* factor for each column.
|
||||||
|
* @param int $height Barcode height in user units (excluding padding).
|
||||||
|
* A negative value indicates the multiplication
|
||||||
|
* factor for each row.
|
||||||
|
* @param string $color Foreground color in Web notation
|
||||||
|
* (color name, or hexadecimal code, or CSS syntax)
|
||||||
|
* @param array{int, int, int, int} $padding Additional padding to add around the barcode
|
||||||
|
* (top, right, bottom, left) in user units. A
|
||||||
|
* negative value indicates the multiplication
|
||||||
|
* factor for each row or column.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
public function getBarcodeObj(
|
||||||
|
string $type,
|
||||||
|
string $code,
|
||||||
|
int $width = -1,
|
||||||
|
int $height = -1,
|
||||||
|
string $color = 'black',
|
||||||
|
array $padding = [0, 0, 0, 0]
|
||||||
|
): Model {
|
||||||
|
// extract extra parameters (if any)
|
||||||
|
$params = explode(',', $type);
|
||||||
|
$type = array_shift($params);
|
||||||
|
|
||||||
|
$bclass = match ($type) {
|
||||||
|
'C128' => 'Linear\\CodeOneTwoEight', // CODE 128
|
||||||
|
'C128A' => 'Linear\\CodeOneTwoEight\\CodeOneTwoEightA', // CODE 128 A
|
||||||
|
'C128B' => 'Linear\\CodeOneTwoEight\\CodeOneTwoEightB', // CODE 128 B
|
||||||
|
'C128C' => 'Linear\\CodeOneTwoEight\\CodeOneTwoEightC', // CODE 128 C
|
||||||
|
'C39' => 'Linear\\CodeThreeNine', // CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.
|
||||||
|
'C39+' => 'Linear\\CodeThreeNineCheck', // CODE 39 + CHECKSUM
|
||||||
|
'C39E' => 'Linear\\CodeThreeNineExt', // CODE 39 EXTENDED
|
||||||
|
'C39E+' => 'Linear\\CodeThreeNineExtCheck', // CODE 39 EXTENDED + CHECKSUM
|
||||||
|
'C93' => 'Linear\\CodeNineThree', // CODE 93 - USS-93
|
||||||
|
'CODABAR' => 'Linear\\Codabar', // CODABAR
|
||||||
|
'CODE11' => 'Linear\\CodeOneOne', // CODE 11
|
||||||
|
'EAN13' => 'Linear\\EanOneThree', // EAN 13
|
||||||
|
'EAN2' => 'Linear\\EanTwo', // EAN 2-Digits UPC-Based Extension
|
||||||
|
'EAN5' => 'Linear\\EanFive', // EAN 5-Digits UPC-Based Extension
|
||||||
|
'EAN8' => 'Linear\\EanEight', // EAN 8
|
||||||
|
'I25' => 'Linear\\InterleavedTwoOfFive', // Interleaved 2 of 5
|
||||||
|
'I25+' => 'Linear\\InterleavedTwoOfFiveCheck', // Interleaved 2 of 5 + CHECKSUM
|
||||||
|
'IMB' => 'Linear\\Imb', // IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
|
||||||
|
'IMBPRE' => 'Linear\\ImbPre', // IMB - Intelligent Mail Barcode pre-processed
|
||||||
|
'KIX' => 'Linear\\KlantIndex', // KIX (Klant index - Customer index)
|
||||||
|
'LRAW' => 'Linear\\Raw', // 1D RAW MODE (comma-separated rows of 01 strings)
|
||||||
|
'MSI' => 'Linear\\Msi', // MSI (Variation of Plessey code)
|
||||||
|
'MSI+' => 'Linear\\MsiCheck', // MSI + CHECKSUM (modulo 11)
|
||||||
|
'PHARMA' => 'Linear\\Pharma', // PHARMACODE
|
||||||
|
'PHARMA2T' => 'Linear\\PharmaTwoTracks', // PHARMACODE TWO-TRACKS
|
||||||
|
'PLANET' => 'Linear\\Planet', // PLANET
|
||||||
|
'POSTNET' => 'Linear\\Postnet', // POSTNET
|
||||||
|
'RMS4CC' => 'Linear\\RoyalMailFourCc', // RMS4CC (Royal Mail 4-state Customer Bar Code)
|
||||||
|
'S25' => 'Linear\\StandardTwoOfFive', // Standard 2 of 5
|
||||||
|
'S25+' => 'Linear\\StandardTwoOfFiveCheck', // Standard 2 of 5 + CHECKSUM
|
||||||
|
'UPCA' => 'Linear\\UpcA', // UPC-A
|
||||||
|
'UPCE' => 'Linear\\UpcE', // UPC-E
|
||||||
|
'AZTEC' => 'Square\\Aztec', // AZTEC Code (ISO/IEC 24778:2008)
|
||||||
|
'DATAMATRIX' => 'Square\\Datamatrix', // DATAMATRIX (ISO/IEC 16022)
|
||||||
|
'PDF417' => 'Square\\PdfFourOneSeven', // PDF417 (ISO/IEC 15438:2006)
|
||||||
|
'QRCODE' => 'Square\\QrCode', // QR-CODE
|
||||||
|
'SRAW' => 'Square\\Raw', // 2D RAW MODE (comma-separated rows of 01 strings)
|
||||||
|
default => throw new BarcodeException('Unsupported barcode type: ' . $type)
|
||||||
|
};
|
||||||
|
|
||||||
|
$class = '\\Com\\Tecnick\\Barcode\\Type\\' . $bclass;
|
||||||
|
/* @phpstan-ignore-next-line */
|
||||||
|
return new $class($code, $width, $height, $color, $params, $padding);
|
||||||
|
}
|
||||||
|
}
|
||||||
34
vendor/tecnickcom/tc-lib-barcode/src/Exception.php
vendored
Normal file
34
vendor/tecnickcom/tc-lib-barcode/src/Exception.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Exception
|
||||||
|
*
|
||||||
|
* Custom Exception class
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class Exception extends \Exception
|
||||||
|
{
|
||||||
|
}
|
||||||
199
vendor/tecnickcom/tc-lib-barcode/src/Model.php
vendored
Normal file
199
vendor/tecnickcom/tc-lib-barcode/src/Model.php
vendored
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2015-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
use Com\Tecnick\Color\Exception as ColorException;
|
||||||
|
use Com\Tecnick\Color\Model\Rgb;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type
|
||||||
|
*
|
||||||
|
* Barcode Type class
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2015-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
interface Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Set the size of the barcode to be exported
|
||||||
|
*
|
||||||
|
* @param int $width Barcode width in user units (excluding padding).
|
||||||
|
* A negative value indicates the multiplication
|
||||||
|
* factor for each column.
|
||||||
|
* @param int $height Barcode height in user units (excluding padding).
|
||||||
|
* A negative value indicates the multiplication
|
||||||
|
* factor for each row.
|
||||||
|
* @param array{int, int, int, int} $padding Additional padding to add around the barcode
|
||||||
|
* (top, right, bottom, left) in user units. A
|
||||||
|
* negative value indicates the number or rows
|
||||||
|
* or columns.
|
||||||
|
*/
|
||||||
|
public function setSize(int $width, int $height, array $padding = [0, 0, 0, 0]): static;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the color of the bars.
|
||||||
|
* If the color is transparent or empty it will be set to the default black color.
|
||||||
|
*
|
||||||
|
* @param string $color Foreground color in Web notation (color name, or hexadecimal code, or CSS syntax)
|
||||||
|
*
|
||||||
|
* @throws ColorException in case of color error
|
||||||
|
* @throws BarcodeException in case of empty or transparent color
|
||||||
|
*/
|
||||||
|
public function setColor(string $color): static;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the background color
|
||||||
|
*
|
||||||
|
* @param string $color Background color in Web notation (color name, or hexadecimal code, or CSS syntax)
|
||||||
|
*
|
||||||
|
* @throws ColorException in case of color error
|
||||||
|
*/
|
||||||
|
public function setBackgroundColor(string $color): static;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the barcode raw array
|
||||||
|
*
|
||||||
|
* @return array{
|
||||||
|
* 'type': string,
|
||||||
|
* 'format': string,
|
||||||
|
* 'params': array<int|float|string>,
|
||||||
|
* 'code': string,
|
||||||
|
* 'extcode': string,
|
||||||
|
* 'ncols': int,
|
||||||
|
* 'nrows': int,
|
||||||
|
* 'width': int,
|
||||||
|
* 'height': int,
|
||||||
|
* 'width_ratio': float,
|
||||||
|
* 'height_ratio': float,
|
||||||
|
* 'padding': array{'T': int, 'R': int, 'B': int, 'L': int},
|
||||||
|
* 'full_width': int,
|
||||||
|
* 'full_height': int,
|
||||||
|
* 'color_obj': Rgb,
|
||||||
|
* 'bg_color_obj': ?Rgb,
|
||||||
|
* 'bars': array<array{int, int, int, int}>,
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
public function getArray(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the extended code (code + checksum)
|
||||||
|
*/
|
||||||
|
public function getExtendedCode(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the barcode as SVG image object
|
||||||
|
*
|
||||||
|
* @param string|null $filename The file name without extension (optional).
|
||||||
|
* Only allows alphanumeric characters, underscores and hyphens.
|
||||||
|
* Defaults to a md5 hash of the data.
|
||||||
|
* The file extension is always '.svg'.
|
||||||
|
*/
|
||||||
|
public function getSvg(?string $filename = null): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the barcode as inline SVG code.
|
||||||
|
*
|
||||||
|
* @return string Inline SVG code.
|
||||||
|
*/
|
||||||
|
public function getInlineSvgCode(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the barcode as SVG code, including the XML declaration.
|
||||||
|
*
|
||||||
|
* @return string SVG code
|
||||||
|
*/
|
||||||
|
public function getSvgCode(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an HTML representation of the barcode.
|
||||||
|
*
|
||||||
|
* @return string HTML code (DIV block)
|
||||||
|
*/
|
||||||
|
public function getHtmlDiv(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Barcode as PNG Image (requires GD or Imagick library)
|
||||||
|
*
|
||||||
|
* @param string|null $filename The file name without extension (optional).
|
||||||
|
* Only allows alphanumeric characters, underscores and hyphens.
|
||||||
|
* Defaults to a md5 hash of the data.
|
||||||
|
* The file extension is always '.png'.
|
||||||
|
*/
|
||||||
|
public function getPng(?string $filename = null): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the barcode as PNG image (requires GD or Imagick library)
|
||||||
|
*
|
||||||
|
* @param bool $imagick If true try to use the Imagick extension
|
||||||
|
*
|
||||||
|
* @return string PNG image data
|
||||||
|
*/
|
||||||
|
public function getPngData(bool $imagick = true): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the barcode as PNG image (requires Imagick library)
|
||||||
|
*
|
||||||
|
* @throws BarcodeException if the Imagick library is not installed
|
||||||
|
*/
|
||||||
|
public function getPngDataImagick(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the barcode as GD image object (requires GD library)
|
||||||
|
*
|
||||||
|
* @throws BarcodeException if the GD library is not installed
|
||||||
|
*/
|
||||||
|
public function getGd(): \GdImage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a raw barcode string representation using characters
|
||||||
|
*
|
||||||
|
* @param string $space_char Character or string to use for filling empty spaces
|
||||||
|
* @param string $bar_char Character or string to use for filling bars
|
||||||
|
*/
|
||||||
|
public function getGrid(string $space_char = '0', string $bar_char = '1'): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a raw barcode grid array
|
||||||
|
*
|
||||||
|
* @param string $space_char Character or string to use for filling empty spaces
|
||||||
|
* @param string $bar_char Character or string to use for filling bars
|
||||||
|
*
|
||||||
|
* @return array<int, array<int, string>>
|
||||||
|
*/
|
||||||
|
public function getGridArray(string $space_char = '0', string $bar_char = '1'): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the array containing all the formatted bars coordinates
|
||||||
|
*
|
||||||
|
* @return array<int, array{float, float, float, float}>
|
||||||
|
*/
|
||||||
|
public function getBarsArrayXYXY(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the array containing all the formatted bars coordinates
|
||||||
|
*
|
||||||
|
* @return array<int, array{float, float, float, float}>
|
||||||
|
*/
|
||||||
|
public function getBarsArrayXYWH(): array;
|
||||||
|
}
|
||||||
650
vendor/tecnickcom/tc-lib-barcode/src/Type.php
vendored
Normal file
650
vendor/tecnickcom/tc-lib-barcode/src/Type.php
vendored
Normal file
@@ -0,0 +1,650 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2015-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
use Com\Tecnick\Color\Exception as ColorException;
|
||||||
|
use Com\Tecnick\Color\Model\Rgb;
|
||||||
|
use Com\Tecnick\Color\Pdf;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type
|
||||||
|
*
|
||||||
|
* Barcode Type class
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2015-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* @SuppressWarnings("PHPMD.ExcessiveClassComplexity")
|
||||||
|
*/
|
||||||
|
abstract class Type extends \Com\Tecnick\Barcode\Type\Convert implements Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Initialize a new barcode object
|
||||||
|
*
|
||||||
|
* @param string $code Barcode content
|
||||||
|
* @param int $width Barcode width in user units (excluding padding).
|
||||||
|
* A negative value indicates the multiplication
|
||||||
|
* factor for each column.
|
||||||
|
* @param int $height Barcode height in user units (excluding padding).
|
||||||
|
* A negative value indicates the multiplication
|
||||||
|
* factor for each row.
|
||||||
|
* @param string $color Foreground color in Web notation
|
||||||
|
* (color name, or hexadecimal code, or CSS syntax)
|
||||||
|
* @param array<int|float|string> $params Array containing extra parameters for the specified barcode type
|
||||||
|
* @param array{int, int, int, int} $padding Additional padding to add around the barcode
|
||||||
|
* (top, right, bottom, left) in user units. A
|
||||||
|
* negative value indicates the number or rows
|
||||||
|
* or columns.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
* @throws ColorException in case of color error
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
string $code,
|
||||||
|
int $width = -1,
|
||||||
|
int $height = -1,
|
||||||
|
string $color = 'black',
|
||||||
|
array $params = [],
|
||||||
|
array $padding = [0, 0, 0, 0]
|
||||||
|
) {
|
||||||
|
$this->code = $code;
|
||||||
|
$this->extcode = $code;
|
||||||
|
$this->params = $params;
|
||||||
|
$this->setParameters();
|
||||||
|
$this->setBars();
|
||||||
|
$this->setSize($width, $height, $padding);
|
||||||
|
$this->setColor($color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set extra (optional) parameters
|
||||||
|
*/
|
||||||
|
protected function setParameters(): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bars array
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the size of the barcode to be exported
|
||||||
|
*
|
||||||
|
* @param int $width Barcode width in user units (excluding padding).
|
||||||
|
* A negative value indicates the multiplication
|
||||||
|
* factor for each column.
|
||||||
|
* @param int $height Barcode height in user units (excluding padding).
|
||||||
|
* A negative value indicates the multiplication
|
||||||
|
* factor for each row.
|
||||||
|
* @param array{int, int, int, int} $padding Additional padding to add around the barcode
|
||||||
|
* (top, right, bottom, left) in user units. A
|
||||||
|
* negative value indicates the number or rows
|
||||||
|
* or columns.
|
||||||
|
*/
|
||||||
|
public function setSize(
|
||||||
|
int $width,
|
||||||
|
int $height,
|
||||||
|
array $padding = [0, 0, 0, 0]
|
||||||
|
): static {
|
||||||
|
$this->width = $width;
|
||||||
|
if ($this->width <= 0) {
|
||||||
|
$this->width = (abs(min(-1, $this->width)) * $this->ncols);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->height = $height;
|
||||||
|
if ($this->height <= 0) {
|
||||||
|
$this->height = (abs(min(-1, $this->height)) * $this->nrows);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->width_ratio = ($this->width / $this->ncols);
|
||||||
|
$this->height_ratio = ($this->height / $this->nrows);
|
||||||
|
|
||||||
|
$this->setPadding($padding);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the barcode padding
|
||||||
|
*
|
||||||
|
* @param array{int, int, int, int} $padding Additional padding to add around the barcode
|
||||||
|
* (top, right, bottom, left) in user units.
|
||||||
|
* A negative value indicates the number or rows or columns.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setPadding(array $padding): static
|
||||||
|
{
|
||||||
|
if (count($padding) != 4) {
|
||||||
|
throw new BarcodeException(
|
||||||
|
'Invalid padding, expecting an array of 4 numbers (top, right, bottom, left)'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$map = [
|
||||||
|
['T', $this->height_ratio],
|
||||||
|
['R', $this->width_ratio],
|
||||||
|
['B', $this->height_ratio],
|
||||||
|
['L', $this->width_ratio],
|
||||||
|
];
|
||||||
|
foreach ($padding as $key => $val) {
|
||||||
|
if ($val < 0) {
|
||||||
|
$val = (abs(min(-1, $val)) * $map[$key][1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->padding[$map[$key][0]] = (int) $val;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the color of the bars.
|
||||||
|
* If the color is transparent or empty it will be set to the default black color.
|
||||||
|
*
|
||||||
|
* @param string $color Foreground color in Web notation (color name, or hexadecimal code, or CSS syntax)
|
||||||
|
*
|
||||||
|
* @throws ColorException in case of color error
|
||||||
|
* @throws BarcodeException in case of empty or transparent color
|
||||||
|
*/
|
||||||
|
public function setColor(string $color): static
|
||||||
|
{
|
||||||
|
$colobj = $this->getRgbColorObject($color);
|
||||||
|
if (! $colobj instanceof \Com\Tecnick\Color\Model\Rgb) {
|
||||||
|
throw new BarcodeException('The foreground color cannot be empty or transparent');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->color_obj = $colobj;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the background color
|
||||||
|
*
|
||||||
|
* @param string $color Background color in Web notation (color name, or hexadecimal code, or CSS syntax)
|
||||||
|
*
|
||||||
|
* @throws ColorException in case of color error
|
||||||
|
*/
|
||||||
|
public function setBackgroundColor(string $color): static
|
||||||
|
{
|
||||||
|
$this->bg_color_obj = $this->getRgbColorObject($color);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the RGB Color object for the given color representation
|
||||||
|
*
|
||||||
|
* @param string $color Color in Web notation (color name, or hexadecimal code, or CSS syntax)
|
||||||
|
*
|
||||||
|
* @throws ColorException in case of color error
|
||||||
|
*/
|
||||||
|
protected function getRgbColorObject(string $color): ?Rgb
|
||||||
|
{
|
||||||
|
$pdf = new Pdf();
|
||||||
|
$cobj = $pdf->getColorObject($color);
|
||||||
|
if ($cobj instanceof \Com\Tecnick\Color\Model) {
|
||||||
|
return new Rgb($cobj->toRgbArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the barcode raw array
|
||||||
|
*
|
||||||
|
* @return array{
|
||||||
|
* 'type': string,
|
||||||
|
* 'format': string,
|
||||||
|
* 'params': array<int|float|string>,
|
||||||
|
* 'code': string,
|
||||||
|
* 'extcode': string,
|
||||||
|
* 'ncols': int,
|
||||||
|
* 'nrows': int,
|
||||||
|
* 'width': int,
|
||||||
|
* 'height': int,
|
||||||
|
* 'width_ratio': float,
|
||||||
|
* 'height_ratio': float,
|
||||||
|
* 'padding': array{'T': int, 'R': int, 'B': int, 'L': int},
|
||||||
|
* 'full_width': int,
|
||||||
|
* 'full_height': int,
|
||||||
|
* 'color_obj': Rgb,
|
||||||
|
* 'bg_color_obj': ?Rgb,
|
||||||
|
* 'bars': array<array{int, int, int, int}>,
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
public function getArray(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'type' => $this::TYPE,
|
||||||
|
'format' => $this::FORMAT,
|
||||||
|
'params' => $this->params,
|
||||||
|
'code' => $this->code,
|
||||||
|
'extcode' => $this->extcode,
|
||||||
|
'ncols' => $this->ncols,
|
||||||
|
'nrows' => $this->nrows,
|
||||||
|
'width' => $this->width,
|
||||||
|
'height' => $this->height,
|
||||||
|
'width_ratio' => $this->width_ratio,
|
||||||
|
'height_ratio' => $this->height_ratio,
|
||||||
|
'padding' => $this->padding,
|
||||||
|
'full_width' => ($this->width + $this->padding['L'] + $this->padding['R']),
|
||||||
|
'full_height' => ($this->height + $this->padding['T'] + $this->padding['B']),
|
||||||
|
'color_obj' => $this->color_obj,
|
||||||
|
'bg_color_obj' => $this->bg_color_obj,
|
||||||
|
'bars' => $this->bars,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the extended code (code + checksum)
|
||||||
|
*/
|
||||||
|
public function getExtendedCode(): string
|
||||||
|
{
|
||||||
|
return $this->extcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends the data as file to the browser.
|
||||||
|
*
|
||||||
|
* @param string $data The file data.
|
||||||
|
* @param string $mime The file MIME type (i.e. 'application/svg+xml' or 'image/png').
|
||||||
|
* @param string $fileext The file extension (i.e. 'svg' or 'png').
|
||||||
|
* @param string|null $filename The file name without extension (optional).
|
||||||
|
* Only allows alphanumeric characters, underscores and hyphens.
|
||||||
|
* Defaults to a md5 hash of the data.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function getHTTPFile(
|
||||||
|
string $data,
|
||||||
|
string $mime,
|
||||||
|
string $fileext,
|
||||||
|
?string $filename = null,
|
||||||
|
): void {
|
||||||
|
if (is_null($filename) || (preg_match('/^[a-zA-Z0-9_\-]{1,250}$/', $filename) !== 1)) {
|
||||||
|
$filename = md5($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
header('Content-Type: ' . $mime);
|
||||||
|
header('Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1');
|
||||||
|
header('Pragma: public');
|
||||||
|
header('Expires: Thu, 04 jan 1973 00:00:00 GMT'); // Date in the past
|
||||||
|
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||||
|
header('Content-Disposition: inline; filename="' . $filename . '.' . $fileext . '";');
|
||||||
|
if (empty($_SERVER['HTTP_ACCEPT_ENCODING'])) {
|
||||||
|
// the content length may vary if the server is using compression
|
||||||
|
header('Content-Length: ' . strlen($data));
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the barcode as SVG image object.
|
||||||
|
*
|
||||||
|
* @param string|null $filename The file name without extension (optional).
|
||||||
|
* Only allows alphanumeric characters, underscores and hyphens.
|
||||||
|
* Defaults to a md5 hash of the data.
|
||||||
|
* The file extension is always '.svg'.
|
||||||
|
*/
|
||||||
|
public function getSvg(?string $filename = null): void
|
||||||
|
{
|
||||||
|
$this->getHTTPFile($this->getSvgCode(), 'application/svg+xml', 'svg', $filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the barcode as inline SVG code.
|
||||||
|
*
|
||||||
|
* @return string Inline SVG code.
|
||||||
|
*/
|
||||||
|
public function getInlineSvgCode(): string
|
||||||
|
{
|
||||||
|
// flags for htmlspecialchars
|
||||||
|
$hflag = ENT_NOQUOTES;
|
||||||
|
if (defined('ENT_XML1') && defined('ENT_DISALLOWED')) {
|
||||||
|
$hflag = ENT_XML1 | ENT_DISALLOWED;
|
||||||
|
}
|
||||||
|
|
||||||
|
$width = sprintf('%F', ($this->width + $this->padding['L'] + $this->padding['R']));
|
||||||
|
$height = sprintf('%F', ($this->height + $this->padding['T'] + $this->padding['B']));
|
||||||
|
|
||||||
|
$svg = '<svg'
|
||||||
|
. ' version="1.2"'
|
||||||
|
. ' baseProfile="full"'
|
||||||
|
. ' xmlns="http://www.w3.org/2000/svg"'
|
||||||
|
. ' xmlns:xlink="http://www.w3.org/1999/xlink"'
|
||||||
|
. ' xmlns:ev="http://www.w3.org/2001/xml-events"'
|
||||||
|
. ' width="' . $width . '"'
|
||||||
|
. ' height="' . $height . '"'
|
||||||
|
. ' viewBox="0 0 ' . $width . ' ' . $height . '"'
|
||||||
|
. '>' . "\n"
|
||||||
|
. "\t" . '<desc>' . htmlspecialchars($this->code, $hflag, 'UTF-8') . '</desc>' . "\n";
|
||||||
|
if ($this->bg_color_obj instanceof \Com\Tecnick\Color\Model\Rgb) {
|
||||||
|
$svg .= ' <rect x="0" y="0" width="' . $width . '"'
|
||||||
|
. ' height="' . $height . '"'
|
||||||
|
. ' fill="' . $this->bg_color_obj->getRgbHexColor() . '"'
|
||||||
|
. ' stroke="none"'
|
||||||
|
. ' stroke-width="0"'
|
||||||
|
. ' stroke-linecap="square"'
|
||||||
|
. ' />' . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$svg .= ' <g id="bars" fill="' . $this->color_obj->getRgbHexColor() . '"'
|
||||||
|
. ' stroke="none"'
|
||||||
|
. ' stroke-width="0"'
|
||||||
|
. ' stroke-linecap="square"'
|
||||||
|
. '>' . "\n";
|
||||||
|
$bars = $this->getBarsArrayXYWH();
|
||||||
|
foreach ($bars as $bar) {
|
||||||
|
$svg .= ' <rect x="' . sprintf('%F', $bar[0]) . '"'
|
||||||
|
. ' y="' . sprintf('%F', $bar[1]) . '"'
|
||||||
|
. ' width="' . sprintf('%F', $bar[2]) . '"'
|
||||||
|
. ' height="' . sprintf('%F', $bar[3]) . '"'
|
||||||
|
. ' />' . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $svg . (' </g>' . "\n"
|
||||||
|
. '</svg>' . "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the barcode as SVG code, including the XML declaration.
|
||||||
|
*
|
||||||
|
* @return string SVG code
|
||||||
|
*/
|
||||||
|
public function getSvgCode(): string
|
||||||
|
{
|
||||||
|
return '<?xml version="1.0" standalone="no" ?>'
|
||||||
|
. "\n"
|
||||||
|
. $this->getInlineSvgCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an HTML representation of the barcode.
|
||||||
|
*
|
||||||
|
* @return string HTML code (DIV block)
|
||||||
|
*/
|
||||||
|
public function getHtmlDiv(): string
|
||||||
|
{
|
||||||
|
$html = '<div style="width:' . sprintf('%F', ($this->width + $this->padding['L'] + $this->padding['R'])) . 'px;'
|
||||||
|
. 'height:' . sprintf('%F', ($this->height + $this->padding['T'] + $this->padding['B'])) . 'px;'
|
||||||
|
. 'position:relative;'
|
||||||
|
. 'font-size:0;'
|
||||||
|
. 'border:none;'
|
||||||
|
. 'padding:0;'
|
||||||
|
. 'margin:0;';
|
||||||
|
if ($this->bg_color_obj instanceof \Com\Tecnick\Color\Model\Rgb) {
|
||||||
|
$html .= 'background-color:' . $this->bg_color_obj->getCssColor() . ';';
|
||||||
|
}
|
||||||
|
|
||||||
|
$html .= '">' . "\n";
|
||||||
|
$bars = $this->getBarsArrayXYWH();
|
||||||
|
foreach ($bars as $bar) {
|
||||||
|
$html .= ' <div style="background-color:' . $this->color_obj->getCssColor() . ';'
|
||||||
|
. 'left:' . sprintf('%F', $bar[0]) . 'px;'
|
||||||
|
. 'top:' . sprintf('%F', $bar[1]) . 'px;'
|
||||||
|
. 'width:' . sprintf('%F', $bar[2]) . 'px;'
|
||||||
|
. 'height:' . sprintf('%F', $bar[3]) . 'px;'
|
||||||
|
. 'position:absolute;'
|
||||||
|
. 'border:none;'
|
||||||
|
. 'padding:0;'
|
||||||
|
. 'margin:0;'
|
||||||
|
. '"> </div>' . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $html . ('</div>' . "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Barcode as PNG Image (requires GD or Imagick library)
|
||||||
|
*
|
||||||
|
* @param string|null $filename The file name without extension (optional).
|
||||||
|
* Only allows alphanumeric characters, underscores and hyphens.
|
||||||
|
* Defaults to a md5 hash of the data.
|
||||||
|
* The file extension is always '.png'.
|
||||||
|
*/
|
||||||
|
public function getPng(?string $filename = null): void
|
||||||
|
{
|
||||||
|
$this->getHTTPFile($this->getPngData(), 'image/png', 'png', $filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the barcode as PNG image (requires GD or Imagick library)
|
||||||
|
*
|
||||||
|
* @param bool $imagick If true try to use the Imagick extension
|
||||||
|
*
|
||||||
|
* @return string PNG image data
|
||||||
|
*/
|
||||||
|
public function getPngData(bool $imagick = true): string
|
||||||
|
{
|
||||||
|
if ($imagick && extension_loaded('imagick')) {
|
||||||
|
return $this->getPngDataImagick();
|
||||||
|
}
|
||||||
|
|
||||||
|
$gdImage = $this->getGd();
|
||||||
|
ob_start();
|
||||||
|
imagepng($gdImage);
|
||||||
|
$data = ob_get_clean();
|
||||||
|
if ($data === false) {
|
||||||
|
throw new BarcodeException('Unable to get PNG data');
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the barcode as PNG image (requires Imagick library)
|
||||||
|
*
|
||||||
|
* @throws BarcodeException if the Imagick library is not installed
|
||||||
|
*/
|
||||||
|
public function getPngDataImagick(): string
|
||||||
|
{
|
||||||
|
$imagick = new \Imagick();
|
||||||
|
$width = (int) ceil($this->width + $this->padding['L'] + $this->padding['R']);
|
||||||
|
$height = (int) ceil($this->height + $this->padding['T'] + $this->padding['B']);
|
||||||
|
$imagick->newImage($width, $height, 'none', 'png');
|
||||||
|
$imagickdraw = new \imagickdraw();
|
||||||
|
if ($this->bg_color_obj instanceof \Com\Tecnick\Color\Model\Rgb) {
|
||||||
|
$rgbcolor = $this->bg_color_obj->getNormalizedArray(255);
|
||||||
|
$bg_color = new \imagickpixel('rgb(' . $rgbcolor['R'] . ',' . $rgbcolor['G'] . ',' . $rgbcolor['B'] . ')');
|
||||||
|
$imagickdraw->setfillcolor($bg_color);
|
||||||
|
$imagickdraw->rectangle(0, 0, $width, $height);
|
||||||
|
}
|
||||||
|
|
||||||
|
$rgbcolor = $this->color_obj->getNormalizedArray(255);
|
||||||
|
$bar_color = new \imagickpixel('rgb(' . $rgbcolor['R'] . ',' . $rgbcolor['G'] . ',' . $rgbcolor['B'] . ')');
|
||||||
|
$imagickdraw->setfillcolor($bar_color);
|
||||||
|
$bars = $this->getBarsArrayXYXY();
|
||||||
|
foreach ($bars as $bar) {
|
||||||
|
$imagickdraw->rectangle($bar[0], $bar[1], $bar[2], $bar[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$imagick->drawimage($imagickdraw);
|
||||||
|
return $imagick->getImageBlob();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the barcode as GD image object (requires GD library)
|
||||||
|
*
|
||||||
|
* @throws BarcodeException if the GD library is not installed
|
||||||
|
*/
|
||||||
|
public function getGd(): \GdImage
|
||||||
|
{
|
||||||
|
$width = max(1, (int) ceil($this->width + $this->padding['L'] + $this->padding['R']));
|
||||||
|
$height = max(1, (int) ceil($this->height + $this->padding['T'] + $this->padding['B']));
|
||||||
|
$img = imagecreate($width, $height);
|
||||||
|
if ($img === false) {
|
||||||
|
throw new BarcodeException('Unable to create GD image');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $this->bg_color_obj instanceof \Com\Tecnick\Color\Model\Rgb) {
|
||||||
|
$bgobj = clone $this->color_obj;
|
||||||
|
$rgbcolor = $bgobj->invertColor()->getNormalizedArray(255);
|
||||||
|
$background_color = imagecolorallocate(
|
||||||
|
$img,
|
||||||
|
(int) round($rgbcolor['R']), // @phpstan-ignore argument.type
|
||||||
|
(int) round($rgbcolor['G']), // @phpstan-ignore argument.type
|
||||||
|
(int) round($rgbcolor['B']), // @phpstan-ignore argument.type
|
||||||
|
);
|
||||||
|
if ($background_color === false) {
|
||||||
|
throw new BarcodeException('Unable to allocate default GD background color');
|
||||||
|
}
|
||||||
|
imagecolortransparent($img, $background_color);
|
||||||
|
} else {
|
||||||
|
$rgbcolor = $this->bg_color_obj->getNormalizedArray(255);
|
||||||
|
$bg_color = imagecolorallocate(
|
||||||
|
$img,
|
||||||
|
(int) round($rgbcolor['R']), // @phpstan-ignore argument.type
|
||||||
|
(int) round($rgbcolor['G']), // @phpstan-ignore argument.type
|
||||||
|
(int) round($rgbcolor['B']), // @phpstan-ignore argument.type
|
||||||
|
);
|
||||||
|
if ($bg_color === false) {
|
||||||
|
throw new BarcodeException('Unable to allocate GD background color');
|
||||||
|
}
|
||||||
|
imagefilledrectangle($img, 0, 0, $width, $height, $bg_color);
|
||||||
|
}
|
||||||
|
|
||||||
|
$rgbcolor = $this->color_obj->getNormalizedArray(255);
|
||||||
|
$bar_color = imagecolorallocate(
|
||||||
|
$img,
|
||||||
|
(int) round($rgbcolor['R']), // @phpstan-ignore argument.type
|
||||||
|
(int) round($rgbcolor['G']), // @phpstan-ignore argument.type
|
||||||
|
(int) round($rgbcolor['B']), // @phpstan-ignore argument.type
|
||||||
|
);
|
||||||
|
if ($bar_color === false) {
|
||||||
|
throw new BarcodeException('Unable to allocate GD foreground color');
|
||||||
|
}
|
||||||
|
$bars = $this->getBarsArrayXYXY();
|
||||||
|
foreach ($bars as $bar) {
|
||||||
|
imagefilledrectangle(
|
||||||
|
$img,
|
||||||
|
(int) floor($bar[0]),
|
||||||
|
(int) floor($bar[1]),
|
||||||
|
(int) floor($bar[2]),
|
||||||
|
(int) floor($bar[3]),
|
||||||
|
$bar_color
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $img;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a raw barcode string representation using characters
|
||||||
|
*
|
||||||
|
* @param string $space_char Character or string to use for filling empty spaces
|
||||||
|
* @param string $bar_char Character or string to use for filling bars
|
||||||
|
*/
|
||||||
|
public function getGrid(
|
||||||
|
string $space_char = '0',
|
||||||
|
string $bar_char = '1'
|
||||||
|
): string {
|
||||||
|
$raw = $this->getGridArray($space_char, $bar_char);
|
||||||
|
$grid = '';
|
||||||
|
foreach ($raw as $row) {
|
||||||
|
$grid .= implode('', $row) . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the array containing all the formatted bars coordinates
|
||||||
|
*
|
||||||
|
* @return array<int, array{float, float, float, float}>
|
||||||
|
*/
|
||||||
|
public function getBarsArrayXYXY(): array
|
||||||
|
{
|
||||||
|
$rect = [];
|
||||||
|
foreach ($this->bars as $bar) {
|
||||||
|
if ($bar[2] <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($bar[3] <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rect[] = $this->getBarRectXYXY($bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->nrows > 1) {
|
||||||
|
// reprint rotated to cancel row gaps
|
||||||
|
$rot = $this->getRotatedBarArray();
|
||||||
|
foreach ($rot as $bar) {
|
||||||
|
if ($bar[2] <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($bar[3] <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rect[] = $this->getBarRectXYXY($bar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rect;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the array containing all the formatted bars coordinates
|
||||||
|
*
|
||||||
|
* @return array<int, array{float, float, float, float}>
|
||||||
|
*/
|
||||||
|
public function getBarsArrayXYWH(): array
|
||||||
|
{
|
||||||
|
$rect = [];
|
||||||
|
foreach ($this->bars as $bar) {
|
||||||
|
if ($bar[2] <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($bar[3] <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rect[] = $this->getBarRectXYWH($bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->nrows > 1) {
|
||||||
|
// reprint rotated to cancel row gaps
|
||||||
|
$rot = $this->getRotatedBarArray();
|
||||||
|
foreach ($rot as $bar) {
|
||||||
|
if ($bar[2] <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($bar[3] <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rect[] = $this->getBarRectXYWH($bar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rect;
|
||||||
|
}
|
||||||
|
}
|
||||||
336
vendor/tecnickcom/tc-lib-barcode/src/Type/Convert.php
vendored
Normal file
336
vendor/tecnickcom/tc-lib-barcode/src/Type/Convert.php
vendored
Normal file
@@ -0,0 +1,336 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
use Com\Tecnick\Color\Model\Rgb as Color;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Convert
|
||||||
|
*
|
||||||
|
* Barcode Convert class
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
abstract class Convert
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode type (linear or square)
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const TYPE = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array containing extra parameters for the specified barcode type
|
||||||
|
*
|
||||||
|
* @var array<int|float|string>
|
||||||
|
*/
|
||||||
|
protected array $params = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code to convert (barcode content)
|
||||||
|
*/
|
||||||
|
protected string $code = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resulting code after applying checksum etc.
|
||||||
|
*/
|
||||||
|
protected string $extcode = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Total number of columns
|
||||||
|
*/
|
||||||
|
protected int $ncols = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Total number of rows
|
||||||
|
*/
|
||||||
|
protected int $nrows = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array containing the position and dimensions of each barcode bar
|
||||||
|
* (x, y, width, height)
|
||||||
|
*
|
||||||
|
* @var array<array{int, int, int, int}>
|
||||||
|
*/
|
||||||
|
protected array $bars = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Barcode width
|
||||||
|
*/
|
||||||
|
protected int $width = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Barcode height
|
||||||
|
*/
|
||||||
|
protected int $height = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Additional padding to add around the barcode (top, right, bottom, left) in user units.
|
||||||
|
* A negative value indicates the multiplication factor for each row or column.
|
||||||
|
*
|
||||||
|
* @var array{'T': int, 'R': int, 'B': int, 'L': int}
|
||||||
|
*/
|
||||||
|
protected array $padding = [
|
||||||
|
'T' => 0,
|
||||||
|
'R' => 0,
|
||||||
|
'B' => 0,
|
||||||
|
'L' => 0,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ratio between the barcode width and the number of rows
|
||||||
|
*/
|
||||||
|
protected float $width_ratio = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ratio between the barcode height and the number of columns
|
||||||
|
*/
|
||||||
|
protected float $height_ratio = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Foreground Color object
|
||||||
|
*/
|
||||||
|
protected Color $color_obj;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Backgorund Color object
|
||||||
|
*/
|
||||||
|
protected ?Color $bg_color_obj = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process binary sequence rows.
|
||||||
|
*
|
||||||
|
* @param array<int, string|array<int>> $rows Binary sequence data to process
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function processBinarySequence(array $rows): void
|
||||||
|
{
|
||||||
|
if ($rows === []) {
|
||||||
|
throw new BarcodeException('Empty input string');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->nrows = count($rows);
|
||||||
|
$this->ncols = is_array($rows[0]) ? count($rows[0]) : strlen($rows[0]);
|
||||||
|
|
||||||
|
if ($this->ncols === 0) {
|
||||||
|
throw new BarcodeException('Empty columns');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->bars = [];
|
||||||
|
foreach ($rows as $posy => $row) {
|
||||||
|
if (! is_array($row)) {
|
||||||
|
$row = str_split($row, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$prevcol = '';
|
||||||
|
$bar_width = 0;
|
||||||
|
$row[] = '0';
|
||||||
|
for ($posx = 0; $posx <= $this->ncols; ++$posx) {
|
||||||
|
if ($row[$posx] != $prevcol) {
|
||||||
|
if ($prevcol == '1') {
|
||||||
|
$this->bars[] = [($posx - $bar_width), $posy, $bar_width, 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
$bar_width = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
++$bar_width;
|
||||||
|
$prevcol = $row[$posx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract rows from a binary sequence of comma-separated 01 strings.
|
||||||
|
*
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
protected function getRawCodeRows(string $data): array
|
||||||
|
{
|
||||||
|
$search = [
|
||||||
|
'/[\s]*/s', // remove spaces and newlines
|
||||||
|
'/^[\[,]+/', // remove trailing brackets or commas
|
||||||
|
'/[\],]+$/', // remove trailing brackets or commas
|
||||||
|
'/[\]][\[]$/', // convert bracket -separated to comma-separated
|
||||||
|
];
|
||||||
|
|
||||||
|
$replace = ['', '', '', ''];
|
||||||
|
|
||||||
|
$code = preg_replace($search, $replace, $data);
|
||||||
|
if ($code === null) {
|
||||||
|
throw new BarcodeException('Invalid input string');
|
||||||
|
}
|
||||||
|
|
||||||
|
return explode(',', $code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert large integer number to hexadecimal representation.
|
||||||
|
*
|
||||||
|
* @param string $number Number to convert (as string)
|
||||||
|
*
|
||||||
|
* @return string hexadecimal representation
|
||||||
|
*/
|
||||||
|
protected function convertDecToHex(string $number): string
|
||||||
|
{
|
||||||
|
if ($number == 0) {
|
||||||
|
return '00';
|
||||||
|
}
|
||||||
|
|
||||||
|
$hex = [];
|
||||||
|
while ($number > 0) {
|
||||||
|
$hex[] = strtoupper(dechex((int) bcmod($number, '16')));
|
||||||
|
$number = bcdiv($number, '16', 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
$hex = array_reverse($hex);
|
||||||
|
return implode('', $hex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert large hexadecimal number to decimal representation (string).
|
||||||
|
*
|
||||||
|
* @param string $hex Hexadecimal number to convert (as string)
|
||||||
|
*
|
||||||
|
* @return string hexadecimal representation
|
||||||
|
*/
|
||||||
|
protected function convertHexToDec(string $hex): string
|
||||||
|
{
|
||||||
|
$dec = '0';
|
||||||
|
$bitval = '1';
|
||||||
|
$len = strlen($hex);
|
||||||
|
for ($pos = ($len - 1); $pos >= 0; --$pos) {
|
||||||
|
$dec = bcadd($dec, bcmul((string) hexdec($hex[$pos]), $bitval));
|
||||||
|
$bitval = bcmul($bitval, '16');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $dec;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a raw barcode grid array
|
||||||
|
*
|
||||||
|
* @param string $space_char Character or string to use for filling empty spaces
|
||||||
|
* @param string $bar_char Character or string to use for filling bars
|
||||||
|
*
|
||||||
|
* @return array<int, array<int, string>>
|
||||||
|
*/
|
||||||
|
public function getGridArray(
|
||||||
|
string $space_char = '0',
|
||||||
|
string $bar_char = '1'
|
||||||
|
): array {
|
||||||
|
$raw = array_fill(0, $this->nrows, array_fill(0, $this->ncols, $space_char));
|
||||||
|
foreach ($this->bars as $bar) {
|
||||||
|
if ($bar[2] <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($bar[3] <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($vert = 0; $vert < $bar[3]; ++$vert) {
|
||||||
|
for ($horiz = 0; $horiz < $bar[2]; ++$horiz) {
|
||||||
|
$raw[($bar[1] + $vert)][($bar[0] + $horiz)] = $bar_char;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the bars array ordered by columns
|
||||||
|
*
|
||||||
|
* @return array<int, array{int, int, int, int}>
|
||||||
|
*/
|
||||||
|
protected function getRotatedBarArray(): array
|
||||||
|
{
|
||||||
|
$grid = $this->getGridArray();
|
||||||
|
$cols = array_map(null, ...$grid);
|
||||||
|
$bars = [];
|
||||||
|
foreach ($cols as $posx => $col) {
|
||||||
|
$prevrow = '';
|
||||||
|
$bar_height = 0;
|
||||||
|
$col[] = '0';
|
||||||
|
for ($posy = 0; $posy <= $this->nrows; ++$posy) {
|
||||||
|
if ($col[$posy] != $prevrow) {
|
||||||
|
if ($prevrow == '1') {
|
||||||
|
$bars[] = [$posx, ($posy - $bar_height), 1, $bar_height];
|
||||||
|
}
|
||||||
|
|
||||||
|
$bar_height = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
++$bar_height;
|
||||||
|
$prevrow = $col[$posy];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $bars;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the adjusted rectangular coordinates (x1,y1,x2,y2) for the specified bar
|
||||||
|
*
|
||||||
|
* @param array{int, int, int, int} $bar Raw bar coordinates
|
||||||
|
*
|
||||||
|
* @return array{float, float, float, float} Bar coordinates
|
||||||
|
*/
|
||||||
|
protected function getBarRectXYXY(array $bar): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
($this->padding['L'] + ($bar[0] * $this->width_ratio)),
|
||||||
|
($this->padding['T'] + ($bar[1] * $this->height_ratio)),
|
||||||
|
($this->padding['L'] + (($bar[0] + $bar[2]) * $this->width_ratio) - 1),
|
||||||
|
($this->padding['T'] + (($bar[1] + $bar[3]) * $this->height_ratio) - 1),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the adjusted rectangular coordinates (x,y,w,h) for the specified bar
|
||||||
|
*
|
||||||
|
* @param array{int, int, int, int} $bar Raw bar coordinates
|
||||||
|
*
|
||||||
|
* @return array{float, float, float, float} Bar coordinates
|
||||||
|
*/
|
||||||
|
protected function getBarRectXYWH(array $bar): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
($this->padding['L'] + ($bar[0] * $this->width_ratio)),
|
||||||
|
($this->padding['T'] + ($bar[1] * $this->height_ratio)),
|
||||||
|
($bar[2] * $this->width_ratio),
|
||||||
|
($bar[3] * $this->height_ratio),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
40
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear.php
vendored
Normal file
40
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Linear.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear
|
||||||
|
*
|
||||||
|
* Barcode type class
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
abstract class Linear extends \Com\Tecnick\Barcode\Type
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode type
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const TYPE = 'linear';
|
||||||
|
}
|
||||||
109
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/Codabar.php
vendored
Normal file
109
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/Codabar.php
vendored
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Codabar.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\Codabar;
|
||||||
|
*
|
||||||
|
* Codabar Barcode type class
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class Codabar extends \Com\Tecnick\Barcode\Type\Linear
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'CODABAR';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map characters to barcodes
|
||||||
|
*
|
||||||
|
* @var array<int|string, string>
|
||||||
|
*/
|
||||||
|
protected const CHBAR = [
|
||||||
|
'0' => '11111221',
|
||||||
|
'1' => '11112211',
|
||||||
|
'2' => '11121121',
|
||||||
|
'3' => '22111111',
|
||||||
|
'4' => '11211211',
|
||||||
|
'5' => '21111211',
|
||||||
|
'6' => '12111121',
|
||||||
|
'7' => '12112111',
|
||||||
|
'8' => '12211111',
|
||||||
|
'9' => '21121111',
|
||||||
|
'-' => '11122111',
|
||||||
|
'$' => '11221111',
|
||||||
|
':' => '21112121',
|
||||||
|
'/' => '21211121',
|
||||||
|
'.' => '21212111',
|
||||||
|
'+' => '11222221',
|
||||||
|
'A' => '11221211',
|
||||||
|
'B' => '12121121',
|
||||||
|
'C' => '11121221',
|
||||||
|
'D' => '11122211',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format code
|
||||||
|
*/
|
||||||
|
protected function formatCode(): void
|
||||||
|
{
|
||||||
|
$this->extcode = 'A' . strtoupper($this->code) . 'A';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bars array.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
$this->ncols = 0;
|
||||||
|
$this->nrows = 1;
|
||||||
|
$this->bars = [];
|
||||||
|
$this->formatCode();
|
||||||
|
$clen = strlen($this->extcode);
|
||||||
|
for ($chr = 0; $chr < $clen; ++$chr) {
|
||||||
|
$char = $this->extcode[$chr];
|
||||||
|
if (! isset($this::CHBAR[$char])) {
|
||||||
|
throw new BarcodeException('Invalid character: chr(' . ord($char) . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($pos = 0; $pos < 8; ++$pos) {
|
||||||
|
$bar_width = (int) $this::CHBAR[$char][$pos];
|
||||||
|
if (($pos % 2) == 0) {
|
||||||
|
$this->bars[] = [$this->ncols, 0, $bar_width, 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ncols += $bar_width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
--$this->ncols;
|
||||||
|
}
|
||||||
|
}
|
||||||
372
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeNineThree.php
vendored
Normal file
372
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeNineThree.php
vendored
Normal file
@@ -0,0 +1,372 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CodeNineThree.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\CodeNineThree;
|
||||||
|
*
|
||||||
|
* CodeNineThree Barcode type class
|
||||||
|
* CODE 93 - USS-93
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class CodeNineThree extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtCheck
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'C93';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map characters to barcodes
|
||||||
|
*
|
||||||
|
* @var array<int|string, string>
|
||||||
|
*/
|
||||||
|
protected const CHBAR = [
|
||||||
|
32 => '311211', // space
|
||||||
|
36 => '321111', // $
|
||||||
|
37 => '211131', // %
|
||||||
|
42 => '111141', // start-stop
|
||||||
|
43 => '113121', // +
|
||||||
|
45 => '121131', // -
|
||||||
|
46 => '311112', // .
|
||||||
|
47 => '112131', // /
|
||||||
|
48 => '131112', // 0
|
||||||
|
49 => '111213', // 1
|
||||||
|
50 => '111312', // 2
|
||||||
|
51 => '111411', // 3
|
||||||
|
52 => '121113', // 4
|
||||||
|
53 => '121212', // 5
|
||||||
|
54 => '121311', // 6
|
||||||
|
55 => '111114', // 7
|
||||||
|
56 => '131211', // 8
|
||||||
|
57 => '141111', // 9
|
||||||
|
65 => '211113', // A
|
||||||
|
66 => '211212', // B
|
||||||
|
67 => '211311', // C
|
||||||
|
68 => '221112', // D
|
||||||
|
69 => '221211', // E
|
||||||
|
70 => '231111', // F
|
||||||
|
71 => '112113', // G
|
||||||
|
72 => '112212', // H
|
||||||
|
73 => '112311', // I
|
||||||
|
74 => '122112', // J
|
||||||
|
75 => '132111', // K
|
||||||
|
76 => '111123', // L
|
||||||
|
77 => '111222', // M
|
||||||
|
78 => '111321', // N
|
||||||
|
79 => '121122', // O
|
||||||
|
80 => '131121', // P
|
||||||
|
81 => '212112', // Q
|
||||||
|
82 => '212211', // R
|
||||||
|
83 => '211122', // S
|
||||||
|
84 => '211221', // T
|
||||||
|
85 => '221121', // U
|
||||||
|
86 => '222111', // V
|
||||||
|
87 => '112122', // W
|
||||||
|
88 => '112221', // X
|
||||||
|
89 => '122121', // Y
|
||||||
|
90 => '123111', // Z
|
||||||
|
128 => '121221', // ($)
|
||||||
|
129 => '311121', // (/)
|
||||||
|
130 => '122211', // (+)
|
||||||
|
131 => '312111', // (%)
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map for extended characters
|
||||||
|
*
|
||||||
|
* @var array<string>
|
||||||
|
*/
|
||||||
|
protected const EXTCODES = [
|
||||||
|
"\x83U",
|
||||||
|
"\x80A",
|
||||||
|
"\x80B",
|
||||||
|
"\x80C",
|
||||||
|
"\x80D",
|
||||||
|
"\x80E",
|
||||||
|
"\x80F",
|
||||||
|
"\x80G",
|
||||||
|
"\x80H",
|
||||||
|
"\x80I",
|
||||||
|
"\x80J",
|
||||||
|
"\x80K",
|
||||||
|
"\x80L",
|
||||||
|
"\x80M",
|
||||||
|
"\x80N",
|
||||||
|
"\x80O",
|
||||||
|
"\x80P",
|
||||||
|
"\x80Q",
|
||||||
|
"\x80R",
|
||||||
|
"\x80S",
|
||||||
|
"\x80T",
|
||||||
|
"\x80U",
|
||||||
|
"\x80V",
|
||||||
|
"\x80W",
|
||||||
|
"\x80X",
|
||||||
|
"\x80Y",
|
||||||
|
"\x80Z",
|
||||||
|
"\x83A",
|
||||||
|
"\x83B",
|
||||||
|
"\x83C",
|
||||||
|
"\x83D",
|
||||||
|
"\x83E",
|
||||||
|
" ",
|
||||||
|
"\x81A",
|
||||||
|
"\x81B",
|
||||||
|
"\x81C",
|
||||||
|
"\x81D",
|
||||||
|
"\x81E",
|
||||||
|
|
||||||
|
"\x81F",
|
||||||
|
"\x81G",
|
||||||
|
"\x81H",
|
||||||
|
"\x81I",
|
||||||
|
"\x81J",
|
||||||
|
"\x81K",
|
||||||
|
"\x81L",
|
||||||
|
"-",
|
||||||
|
".",
|
||||||
|
"\x81O",
|
||||||
|
"0",
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
"3",
|
||||||
|
"4",
|
||||||
|
"5",
|
||||||
|
"6",
|
||||||
|
"7",
|
||||||
|
"8",
|
||||||
|
"9",
|
||||||
|
"\x81Z",
|
||||||
|
"\x83F",
|
||||||
|
"\x83G",
|
||||||
|
"\x83H",
|
||||||
|
"\x83I",
|
||||||
|
"\x83J",
|
||||||
|
"\x83V",
|
||||||
|
"A",
|
||||||
|
"B",
|
||||||
|
"C",
|
||||||
|
"D",
|
||||||
|
"E",
|
||||||
|
"F",
|
||||||
|
"G",
|
||||||
|
"H",
|
||||||
|
"I",
|
||||||
|
"J",
|
||||||
|
"K",
|
||||||
|
"L",
|
||||||
|
"M",
|
||||||
|
"N",
|
||||||
|
"O",
|
||||||
|
"P",
|
||||||
|
"Q",
|
||||||
|
"R",
|
||||||
|
"S",
|
||||||
|
"T",
|
||||||
|
"U",
|
||||||
|
"V",
|
||||||
|
"W",
|
||||||
|
"X",
|
||||||
|
"Y",
|
||||||
|
"Z",
|
||||||
|
"\x83K",
|
||||||
|
"\x83L",
|
||||||
|
"\x83M",
|
||||||
|
"\x83N",
|
||||||
|
"\x83O",
|
||||||
|
"\x83W",
|
||||||
|
"\x82A",
|
||||||
|
"\x82B",
|
||||||
|
"\x82C",
|
||||||
|
"\x82D",
|
||||||
|
"\x82E",
|
||||||
|
"\x82F",
|
||||||
|
"\x82G",
|
||||||
|
"\x82H",
|
||||||
|
"\x82I",
|
||||||
|
"\x82J",
|
||||||
|
"\x82K",
|
||||||
|
"\x82L",
|
||||||
|
"\x82M",
|
||||||
|
"\x82N",
|
||||||
|
"\x82O",
|
||||||
|
"\x82P",
|
||||||
|
"\x82Q",
|
||||||
|
"\x82R",
|
||||||
|
"\x82S",
|
||||||
|
"\x82T",
|
||||||
|
"\x82U",
|
||||||
|
"\x82V",
|
||||||
|
"\x82W",
|
||||||
|
"\x82X",
|
||||||
|
"\x82Y",
|
||||||
|
"\x82Z",
|
||||||
|
"\x83P",
|
||||||
|
"\x83Q",
|
||||||
|
"\x83R",
|
||||||
|
"\x83S",
|
||||||
|
"\x83T",
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Characters used for checksum
|
||||||
|
*
|
||||||
|
* @var array<string>
|
||||||
|
*/
|
||||||
|
protected const CHKSUM = [
|
||||||
|
'0',
|
||||||
|
'1',
|
||||||
|
'2',
|
||||||
|
'3',
|
||||||
|
'4',
|
||||||
|
'5',
|
||||||
|
'6',
|
||||||
|
'7',
|
||||||
|
'8',
|
||||||
|
'9',
|
||||||
|
'A',
|
||||||
|
'B',
|
||||||
|
'C',
|
||||||
|
'D',
|
||||||
|
'E',
|
||||||
|
'F',
|
||||||
|
'G',
|
||||||
|
'H',
|
||||||
|
'I',
|
||||||
|
'J',
|
||||||
|
'K',
|
||||||
|
'L',
|
||||||
|
'M',
|
||||||
|
'N',
|
||||||
|
'O',
|
||||||
|
'P',
|
||||||
|
'Q',
|
||||||
|
'R',
|
||||||
|
'S',
|
||||||
|
'T',
|
||||||
|
'U',
|
||||||
|
'V',
|
||||||
|
'W',
|
||||||
|
'X',
|
||||||
|
'Y',
|
||||||
|
'Z',
|
||||||
|
'-',
|
||||||
|
'.',
|
||||||
|
' ',
|
||||||
|
'$',
|
||||||
|
'/',
|
||||||
|
'+',
|
||||||
|
'%',
|
||||||
|
'<',
|
||||||
|
'=',
|
||||||
|
'>',
|
||||||
|
'?',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate CODE 93 checksum (modulo 47).
|
||||||
|
*
|
||||||
|
* @param string $code Code to represent.
|
||||||
|
*
|
||||||
|
* @return string char checksum.
|
||||||
|
*/
|
||||||
|
protected function getChecksum(string $code): string
|
||||||
|
{
|
||||||
|
// translate special characters
|
||||||
|
$code = strtr($code, chr(128) . chr(131) . chr(129) . chr(130), '<=>?');
|
||||||
|
$clen = strlen($code);
|
||||||
|
// calculate check digit C
|
||||||
|
$pck = 1;
|
||||||
|
$check = 0;
|
||||||
|
for ($idx = ($clen - 1); $idx >= 0; --$idx) {
|
||||||
|
$key = array_keys($this::CHKSUM, $code[$idx]);
|
||||||
|
$check += ($key[0] * $pck);
|
||||||
|
++$pck;
|
||||||
|
if ($pck > 20) {
|
||||||
|
$pck = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$check %= 47;
|
||||||
|
$chk = $this::CHKSUM[$check];
|
||||||
|
$code .= $chk;
|
||||||
|
// calculate check digit K
|
||||||
|
$pck = 1;
|
||||||
|
$check = 0;
|
||||||
|
for ($idx = $clen; $idx >= 0; --$idx) {
|
||||||
|
$key = array_keys($this::CHKSUM, $code[$idx]);
|
||||||
|
$check += ($key[0] * $pck);
|
||||||
|
++$pck;
|
||||||
|
if ($pck > 15) {
|
||||||
|
$pck = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$check %= 47;
|
||||||
|
$key = $this::CHKSUM[$check];
|
||||||
|
$checksum = $chk . $key;
|
||||||
|
// restore special characters
|
||||||
|
$checksum = strtr(
|
||||||
|
$checksum,
|
||||||
|
'<=>?',
|
||||||
|
chr(128) . chr(131) . chr(129) . chr(130)
|
||||||
|
);
|
||||||
|
return $checksum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bars array.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*
|
||||||
|
* @SuppressWarnings("PHPMD.ExcessiveMethodLength")
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
$this->ncols = 0;
|
||||||
|
$this->nrows = 1;
|
||||||
|
$this->bars = [];
|
||||||
|
$this->formatCode();
|
||||||
|
$clen = strlen($this->extcode);
|
||||||
|
for ($chr = 0; $chr < $clen; ++$chr) {
|
||||||
|
$char = ord($this->extcode[$chr]);
|
||||||
|
for ($pos = 0; $pos < 6; ++$pos) {
|
||||||
|
$bar_width = (int) $this::CHBAR[$char][$pos];
|
||||||
|
if (($pos % 2) == 0) {
|
||||||
|
$this->bars[] = [$this->ncols, 0, $bar_width, 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ncols += $bar_width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->bars[] = [$this->ncols, 0, 1, 1];
|
||||||
|
++$this->ncols;
|
||||||
|
}
|
||||||
|
}
|
||||||
154
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeOneOne.php
vendored
Normal file
154
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeOneOne.php
vendored
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CodeOneOne.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\CodeOneOne;
|
||||||
|
*
|
||||||
|
* CodeOneOne Barcode type class
|
||||||
|
* CODE 11
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class CodeOneOne extends \Com\Tecnick\Barcode\Type\Linear
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'CODE11';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map characters to barcodes
|
||||||
|
*
|
||||||
|
* @var array<int|string, string>
|
||||||
|
*/
|
||||||
|
protected const CHBAR = [
|
||||||
|
'0' => '111121',
|
||||||
|
'1' => '211121',
|
||||||
|
'2' => '121121',
|
||||||
|
'3' => '221111',
|
||||||
|
'4' => '112121',
|
||||||
|
'5' => '212111',
|
||||||
|
'6' => '122111',
|
||||||
|
'7' => '111221',
|
||||||
|
'8' => '211211',
|
||||||
|
'9' => '211111',
|
||||||
|
'-' => '112111',
|
||||||
|
'S' => '112211',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the checksum.
|
||||||
|
*
|
||||||
|
* @param string $code Code to represent.
|
||||||
|
*
|
||||||
|
* @return string char checksum.
|
||||||
|
*/
|
||||||
|
protected function getChecksum(string $code): string
|
||||||
|
{
|
||||||
|
$len = strlen($code);
|
||||||
|
// calculate check digit C
|
||||||
|
$ptr = 1;
|
||||||
|
$ccheck = 0;
|
||||||
|
for ($pos = ($len - 1); $pos >= 0; --$pos) {
|
||||||
|
$digit = $code[$pos];
|
||||||
|
$dval = $digit == '-' ? 10 : (int) $digit;
|
||||||
|
|
||||||
|
$ccheck += ($dval * $ptr);
|
||||||
|
++$ptr;
|
||||||
|
if ($ptr > 10) {
|
||||||
|
$ptr = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$ccheck %= 11;
|
||||||
|
if ($ccheck == 10) {
|
||||||
|
$ccheck = '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($len <= 10) {
|
||||||
|
return ((string) $ccheck);
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculate check digit K
|
||||||
|
$code .= $ccheck;
|
||||||
|
$ptr = 1;
|
||||||
|
$kcheck = 0;
|
||||||
|
for ($pos = $len; $pos >= 0; --$pos) {
|
||||||
|
$digit = $code[$pos];
|
||||||
|
$dval = $digit == '-' ? 10 : (int) $digit;
|
||||||
|
|
||||||
|
$kcheck += ($dval * $ptr);
|
||||||
|
++$ptr;
|
||||||
|
if ($ptr > 9) {
|
||||||
|
$ptr = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$kcheck %= 11;
|
||||||
|
return ((string) $ccheck . $kcheck);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format code
|
||||||
|
*/
|
||||||
|
protected function formatCode(): void
|
||||||
|
{
|
||||||
|
$this->extcode = 'S' . $this->code . $this->getChecksum($this->code) . 'S';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bars array.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
$this->ncols = 0;
|
||||||
|
$this->nrows = 1;
|
||||||
|
$this->bars = [];
|
||||||
|
$this->formatCode();
|
||||||
|
$clen = strlen($this->extcode);
|
||||||
|
for ($chr = 0; $chr < $clen; ++$chr) {
|
||||||
|
$char = $this->extcode[$chr];
|
||||||
|
if (! isset($this::CHBAR[$char])) {
|
||||||
|
throw new BarcodeException('Invalid character: chr(' . ord($char) . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($pos = 0; $pos < 6; ++$pos) {
|
||||||
|
$bar_width = (int) $this::CHBAR[$char][$pos];
|
||||||
|
if ((($pos % 2) == 0) && ($bar_width > 0)) {
|
||||||
|
$this->bars[] = [$this->ncols, 0, $bar_width, 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ncols += $bar_width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
--$this->ncols;
|
||||||
|
}
|
||||||
|
}
|
||||||
249
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeOneTwoEight.php
vendored
Normal file
249
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeOneTwoEight.php
vendored
Normal file
@@ -0,0 +1,249 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CodeOneTwoEight.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight;
|
||||||
|
*
|
||||||
|
* CodeOneTwoEight Barcode type class
|
||||||
|
* CODE 128
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class CodeOneTwoEight extends \Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight\Process
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the coe point array
|
||||||
|
*
|
||||||
|
* @return array<int, int>
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function getCodeData(): array
|
||||||
|
{
|
||||||
|
$code = $this->code;
|
||||||
|
// array of symbols
|
||||||
|
$code_data = [];
|
||||||
|
// split code into sequences
|
||||||
|
$sequence = $this->getNumericSequence($code);
|
||||||
|
// process the sequence
|
||||||
|
$startid = 0;
|
||||||
|
foreach ($sequence as $key => $seq) {
|
||||||
|
$processMethod = 'processSequence' . $seq[0];
|
||||||
|
$this->$processMethod($sequence, $code_data, $startid, $key, $seq);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->finalizeCodeData($code_data, $startid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the A sequence
|
||||||
|
*
|
||||||
|
* @param array<int, array<int, string>> $sequence Sequence to process
|
||||||
|
* @param array<int, int> $code_data Array of codepoints to alter
|
||||||
|
* @param int $startid Start ID
|
||||||
|
* @param int $key Sequence current key
|
||||||
|
* @param array{string, string, int} $seq Sequence current value
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function processSequenceA(
|
||||||
|
array &$sequence,
|
||||||
|
array &$code_data,
|
||||||
|
int &$startid,
|
||||||
|
int $key,
|
||||||
|
array $seq
|
||||||
|
): void {
|
||||||
|
if ($key == 0) {
|
||||||
|
$startid = 103;
|
||||||
|
} elseif ($sequence[($key - 1)][0] != 'A') {
|
||||||
|
if (
|
||||||
|
($seq[2] == 1)
|
||||||
|
&& ($key > 0)
|
||||||
|
&& ($sequence[($key - 1)][0] == 'B')
|
||||||
|
&& (! isset($sequence[($key - 1)][3]))
|
||||||
|
) {
|
||||||
|
// single character shift
|
||||||
|
$code_data[] = 98;
|
||||||
|
// mark shift
|
||||||
|
$sequence[$key][3] = '';
|
||||||
|
} elseif (! isset($sequence[($key - 1)][3])) {
|
||||||
|
$code_data[] = 101;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->getCodeDataA($code_data, $seq[1], (int) $seq[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the B sequence
|
||||||
|
*
|
||||||
|
* @param array<int, array<int, string>> $sequence Sequence to process
|
||||||
|
* @param array<int, int> $code_data Array of codepoints to alter
|
||||||
|
* @param int $startid Start ID
|
||||||
|
* @param int $key Sequence current key
|
||||||
|
* @param array{string, string, int} $seq Sequence current value
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function processSequenceB(
|
||||||
|
array &$sequence,
|
||||||
|
array &$code_data,
|
||||||
|
int &$startid,
|
||||||
|
int $key,
|
||||||
|
array $seq
|
||||||
|
): void {
|
||||||
|
if ($key == 0) {
|
||||||
|
$this->processSequenceBA($sequence, $code_data, $startid, $key, $seq);
|
||||||
|
} elseif ($sequence[($key - 1)][0] != 'B') {
|
||||||
|
$this->processSequenceBB($sequence, $code_data, $key, $seq);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->getCodeDataB($code_data, $seq[1], (int) $seq[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the B-A sequence
|
||||||
|
*
|
||||||
|
* @param array<int, array<int, string>> $sequence Sequence to process
|
||||||
|
* @param array<int, int> $code_data Array of codepoints to alter
|
||||||
|
* @param int $startid Start ID
|
||||||
|
* @param int $key Sequence current key
|
||||||
|
* @param array{string, string, int} $seq Sequence current value
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function processSequenceBA(
|
||||||
|
array &$sequence,
|
||||||
|
array &$code_data,
|
||||||
|
int &$startid,
|
||||||
|
int $key,
|
||||||
|
array $seq
|
||||||
|
): void {
|
||||||
|
$tmpchr = ord($seq[1][0]);
|
||||||
|
if (
|
||||||
|
($seq[2] == 1)
|
||||||
|
&& ($tmpchr >= 241)
|
||||||
|
&& ($tmpchr <= 244)
|
||||||
|
&& isset($sequence[($key + 1)])
|
||||||
|
&& ($sequence[($key + 1)][0] != 'B')
|
||||||
|
) {
|
||||||
|
switch ($sequence[($key + 1)][0]) {
|
||||||
|
case 'A':
|
||||||
|
$startid = 103;
|
||||||
|
$sequence[$key][0] = 'A';
|
||||||
|
$code_data[] = $this::FNC_A[$tmpchr];
|
||||||
|
break;
|
||||||
|
case 'C':
|
||||||
|
$startid = 105;
|
||||||
|
$sequence[$key][0] = 'C';
|
||||||
|
$code_data[] = $this::FNC_A[$tmpchr];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$startid = 104;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the B-B sequence
|
||||||
|
*
|
||||||
|
* @param array<int, array<int, string>> $sequence Sequence to process
|
||||||
|
* @param array<int, int> $code_data Array of codepoints to alter
|
||||||
|
* @param int $key Sequence current key
|
||||||
|
* @param array{string, string, int} $seq Sequence current value
|
||||||
|
*/
|
||||||
|
protected function processSequenceBB(
|
||||||
|
array &$sequence,
|
||||||
|
array &$code_data,
|
||||||
|
int $key,
|
||||||
|
array $seq
|
||||||
|
): void {
|
||||||
|
if (
|
||||||
|
($seq[2] == 1)
|
||||||
|
&& ($key > 0)
|
||||||
|
&& ($sequence[($key - 1)][0] == 'A')
|
||||||
|
&& (! isset($sequence[($key - 1)][3]))
|
||||||
|
) {
|
||||||
|
// single character shift
|
||||||
|
$code_data[] = 98;
|
||||||
|
// mark shift
|
||||||
|
$sequence[$key][3] = '';
|
||||||
|
} elseif (! isset($sequence[($key - 1)][3])) {
|
||||||
|
$code_data[] = 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the C sequence
|
||||||
|
*
|
||||||
|
* @param array<int, array<int, string>> $sequence Sequence to process
|
||||||
|
* @param array<int, int> $code_data Array of codepoints to alter
|
||||||
|
* @param int $startid Start ID
|
||||||
|
* @param int $key Sequence current key
|
||||||
|
* @param array{string, string, int} $seq Sequence current value
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function processSequenceC(
|
||||||
|
array &$sequence,
|
||||||
|
array &$code_data,
|
||||||
|
int &$startid,
|
||||||
|
int $key,
|
||||||
|
array $seq
|
||||||
|
): void {
|
||||||
|
if ($key == 0) {
|
||||||
|
$startid = 105;
|
||||||
|
} elseif ($sequence[($key - 1)][0] != 'C') {
|
||||||
|
$code_data[] = 99;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->getCodeDataC($code_data, $seq[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bars array.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
$code_data = $this->getCodeData();
|
||||||
|
$this->ncols = 0;
|
||||||
|
$this->nrows = 1;
|
||||||
|
$this->bars = [];
|
||||||
|
foreach ($code_data as $val) {
|
||||||
|
$seq = $this::CHBAR[$val];
|
||||||
|
for ($pos = 0; $pos < 6; ++$pos) {
|
||||||
|
$bar_width = (int) $seq[$pos];
|
||||||
|
if ((($pos % 2) == 0) && ($bar_width > 0)) {
|
||||||
|
$this->bars[] = [$this->ncols, 0, $bar_width, 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ncols += $bar_width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
59
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightA.php
vendored
Normal file
59
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightA.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight\A;
|
||||||
|
*
|
||||||
|
* CodeOneTwoEightA Barcode type class
|
||||||
|
* CODE 128 A
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class CodeOneTwoEightA extends \Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'C128A';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the code point array
|
||||||
|
*
|
||||||
|
* @return array<int, int>
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function getCodeData(): array
|
||||||
|
{
|
||||||
|
$code = $this->code;
|
||||||
|
$len = strlen($code);
|
||||||
|
$code_data = [];
|
||||||
|
$this->getCodeDataA($code_data, $code, $len);
|
||||||
|
return $this->finalizeCodeData($code_data, 103);
|
||||||
|
}
|
||||||
|
}
|
||||||
59
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightB.php
vendored
Normal file
59
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightB.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* B.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight\B;
|
||||||
|
*
|
||||||
|
* CodeOneTwoEightB Barcode type class
|
||||||
|
* CODE 128 B
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class CodeOneTwoEightB extends \Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'C128B';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the code point array
|
||||||
|
*
|
||||||
|
* @return array<int, int>
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function getCodeData(): array
|
||||||
|
{
|
||||||
|
$code = $this->code;
|
||||||
|
$len = strlen($code);
|
||||||
|
$code_data = [];
|
||||||
|
$this->getCodeDataB($code_data, $code, $len);
|
||||||
|
return $this->finalizeCodeData($code_data, 104);
|
||||||
|
}
|
||||||
|
}
|
||||||
63
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightC.php
vendored
Normal file
63
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightC.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* C.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight\C;
|
||||||
|
*
|
||||||
|
* CodeOneTwoEightC Barcode type class
|
||||||
|
* CODE 128 C
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class CodeOneTwoEightC extends \Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'C128C';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the code point array
|
||||||
|
*
|
||||||
|
* @return array<int, int>
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function getCodeData(): array
|
||||||
|
{
|
||||||
|
$code = $this->code;
|
||||||
|
$code_data = [];
|
||||||
|
if (ord($code[0]) == 241) {
|
||||||
|
$code_data[] = 102;
|
||||||
|
$code = substr($code, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->getCodeDataC($code_data, $code);
|
||||||
|
return $this->finalizeCodeData($code_data, 105);
|
||||||
|
}
|
||||||
|
}
|
||||||
432
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeOneTwoEight/Process.php
vendored
Normal file
432
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeOneTwoEight/Process.php
vendored
Normal file
@@ -0,0 +1,432 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight\Process;
|
||||||
|
*
|
||||||
|
* Process methods for CodeOneTwoEight Barcode type class
|
||||||
|
* CODE 128
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
abstract class Process extends \Com\Tecnick\Barcode\Type\Linear
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'C128';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map characters to barcodes
|
||||||
|
*
|
||||||
|
* @var array<string>
|
||||||
|
*/
|
||||||
|
protected const CHBAR = [
|
||||||
|
'212222', // 00
|
||||||
|
'222122', // 01
|
||||||
|
'222221', // 02
|
||||||
|
'121223', // 03
|
||||||
|
'121322', // 04
|
||||||
|
'131222', // 05
|
||||||
|
'122213', // 06
|
||||||
|
'122312', // 07
|
||||||
|
'132212', // 08
|
||||||
|
'221213', // 09
|
||||||
|
'221312', // 10
|
||||||
|
'231212', // 11
|
||||||
|
'112232', // 12
|
||||||
|
'122132', // 13
|
||||||
|
'122231', // 14
|
||||||
|
'113222', // 15
|
||||||
|
'123122', // 16
|
||||||
|
'123221', // 17
|
||||||
|
'223211', // 18
|
||||||
|
'221132', // 19
|
||||||
|
'221231', // 20
|
||||||
|
'213212', // 21
|
||||||
|
'223112', // 22
|
||||||
|
'312131', // 23
|
||||||
|
'311222', // 24
|
||||||
|
'321122', // 25
|
||||||
|
'321221', // 26
|
||||||
|
'312212', // 27
|
||||||
|
'322112', // 28
|
||||||
|
'322211', // 29
|
||||||
|
'212123', // 30
|
||||||
|
'212321', // 31
|
||||||
|
'232121', // 32
|
||||||
|
'111323', // 33
|
||||||
|
'131123', // 34
|
||||||
|
'131321', // 35
|
||||||
|
'112313', // 36
|
||||||
|
'132113', // 37
|
||||||
|
'132311', // 38
|
||||||
|
'211313', // 39
|
||||||
|
'231113', // 40
|
||||||
|
'231311', // 41
|
||||||
|
'112133', // 42
|
||||||
|
'112331', // 43
|
||||||
|
'132131', // 44
|
||||||
|
'113123', // 45
|
||||||
|
'113321', // 46
|
||||||
|
'133121', // 47
|
||||||
|
'313121', // 48
|
||||||
|
'211331', // 49
|
||||||
|
'231131', // 50
|
||||||
|
'213113', // 51
|
||||||
|
'213311', // 52
|
||||||
|
'213131', // 53
|
||||||
|
'311123', // 54
|
||||||
|
'311321', // 55
|
||||||
|
'331121', // 56
|
||||||
|
'312113', // 57
|
||||||
|
'312311', // 58
|
||||||
|
'332111', // 59
|
||||||
|
'314111', // 60
|
||||||
|
'221411', // 61
|
||||||
|
'431111', // 62
|
||||||
|
'111224', // 63
|
||||||
|
'111422', // 64
|
||||||
|
'121124', // 65
|
||||||
|
'121421', // 66
|
||||||
|
'141122', // 67
|
||||||
|
'141221', // 68
|
||||||
|
'112214', // 69
|
||||||
|
'112412', // 70
|
||||||
|
'122114', // 71
|
||||||
|
'122411', // 72
|
||||||
|
'142112', // 73
|
||||||
|
'142211', // 74
|
||||||
|
'241211', // 75
|
||||||
|
'221114', // 76
|
||||||
|
'413111', // 77
|
||||||
|
'241112', // 78
|
||||||
|
'134111', // 79
|
||||||
|
'111242', // 80
|
||||||
|
'121142', // 81
|
||||||
|
'121241', // 82
|
||||||
|
'114212', // 83
|
||||||
|
'124112', // 84
|
||||||
|
'124211', // 85
|
||||||
|
'411212', // 86
|
||||||
|
'421112', // 87
|
||||||
|
'421211', // 88
|
||||||
|
'212141', // 89
|
||||||
|
'214121', // 90
|
||||||
|
'412121', // 91
|
||||||
|
'111143', // 92
|
||||||
|
'111341', // 93
|
||||||
|
'131141', // 94
|
||||||
|
'114113', // 95
|
||||||
|
'114311', // 96
|
||||||
|
'411113', // 97
|
||||||
|
'411311', // 98
|
||||||
|
'113141', // 99
|
||||||
|
'114131', // 100
|
||||||
|
'311141', // 101
|
||||||
|
'411131', // 102
|
||||||
|
'211412', // 103 START A
|
||||||
|
'211214', // 104 START B
|
||||||
|
'211232', // 105 START C
|
||||||
|
'233111', // STOP
|
||||||
|
'200000', // END
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map ASCII characters for code A (ASCII 00 - 95)
|
||||||
|
* // 128A (Code Set A) - ASCII characters 00 to 95 (0-9, A-Z and control codes), special characters
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const KEYS_A = ' !"#$%&\'()*+,-./'
|
||||||
|
. '0123456789'
|
||||||
|
. ':;<=>?@'
|
||||||
|
. 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||||
|
. '[\\]^_'
|
||||||
|
. "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"
|
||||||
|
. "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map ASCII characters for code B (ASCII 32 - 127)
|
||||||
|
* // 128B (Code Set B) - ASCII characters 32 to 127 (0-9, A-Z, a-z), special characters
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const KEYS_B = ' !"#$%&\'()*+,-./'
|
||||||
|
. '0123456789'
|
||||||
|
. ':;<=>?@'
|
||||||
|
. 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||||
|
. '[\\]^_`'
|
||||||
|
. 'abcdefghijklmnopqrstuvwxyz'
|
||||||
|
. '{|}~'
|
||||||
|
. "\x7F";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map special FNC codes for Code Set A (FNC 1-4)
|
||||||
|
*
|
||||||
|
* @var array<int, int>
|
||||||
|
*/
|
||||||
|
protected const FNC_A = [
|
||||||
|
241 => 102,
|
||||||
|
242 => 97,
|
||||||
|
243 => 96,
|
||||||
|
244 => 101,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map special FNC codes for Code Set B (FNC 1-4)
|
||||||
|
*
|
||||||
|
* @var array<int, int>
|
||||||
|
*/
|
||||||
|
protected const FNC_B = [
|
||||||
|
241 => 102,
|
||||||
|
242 => 97,
|
||||||
|
243 => 96,
|
||||||
|
244 => 100,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the numeric sequence (if any)
|
||||||
|
*
|
||||||
|
* @param string $code Code to parse
|
||||||
|
*
|
||||||
|
* @return array<int, array{string, string, int}>
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function getNumericSequence(string $code): array
|
||||||
|
{
|
||||||
|
$sequence = [];
|
||||||
|
$len = strlen($code);
|
||||||
|
// get numeric sequences (if any)
|
||||||
|
$numseq = [];
|
||||||
|
preg_match_all('/(\d{4,})/', $code, $numseq, PREG_OFFSET_CAPTURE);
|
||||||
|
if (! empty($numseq[1])) {
|
||||||
|
$end_offset = 0;
|
||||||
|
foreach ($numseq[1] as $val) {
|
||||||
|
// offset to the start of numeric substr
|
||||||
|
$offset = $val[1];
|
||||||
|
|
||||||
|
// numeric sequence
|
||||||
|
$slen = strlen($val[0]);
|
||||||
|
if ($slen % 2 != 0) {
|
||||||
|
// the length must be even
|
||||||
|
--$slen;
|
||||||
|
// add 1 to start of offset so numbers are c type encoded "from the end"
|
||||||
|
++$offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($offset > $end_offset) {
|
||||||
|
// non numeric sequence
|
||||||
|
$sequence = array_merge(
|
||||||
|
$sequence,
|
||||||
|
$this->get128ABsequence(substr($code, $end_offset, ($offset - $end_offset)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sequence[] = ['C', substr($code, $offset, $slen), $slen];
|
||||||
|
$end_offset = $offset + $slen;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($end_offset < $len) {
|
||||||
|
$sequence = array_merge($sequence, $this->get128ABsequence(substr($code, $end_offset)));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// text code (non C mode)
|
||||||
|
$sequence = array_merge($sequence, $this->get128ABsequence($code));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sequence;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Split text code in A/B sequence for 128 code
|
||||||
|
*
|
||||||
|
* @param string $code Code to split
|
||||||
|
*
|
||||||
|
* @return array<int, array{string, string, int}>
|
||||||
|
*/
|
||||||
|
protected function get128ABsequence(string $code): array
|
||||||
|
{
|
||||||
|
$len = strlen($code);
|
||||||
|
$sequence = [];
|
||||||
|
// get A sequences (if any)
|
||||||
|
$aseq = [];
|
||||||
|
preg_match_all('/([\x00-\x1f])/', $code, $aseq, PREG_OFFSET_CAPTURE);
|
||||||
|
if (! empty($aseq[1])) {
|
||||||
|
// get the entire A sequence (excluding FNC1-FNC4)
|
||||||
|
preg_match_all('/([\x00-\x5f]+)/', $code, $aseq, PREG_OFFSET_CAPTURE);
|
||||||
|
$end_offset = 0;
|
||||||
|
foreach ($aseq[1] as $val) {
|
||||||
|
$offset = $val[1];
|
||||||
|
if ($offset > $end_offset) {
|
||||||
|
// B sequence
|
||||||
|
$sequence[] = ['B', substr($code, $end_offset, ($offset - $end_offset)), ($offset - $end_offset)];
|
||||||
|
}
|
||||||
|
|
||||||
|
// A sequence
|
||||||
|
$slen = strlen($val[0]);
|
||||||
|
$sequence[] = ['A', substr($code, $offset, $slen), $slen];
|
||||||
|
$end_offset = $offset + $slen;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($end_offset < $len) {
|
||||||
|
$sequence[] = ['B', substr($code, $end_offset), ($len - $end_offset)];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// only B sequence
|
||||||
|
$sequence[] = ['B', $code, $len];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sequence;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the A code point array
|
||||||
|
*
|
||||||
|
* @param array<int, int> $code_data Array of codepoints to alter
|
||||||
|
* @param string $code Code to process
|
||||||
|
* @param int $len Number of characters to process
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function getCodeDataA(
|
||||||
|
array &$code_data,
|
||||||
|
string $code,
|
||||||
|
int $len
|
||||||
|
): void {
|
||||||
|
for ($pos = 0; $pos < $len; ++$pos) {
|
||||||
|
$char = $code[$pos];
|
||||||
|
$char_id = ord($char);
|
||||||
|
if (($char_id >= 241) && ($char_id <= 244)) {
|
||||||
|
$code_data[] = $this::FNC_A[$char_id];
|
||||||
|
} elseif ($char_id <= 95) {
|
||||||
|
$cdpos = strpos($this::KEYS_A, $char);
|
||||||
|
$code_data[] = is_int($cdpos) ? $cdpos : 0;
|
||||||
|
} else {
|
||||||
|
throw new BarcodeException('Invalid character sequence');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the B code point array
|
||||||
|
*
|
||||||
|
* @param array<int, int> $code_data Array of codepoints to alter
|
||||||
|
* @param string $code Code to process
|
||||||
|
* @param int $len Number of characters to process
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function getCodeDataB(
|
||||||
|
array &$code_data,
|
||||||
|
string $code,
|
||||||
|
int $len
|
||||||
|
): void {
|
||||||
|
for ($pos = 0; $pos < $len; ++$pos) {
|
||||||
|
$char = $code[$pos];
|
||||||
|
$char_id = ord($char);
|
||||||
|
if (($char_id >= 241) && ($char_id <= 244)) {
|
||||||
|
$code_data[] = $this::FNC_B[$char_id];
|
||||||
|
} elseif (($char_id >= 32) && ($char_id <= 127)) {
|
||||||
|
$cdpos = strpos($this::KEYS_B, $char);
|
||||||
|
$code_data[] = is_int($cdpos) ? $cdpos : 0;
|
||||||
|
} else {
|
||||||
|
throw new BarcodeException('Invalid character sequence: ' . $char_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the C code point array
|
||||||
|
*
|
||||||
|
* @param array<int, int> $code_data Array of codepoints to alter
|
||||||
|
* @param string $code Code to process
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function getCodeDataC(
|
||||||
|
array &$code_data,
|
||||||
|
string $code
|
||||||
|
): void {
|
||||||
|
// code blocks separated by FNC1 (chr 241)
|
||||||
|
$blocks = explode(chr(241), $code);
|
||||||
|
|
||||||
|
foreach ($blocks as $block) {
|
||||||
|
$len = strlen($block);
|
||||||
|
|
||||||
|
if ($len % 2 != 0) {
|
||||||
|
throw new BarcodeException('The length of each FNC1-separated code block must be even');
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($pos = 0; $pos < $len; $pos += 2) {
|
||||||
|
$chrnum = $block[$pos] . $block[($pos + 1)];
|
||||||
|
if (preg_match('/(\d{2})/', $chrnum) > 0) {
|
||||||
|
$code_data[] = (int) $chrnum;
|
||||||
|
} else {
|
||||||
|
throw new BarcodeException('Invalid character sequence');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$code_data[] = 102;
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove last 102 code
|
||||||
|
array_pop($code_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finalize code data
|
||||||
|
*
|
||||||
|
* @param array<int, int> $code_data Array of codepoints to alter
|
||||||
|
* @param int $startid Start ID code
|
||||||
|
*
|
||||||
|
* @return array<int, int> Array of codepoints
|
||||||
|
*/
|
||||||
|
protected function finalizeCodeData(
|
||||||
|
array $code_data,
|
||||||
|
int $startid
|
||||||
|
): array {
|
||||||
|
// calculate check character
|
||||||
|
$sum = $startid;
|
||||||
|
foreach ($code_data as $key => $val) {
|
||||||
|
$sum += ($val * ($key + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
// add check character
|
||||||
|
$code_data[] = ($sum % 103);
|
||||||
|
|
||||||
|
// add stop sequence
|
||||||
|
$code_data[] = 106;
|
||||||
|
$code_data[] = 107;
|
||||||
|
// add start code at the beginning
|
||||||
|
array_unshift($code_data, $startid);
|
||||||
|
|
||||||
|
return $code_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
49
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeThreeNine.php
vendored
Normal file
49
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeThreeNine.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CodeThreeNine.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\CodeThreeNine
|
||||||
|
*
|
||||||
|
* CodeThreeNine Barcode type class
|
||||||
|
* CODE 39
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class CodeThreeNine extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtCheck
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'C39';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format code
|
||||||
|
*/
|
||||||
|
protected function formatCode(): void
|
||||||
|
{
|
||||||
|
$this->extcode = '*' . strtoupper($this->code) . '*';
|
||||||
|
}
|
||||||
|
}
|
||||||
50
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeThreeNineCheck.php
vendored
Normal file
50
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeThreeNineCheck.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CodeThreeNineCheck.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\CodeThreeNineCheck
|
||||||
|
*
|
||||||
|
* CodeThreeNineCheck Barcode type class
|
||||||
|
* CODE 39 + CHECKSUM
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class CodeThreeNineCheck extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtCheck
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'C39+';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format code
|
||||||
|
*/
|
||||||
|
protected function formatCode(): void
|
||||||
|
{
|
||||||
|
$code = strtoupper($this->code);
|
||||||
|
$this->extcode = '*' . $code . $this->getChecksum($code) . '*';
|
||||||
|
}
|
||||||
|
}
|
||||||
49
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeThreeNineExt.php
vendored
Normal file
49
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeThreeNineExt.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CodeThreeNineExt.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\CodeThreeNineExt
|
||||||
|
*
|
||||||
|
* CodeThreeNineExt Barcode type class
|
||||||
|
* CODE 39 EXTENDED
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class CodeThreeNineExt extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtCheck
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'C39E';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format code
|
||||||
|
*/
|
||||||
|
protected function formatCode(): void
|
||||||
|
{
|
||||||
|
$this->extcode = '*' . $this->getExtendCode(strtoupper($this->code)) . '*';
|
||||||
|
}
|
||||||
|
}
|
||||||
368
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeThreeNineExtCheck.php
vendored
Normal file
368
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeThreeNineExtCheck.php
vendored
Normal file
@@ -0,0 +1,368 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CodeThreeNineExtCheck.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtCheck
|
||||||
|
*
|
||||||
|
* CodeThreeNineExtCheck Barcode type class
|
||||||
|
* CODE 39 EXTENDED + CHECKSUM
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class CodeThreeNineExtCheck extends \Com\Tecnick\Barcode\Type\Linear
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'C39E+';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map characters to barcodes
|
||||||
|
*
|
||||||
|
* @var array<int|string, string>
|
||||||
|
*/
|
||||||
|
protected const CHBAR = [
|
||||||
|
'0' => '111331311',
|
||||||
|
'1' => '311311113',
|
||||||
|
'2' => '113311113',
|
||||||
|
'3' => '313311111',
|
||||||
|
'4' => '111331113',
|
||||||
|
'5' => '311331111',
|
||||||
|
'6' => '113331111',
|
||||||
|
'7' => '111311313',
|
||||||
|
'8' => '311311311',
|
||||||
|
'9' => '113311311',
|
||||||
|
'A' => '311113113',
|
||||||
|
'B' => '113113113',
|
||||||
|
'C' => '313113111',
|
||||||
|
'D' => '111133113',
|
||||||
|
'E' => '311133111',
|
||||||
|
'F' => '113133111',
|
||||||
|
'G' => '111113313',
|
||||||
|
'H' => '311113311',
|
||||||
|
'I' => '113113311',
|
||||||
|
'J' => '111133311',
|
||||||
|
'K' => '311111133',
|
||||||
|
'L' => '113111133',
|
||||||
|
'M' => '313111131',
|
||||||
|
'N' => '111131133',
|
||||||
|
'O' => '311131131',
|
||||||
|
'P' => '113131131',
|
||||||
|
'Q' => '111111333',
|
||||||
|
'R' => '311111331',
|
||||||
|
'S' => '113111331',
|
||||||
|
'T' => '111131331',
|
||||||
|
'U' => '331111113',
|
||||||
|
'V' => '133111113',
|
||||||
|
'W' => '333111111',
|
||||||
|
'X' => '131131113',
|
||||||
|
'Y' => '331131111',
|
||||||
|
'Z' => '133131111',
|
||||||
|
'-' => '131111313',
|
||||||
|
'.' => '331111311',
|
||||||
|
' ' => '133111311',
|
||||||
|
'$' => '131313111',
|
||||||
|
'/' => '131311131',
|
||||||
|
'+' => '131113131',
|
||||||
|
'%' => '111313131',
|
||||||
|
'*' => '131131311',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map for extended characters
|
||||||
|
*
|
||||||
|
* @var array<string>
|
||||||
|
*/
|
||||||
|
protected const EXTCODES = [
|
||||||
|
'%U',
|
||||||
|
'$A',
|
||||||
|
'$B',
|
||||||
|
'$C',
|
||||||
|
'$D',
|
||||||
|
'$E',
|
||||||
|
'$F',
|
||||||
|
'$G',
|
||||||
|
'$H',
|
||||||
|
'$I',
|
||||||
|
'$J',
|
||||||
|
'$K',
|
||||||
|
'$L',
|
||||||
|
'$M',
|
||||||
|
'$N',
|
||||||
|
'$O',
|
||||||
|
'$P',
|
||||||
|
'$Q',
|
||||||
|
'$R',
|
||||||
|
'$S',
|
||||||
|
'$T',
|
||||||
|
'$U',
|
||||||
|
'$V',
|
||||||
|
'$W',
|
||||||
|
'$X',
|
||||||
|
'$Y',
|
||||||
|
'$Z',
|
||||||
|
'%A',
|
||||||
|
'%B',
|
||||||
|
'%C',
|
||||||
|
'%D',
|
||||||
|
'%E',
|
||||||
|
' ',
|
||||||
|
'/A',
|
||||||
|
'/B',
|
||||||
|
'/C',
|
||||||
|
'/D',
|
||||||
|
'/E',
|
||||||
|
'/F',
|
||||||
|
'/G',
|
||||||
|
'/H',
|
||||||
|
'/I',
|
||||||
|
'/J',
|
||||||
|
'/K',
|
||||||
|
'/L',
|
||||||
|
'-',
|
||||||
|
'.',
|
||||||
|
'/O',
|
||||||
|
'0',
|
||||||
|
'1',
|
||||||
|
'2',
|
||||||
|
'3',
|
||||||
|
'4',
|
||||||
|
'5',
|
||||||
|
'6',
|
||||||
|
'7',
|
||||||
|
'8',
|
||||||
|
'9',
|
||||||
|
'/Z',
|
||||||
|
'%F',
|
||||||
|
'%G',
|
||||||
|
'%H',
|
||||||
|
'%I',
|
||||||
|
'%J',
|
||||||
|
'%V',
|
||||||
|
'A',
|
||||||
|
'B',
|
||||||
|
'C',
|
||||||
|
'D',
|
||||||
|
'E',
|
||||||
|
'F',
|
||||||
|
'G',
|
||||||
|
'H',
|
||||||
|
'I',
|
||||||
|
'J',
|
||||||
|
'K',
|
||||||
|
'L',
|
||||||
|
'M',
|
||||||
|
'N',
|
||||||
|
'O',
|
||||||
|
'P',
|
||||||
|
'Q',
|
||||||
|
'R',
|
||||||
|
'S',
|
||||||
|
'T',
|
||||||
|
'U',
|
||||||
|
'V',
|
||||||
|
'W',
|
||||||
|
'X',
|
||||||
|
'Y',
|
||||||
|
'Z',
|
||||||
|
'%K',
|
||||||
|
'%L',
|
||||||
|
'%M',
|
||||||
|
'%N',
|
||||||
|
'%O',
|
||||||
|
'%W',
|
||||||
|
'+A',
|
||||||
|
'+B',
|
||||||
|
'+C',
|
||||||
|
'+D',
|
||||||
|
'+E',
|
||||||
|
'+F',
|
||||||
|
'+G',
|
||||||
|
'+H',
|
||||||
|
'+I',
|
||||||
|
'+J',
|
||||||
|
'+K',
|
||||||
|
'+L',
|
||||||
|
'+M',
|
||||||
|
'+N',
|
||||||
|
'+O',
|
||||||
|
'+P',
|
||||||
|
'+Q',
|
||||||
|
'+R',
|
||||||
|
'+S',
|
||||||
|
'+T',
|
||||||
|
'+U',
|
||||||
|
'+V',
|
||||||
|
'+W',
|
||||||
|
'+X',
|
||||||
|
'+Y',
|
||||||
|
'+Z',
|
||||||
|
'%P',
|
||||||
|
'%Q',
|
||||||
|
'%R',
|
||||||
|
'%S',
|
||||||
|
'%T',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Characters used for checksum
|
||||||
|
*
|
||||||
|
* @var array<string>
|
||||||
|
*/
|
||||||
|
protected const CHKSUM = [
|
||||||
|
'0',
|
||||||
|
'1',
|
||||||
|
'2',
|
||||||
|
'3',
|
||||||
|
'4',
|
||||||
|
'5',
|
||||||
|
'6',
|
||||||
|
'7',
|
||||||
|
'8',
|
||||||
|
'9',
|
||||||
|
'A',
|
||||||
|
'B',
|
||||||
|
'C',
|
||||||
|
'D',
|
||||||
|
'E',
|
||||||
|
'F',
|
||||||
|
'G',
|
||||||
|
'H',
|
||||||
|
'I',
|
||||||
|
'J',
|
||||||
|
'K',
|
||||||
|
'L',
|
||||||
|
'M',
|
||||||
|
'N',
|
||||||
|
'O',
|
||||||
|
'P',
|
||||||
|
'Q',
|
||||||
|
'R',
|
||||||
|
'S',
|
||||||
|
'T',
|
||||||
|
'U',
|
||||||
|
'V',
|
||||||
|
'W',
|
||||||
|
'X',
|
||||||
|
'Y',
|
||||||
|
'Z',
|
||||||
|
'-',
|
||||||
|
'.',
|
||||||
|
' ',
|
||||||
|
'$',
|
||||||
|
'/',
|
||||||
|
'+',
|
||||||
|
'%',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode a string to be used for CODE 39 Extended mode.
|
||||||
|
*
|
||||||
|
* @param string $code Code to extend
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function getExtendCode(string $code): string
|
||||||
|
{
|
||||||
|
$ext = '';
|
||||||
|
$clen = strlen($code);
|
||||||
|
for ($chr = 0; $chr < $clen; ++$chr) {
|
||||||
|
$item = ord($code[$chr]);
|
||||||
|
if ($item > 127) {
|
||||||
|
throw new BarcodeException('Invalid character: chr(' . $item . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
$ext .= $this::EXTCODES[$item];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate CODE 39 checksum (modulo 43).
|
||||||
|
*
|
||||||
|
* @param string $code Code to represent.
|
||||||
|
*
|
||||||
|
* @return string char checksum.
|
||||||
|
*/
|
||||||
|
protected function getChecksum(string $code): string
|
||||||
|
{
|
||||||
|
$sum = 0;
|
||||||
|
$clen = strlen($code);
|
||||||
|
for ($chr = 0; $chr < $clen; ++$chr) {
|
||||||
|
$key = array_keys($this::CHKSUM, $code[$chr]);
|
||||||
|
$sum += $key[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
$idx = ($sum % 43);
|
||||||
|
return $this::CHKSUM[$idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format code
|
||||||
|
*/
|
||||||
|
protected function formatCode(): void
|
||||||
|
{
|
||||||
|
$code = $this->getExtendCode(strtoupper($this->code));
|
||||||
|
$this->extcode = '*' . $code . $this->getChecksum($code) . '*';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bars array.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
$this->ncols = 0;
|
||||||
|
$this->nrows = 1;
|
||||||
|
$this->bars = [];
|
||||||
|
$this->formatCode();
|
||||||
|
$clen = strlen($this->extcode);
|
||||||
|
for ($chr = 0; $chr < $clen; ++$chr) {
|
||||||
|
$char = $this->extcode[$chr];
|
||||||
|
if (! isset($this::CHBAR[$char])) {
|
||||||
|
throw new BarcodeException('Invalid character: chr(' . ord($char) . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($pos = 0; $pos < 9; ++$pos) {
|
||||||
|
$bar_width = (int) $this::CHBAR[$char][$pos];
|
||||||
|
if ((($pos % 2) == 0) && ($bar_width > 0)) {
|
||||||
|
$this->bars[] = [$this->ncols, 0, $bar_width, 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ncols += $bar_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
// intercharacter gap
|
||||||
|
++$this->ncols;
|
||||||
|
}
|
||||||
|
|
||||||
|
--$this->ncols;
|
||||||
|
}
|
||||||
|
}
|
||||||
71
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/EanEight.php
vendored
Normal file
71
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/EanEight.php
vendored
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EanEight.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\EanEight;
|
||||||
|
*
|
||||||
|
* EanEight Barcode type class
|
||||||
|
* EAN 8
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class EanEight extends \Com\Tecnick\Barcode\Type\Linear\EanOneThree
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'EAN8';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fixed code length
|
||||||
|
*/
|
||||||
|
protected int $code_length = 8;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bars array.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
$this->formatCode();
|
||||||
|
$seq = '101'; // left guard bar
|
||||||
|
$half_len = (int) ceil($this->code_length / 2);
|
||||||
|
for ($pos = 0; $pos < $half_len; ++$pos) {
|
||||||
|
$seq .= $this::CHBAR['A'][$this->extcode[$pos]];
|
||||||
|
}
|
||||||
|
|
||||||
|
$seq .= '01010'; // center guard bar
|
||||||
|
for ($pos = $half_len; $pos < $this->code_length; ++$pos) {
|
||||||
|
$seq .= $this::CHBAR['C'][$this->extcode[$pos]];
|
||||||
|
}
|
||||||
|
|
||||||
|
$seq .= '101'; // right guard bar
|
||||||
|
$this->processBinarySequence($this->getRawCodeRows($seq));
|
||||||
|
}
|
||||||
|
}
|
||||||
77
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/EanFive.php
vendored
Normal file
77
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/EanFive.php
vendored
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EanFive.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\EanFive;
|
||||||
|
*
|
||||||
|
* EanFive Barcode type class
|
||||||
|
* EAN 5-Digits UPC-Based Extension
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class EanFive extends \Com\Tecnick\Barcode\Type\Linear\EanTwo
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'EAN5';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fixed code length
|
||||||
|
*/
|
||||||
|
protected int $code_length = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map parities
|
||||||
|
*
|
||||||
|
* @var array<int|string, array<string>>
|
||||||
|
*/
|
||||||
|
protected const PARITIES = [
|
||||||
|
'0' => ['B', 'B', 'A', 'A', 'A'],
|
||||||
|
'1' => ['B', 'A', 'B', 'A', 'A'],
|
||||||
|
'2' => ['B', 'A', 'A', 'B', 'A'],
|
||||||
|
'3' => ['B', 'A', 'A', 'A', 'B'],
|
||||||
|
'4' => ['A', 'B', 'B', 'A', 'A'],
|
||||||
|
'5' => ['A', 'A', 'B', 'B', 'A'],
|
||||||
|
'6' => ['A', 'A', 'A', 'B', 'B'],
|
||||||
|
'7' => ['A', 'B', 'A', 'B', 'A'],
|
||||||
|
'8' => ['A', 'B', 'A', 'A', 'B'],
|
||||||
|
'9' => ['A', 'A', 'B', 'A', 'B'],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate checksum
|
||||||
|
*
|
||||||
|
* @param string $code Code to represent.
|
||||||
|
*
|
||||||
|
* @return int char checksum.
|
||||||
|
*/
|
||||||
|
protected function getChecksum(string $code): int
|
||||||
|
{
|
||||||
|
return (((3 * ((int) $code[0] + (int) $code[2] + (int) $code[4]))
|
||||||
|
+ (9 * ((int) $code[1] + (int) $code[3]))) % 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
204
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/EanOneThree.php
vendored
Normal file
204
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/EanOneThree.php
vendored
Normal file
@@ -0,0 +1,204 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EanOneThree.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\EanOneThree;
|
||||||
|
*
|
||||||
|
* EanOneThree Barcode type class
|
||||||
|
* EAN 13
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class EanOneThree extends \Com\Tecnick\Barcode\Type\Linear
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'EAN13';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fixed code length
|
||||||
|
*/
|
||||||
|
protected int $code_length = 13;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check digit
|
||||||
|
*/
|
||||||
|
protected int $check = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map characters to barcodes
|
||||||
|
*
|
||||||
|
* @var array<int|string, array<int|string, string>>
|
||||||
|
*/
|
||||||
|
protected const CHBAR = [
|
||||||
|
'A' => [
|
||||||
|
// left odd parity
|
||||||
|
'0' => '0001101',
|
||||||
|
'1' => '0011001',
|
||||||
|
'2' => '0010011',
|
||||||
|
'3' => '0111101',
|
||||||
|
'4' => '0100011',
|
||||||
|
'5' => '0110001',
|
||||||
|
'6' => '0101111',
|
||||||
|
'7' => '0111011',
|
||||||
|
'8' => '0110111',
|
||||||
|
'9' => '0001011',
|
||||||
|
],
|
||||||
|
'B' => [
|
||||||
|
// left even parity
|
||||||
|
'0' => '0100111',
|
||||||
|
'1' => '0110011',
|
||||||
|
'2' => '0011011',
|
||||||
|
'3' => '0100001',
|
||||||
|
'4' => '0011101',
|
||||||
|
'5' => '0111001',
|
||||||
|
'6' => '0000101',
|
||||||
|
'7' => '0010001',
|
||||||
|
'8' => '0001001',
|
||||||
|
'9' => '0010111',
|
||||||
|
],
|
||||||
|
'C' => [
|
||||||
|
// right
|
||||||
|
'0' => '1110010',
|
||||||
|
'1' => '1100110',
|
||||||
|
'2' => '1101100',
|
||||||
|
'3' => '1000010',
|
||||||
|
'4' => '1011100',
|
||||||
|
'5' => '1001110',
|
||||||
|
'6' => '1010000',
|
||||||
|
'7' => '1000100',
|
||||||
|
'8' => '1001000',
|
||||||
|
'9' => '1110100',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map parities
|
||||||
|
*
|
||||||
|
* @var array<int|string, string>
|
||||||
|
*/
|
||||||
|
protected const PARITIES = [
|
||||||
|
'0' => 'AAAAAA',
|
||||||
|
'1' => 'AABABB',
|
||||||
|
'2' => 'AABBAB',
|
||||||
|
'3' => 'AABBBA',
|
||||||
|
'4' => 'ABAABB',
|
||||||
|
'5' => 'ABBAAB',
|
||||||
|
'6' => 'ABBBAA',
|
||||||
|
'7' => 'ABABAB',
|
||||||
|
'8' => 'ABABBA',
|
||||||
|
'9' => 'ABBABA',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate checksum
|
||||||
|
*
|
||||||
|
* @param string $code Code to represent.
|
||||||
|
*
|
||||||
|
* @return int char checksum.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function getChecksum(string $code): int
|
||||||
|
{
|
||||||
|
$data_len = ($this->code_length - 1);
|
||||||
|
$code_len = strlen($code);
|
||||||
|
$sum_a = 0;
|
||||||
|
for ($pos = 1; $pos < $data_len; $pos += 2) {
|
||||||
|
$sum_a += (int) $code[$pos];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->code_length > 12) {
|
||||||
|
$sum_a *= 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sum_b = 0;
|
||||||
|
for ($pos = 0; $pos < $data_len; $pos += 2) {
|
||||||
|
$sum_b += (int) ($code[$pos]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->code_length < 13) {
|
||||||
|
$sum_b *= 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->check = ($sum_a + $sum_b) % 10;
|
||||||
|
if ($this->check > 0) {
|
||||||
|
$this->check = (10 - $this->check);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($code_len == $data_len) {
|
||||||
|
// add check digit
|
||||||
|
return $this->check;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->check !== (int) $code[$data_len]) {
|
||||||
|
// wrong check digit
|
||||||
|
throw new BarcodeException('Invalid check digit: ' . $this->check);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format code
|
||||||
|
*/
|
||||||
|
protected function formatCode(): void
|
||||||
|
{
|
||||||
|
$code = str_pad($this->code, ($this->code_length - 1), '0', STR_PAD_LEFT);
|
||||||
|
$this->extcode = $code . $this->getChecksum($code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bars array.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
if (! is_numeric($this->code)) {
|
||||||
|
throw new BarcodeException('Input code must be a number');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->formatCode();
|
||||||
|
$seq = '101'; // left guard bar
|
||||||
|
$half_len = (int) ceil($this->code_length / 2);
|
||||||
|
$parity = $this::PARITIES[$this->extcode[0]];
|
||||||
|
for ($pos = 1; $pos < $half_len; ++$pos) {
|
||||||
|
$seq .= $this::CHBAR[$parity[($pos - 1)]][$this->extcode[$pos]];
|
||||||
|
}
|
||||||
|
|
||||||
|
$seq .= '01010'; // center guard bar
|
||||||
|
for ($pos = $half_len; $pos < $this->code_length; ++$pos) {
|
||||||
|
$seq .= $this::CHBAR['C'][$this->extcode[$pos]];
|
||||||
|
}
|
||||||
|
|
||||||
|
$seq .= '101'; // right guard bar
|
||||||
|
$this->processBinarySequence($this->getRawCodeRows($seq));
|
||||||
|
}
|
||||||
|
}
|
||||||
135
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/EanTwo.php
vendored
Normal file
135
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/EanTwo.php
vendored
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EanTwo.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\EanTwo;
|
||||||
|
*
|
||||||
|
* EanTwo Barcode type class
|
||||||
|
* EAN 2-Digits UPC-Based Extension
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class EanTwo extends \Com\Tecnick\Barcode\Type\Linear
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'EAN2';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fixed code length
|
||||||
|
*/
|
||||||
|
protected int $code_length = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map characters to barcodes
|
||||||
|
*
|
||||||
|
* @var array<string, array<int|string, string>>
|
||||||
|
*/
|
||||||
|
protected const CHBAR = [
|
||||||
|
'A' => [
|
||||||
|
// left odd parity
|
||||||
|
'0' => '0001101',
|
||||||
|
'1' => '0011001',
|
||||||
|
'2' => '0010011',
|
||||||
|
'3' => '0111101',
|
||||||
|
'4' => '0100011',
|
||||||
|
'5' => '0110001',
|
||||||
|
'6' => '0101111',
|
||||||
|
'7' => '0111011',
|
||||||
|
'8' => '0110111',
|
||||||
|
'9' => '0001011',
|
||||||
|
],
|
||||||
|
'B' => [
|
||||||
|
// left even parity
|
||||||
|
'0' => '0100111',
|
||||||
|
'1' => '0110011',
|
||||||
|
'2' => '0011011',
|
||||||
|
'3' => '0100001',
|
||||||
|
'4' => '0011101',
|
||||||
|
'5' => '0111001',
|
||||||
|
'6' => '0000101',
|
||||||
|
'7' => '0010001',
|
||||||
|
'8' => '0001001',
|
||||||
|
'9' => '0010111',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map parities
|
||||||
|
*
|
||||||
|
* @var array<int|string, array<string>>
|
||||||
|
*/
|
||||||
|
protected const PARITIES = [
|
||||||
|
'0' => ['A', 'A'],
|
||||||
|
'1' => ['A', 'B'],
|
||||||
|
'2' => ['B', 'A'],
|
||||||
|
'3' => ['B', 'B'],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate checksum
|
||||||
|
*
|
||||||
|
* @param string $code Code to represent.
|
||||||
|
*
|
||||||
|
* @return int char checksum.
|
||||||
|
*/
|
||||||
|
protected function getChecksum(string $code): int
|
||||||
|
{
|
||||||
|
return ((int) $code % 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format code
|
||||||
|
*/
|
||||||
|
protected function formatCode(): void
|
||||||
|
{
|
||||||
|
$this->extcode = str_pad($this->code, $this->code_length, '0', STR_PAD_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bars array.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
$this->formatCode();
|
||||||
|
$chk = $this->getChecksum($this->extcode);
|
||||||
|
$parity = $this::PARITIES[$chk];
|
||||||
|
$seq = '1011'; // left guard bar
|
||||||
|
$seq .= $this::CHBAR[$parity[0]][$this->extcode[0]];
|
||||||
|
$len = strlen($this->extcode);
|
||||||
|
for ($pos = 1; $pos < $len; ++$pos) {
|
||||||
|
$seq .= '01'; // separator
|
||||||
|
$seq .= $this::CHBAR[$parity[$pos]][$this->extcode[$pos]];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->processBinarySequence($this->getRawCodeRows($seq));
|
||||||
|
}
|
||||||
|
}
|
||||||
575
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/Imb.php
vendored
Normal file
575
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/Imb.php
vendored
Normal file
@@ -0,0 +1,575 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Imb.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2015-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\Imb;
|
||||||
|
*
|
||||||
|
* Imb Barcode type class
|
||||||
|
* IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
|
||||||
|
*
|
||||||
|
* Intelligent Mail barcode is a 65-bar code for use on mail in the United States.
|
||||||
|
* The fields are described as follows:
|
||||||
|
* * The Barcode Identifier shall be assigned by USPS to encode the presort identification that is currently
|
||||||
|
* printed in human readable form on the optional endorsement line (OEL) as well as for future USPS use.
|
||||||
|
* This shall be two digits, with the second digit in the range of 0–4. The allowable encoding ranges shall be
|
||||||
|
* 00–04, 10–14, 20–24, 30–34, 40–44, 50–54, 60–64, 70–74, 80–84, and 90–94.
|
||||||
|
* * The Service Type Identifier shall be assigned by USPS for any combination of services requested on the mailpiece.
|
||||||
|
* The allowable encoding range shall be 000http://it2.php.net/manual/en/function.dechex.php–999.
|
||||||
|
* Each 3-digit value shall correspond to a particular mail class with a particular combination of service(s).
|
||||||
|
* Each service program, such as OneCode Confirm and OneCode ACS, shall provide the list of Service Type Identifier
|
||||||
|
* values.
|
||||||
|
* * The Mailer or Customer Identifier shall be assigned by USPS as a unique, 6 or 9 digit number that identifies
|
||||||
|
* a business entity. The allowable encoding range for the 6 digit Mailer ID shall be 000000- 899999, while the
|
||||||
|
* allowable encoding range for the 9 digit Mailer ID shall be 900000000-999999999. The Serial or
|
||||||
|
* Sequence Number shall be assigned by the mailer for uniquely identifying and tracking mailpieces.
|
||||||
|
* The allowable encoding range shall be 000000000–999999999 when used with a 6 digit Mailer ID and 000000-999999
|
||||||
|
* when used with a 9 digit Mailer ID. e. The Delivery Point ZIP Code shall be assigned by the mailer for routing
|
||||||
|
* the mailpiece. This shall replace POSTNET for routing the mailpiece to its final delivery point.
|
||||||
|
* The length may be 0, 5, 9, or 11 digits. The allowable encoding ranges shall be no ZIP Code, 00000–99999,
|
||||||
|
* 000000000–999999999, and 00000000000–99999999999. An hyphen '-' is required before the zip/delivery point.
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2015-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class Imb extends \Com\Tecnick\Barcode\Type\Linear
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'IMB';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ASC characters
|
||||||
|
*
|
||||||
|
* @var array<int>
|
||||||
|
*/
|
||||||
|
protected const ASC_CHR = [
|
||||||
|
4,
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
6,
|
||||||
|
3,
|
||||||
|
5,
|
||||||
|
1,
|
||||||
|
9,
|
||||||
|
8,
|
||||||
|
7,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
0,
|
||||||
|
6,
|
||||||
|
4,
|
||||||
|
8,
|
||||||
|
2,
|
||||||
|
9,
|
||||||
|
5,
|
||||||
|
3,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
3,
|
||||||
|
7,
|
||||||
|
4,
|
||||||
|
6,
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
2,
|
||||||
|
0,
|
||||||
|
5,
|
||||||
|
1,
|
||||||
|
9,
|
||||||
|
4,
|
||||||
|
3,
|
||||||
|
8,
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
4,
|
||||||
|
3,
|
||||||
|
9,
|
||||||
|
5,
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
3,
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
4,
|
||||||
|
0,
|
||||||
|
9,
|
||||||
|
1,
|
||||||
|
7,
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
4,
|
||||||
|
6,
|
||||||
|
3,
|
||||||
|
7,
|
||||||
|
1,
|
||||||
|
9,
|
||||||
|
5,
|
||||||
|
8,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DSC characters
|
||||||
|
*
|
||||||
|
* @var array<int>
|
||||||
|
*/
|
||||||
|
protected const DSC_CHR = [
|
||||||
|
7,
|
||||||
|
1,
|
||||||
|
9,
|
||||||
|
5,
|
||||||
|
8,
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
4,
|
||||||
|
6,
|
||||||
|
3,
|
||||||
|
5,
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
7,
|
||||||
|
3,
|
||||||
|
0,
|
||||||
|
6,
|
||||||
|
1,
|
||||||
|
7,
|
||||||
|
4,
|
||||||
|
6,
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
2,
|
||||||
|
5,
|
||||||
|
1,
|
||||||
|
7,
|
||||||
|
5,
|
||||||
|
4,
|
||||||
|
3,
|
||||||
|
8,
|
||||||
|
7,
|
||||||
|
6,
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
5,
|
||||||
|
4,
|
||||||
|
9,
|
||||||
|
3,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
6,
|
||||||
|
8,
|
||||||
|
2,
|
||||||
|
0,
|
||||||
|
4,
|
||||||
|
5,
|
||||||
|
9,
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
5,
|
||||||
|
2,
|
||||||
|
6,
|
||||||
|
3,
|
||||||
|
8,
|
||||||
|
5,
|
||||||
|
1,
|
||||||
|
9,
|
||||||
|
8,
|
||||||
|
7,
|
||||||
|
4,
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
6,
|
||||||
|
3,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ASC positions
|
||||||
|
*
|
||||||
|
* @var array<int>
|
||||||
|
*/
|
||||||
|
protected const ASC_POS = [
|
||||||
|
3,
|
||||||
|
0,
|
||||||
|
8,
|
||||||
|
11,
|
||||||
|
1,
|
||||||
|
12,
|
||||||
|
8,
|
||||||
|
11,
|
||||||
|
10,
|
||||||
|
6,
|
||||||
|
4,
|
||||||
|
12,
|
||||||
|
2,
|
||||||
|
7,
|
||||||
|
9,
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
9,
|
||||||
|
2,
|
||||||
|
8,
|
||||||
|
4,
|
||||||
|
0,
|
||||||
|
12,
|
||||||
|
7,
|
||||||
|
10,
|
||||||
|
9,
|
||||||
|
0,
|
||||||
|
7,
|
||||||
|
10,
|
||||||
|
5,
|
||||||
|
7,
|
||||||
|
9,
|
||||||
|
6,
|
||||||
|
8,
|
||||||
|
2,
|
||||||
|
12,
|
||||||
|
1,
|
||||||
|
4,
|
||||||
|
2,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
5,
|
||||||
|
4,
|
||||||
|
6,
|
||||||
|
12,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
9,
|
||||||
|
4,
|
||||||
|
7,
|
||||||
|
5,
|
||||||
|
10,
|
||||||
|
2,
|
||||||
|
6,
|
||||||
|
9,
|
||||||
|
11,
|
||||||
|
2,
|
||||||
|
12,
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
5,
|
||||||
|
11,
|
||||||
|
0,
|
||||||
|
3,
|
||||||
|
2,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DSC positions
|
||||||
|
*
|
||||||
|
* @var array<int>
|
||||||
|
*/
|
||||||
|
protected const DSC_POS = [
|
||||||
|
2,
|
||||||
|
10,
|
||||||
|
12,
|
||||||
|
5,
|
||||||
|
9,
|
||||||
|
1,
|
||||||
|
5,
|
||||||
|
4,
|
||||||
|
3,
|
||||||
|
9,
|
||||||
|
11,
|
||||||
|
5,
|
||||||
|
10,
|
||||||
|
1,
|
||||||
|
6,
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
1,
|
||||||
|
10,
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
11,
|
||||||
|
8,
|
||||||
|
6,
|
||||||
|
1,
|
||||||
|
12,
|
||||||
|
3,
|
||||||
|
8,
|
||||||
|
6,
|
||||||
|
4,
|
||||||
|
4,
|
||||||
|
11,
|
||||||
|
0,
|
||||||
|
6,
|
||||||
|
1,
|
||||||
|
9,
|
||||||
|
11,
|
||||||
|
5,
|
||||||
|
3,
|
||||||
|
7,
|
||||||
|
3,
|
||||||
|
10,
|
||||||
|
7,
|
||||||
|
11,
|
||||||
|
8,
|
||||||
|
2,
|
||||||
|
10,
|
||||||
|
3,
|
||||||
|
5,
|
||||||
|
8,
|
||||||
|
0,
|
||||||
|
3,
|
||||||
|
12,
|
||||||
|
11,
|
||||||
|
8,
|
||||||
|
4,
|
||||||
|
5,
|
||||||
|
1,
|
||||||
|
3,
|
||||||
|
0,
|
||||||
|
7,
|
||||||
|
12,
|
||||||
|
9,
|
||||||
|
8,
|
||||||
|
10,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse unsigned short value
|
||||||
|
*
|
||||||
|
* @param int $num Value to reversr
|
||||||
|
*
|
||||||
|
* @return int reversed value
|
||||||
|
*/
|
||||||
|
protected function getReversedUnsignedShort(int $num): int
|
||||||
|
{
|
||||||
|
$rev = 0;
|
||||||
|
for ($pos = 0; $pos < 16; ++$pos) {
|
||||||
|
$rev <<= 1;
|
||||||
|
$rev |= ($num & 1);
|
||||||
|
$num >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rev;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Frame Check Sequence
|
||||||
|
*
|
||||||
|
* @param array<int, string> $code_arr Array of hexadecimal values (13 bytes holding 102 bits right justified).
|
||||||
|
*
|
||||||
|
* @return int 11 bit Frame Check Sequence as integer (decimal base)
|
||||||
|
*/
|
||||||
|
protected function getFrameCheckSequence(array $code_arr): int
|
||||||
|
{
|
||||||
|
$genpoly = 0x0F35; // generator polynomial
|
||||||
|
$fcs = 0x07FF; // Frame Check Sequence
|
||||||
|
// do most significant byte skipping the 2 most significant bits
|
||||||
|
$data = hexdec($code_arr[0]) << 5;
|
||||||
|
for ($bit = 2; $bit < 8; ++$bit) {
|
||||||
|
$fcs = (($fcs ^ $data) & 0x400) !== 0 ? ($fcs << 1) ^ $genpoly : $fcs << 1;
|
||||||
|
|
||||||
|
$fcs &= 0x7FF;
|
||||||
|
$data <<= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// do rest of bytes
|
||||||
|
for ($byte = 1; $byte < 13; ++$byte) {
|
||||||
|
$data = hexdec($code_arr[$byte]) << 3;
|
||||||
|
for ($bit = 0; $bit < 8; ++$bit) {
|
||||||
|
$fcs = (($fcs ^ $data) & 0x400) !== 0 ? ($fcs << 1) ^ $genpoly : $fcs << 1;
|
||||||
|
|
||||||
|
$fcs &= 0x7FF;
|
||||||
|
$data <<= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $fcs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Nof13 tables
|
||||||
|
*
|
||||||
|
* @param int $type Table type: 2 for 2of13 table, 5 for 5of13table
|
||||||
|
* @param int $size Table size (78 for n=2 and 1287 for n=5)
|
||||||
|
*
|
||||||
|
* @return array<int, int> requested table
|
||||||
|
*/
|
||||||
|
protected function getTables(int $type, int $size): array
|
||||||
|
{
|
||||||
|
$table = [];
|
||||||
|
$lli = 0; // LUT lower index
|
||||||
|
$lui = $size - 1; // LUT upper index
|
||||||
|
for ($count = 0; $count < 8192; ++$count) {
|
||||||
|
$bit_count = 0;
|
||||||
|
for ($bit_index = 0; $bit_index < 13; ++$bit_index) {
|
||||||
|
$bit_count += (int) (($count & (1 << $bit_index)) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we don't have the right number of bits on, go on to the next value
|
||||||
|
if ($bit_count === $type) {
|
||||||
|
$reverse = ($this->getReversedUnsignedShort($count) >> 3);
|
||||||
|
// if the reverse is less than count, we have already visited this pair before
|
||||||
|
if ($reverse >= $count) {
|
||||||
|
// If count is symmetric, place it at the first free slot from the end of the list.
|
||||||
|
// Otherwise, place it at the first free slot from the beginning of the list AND place
|
||||||
|
// $reverse ath the next free slot from the beginning of the list
|
||||||
|
if ($reverse == $count) {
|
||||||
|
$table[$lui] = $count;
|
||||||
|
--$lui;
|
||||||
|
} else {
|
||||||
|
$table[$lli] = $count;
|
||||||
|
++$lli;
|
||||||
|
$table[$lli] = $reverse;
|
||||||
|
++$lli;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $table;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the routing code binary block
|
||||||
|
*
|
||||||
|
* @param numeric-string $routing_code the routing code
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function getRoutingCode(string $routing_code): string
|
||||||
|
{
|
||||||
|
// Conversion of Routing Code
|
||||||
|
return match (strlen($routing_code)) {
|
||||||
|
0 => '0',
|
||||||
|
5 => bcadd($routing_code, '1'),
|
||||||
|
9 => bcadd($routing_code, '100001'),
|
||||||
|
11 => bcadd($routing_code, '1000100001'),
|
||||||
|
default => throw new BarcodeException('Invalid routing code'),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the processed array of characters
|
||||||
|
*
|
||||||
|
* @return array<int, int>
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function getCharsArray(): array
|
||||||
|
{
|
||||||
|
$this->ncols = 0;
|
||||||
|
$this->nrows = 3;
|
||||||
|
$this->bars = [];
|
||||||
|
$code_arr = explode('-', $this->code);
|
||||||
|
$tracking_number = $code_arr[0];
|
||||||
|
$binary_code = '0';
|
||||||
|
if (isset($code_arr[1])) {
|
||||||
|
$binary_code = $this->getRoutingCode($code_arr[1]); // @phpstan-ignore argument.type
|
||||||
|
}
|
||||||
|
|
||||||
|
$binary_code = bcmul($binary_code, '10'); // @phpstan-ignore argument.type
|
||||||
|
$binary_code = bcadd($binary_code, $tracking_number[0]); // @phpstan-ignore argument.type
|
||||||
|
$binary_code = bcmul($binary_code, '5'); // @phpstan-ignore argument.type
|
||||||
|
$binary_code = bcadd($binary_code, $tracking_number[1]); // @phpstan-ignore argument.type
|
||||||
|
$binary_code .= substr($tracking_number, 2, 18);
|
||||||
|
// convert to hexadecimal
|
||||||
|
$binary_code = $this->convertDecToHex($binary_code);
|
||||||
|
// pad to get 13 bytes
|
||||||
|
$binary_code = str_pad($binary_code, 26, '0', STR_PAD_LEFT);
|
||||||
|
// convert string to array of bytes
|
||||||
|
$binary_code_arr = chunk_split($binary_code, 2, "\r");
|
||||||
|
$binary_code_arr = substr($binary_code_arr, 0, -1);
|
||||||
|
$binary_code_arr = explode("\r", $binary_code_arr);
|
||||||
|
// calculate frame check sequence
|
||||||
|
$fcs = $this->getFrameCheckSequence($binary_code_arr);
|
||||||
|
// exclude first 2 bits from first byte
|
||||||
|
$first_byte = sprintf('%2s', dechex((int) (hexdec($binary_code_arr[0]) << 2) >> 2));
|
||||||
|
$binary_code_102bit = $first_byte . substr($binary_code, 2);
|
||||||
|
// convert binary data to codewords
|
||||||
|
$codewords = [];
|
||||||
|
$data = $this->convertHexToDec($binary_code_102bit);
|
||||||
|
$codewords[0] = bcmod($data, '636') * 2;
|
||||||
|
$data = bcdiv($data, '636');
|
||||||
|
for ($pos = 1; $pos < 9; ++$pos) {
|
||||||
|
$codewords[$pos] = bcmod($data, '1365');
|
||||||
|
$data = bcdiv($data, '1365');
|
||||||
|
}
|
||||||
|
|
||||||
|
$codewords[9] = $data;
|
||||||
|
if (($fcs >> 10) == 1) {
|
||||||
|
$codewords[9] += 659;
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate lookup tables
|
||||||
|
$table2of13 = $this->getTables(2, 78);
|
||||||
|
$table5of13 = $this->getTables(5, 1287);
|
||||||
|
// convert codewords to characters
|
||||||
|
$characters = [];
|
||||||
|
$bitmask = 512;
|
||||||
|
foreach ($codewords as $codeword) {
|
||||||
|
$chrcode = $codeword <= 1286 ? $table5of13[$codeword] : $table2of13[($codeword - 1287)];
|
||||||
|
|
||||||
|
if (($fcs & $bitmask) > 0) {
|
||||||
|
// bitwise invert
|
||||||
|
$chrcode = ((~(int) $chrcode) & 8191);
|
||||||
|
}
|
||||||
|
|
||||||
|
$characters[] = $chrcode;
|
||||||
|
$bitmask /= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_reverse($characters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bars array.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
$chars = $this->getCharsArray();
|
||||||
|
for ($pos = 0; $pos < 65; ++$pos) {
|
||||||
|
$asc = (($chars[self::ASC_CHR[$pos]] & 2 ** self::ASC_POS[$pos]) > 0);
|
||||||
|
$dsc = (($chars[self::DSC_CHR[$pos]] & 2 ** self::DSC_POS[$pos]) > 0);
|
||||||
|
if ($asc && $dsc) {
|
||||||
|
// full bar (F)
|
||||||
|
$this->bars[] = [$this->ncols, 0, 1, 3];
|
||||||
|
} elseif ($asc) {
|
||||||
|
// ascender (A)
|
||||||
|
$this->bars[] = [$this->ncols, 0, 1, 2];
|
||||||
|
} elseif ($dsc) {
|
||||||
|
// descender (D)
|
||||||
|
$this->bars[] = [$this->ncols, 1, 1, 2];
|
||||||
|
} else {
|
||||||
|
// tracker (T)
|
||||||
|
$this->bars[] = [$this->ncols, 1, 1, 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ncols += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
--$this->ncols;
|
||||||
|
}
|
||||||
|
}
|
||||||
84
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/ImbPre.php
vendored
Normal file
84
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/ImbPre.php
vendored
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ImbPre.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\ImbPre;
|
||||||
|
*
|
||||||
|
* ImbPre Barcode type class
|
||||||
|
* IMB - Intelligent Mail Barcode pre-processed (USPS-B-3200)
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class ImbPre extends \Com\Tecnick\Barcode\Type\Linear
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'IMBPRE';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bars array.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
$code = strtolower($this->code);
|
||||||
|
if (preg_match('/^[fadt]{65}$/', $code) != 1) {
|
||||||
|
throw new BarcodeException('Invalid character sequence');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ncols = 0;
|
||||||
|
$this->nrows = 3;
|
||||||
|
$this->bars = [];
|
||||||
|
for ($pos = 0; $pos < 65; ++$pos) {
|
||||||
|
switch ($code[$pos]) {
|
||||||
|
case 'f':
|
||||||
|
// full bar
|
||||||
|
$this->bars[] = [$this->ncols, 0, 1, 3];
|
||||||
|
break;
|
||||||
|
case 'a':
|
||||||
|
// ascender
|
||||||
|
$this->bars[] = [$this->ncols, 0, 1, 2];
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
// descender
|
||||||
|
$this->bars[] = [$this->ncols, 1, 1, 2];
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
// tracker (short)
|
||||||
|
$this->bars[] = [$this->ncols, 1, 1, 1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ncols += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
--$this->ncols;
|
||||||
|
}
|
||||||
|
}
|
||||||
49
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/InterleavedTwoOfFive.php
vendored
Normal file
49
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/InterleavedTwoOfFive.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* InterleavedTwoOfFive.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\InterleavedTwoOfFive;
|
||||||
|
*
|
||||||
|
* InterleavedTwoOfFive Barcode type class
|
||||||
|
* Interleaved 2 of 5
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class InterleavedTwoOfFive extends \Com\Tecnick\Barcode\Type\Linear\InterleavedTwoOfFiveCheck
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'I25';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format code
|
||||||
|
*/
|
||||||
|
protected function formatCode(): void
|
||||||
|
{
|
||||||
|
$this->extcode = $this->code;
|
||||||
|
}
|
||||||
|
}
|
||||||
118
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/InterleavedTwoOfFiveCheck.php
vendored
Normal file
118
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/InterleavedTwoOfFiveCheck.php
vendored
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* InterleavedTwoOfFiveCheck.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\InterleavedTwoOfFiveCheck;
|
||||||
|
*
|
||||||
|
* InterleavedTwoOfFiveCheck Barcode type class
|
||||||
|
* Interleaved 2 of 5 + CHECKSUM
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class InterleavedTwoOfFiveCheck extends \Com\Tecnick\Barcode\Type\Linear\StandardTwoOfFiveCheck
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'I25+';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map characters to barcodes
|
||||||
|
*
|
||||||
|
* @var array<int|string, string>
|
||||||
|
*/
|
||||||
|
protected const CHBAR = [
|
||||||
|
'0' => '11221',
|
||||||
|
'1' => '21112',
|
||||||
|
'2' => '12112',
|
||||||
|
'3' => '22111',
|
||||||
|
'4' => '11212',
|
||||||
|
'5' => '21211',
|
||||||
|
'6' => '12211',
|
||||||
|
'7' => '11122',
|
||||||
|
'8' => '21121',
|
||||||
|
'9' => '12121',
|
||||||
|
'A' => '11',
|
||||||
|
'Z' => '21',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format code
|
||||||
|
*/
|
||||||
|
protected function formatCode(): void
|
||||||
|
{
|
||||||
|
$this->extcode = $this->code . $this->getChecksum($this->code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bars array.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
$this->formatCode();
|
||||||
|
if (strlen($this->extcode) % 2 != 0) {
|
||||||
|
// add leading zero if code-length is odd
|
||||||
|
$this->extcode = '0' . $this->extcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add start and stop codes
|
||||||
|
$this->extcode = 'AA' . strtolower($this->extcode) . 'ZA';
|
||||||
|
$this->ncols = 0;
|
||||||
|
$this->nrows = 1;
|
||||||
|
$this->bars = [];
|
||||||
|
$clen = strlen($this->extcode);
|
||||||
|
for ($idx = 0; $idx < $clen; $idx += 2) {
|
||||||
|
$char_bar = $this->extcode[$idx];
|
||||||
|
$char_space = $this->extcode[($idx + 1)];
|
||||||
|
if ((! isset($this::CHBAR[$char_bar])) || (! isset($this::CHBAR[$char_space]))) {
|
||||||
|
throw new BarcodeException('Invalid character sequence: ' . $char_bar . $char_space);
|
||||||
|
}
|
||||||
|
|
||||||
|
// create a bar-space sequence
|
||||||
|
$seq = '';
|
||||||
|
$chrlen = strlen($this::CHBAR[$char_bar]);
|
||||||
|
for ($pos = 0; $pos < $chrlen; ++$pos) {
|
||||||
|
$seq .= $this::CHBAR[$char_bar][$pos] . $this::CHBAR[$char_space][$pos];
|
||||||
|
}
|
||||||
|
|
||||||
|
$seqlen = strlen($seq);
|
||||||
|
for ($pos = 0; $pos < $seqlen; ++$pos) {
|
||||||
|
$bar_width = (int) $seq[$pos];
|
||||||
|
if ((($pos % 2) == 0) && ($bar_width > 0)) {
|
||||||
|
$this->bars[] = [$this->ncols, 0, $bar_width, 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ncols += $bar_width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
--$this->ncols;
|
||||||
|
}
|
||||||
|
}
|
||||||
64
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/KlantIndex.php
vendored
Normal file
64
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/KlantIndex.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KlantIndex.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\KlantIndex;
|
||||||
|
*
|
||||||
|
* KlantIndex Barcode type class
|
||||||
|
* KIX (Klant index - Customer index)
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class KlantIndex extends \Com\Tecnick\Barcode\Type\Linear\RoyalMailFourCc
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'KIX';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format code
|
||||||
|
*/
|
||||||
|
protected function formatCode(): void
|
||||||
|
{
|
||||||
|
$this->extcode = strtoupper($this->code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bars array.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
$this->ncols = 0;
|
||||||
|
$this->nrows = 3;
|
||||||
|
$this->bars = [];
|
||||||
|
$this->getCoreBars();
|
||||||
|
}
|
||||||
|
}
|
||||||
49
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/Msi.php
vendored
Normal file
49
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/Msi.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Msi.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\Msi;
|
||||||
|
*
|
||||||
|
* Msi Barcode type class
|
||||||
|
* MSI (Variation of Plessey code)
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class Msi extends \Com\Tecnick\Barcode\Type\Linear\MsiCheck
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'MSI';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format code
|
||||||
|
*/
|
||||||
|
protected function formatCode(): void
|
||||||
|
{
|
||||||
|
$this->extcode = $this->code;
|
||||||
|
}
|
||||||
|
}
|
||||||
131
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/MsiCheck.php
vendored
Normal file
131
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/MsiCheck.php
vendored
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MsiCheck.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\MsiCheck;
|
||||||
|
*
|
||||||
|
* MsiCheck Barcode type class
|
||||||
|
* MSI + CHECKSUM (modulo 11)
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class MsiCheck extends \Com\Tecnick\Barcode\Type\Linear
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'MSI+';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map characters to barcodes
|
||||||
|
*
|
||||||
|
* @var array<int|string, string>
|
||||||
|
*/
|
||||||
|
protected const CHBAR = [
|
||||||
|
'0' => '100100100100',
|
||||||
|
'1' => '100100100110',
|
||||||
|
'2' => '100100110100',
|
||||||
|
'3' => '100100110110',
|
||||||
|
'4' => '100110100100',
|
||||||
|
'5' => '100110100110',
|
||||||
|
'6' => '100110110100',
|
||||||
|
'7' => '100110110110',
|
||||||
|
'8' => '110100100100',
|
||||||
|
'9' => '110100100110',
|
||||||
|
'A' => '110100110100',
|
||||||
|
'B' => '110100110110',
|
||||||
|
'C' => '110110100100',
|
||||||
|
'D' => '110110100110',
|
||||||
|
'E' => '110110110100',
|
||||||
|
'F' => '110110110110',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the checksum
|
||||||
|
*
|
||||||
|
* @param string $code Code to represent.
|
||||||
|
*
|
||||||
|
* @return int char checksum.
|
||||||
|
*/
|
||||||
|
protected function getChecksum(string $code): int
|
||||||
|
{
|
||||||
|
$clen = strlen($code);
|
||||||
|
$pix = 2;
|
||||||
|
$check = 0;
|
||||||
|
for ($pos = ($clen - 1); $pos >= 0; --$pos) {
|
||||||
|
$hex = $code[$pos];
|
||||||
|
if (! ctype_xdigit($hex)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$check += (hexdec($hex) * $pix);
|
||||||
|
++$pix;
|
||||||
|
if ($pix > 7) {
|
||||||
|
$pix = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$check %= 11;
|
||||||
|
if ($check > 0) {
|
||||||
|
return 11 - $check;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $check;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format code
|
||||||
|
*/
|
||||||
|
protected function formatCode(): void
|
||||||
|
{
|
||||||
|
$this->extcode = $this->code . $this->getChecksum($this->code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bars array.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
$this->formatCode();
|
||||||
|
$seq = '110'; // left guard
|
||||||
|
$clen = strlen($this->extcode);
|
||||||
|
for ($pos = 0; $pos < $clen; ++$pos) {
|
||||||
|
$digit = $this->extcode[$pos];
|
||||||
|
if (! isset($this::CHBAR[$digit])) {
|
||||||
|
throw new BarcodeException('Invalid character: chr(' . ord($digit) . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
$seq .= $this::CHBAR[$digit];
|
||||||
|
}
|
||||||
|
|
||||||
|
$seq .= '1001'; // right guard
|
||||||
|
$this->processBinarySequence($this->getRawCodeRows($seq));
|
||||||
|
}
|
||||||
|
}
|
||||||
69
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/Pharma.php
vendored
Normal file
69
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/Pharma.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pharma.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\Pharma;
|
||||||
|
*
|
||||||
|
* Pharma Barcode type class
|
||||||
|
* PHARMACODE
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class Pharma extends \Com\Tecnick\Barcode\Type\Linear
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'PHARMA';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bars array.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
$seq = '';
|
||||||
|
$code = (int) $this->code;
|
||||||
|
while ($code > 0) {
|
||||||
|
if (($code % 2) == 0) {
|
||||||
|
$seq .= '11100';
|
||||||
|
$code -= 2;
|
||||||
|
} else {
|
||||||
|
$seq .= '100';
|
||||||
|
--$code;
|
||||||
|
}
|
||||||
|
|
||||||
|
$code /= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
$seq = substr($seq, 0, -2);
|
||||||
|
$seq = strrev($seq);
|
||||||
|
$this->processBinarySequence($this->getRawCodeRows($seq));
|
||||||
|
}
|
||||||
|
}
|
||||||
93
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/PharmaTwoTracks.php
vendored
Normal file
93
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/PharmaTwoTracks.php
vendored
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PharmaTwoTracks.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\PharmaTwoTracks;
|
||||||
|
*
|
||||||
|
* PharmaTwoTracks Barcode type class
|
||||||
|
* PHARMACODE TWO-TRACKS
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class PharmaTwoTracks extends \Com\Tecnick\Barcode\Type\Linear
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'PHARMA2T';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bars array.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
$seq = '';
|
||||||
|
$code = (int) $this->code;
|
||||||
|
|
||||||
|
do {
|
||||||
|
switch ($code % 3) {
|
||||||
|
case 0:
|
||||||
|
$seq .= '3';
|
||||||
|
$code = (($code - 3) / 3);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
$seq .= '1';
|
||||||
|
$code = (($code - 1) / 3);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$seq .= '2';
|
||||||
|
$code = (($code - 2) / 3);
|
||||||
|
}
|
||||||
|
} while ($code != 0);
|
||||||
|
|
||||||
|
$seq = strrev($seq);
|
||||||
|
$this->ncols = 0;
|
||||||
|
$this->nrows = 2;
|
||||||
|
$this->bars = [];
|
||||||
|
$len = strlen($seq);
|
||||||
|
for ($pos = 0; $pos < $len; ++$pos) {
|
||||||
|
switch ($seq[$pos]) {
|
||||||
|
case '1':
|
||||||
|
$this->bars[] = [$this->ncols, 1, 1, 1];
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
$this->bars[] = [$this->ncols, 0, 1, 1];
|
||||||
|
break;
|
||||||
|
case '3':
|
||||||
|
$this->bars[] = [$this->ncols, 0, 1, 2];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ncols += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
--$this->ncols;
|
||||||
|
}
|
||||||
|
}
|
||||||
59
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/Planet.php
vendored
Normal file
59
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/Planet.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Planet.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\Planet;
|
||||||
|
*
|
||||||
|
* Planet Barcode type class
|
||||||
|
* PLANET
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class Planet extends \Com\Tecnick\Barcode\Type\Linear\Postnet
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'PLANET';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map characters to barcodes
|
||||||
|
*
|
||||||
|
* @var array<int|string, string>
|
||||||
|
*/
|
||||||
|
protected const CHBAR = [
|
||||||
|
'0' => '11222',
|
||||||
|
'1' => '22211',
|
||||||
|
'2' => '22121',
|
||||||
|
'3' => '22112',
|
||||||
|
'4' => '21221',
|
||||||
|
'5' => '21212',
|
||||||
|
'6' => '21122',
|
||||||
|
'7' => '12221',
|
||||||
|
'8' => '12212',
|
||||||
|
'9' => '12122',
|
||||||
|
];
|
||||||
|
}
|
||||||
129
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/Postnet.php
vendored
Normal file
129
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/Postnet.php
vendored
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Postnet.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\Postnet;
|
||||||
|
*
|
||||||
|
* Postnet Barcode type class
|
||||||
|
* POSTNET
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class Postnet extends \Com\Tecnick\Barcode\Type\Linear
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'POSTNET';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map characters to barcodes
|
||||||
|
*
|
||||||
|
* @var array<int|string, string>
|
||||||
|
*/
|
||||||
|
protected const CHBAR = [
|
||||||
|
'0' => '22111',
|
||||||
|
'1' => '11122',
|
||||||
|
'2' => '11212',
|
||||||
|
'3' => '11221',
|
||||||
|
'4' => '12112',
|
||||||
|
'5' => '12121',
|
||||||
|
'6' => '12211',
|
||||||
|
'7' => '21112',
|
||||||
|
'8' => '21121',
|
||||||
|
'9' => '21211',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the checksum.
|
||||||
|
*
|
||||||
|
* @param string $code Code to represent.
|
||||||
|
*
|
||||||
|
* @return int char checksum.
|
||||||
|
*/
|
||||||
|
protected function getChecksum(string $code): int
|
||||||
|
{
|
||||||
|
$sum = 0;
|
||||||
|
$len = strlen($code);
|
||||||
|
for ($pos = 0; $pos < $len; ++$pos) {
|
||||||
|
$sum += (int) $code[$pos];
|
||||||
|
}
|
||||||
|
|
||||||
|
$check = ($sum % 10);
|
||||||
|
if ($check > 0) {
|
||||||
|
return 10 - $check;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $check;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format code
|
||||||
|
*/
|
||||||
|
protected function formatCode(): void
|
||||||
|
{
|
||||||
|
$code = preg_replace('/[-\s]+/', '', $this->code);
|
||||||
|
if ($code === null) {
|
||||||
|
throw new BarcodeException('Code not valid');
|
||||||
|
}
|
||||||
|
$this->extcode = $code . $this->getChecksum($code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bars array.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
$this->ncols = 0;
|
||||||
|
$this->nrows = 2;
|
||||||
|
$this->bars = [];
|
||||||
|
$this->formatCode();
|
||||||
|
$clen = strlen($this->extcode);
|
||||||
|
// start bar
|
||||||
|
$this->bars[] = [$this->ncols, 0, 1, 2];
|
||||||
|
$this->ncols += 2;
|
||||||
|
for ($chr = 0; $chr < $clen; ++$chr) {
|
||||||
|
$char = $this->extcode[$chr];
|
||||||
|
if (! isset($this::CHBAR[$char])) {
|
||||||
|
throw new BarcodeException('Invalid character: chr(' . ord($char) . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($pos = 0; $pos < 5; ++$pos) {
|
||||||
|
$bar_height = (int) $this::CHBAR[$char][$pos];
|
||||||
|
$this->bars[] = [$this->ncols, (int) floor(1 / $bar_height), 1, $bar_height];
|
||||||
|
$this->ncols += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// end bar
|
||||||
|
$this->bars[] = [$this->ncols, 0, 1, 2];
|
||||||
|
++$this->ncols;
|
||||||
|
}
|
||||||
|
}
|
||||||
48
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/Raw.php
vendored
Normal file
48
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/Raw.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Raw.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\Raw
|
||||||
|
*
|
||||||
|
* Raw Barcode type class
|
||||||
|
* RAW MODE (comma-separated rows)
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class Raw extends \Com\Tecnick\Barcode\Type\Raw
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode type
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const TYPE = 'linear';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'LRAW';
|
||||||
|
}
|
||||||
224
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/RoyalMailFourCc.php
vendored
Normal file
224
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/RoyalMailFourCc.php
vendored
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RoyalMailFourCC.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\RoyalMailFourCc;
|
||||||
|
*
|
||||||
|
* RoyalMailFourCC Barcode type class
|
||||||
|
* RMS4CC (Royal Mail 4-state Customer Bar Code)
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class RoyalMailFourCc extends \Com\Tecnick\Barcode\Type\Linear
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'RMS4CC';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map characters to barcodes
|
||||||
|
*
|
||||||
|
* @var array<int|string, string>
|
||||||
|
*/
|
||||||
|
protected const CHBAR = [
|
||||||
|
'0' => '3322',
|
||||||
|
'1' => '3412',
|
||||||
|
'2' => '3421',
|
||||||
|
'3' => '4312',
|
||||||
|
'4' => '4321',
|
||||||
|
'5' => '4411',
|
||||||
|
'6' => '3142',
|
||||||
|
'7' => '3232',
|
||||||
|
'8' => '3241',
|
||||||
|
'9' => '4132',
|
||||||
|
'A' => '4141',
|
||||||
|
'B' => '4231',
|
||||||
|
'C' => '3124',
|
||||||
|
'D' => '3214',
|
||||||
|
'E' => '3223',
|
||||||
|
'F' => '4114',
|
||||||
|
'G' => '4123',
|
||||||
|
'H' => '4213',
|
||||||
|
'I' => '1342',
|
||||||
|
'J' => '1432',
|
||||||
|
'K' => '1441',
|
||||||
|
'L' => '2332',
|
||||||
|
'M' => '2341',
|
||||||
|
'N' => '2431',
|
||||||
|
'O' => '1324',
|
||||||
|
'P' => '1414',
|
||||||
|
'Q' => '1423',
|
||||||
|
'R' => '2314',
|
||||||
|
'S' => '2323',
|
||||||
|
'T' => '2413',
|
||||||
|
'U' => '1144',
|
||||||
|
'V' => '1234',
|
||||||
|
'W' => '1243',
|
||||||
|
'X' => '2134',
|
||||||
|
'Y' => '2143',
|
||||||
|
'Z' => '2233',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Characters used for checksum
|
||||||
|
*
|
||||||
|
* @var array<int|string, string>
|
||||||
|
*/
|
||||||
|
protected const CHKSUM = [
|
||||||
|
'0' => '11',
|
||||||
|
'1' => '12',
|
||||||
|
'2' => '13',
|
||||||
|
'3' => '14',
|
||||||
|
'4' => '15',
|
||||||
|
'5' => '10',
|
||||||
|
'6' => '21',
|
||||||
|
'7' => '22',
|
||||||
|
'8' => '23',
|
||||||
|
'9' => '24',
|
||||||
|
'A' => '25',
|
||||||
|
'B' => '20',
|
||||||
|
'C' => '31',
|
||||||
|
'D' => '32',
|
||||||
|
'E' => '33',
|
||||||
|
'F' => '34',
|
||||||
|
'G' => '35',
|
||||||
|
'H' => '30',
|
||||||
|
'I' => '41',
|
||||||
|
'J' => '42',
|
||||||
|
'K' => '43',
|
||||||
|
'L' => '44',
|
||||||
|
'M' => '45',
|
||||||
|
'N' => '40',
|
||||||
|
'O' => '51',
|
||||||
|
'P' => '52',
|
||||||
|
'Q' => '53',
|
||||||
|
'R' => '54',
|
||||||
|
'S' => '55',
|
||||||
|
'T' => '50',
|
||||||
|
'U' => '01',
|
||||||
|
'V' => '02',
|
||||||
|
'W' => '03',
|
||||||
|
'X' => '04',
|
||||||
|
'Y' => '05',
|
||||||
|
'Z' => '00',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the checksum.
|
||||||
|
*
|
||||||
|
* @param string $code code to represent.
|
||||||
|
*
|
||||||
|
* @return int char checksum.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function getChecksum(string $code): int
|
||||||
|
{
|
||||||
|
$row = 0;
|
||||||
|
$col = 0;
|
||||||
|
$len = strlen($code);
|
||||||
|
for ($pos = 0; $pos < $len; ++$pos) {
|
||||||
|
$char = $code[$pos];
|
||||||
|
if (! isset($this::CHKSUM[$char])) {
|
||||||
|
throw new BarcodeException('Invalid character: chr(' . ord($char) . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
$row += (int) $this::CHKSUM[$char][0];
|
||||||
|
$col += (int) $this::CHKSUM[$char][1];
|
||||||
|
}
|
||||||
|
|
||||||
|
$row %= 6;
|
||||||
|
$col %= 6;
|
||||||
|
$check = array_keys($this::CHKSUM, $row . $col);
|
||||||
|
return $check[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format code
|
||||||
|
*/
|
||||||
|
protected function formatCode(): void
|
||||||
|
{
|
||||||
|
$code = strtoupper($this->code);
|
||||||
|
$this->extcode = $code . $this->getChecksum($code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the central bars
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function getCoreBars(): void
|
||||||
|
{
|
||||||
|
$this->formatCode();
|
||||||
|
$clen = strlen($this->extcode);
|
||||||
|
for ($chr = 0; $chr < $clen; ++$chr) {
|
||||||
|
$char = $this->extcode[$chr];
|
||||||
|
for ($pos = 0; $pos < 4; ++$pos) {
|
||||||
|
switch ($this::CHBAR[$char][$pos]) {
|
||||||
|
case '1':
|
||||||
|
$this->bars[] = [$this->ncols, 0, 1, 2];
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
$this->bars[] = [$this->ncols, 0, 1, 3];
|
||||||
|
break;
|
||||||
|
case '3':
|
||||||
|
$this->bars[] = [$this->ncols, 1, 1, 1];
|
||||||
|
break;
|
||||||
|
case '4':
|
||||||
|
$this->bars[] = [$this->ncols, 1, 1, 2];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ncols += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bars array.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
$this->ncols = 0;
|
||||||
|
$this->nrows = 3;
|
||||||
|
$this->bars = [];
|
||||||
|
|
||||||
|
// start bar
|
||||||
|
$this->bars[] = [$this->ncols, 0, 1, 2];
|
||||||
|
$this->ncols += 2;
|
||||||
|
|
||||||
|
$this->getCoreBars();
|
||||||
|
|
||||||
|
// stop bar
|
||||||
|
$this->bars[] = [$this->ncols, 0, 1, 3];
|
||||||
|
++$this->ncols;
|
||||||
|
}
|
||||||
|
}
|
||||||
49
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/StandardTwoOfFive.php
vendored
Normal file
49
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/StandardTwoOfFive.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* StandardTwoOfFive.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\StandardTwoOfFive;
|
||||||
|
*
|
||||||
|
* StandardTwoOfFive Barcode type class
|
||||||
|
* Standard 2 of 5
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class StandardTwoOfFive extends \Com\Tecnick\Barcode\Type\Linear\StandardTwoOfFiveCheck
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'S25';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format code
|
||||||
|
*/
|
||||||
|
protected function formatCode(): void
|
||||||
|
{
|
||||||
|
$this->extcode = $this->code;
|
||||||
|
}
|
||||||
|
}
|
||||||
125
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/StandardTwoOfFiveCheck.php
vendored
Normal file
125
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/StandardTwoOfFiveCheck.php
vendored
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* StandardTwoOfFiveCheck.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\StandardTwoOfFiveCheck;
|
||||||
|
*
|
||||||
|
* StandardTwoOfFiveCheck Barcode type class
|
||||||
|
* Standard 2 of 5 + CHECKSUM
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class StandardTwoOfFiveCheck extends \Com\Tecnick\Barcode\Type\Linear
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'S25+';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map characters to barcodes
|
||||||
|
*
|
||||||
|
* @var array<int|string, string>
|
||||||
|
*/
|
||||||
|
protected const CHBAR = [
|
||||||
|
'0' => '10101110111010',
|
||||||
|
'1' => '11101010101110',
|
||||||
|
'2' => '10111010101110',
|
||||||
|
'3' => '11101110101010',
|
||||||
|
'4' => '10101110101110',
|
||||||
|
'5' => '11101011101010',
|
||||||
|
'6' => '10111011101010',
|
||||||
|
'7' => '10101011101110',
|
||||||
|
'8' => '11101010111010',
|
||||||
|
'9' => '10111010111010',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the checksum
|
||||||
|
*
|
||||||
|
* @param string $code Code to represent.
|
||||||
|
*
|
||||||
|
* @return int char checksum.
|
||||||
|
*/
|
||||||
|
protected function getChecksum(string $code): int
|
||||||
|
{
|
||||||
|
$clen = strlen($code);
|
||||||
|
$sum = 0;
|
||||||
|
for ($idx = 0; $idx < $clen; $idx += 2) {
|
||||||
|
$sum += (int) $code[$idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
$sum *= 3;
|
||||||
|
for ($idx = 1; $idx < $clen; $idx += 2) {
|
||||||
|
$sum += (int) $code[$idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
$check = $sum % 10;
|
||||||
|
if ($check > 0) {
|
||||||
|
return 10 - $check;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $check;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format code
|
||||||
|
*/
|
||||||
|
protected function formatCode(): void
|
||||||
|
{
|
||||||
|
$this->extcode = $this->code . $this->getChecksum($this->code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bars array.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
$this->formatCode();
|
||||||
|
if (strlen($this->extcode) % 2 != 0) {
|
||||||
|
// add leading zero if code-length is odd
|
||||||
|
$this->extcode = '0' . $this->extcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
$seq = '1110111010';
|
||||||
|
$clen = strlen($this->extcode);
|
||||||
|
for ($idx = 0; $idx < $clen; ++$idx) {
|
||||||
|
$digit = $this->extcode[$idx];
|
||||||
|
if (! isset($this::CHBAR[$digit])) {
|
||||||
|
throw new BarcodeException('Invalid character: chr(' . ord($digit) . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
$seq .= $this::CHBAR[$digit];
|
||||||
|
}
|
||||||
|
|
||||||
|
$seq .= '111010111';
|
||||||
|
$this->processBinarySequence($this->getRawCodeRows($seq));
|
||||||
|
}
|
||||||
|
}
|
||||||
57
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/UpcA.php
vendored
Normal file
57
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/UpcA.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UpcA.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\UpcA;
|
||||||
|
*
|
||||||
|
* UpcA Barcode type class
|
||||||
|
* UPC-A
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class UpcA extends \Com\Tecnick\Barcode\Type\Linear\EanOneThree
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'UPCA';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fixed code length
|
||||||
|
*/
|
||||||
|
protected int $code_length = 12;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format the code
|
||||||
|
*/
|
||||||
|
protected function formatCode(): void
|
||||||
|
{
|
||||||
|
$code = str_pad($this->code, ($this->code_length - 1), '0', STR_PAD_LEFT);
|
||||||
|
$code .= $this->getChecksum($code);
|
||||||
|
++$this->code_length;
|
||||||
|
$this->extcode = '0' . $code;
|
||||||
|
}
|
||||||
|
}
|
||||||
170
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/UpcE.php
vendored
Normal file
170
vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/UpcE.php
vendored
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UpcE.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Linear;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Linear\UpcE;
|
||||||
|
*
|
||||||
|
* UpcE Barcode type class
|
||||||
|
* UPC-E
|
||||||
|
*
|
||||||
|
* UPC-E is a variation of UPC-A which allows for a more compact barcode by eliminating "extra" zeros.
|
||||||
|
* Since the resulting UPC-E barcode is about half the size as an UPC-A barcode, UPC-E is generally used on products
|
||||||
|
* with very small packaging where a full UPC-A barcode couldn't reasonably fit.
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class UpcE extends \Com\Tecnick\Barcode\Type\Linear\UpcA
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'UPCE';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fixed code length
|
||||||
|
*/
|
||||||
|
protected int $code_length = 12;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map parities
|
||||||
|
*
|
||||||
|
* @var array<int|string, array<int|string, array<string>>>
|
||||||
|
*/
|
||||||
|
protected const PARITIES_UPCE = [
|
||||||
|
0 => [
|
||||||
|
'0' => ['B', 'B', 'B', 'A', 'A', 'A'],
|
||||||
|
'1' => ['B', 'B', 'A', 'B', 'A', 'A'],
|
||||||
|
'2' => ['B', 'B', 'A', 'A', 'B', 'A'],
|
||||||
|
'3' => ['B', 'B', 'A', 'A', 'A', 'B'],
|
||||||
|
'4' => ['B', 'A', 'B', 'B', 'A', 'A'],
|
||||||
|
'5' => ['B', 'A', 'A', 'B', 'B', 'A'],
|
||||||
|
'6' => ['B', 'A', 'A', 'A', 'B', 'B'],
|
||||||
|
'7' => ['B', 'A', 'B', 'A', 'B', 'A'],
|
||||||
|
'8' => ['B', 'A', 'B', 'A', 'A', 'B'],
|
||||||
|
'9' => ['B', 'A', 'A', 'B', 'A', 'B'],
|
||||||
|
],
|
||||||
|
1 => [
|
||||||
|
'0' => ['A', 'A', 'A', 'B', 'B', 'B'],
|
||||||
|
'1' => ['A', 'A', 'B', 'A', 'B', 'B'],
|
||||||
|
'2' => ['A', 'A', 'B', 'B', 'A', 'B'],
|
||||||
|
'3' => ['A', 'A', 'B', 'B', 'B', 'A'],
|
||||||
|
'4' => ['A', 'B', 'A', 'A', 'B', 'B'],
|
||||||
|
'5' => ['A', 'B', 'B', 'A', 'A', 'B'],
|
||||||
|
'6' => ['A', 'B', 'B', 'B', 'A', 'A'],
|
||||||
|
'7' => ['A', 'B', 'A', 'B', 'A', 'B'],
|
||||||
|
'8' => ['A', 'B', 'A', 'B', 'B', 'A'],
|
||||||
|
'9' => ['A', 'B', 'B', 'A', 'B', 'A'],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert UPC-E code to UPC-A
|
||||||
|
*
|
||||||
|
* @param string $code Code to convert.
|
||||||
|
*/
|
||||||
|
protected function convertUpceToUpca(string $code): string
|
||||||
|
{
|
||||||
|
if ($code[5] < 3) {
|
||||||
|
return '0' . $code[0] . $code[1] . $code[5] . '0000' . $code[2] . $code[3] . $code[4];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($code[5] == 3) {
|
||||||
|
return '0' . $code[0] . $code[1] . $code[2] . '00000' . $code[3] . $code[4];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($code[5] == 4) {
|
||||||
|
return '0' . $code[0] . $code[1] . $code[2] . $code[3] . '00000' . $code[4];
|
||||||
|
}
|
||||||
|
|
||||||
|
return '0' . $code[0] . $code[1] . $code[2] . $code[3] . $code[4] . '0000' . $code[5];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert UPC-A code to UPC-E
|
||||||
|
*
|
||||||
|
* @param string $code Code to convert.
|
||||||
|
*/
|
||||||
|
protected function convertUpcaToUpce(string $code): string
|
||||||
|
{
|
||||||
|
$tmp = substr($code, 4, 3);
|
||||||
|
if (($tmp == '000') || ($tmp == '100') || ($tmp == '200')) {
|
||||||
|
// manufacturer code ends in 000, 100, or 200
|
||||||
|
return substr($code, 2, 2) . substr($code, 9, 3) . substr($code, 4, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$tmp = substr($code, 5, 2);
|
||||||
|
if ($tmp == '00') {
|
||||||
|
// manufacturer code ends in 00
|
||||||
|
return substr($code, 2, 3) . substr($code, 10, 2) . '3';
|
||||||
|
}
|
||||||
|
|
||||||
|
$tmp = substr($code, 6, 1);
|
||||||
|
if ($tmp == '0') {
|
||||||
|
// manufacturer code ends in 0
|
||||||
|
return substr($code, 2, 4) . substr($code, 11, 1) . '4';
|
||||||
|
}
|
||||||
|
|
||||||
|
// manufacturer code does not end in zero
|
||||||
|
return substr($code, 2, 5) . substr($code, 11, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format the code
|
||||||
|
*/
|
||||||
|
protected function formatCode(): void
|
||||||
|
{
|
||||||
|
$code = $this->code;
|
||||||
|
if (strlen($code) == 6) {
|
||||||
|
$code = $this->convertUpceToUpca($code);
|
||||||
|
}
|
||||||
|
|
||||||
|
$code = str_pad($code, ($this->code_length - 1), '0', STR_PAD_LEFT);
|
||||||
|
$code .= $this->getChecksum($code);
|
||||||
|
++$this->code_length;
|
||||||
|
$this->extcode = '0' . $code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bars array.
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
$this->formatCode();
|
||||||
|
$upce_code = $this->convertUpcaToUpce($this->extcode);
|
||||||
|
$seq = '101'; // left guard bar
|
||||||
|
$parity = $this::PARITIES_UPCE[$this->extcode[1]][$this->check];
|
||||||
|
for ($pos = 0; $pos < 6; ++$pos) {
|
||||||
|
$seq .= $this::CHBAR[$parity[$pos]][$upce_code[$pos]];
|
||||||
|
}
|
||||||
|
|
||||||
|
$seq .= '010101'; // right guard bar
|
||||||
|
$this->processBinarySequence($this->getRawCodeRows($seq));
|
||||||
|
}
|
||||||
|
}
|
||||||
42
vendor/tecnickcom/tc-lib-barcode/src/Type/Raw.php
vendored
Normal file
42
vendor/tecnickcom/tc-lib-barcode/src/Type/Raw.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Raw.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2015-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Raw
|
||||||
|
*
|
||||||
|
* Raw Barcode type class
|
||||||
|
* RAW MODE (comma-separated rows)
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2015-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class Raw extends \Com\Tecnick\Barcode\Type
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Generate the bars array
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
$this->processBinarySequence($this->getRawCodeRows($this->code));
|
||||||
|
}
|
||||||
|
}
|
||||||
40
vendor/tecnickcom/tc-lib-barcode/src/Type/Square.php
vendored
Normal file
40
vendor/tecnickcom/tc-lib-barcode/src/Type/Square.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Square.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Square
|
||||||
|
*
|
||||||
|
* Barcode type class
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
abstract class Square extends \Com\Tecnick\Barcode\Type
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode type
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const TYPE = 'square';
|
||||||
|
}
|
||||||
150
vendor/tecnickcom/tc-lib-barcode/src/Type/Square/Aztec.php
vendored
Normal file
150
vendor/tecnickcom/tc-lib-barcode/src/Type/Square/Aztec.php
vendored
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aztec.php
|
||||||
|
*
|
||||||
|
* @since 2023-10-12
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2023-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Square;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
use Com\Tecnick\Barcode\Type\Square\Aztec\Data;
|
||||||
|
use Com\Tecnick\Barcode\Type\Square\Aztec\Encode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Square\Aztec
|
||||||
|
*
|
||||||
|
* Aztec Barcode type class
|
||||||
|
*
|
||||||
|
* @since 2023-10-12
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2015-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class Aztec extends \Com\Tecnick\Barcode\Type\Square
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'AZTEC';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error correction code percentage of error check words.
|
||||||
|
* A minimum of 23% + 3 words is recommended by ISO/IEC 24778:2008a.
|
||||||
|
*/
|
||||||
|
protected int $ecc = 33;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encoding mode
|
||||||
|
*/
|
||||||
|
protected string $hint = 'A';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mode:
|
||||||
|
* - A = Automatic selection between Compact (priority) and Full Range.
|
||||||
|
* - F = Force Full Range mode.
|
||||||
|
*/
|
||||||
|
protected string $mode = 'A';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extended Channel Interpretation (ECI) code to be added at the beginning of the stream.
|
||||||
|
* See Data:ECI for the list of supported codes.
|
||||||
|
* NOTE: Even if special FNC1 or ECI flag characters could be inserted
|
||||||
|
* at any points in the stream, this will only be added at the beginning of the stream.
|
||||||
|
*/
|
||||||
|
protected int $eci = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set extra (optional) parameters:
|
||||||
|
* 1: ECC : Error correction code percentage of error check words.
|
||||||
|
* A minimum of 23% + 3 words is recommended by ISO/IEC 24778:2008a.
|
||||||
|
* 2: HINT : Encoding mode: A=Automatic, B=Binary.
|
||||||
|
* 3: LAYERS : Custom number of layers (0 = auto).
|
||||||
|
* 4: ECI : Extended Channel Interpretation (ECI) code. Use -1 for FNC1. See $this->eci.
|
||||||
|
*
|
||||||
|
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
|
||||||
|
* @SuppressWarnings("PHPMD.NPathComplexity")
|
||||||
|
*/
|
||||||
|
protected function setParameters(): void
|
||||||
|
{
|
||||||
|
parent::setParameters();
|
||||||
|
|
||||||
|
// ecc percentage
|
||||||
|
if (
|
||||||
|
! isset($this->params[0])
|
||||||
|
|| ! is_numeric($this->params[0])
|
||||||
|
|| ! in_array($this->params[0], range(1, 100))
|
||||||
|
) {
|
||||||
|
$this->params[0] = 33;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ecc = (int) $this->params[0];
|
||||||
|
|
||||||
|
// hint
|
||||||
|
if (
|
||||||
|
! isset($this->params[1])
|
||||||
|
|| ! is_string($this->params[1])
|
||||||
|
|| ! in_array($this->params[1], ['A', 'B'])
|
||||||
|
) {
|
||||||
|
$this->params[1] = 'A';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->hint = $this->params[1];
|
||||||
|
|
||||||
|
// mode
|
||||||
|
if (
|
||||||
|
! isset($this->params[2])
|
||||||
|
|| ! is_string($this->params[2])
|
||||||
|
|| ! in_array($this->params[2], ['A', 'F'])
|
||||||
|
) {
|
||||||
|
$this->params[2] = 'A';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->mode = $this->params[2];
|
||||||
|
|
||||||
|
// eci code. Used to set the charset encoding. See $this->eci.
|
||||||
|
if (
|
||||||
|
! isset($this->params[3])
|
||||||
|
|| ! is_numeric($this->params[3])
|
||||||
|
|| ! isset(Data::ECI[(int) $this->params[3]])
|
||||||
|
) {
|
||||||
|
$this->params[3] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->eci = (int) $this->params[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the bars array
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
if (strlen((string) $this->code) == 0) {
|
||||||
|
throw new BarcodeException('Empty input');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$encode = new Encode($this->code, $this->ecc, $this->eci, $this->hint, $this->mode);
|
||||||
|
$grid = $encode->getGrid();
|
||||||
|
$this->processBinarySequence($grid);
|
||||||
|
} catch (BarcodeException $barcodeException) {
|
||||||
|
throw new BarcodeException('AZTEC: ' . $barcodeException->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
391
vendor/tecnickcom/tc-lib-barcode/src/Type/Square/Aztec/Bitstream.php
vendored
Normal file
391
vendor/tecnickcom/tc-lib-barcode/src/Type/Square/Aztec/Bitstream.php
vendored
Normal file
@@ -0,0 +1,391 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bitstream.php
|
||||||
|
*
|
||||||
|
* @since 2023-10-13
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2023-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Square\Aztec;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Square\Aztec\Bitstream
|
||||||
|
*
|
||||||
|
* Bitstream for Aztec Barcode type class
|
||||||
|
*
|
||||||
|
* @since 2023-10-13
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2023-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* @SuppressWarnings("PHPMD.ExcessiveClassComplexity")
|
||||||
|
*/
|
||||||
|
abstract class Bitstream extends \Com\Tecnick\Barcode\Type\Square\Aztec\Layers
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Performs the high-level encoding for the given code and ECI mode.
|
||||||
|
*
|
||||||
|
* @param string $code The code to encode.
|
||||||
|
* @param int $eci The ECI mode to use.
|
||||||
|
* @param string $hint The mode to use.
|
||||||
|
*/
|
||||||
|
protected function highLevelEncoding(
|
||||||
|
string $code,
|
||||||
|
int $eci = 0,
|
||||||
|
string $hint = 'A'
|
||||||
|
): void {
|
||||||
|
$this->addFLG($eci);
|
||||||
|
$chrarr = unpack('C*', $code);
|
||||||
|
if ($chrarr === false) {
|
||||||
|
throw new BarcodeException('Unable to unpack the code');
|
||||||
|
}
|
||||||
|
|
||||||
|
$chars = array_values($chrarr);
|
||||||
|
$chrlen = count($chars);
|
||||||
|
if ($hint == 'B') {
|
||||||
|
$this->binaryEncode($chars, $chrlen); // @phpstan-ignore argument.type
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->autoEncode($chars, $chrlen); // @phpstan-ignore argument.type
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forced binary encoding for the given characters.
|
||||||
|
*
|
||||||
|
* @param array<int> $chars Integer ASCII values of the characters to encode.
|
||||||
|
* @param int $chrlen Lenght of the $chars array.
|
||||||
|
*/
|
||||||
|
protected function binaryEncode(array $chars, int $chrlen): void
|
||||||
|
{
|
||||||
|
$bits = Data::MODE_BITS[Data::MODE_BINARY];
|
||||||
|
$this->addShift(Data::MODE_BINARY);
|
||||||
|
if ($chrlen > 62) {
|
||||||
|
$this->addRawCwd(5, 0);
|
||||||
|
$this->addRawCwd(11, ($chrlen - 31));
|
||||||
|
for ($idx = 0; $idx < $chrlen; ++$idx) {
|
||||||
|
$this->addRawCwd($bits, $chars[$idx]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($chrlen > 31) {
|
||||||
|
$this->addRawCwd(5, 31);
|
||||||
|
for ($idx = 0; $idx < 31; ++$idx) {
|
||||||
|
$this->addRawCwd($bits, $chars[$idx]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addShift(Data::MODE_BINARY);
|
||||||
|
$this->addRawCwd(5, ($chrlen - 31));
|
||||||
|
for ($idx = 31; $idx < $chrlen; ++$idx) {
|
||||||
|
$this->addRawCwd($bits, $chars[$idx]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addRawCwd(5, $chrlen);
|
||||||
|
for ($idx = 0; $idx < $chrlen; ++$idx) {
|
||||||
|
$this->addRawCwd($bits, $chars[$idx]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Automatic encoding for the given characters.
|
||||||
|
*
|
||||||
|
* @param array<int> $chars Integer ASCII values of the characters to encode.
|
||||||
|
* @param int $chrlen Lenght of the $chars array.
|
||||||
|
*/
|
||||||
|
protected function autoEncode(array $chars, int $chrlen): void
|
||||||
|
{
|
||||||
|
$idx = 0;
|
||||||
|
while ($idx < $chrlen) {
|
||||||
|
if ($this->processBinaryChars($chars, $idx, $chrlen)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->processPunctPairs($chars, $idx, $chrlen)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->processModeChars($chars, $idx, $chrlen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process mode characters.
|
||||||
|
*
|
||||||
|
* @param array<int> $chars The array of characters.
|
||||||
|
* @param int $idx The current character index.
|
||||||
|
* @param int $chrlen The total number of characters to process.
|
||||||
|
*/
|
||||||
|
protected function processModeChars(array &$chars, int &$idx, int $chrlen): void
|
||||||
|
{
|
||||||
|
$ord = $chars[$idx];
|
||||||
|
$mode = $this->isSameMode($this->encmode, $ord) ? $this->encmode : $this->charMode($ord);
|
||||||
|
|
||||||
|
$nchr = $this->countModeChars($chars, $idx, $chrlen, $mode);
|
||||||
|
if ($this->encmode !== $mode) {
|
||||||
|
if (
|
||||||
|
($nchr == 1)
|
||||||
|
&& (isset(Data::SHIFT_MAP[$this->encmode][$mode])
|
||||||
|
&& Data::SHIFT_MAP[$this->encmode][$mode] !== [])
|
||||||
|
) {
|
||||||
|
$this->addShift($mode);
|
||||||
|
} else {
|
||||||
|
$this->addLatch($mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->mergeTmpCwd();
|
||||||
|
$idx += $nchr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count consecutive characters in the same mode.
|
||||||
|
*
|
||||||
|
* @param array<int> $chars The array of characters.
|
||||||
|
* @param int $idx The current character index.
|
||||||
|
* @param int $chrlen The total number of characters to process.
|
||||||
|
* @param int $mode The current mode.
|
||||||
|
*/
|
||||||
|
protected function countModeChars(
|
||||||
|
array &$chars,
|
||||||
|
int $idx,
|
||||||
|
int $chrlen,
|
||||||
|
int $mode
|
||||||
|
): int {
|
||||||
|
$this->tmpCdws = [];
|
||||||
|
$nbits = Data::MODE_BITS[$mode];
|
||||||
|
$count = 0;
|
||||||
|
do {
|
||||||
|
$ord = $chars[$idx];
|
||||||
|
if (
|
||||||
|
(! $this->isSameMode($mode, $ord))
|
||||||
|
|| (($idx < ($chrlen - 1)) && ($this->punctPairMode($ord, $chars[($idx + 1)]) > 0))
|
||||||
|
) {
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->tmpCdws[] = [$nbits, $this->charEnc($mode, $ord)];
|
||||||
|
++$count;
|
||||||
|
++$idx;
|
||||||
|
} while ($idx < $chrlen);
|
||||||
|
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process consecutive binary characters.
|
||||||
|
*
|
||||||
|
* @param array<int> $chars The array of characters.
|
||||||
|
* @param int $idx The current character index.
|
||||||
|
* @param int $chrlen The total number of characters to process.
|
||||||
|
*
|
||||||
|
* @return bool True if binary characters have been found and processed.
|
||||||
|
*/
|
||||||
|
protected function processBinaryChars(
|
||||||
|
array &$chars,
|
||||||
|
int &$idx,
|
||||||
|
int $chrlen
|
||||||
|
): bool {
|
||||||
|
$binchrs = $this->countBinaryChars($chars, $idx, $chrlen);
|
||||||
|
if ($binchrs == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$encmode = $this->encmode;
|
||||||
|
$this->addShift(Data::MODE_BINARY);
|
||||||
|
if ($binchrs > 62) {
|
||||||
|
$this->addRawCwd(5, 0);
|
||||||
|
$this->addRawCwd(11, ($binchrs - 31));
|
||||||
|
$this->mergeTmpCwdRaw();
|
||||||
|
$idx += $binchrs;
|
||||||
|
$this->encmode = $encmode;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($binchrs > 31) {
|
||||||
|
$nbits = Data::MODE_BITS[Data::MODE_BINARY];
|
||||||
|
$this->addRawCwd(5, 31);
|
||||||
|
for ($bcw = 0; $bcw < 31; ++$bcw) {
|
||||||
|
$this->addRawCwd($nbits, $this->tmpCdws[$bcw][1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addShift(Data::MODE_BINARY);
|
||||||
|
$this->addRawCwd(5, ($binchrs - 31));
|
||||||
|
for ($bcw = 31; $bcw < $binchrs; ++$bcw) {
|
||||||
|
$this->addRawCwd($nbits, $this->tmpCdws[$bcw][1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$idx += $binchrs;
|
||||||
|
$this->encmode = $encmode;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addRawCwd(5, $binchrs);
|
||||||
|
$this->mergeTmpCwdRaw();
|
||||||
|
$idx += $binchrs;
|
||||||
|
$this->encmode = $encmode;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count consecutive binary characters.
|
||||||
|
*
|
||||||
|
* @param array<int> $chars The array of characters.
|
||||||
|
* @param int $idx The current character index.
|
||||||
|
* @param int $chrlen The total number of characters to process.
|
||||||
|
*
|
||||||
|
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
|
||||||
|
*/
|
||||||
|
protected function countBinaryChars(
|
||||||
|
array &$chars,
|
||||||
|
int $idx,
|
||||||
|
int $chrlen
|
||||||
|
): int {
|
||||||
|
$this->tmpCdws = [];
|
||||||
|
$count = 0;
|
||||||
|
$nbits = Data::MODE_BITS[Data::MODE_BINARY];
|
||||||
|
while (($idx < $chrlen) && ($count < 2048)) {
|
||||||
|
$ord = $chars[$idx];
|
||||||
|
if ($this->charMode($ord) != Data::MODE_BINARY) {
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->tmpCdws[] = [$nbits, $ord];
|
||||||
|
++$count;
|
||||||
|
++$idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process consecutive special Punctuation Pairs.
|
||||||
|
*
|
||||||
|
* @param array<int> $chars The array of characters.
|
||||||
|
* @param int $idx The current character index.
|
||||||
|
* @param int $chrlen The total number of characters to process.
|
||||||
|
*
|
||||||
|
* @return bool True if pair characters have been found and processed.
|
||||||
|
*
|
||||||
|
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
|
||||||
|
*/
|
||||||
|
protected function processPunctPairs(
|
||||||
|
array &$chars,
|
||||||
|
int &$idx,
|
||||||
|
int $chrlen
|
||||||
|
): bool {
|
||||||
|
$ppairs = $this->countPunctPairs($chars, $idx, $chrlen);
|
||||||
|
if ($ppairs == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($this->encmode) {
|
||||||
|
case Data::MODE_PUNCT:
|
||||||
|
break;
|
||||||
|
case Data::MODE_MIXED:
|
||||||
|
$this->addLatch(Data::MODE_PUNCT);
|
||||||
|
break;
|
||||||
|
case Data::MODE_UPPER:
|
||||||
|
case Data::MODE_LOWER:
|
||||||
|
if ($ppairs > 1) {
|
||||||
|
$this->addLatch(Data::MODE_PUNCT);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case Data::MODE_DIGIT:
|
||||||
|
$common = $this->countPunctAndDigitChars($chars, $idx, $chrlen);
|
||||||
|
$clen = count($common);
|
||||||
|
if (($clen > 0) && ($clen < 6)) {
|
||||||
|
$this->tmpCdws = $common;
|
||||||
|
$this->mergeTmpCwdRaw();
|
||||||
|
$idx += $clen;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ppairs > 2) {
|
||||||
|
$this->addLatch(Data::MODE_PUNCT);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->mergeTmpCwd(Data::MODE_PUNCT);
|
||||||
|
$idx += ($ppairs * 2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count consecutive special Punctuation Pairs.
|
||||||
|
*
|
||||||
|
* @param array<int> $chars The array of characters.
|
||||||
|
* @param int $idx The current character index.
|
||||||
|
* @param int $chrlen The total number of characters to process.
|
||||||
|
*/
|
||||||
|
protected function countPunctPairs(
|
||||||
|
array &$chars,
|
||||||
|
int $idx,
|
||||||
|
int $chrlen
|
||||||
|
): int {
|
||||||
|
$this->tmpCdws = [];
|
||||||
|
$pairs = 0;
|
||||||
|
$maxidx = $chrlen - 1;
|
||||||
|
while ($idx < $maxidx) {
|
||||||
|
$pmode = $this->punctPairMode($chars[$idx], $chars[($idx + 1)]);
|
||||||
|
if ($pmode == 0) {
|
||||||
|
return $pairs;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->tmpCdws[] = [5, $pmode];
|
||||||
|
++$pairs;
|
||||||
|
$idx += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $pairs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counts the number of consecutive charcters that are in both PUNCT or DIGIT modes.
|
||||||
|
* Returns the array with the codewords.
|
||||||
|
*
|
||||||
|
* @param array<int> &$chars The string to count the characters in.
|
||||||
|
* @param int $idx The starting index to count from.
|
||||||
|
* @param int $chrlen The length of the string to count.
|
||||||
|
*
|
||||||
|
* @return array<int, array{int, int}> The array of codewords.
|
||||||
|
*/
|
||||||
|
protected function countPunctAndDigitChars(
|
||||||
|
array &$chars,
|
||||||
|
int $idx,
|
||||||
|
int $chrlen
|
||||||
|
): array {
|
||||||
|
$words = [];
|
||||||
|
while ($idx < $chrlen) {
|
||||||
|
$ord = $chars[$idx];
|
||||||
|
if (! $this->isPunctAndDigitChar($ord)) {
|
||||||
|
return $words;
|
||||||
|
}
|
||||||
|
|
||||||
|
$words[] = [4, $this->charEnc(Data::MODE_DIGIT, $ord)];
|
||||||
|
++$idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $words;
|
||||||
|
}
|
||||||
|
}
|
||||||
302
vendor/tecnickcom/tc-lib-barcode/src/Type/Square/Aztec/Codeword.php
vendored
Normal file
302
vendor/tecnickcom/tc-lib-barcode/src/Type/Square/Aztec/Codeword.php
vendored
Normal file
@@ -0,0 +1,302 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Codeword.php
|
||||||
|
*
|
||||||
|
* @since 2023-10-13
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2023-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Square\Aztec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Square\Aztec\Codeword
|
||||||
|
*
|
||||||
|
* Codeword utility methods for Aztec Barcode type class
|
||||||
|
*
|
||||||
|
* @since 2023-10-13
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2023-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
abstract class Codeword
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Current character encoding mode.
|
||||||
|
*/
|
||||||
|
protected int $encmode = Data::MODE_UPPER;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array containing the high-level encoding bitstream.
|
||||||
|
*
|
||||||
|
* @var array<int>
|
||||||
|
*/
|
||||||
|
protected array $bitstream = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Temporary array of codewords.
|
||||||
|
*
|
||||||
|
* @var array<int, array{int, int}>
|
||||||
|
*/
|
||||||
|
protected array $tmpCdws = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count the total number of bits in the bitstream.
|
||||||
|
*/
|
||||||
|
protected int $totbits = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes a character using the specified mode and ordinal value.
|
||||||
|
*
|
||||||
|
* @param int $mode The encoding mode.
|
||||||
|
* @param int $ord The ordinal value of the character to encode.
|
||||||
|
*
|
||||||
|
* @return int The encoded character.
|
||||||
|
*/
|
||||||
|
protected function charEnc(int $mode, int $ord): int
|
||||||
|
{
|
||||||
|
return isset(Data::CHAR_ENC[$mode][$ord]) ? Data::CHAR_ENC[$mode][$ord] : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the character mode for a given ASCII code.
|
||||||
|
*
|
||||||
|
* @param int $ord The ASCII code of the character.
|
||||||
|
*
|
||||||
|
* @return int The character mode.
|
||||||
|
*/
|
||||||
|
protected function charMode(int $ord): int
|
||||||
|
{
|
||||||
|
return isset(Data::CHAR_MODES[$ord]) ? Data::CHAR_MODES[$ord] : Data::MODE_BINARY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if current character is supported by the current code.
|
||||||
|
*
|
||||||
|
* @param int $mode The mode to check.
|
||||||
|
* @param int $ord The character ASCII value to compare against.
|
||||||
|
*
|
||||||
|
* @return bool Returns true if the mode is the same as the ordinal value, false otherwise.
|
||||||
|
*/
|
||||||
|
protected function isSameMode(int $mode, int $ord): bool
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
($mode === $this->charMode($ord))
|
||||||
|
|| (($ord == 32) && ($mode != Data::MODE_PUNCT))
|
||||||
|
|| (($mode == Data::MODE_PUNCT) && (($ord == 13) || ($ord == 44) || ($ord == 46)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the character is in common between the PUNCT and DIGIT modes.
|
||||||
|
* Characters ' ' (32), '.' (46) and ',' (44) are in common between the PUNCT and DIGIT modes.
|
||||||
|
*
|
||||||
|
* @param int $ord Integer ASCII code of the character to check.
|
||||||
|
*/
|
||||||
|
protected function isPunctAndDigitChar(int $ord): bool
|
||||||
|
{
|
||||||
|
return (($ord == 32) || ($ord == 44) || ($ord == 46));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the PUNCT two-bytes code if the given two characters are a punctuation pair.
|
||||||
|
* Punct codes 2–5 encode two bytes each.
|
||||||
|
*
|
||||||
|
* @param int $ord The current curacter code.
|
||||||
|
* @param int $next The next character code.
|
||||||
|
*/
|
||||||
|
protected function punctPairMode(int $ord, int $next): int
|
||||||
|
{
|
||||||
|
$key = (($ord << 8) + $next);
|
||||||
|
return match ($key) {
|
||||||
|
(13 << 8) + 10 => 2,
|
||||||
|
(46 << 8) + 32 => 3,
|
||||||
|
(44 << 8) + 32 => 4,
|
||||||
|
(58 << 8) + 32 => 5,
|
||||||
|
default => 0,
|
||||||
|
}; // no punct pair
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Append a new Codeword as a big-endian bit sequence.
|
||||||
|
*
|
||||||
|
* @param array<int> $bitstream Array of bits to append to.
|
||||||
|
* @param int $totbits Number of bits in the bitstream.
|
||||||
|
* @param int $wsize The number of bits in the codeword.
|
||||||
|
* @param int $value The value of the codeword.
|
||||||
|
*/
|
||||||
|
protected function appendWordToBitstream(
|
||||||
|
array &$bitstream,
|
||||||
|
int &$totbits,
|
||||||
|
int $wsize,
|
||||||
|
int $value
|
||||||
|
): void {
|
||||||
|
for ($idx = ($wsize - 1); $idx >= 0; --$idx) {
|
||||||
|
$bitstream[] = (($value >> $idx) & 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$totbits += $wsize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the bitstream to words.
|
||||||
|
*
|
||||||
|
* @param array<int> $bitstream Array of bits to convert.
|
||||||
|
* @param int $totbits Number of bits in the bitstream.
|
||||||
|
* @param int $wsize The word size.
|
||||||
|
*
|
||||||
|
* @return array<int> Array of words.
|
||||||
|
*/
|
||||||
|
protected function bitstreamToWords(
|
||||||
|
array $bitstream,
|
||||||
|
int $totbits,
|
||||||
|
int $wsize
|
||||||
|
): array {
|
||||||
|
$words = [];
|
||||||
|
$numwords = (int) ceil($totbits / $wsize);
|
||||||
|
for ($idx = 0; $idx < $numwords; ++$idx) {
|
||||||
|
$wrd = 0;
|
||||||
|
for ($bit = 0; $bit < $wsize; ++$bit) {
|
||||||
|
$pos = (($idx * $wsize) + $bit);
|
||||||
|
if (! empty($bitstream[$pos]) || ! isset($bitstream[$pos])) {
|
||||||
|
$wrd |= (1 << ($wsize - $bit - 1)); // reverse order
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$words[] = $wrd;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $words;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new Codeword as a big-endian bit sequence.
|
||||||
|
*
|
||||||
|
* @param int $bits The number of bits in the codeword.
|
||||||
|
* @param int $value The value of the codeword.
|
||||||
|
*/
|
||||||
|
protected function addRawCwd(int $bits, int $value): void
|
||||||
|
{
|
||||||
|
$this->appendWordToBitstream($this->bitstream, $this->totbits, $bits, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a Codeword.
|
||||||
|
*
|
||||||
|
* @param int $mode The encoding mode.
|
||||||
|
* @param int $value The value to encode.
|
||||||
|
*/
|
||||||
|
protected function addCdw(int $mode, int $value): void
|
||||||
|
{
|
||||||
|
$this->addRawCwd(Data::MODE_BITS[$mode], $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Latch to another mode.
|
||||||
|
*
|
||||||
|
* @param int $mode The new encoding mode.
|
||||||
|
*/
|
||||||
|
protected function addLatch(int $mode): void
|
||||||
|
{
|
||||||
|
$latch = Data::LATCH_MAP[$this->encmode][$mode];
|
||||||
|
foreach ($latch as $cdw) {
|
||||||
|
$this->addRawCwd($cdw[0], $cdw[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->encmode = $mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shift to another mode.
|
||||||
|
*/
|
||||||
|
protected function addShift(int $mode): void
|
||||||
|
{
|
||||||
|
$shift = Data::SHIFT_MAP[$this->encmode][$mode];
|
||||||
|
foreach ($shift as $cdw) {
|
||||||
|
$this->addRawCwd($cdw[0], $cdw[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merges the temporary codewords array with the current codewords array.
|
||||||
|
* Shift to the specified mode.
|
||||||
|
*
|
||||||
|
* @param int $mode The encoding mode for the codewords.
|
||||||
|
*/
|
||||||
|
protected function mergeTmpCwdWithShift(int $mode): void
|
||||||
|
{
|
||||||
|
foreach ($this->tmpCdws as $tmpCdw) {
|
||||||
|
$this->addShift($mode);
|
||||||
|
$this->addRawCwd($tmpCdw[0], $tmpCdw[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merges the temporary codewords array with the current codewords array.
|
||||||
|
* No shift is performed.
|
||||||
|
*/
|
||||||
|
protected function mergeTmpCwdRaw(): void
|
||||||
|
{
|
||||||
|
foreach ($this->tmpCdws as $tmpCdw) {
|
||||||
|
$this->addRawCwd($tmpCdw[0], $tmpCdw[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merge temporary codewords with current codewords based on the encoding mode.
|
||||||
|
*
|
||||||
|
* @param int $mode The encoding mode to use for merging codewords.
|
||||||
|
* If negative, the current encoding mode will be used.
|
||||||
|
*/
|
||||||
|
protected function mergeTmpCwd(int $mode = -1): void
|
||||||
|
{
|
||||||
|
if (($mode < 0) || ($this->encmode == $mode)) {
|
||||||
|
$this->mergeTmpCwdRaw();
|
||||||
|
} else {
|
||||||
|
$this->mergeTmpCwdWithShift($mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->tmpCdws = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the FLG (Function Length Group) codeword to the data codewords.
|
||||||
|
*
|
||||||
|
* @param int $eci Extended Channel Interpretation value. If negative, the function does nothing.
|
||||||
|
*/
|
||||||
|
protected function addFLG(int $eci): void
|
||||||
|
{
|
||||||
|
if ($eci < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->encmode != Data::MODE_PUNCT) {
|
||||||
|
$this->addShift(Data::MODE_PUNCT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($eci == 0) {
|
||||||
|
$this->addRawCwd(3, 0); // FNC1
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$seci = (string) $eci;
|
||||||
|
$digits = strlen($seci);
|
||||||
|
$this->addRawCwd(3, $digits); // 1–6 digits
|
||||||
|
for ($idx = 0; $idx < $digits; ++$idx) {
|
||||||
|
$this->addCdw(
|
||||||
|
Data::MODE_DIGIT,
|
||||||
|
$this->charEnc(Data::MODE_DIGIT, ord($seci[$idx]))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
556
vendor/tecnickcom/tc-lib-barcode/src/Type/Square/Aztec/Data.php
vendored
Normal file
556
vendor/tecnickcom/tc-lib-barcode/src/Type/Square/Aztec/Data.php
vendored
Normal file
@@ -0,0 +1,556 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data.php
|
||||||
|
*
|
||||||
|
* @since 2023-10-13
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2023-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Square\Aztec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Square\Aztec\Data
|
||||||
|
*
|
||||||
|
* Data for Aztec Barcode type class
|
||||||
|
*
|
||||||
|
* @since 2023-10-13
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2023-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class Data
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Code character encoding mode for uppercase letters.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public const MODE_UPPER = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code character encoding mode for lowercase letters.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public const MODE_LOWER = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code character encoding mode for digits.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public const MODE_DIGIT = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code character encoding mode for mixed cases.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public const MODE_MIXED = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code character encoding mode for punctuation.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public const MODE_PUNCT = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code character encoding mode for binary.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public const MODE_BINARY = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of bits for each character encoding mode.
|
||||||
|
*
|
||||||
|
* @var array<int>
|
||||||
|
*/
|
||||||
|
public const MODE_BITS = [
|
||||||
|
5, // 0 = MODE_UPPER
|
||||||
|
5, // 1 = MODE_LOWER
|
||||||
|
4, // 2 = MODE_DIGIT
|
||||||
|
5, // 3 = MODE_MIXED
|
||||||
|
5, // 4 = MODE_PUNCT
|
||||||
|
8, // 5 = MODE_BINARY
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code character encoding for each mode.
|
||||||
|
*
|
||||||
|
* @var array<int, array<int>>
|
||||||
|
*/
|
||||||
|
public const CHAR_ENC = [
|
||||||
|
// MODE_UPPER (initial mode)
|
||||||
|
0 => [
|
||||||
|
32 => 1, // ' ' (SP)
|
||||||
|
65 => 2, // 'A'
|
||||||
|
66 => 3, // 'B'
|
||||||
|
67 => 4, // 'C'
|
||||||
|
68 => 5, // 'D'
|
||||||
|
69 => 6, // 'E'
|
||||||
|
70 => 7, // 'F'
|
||||||
|
71 => 8, // 'G'
|
||||||
|
72 => 9, // 'H'
|
||||||
|
73 => 10, // 'I'
|
||||||
|
74 => 11, // 'J'
|
||||||
|
75 => 12, // 'K'
|
||||||
|
76 => 13, // 'L'
|
||||||
|
77 => 14, // 'M'
|
||||||
|
78 => 15, // 'N'
|
||||||
|
79 => 16, // 'O'
|
||||||
|
80 => 17, // 'P'
|
||||||
|
81 => 18, // 'Q'
|
||||||
|
82 => 19, // 'R'
|
||||||
|
83 => 20, // 'S'
|
||||||
|
84 => 21, // 'T'
|
||||||
|
85 => 22, // 'U'
|
||||||
|
86 => 23, // 'V'
|
||||||
|
87 => 24, // 'W'
|
||||||
|
88 => 25, // 'X'
|
||||||
|
89 => 26, // 'Y'
|
||||||
|
90 => 27, // 'Z'
|
||||||
|
],
|
||||||
|
// MODE_LOWER
|
||||||
|
1 => [
|
||||||
|
32 => 1, // ' ' (SP)
|
||||||
|
97 => 2, // 'a'
|
||||||
|
98 => 3, // 'b'
|
||||||
|
99 => 4, // 'c'
|
||||||
|
100 => 5, // 'd'
|
||||||
|
101 => 6, // 'e'
|
||||||
|
102 => 7, // 'f'
|
||||||
|
103 => 8, // 'g'
|
||||||
|
104 => 9, // 'h'
|
||||||
|
105 => 10, // 'i'
|
||||||
|
106 => 11, // 'j'
|
||||||
|
107 => 12, // 'k'
|
||||||
|
108 => 13, // 'l'
|
||||||
|
109 => 14, // 'm'
|
||||||
|
110 => 15, // 'n'
|
||||||
|
111 => 16, // 'o'
|
||||||
|
112 => 17, // 'p'
|
||||||
|
113 => 18, // 'q'
|
||||||
|
114 => 19, // 'r'
|
||||||
|
115 => 20, // 's'
|
||||||
|
116 => 21, // 't'
|
||||||
|
117 => 22, // 'u'
|
||||||
|
118 => 23, // 'v'
|
||||||
|
119 => 24, // 'w'
|
||||||
|
120 => 25, // 'x'
|
||||||
|
121 => 26, // 'y'
|
||||||
|
122 => 27, // 'z'
|
||||||
|
],
|
||||||
|
// MODE_DIGIT
|
||||||
|
2 => [
|
||||||
|
32 => 1, // ' ' (SP)
|
||||||
|
44 => 12, // ','
|
||||||
|
46 => 13, // '.'
|
||||||
|
48 => 2, // '0'
|
||||||
|
49 => 3, // '1'
|
||||||
|
50 => 4, // '2'
|
||||||
|
51 => 5, // '3'
|
||||||
|
52 => 6, // '4'
|
||||||
|
53 => 7, // '5'
|
||||||
|
54 => 8, // '6'
|
||||||
|
55 => 9, // '7'
|
||||||
|
56 => 10, // '8'
|
||||||
|
57 => 11, // '9'
|
||||||
|
],
|
||||||
|
// MODE_MIXED
|
||||||
|
3 => [
|
||||||
|
1 => 2, // '^A' (SOH)
|
||||||
|
2 => 3, // '^B' (STX)
|
||||||
|
3 => 4, // '^C' (ETX)
|
||||||
|
4 => 5, // '^D' (EOT)
|
||||||
|
5 => 6, // '^E' (ENQ)
|
||||||
|
6 => 7, // '^F' (ACK)
|
||||||
|
7 => 8, // '^G' (BEL)
|
||||||
|
8 => 9, // '^H' (BS)
|
||||||
|
9 => 10, // '^I' (HT)
|
||||||
|
10 => 11, // '^J' (LF)
|
||||||
|
11 => 12, // '^K' (VT)
|
||||||
|
12 => 13, // '^L' (FF)
|
||||||
|
13 => 14, // '^M' (CR)
|
||||||
|
27 => 15, // '^[' (ESC)
|
||||||
|
28 => 16, // '^\' (FS)
|
||||||
|
29 => 17, // '^]' (GS)
|
||||||
|
30 => 18, // '^^' (RS)
|
||||||
|
31 => 19, // '^_' (US)
|
||||||
|
64 => 20, // '@'
|
||||||
|
92 => 21, // '\'
|
||||||
|
94 => 22, // '^'
|
||||||
|
95 => 23, // '_'
|
||||||
|
96 => 24, // '`'
|
||||||
|
124 => 25, // '|'
|
||||||
|
126 => 26, // '~'
|
||||||
|
127 => 27, // '^?' (DEL)
|
||||||
|
],
|
||||||
|
// MODE_PUNCT
|
||||||
|
4 => [
|
||||||
|
13 => 1, // '\r' (CR)
|
||||||
|
33 => 6, // '!'
|
||||||
|
34 => 7, // '"'
|
||||||
|
35 => 8, // '#'
|
||||||
|
36 => 9, // '$'
|
||||||
|
37 => 10, // '%'
|
||||||
|
38 => 11, // '&'
|
||||||
|
39 => 12, // '''
|
||||||
|
40 => 13, // '('
|
||||||
|
41 => 14, // ')'
|
||||||
|
42 => 15, // '*'
|
||||||
|
43 => 16, // '+'
|
||||||
|
44 => 17, // ','
|
||||||
|
45 => 18, // '-'
|
||||||
|
46 => 19, // '.'
|
||||||
|
47 => 20, // '/'
|
||||||
|
58 => 21, // ':'
|
||||||
|
59 => 22, // ';'
|
||||||
|
60 => 23, // '<'
|
||||||
|
61 => 24, // '='
|
||||||
|
62 => 25, // '>'
|
||||||
|
63 => 26, // '?'
|
||||||
|
91 => 27, // '['
|
||||||
|
93 => 28, // ']'
|
||||||
|
123 => 29, // '{'
|
||||||
|
125 => 30, // '}'
|
||||||
|
],
|
||||||
|
// MODE_BINARY (all 8-bit values are valid)
|
||||||
|
5 => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map character ASCII codes to their non-binary mode.
|
||||||
|
* Exceptions are:
|
||||||
|
* - the space ' ' character (32) that maps for modes 0,1,2.
|
||||||
|
* - the carriage return '\r' character (13) that maps for modes 3,4.
|
||||||
|
* - the comma ',' and dot '.' characters (44,46) that map for modes 2,4.
|
||||||
|
*
|
||||||
|
* @var array<int>
|
||||||
|
*/
|
||||||
|
public const CHAR_MODES = [
|
||||||
|
1 => 3, // '^A' (SOH)
|
||||||
|
2 => 3, // '^B' (STX)
|
||||||
|
3 => 3, // '^C' (ETX)
|
||||||
|
4 => 3, // '^D' (EOT)
|
||||||
|
5 => 3, // '^E' (ENQ)
|
||||||
|
6 => 3, // '^F' (ACK)
|
||||||
|
7 => 3, // '^G' (BEL)
|
||||||
|
8 => 3, // '^H' (BS)
|
||||||
|
9 => 3, // '^I' (HT)
|
||||||
|
10 => 3, // '^J' (LF)
|
||||||
|
11 => 3, // '^K' (VT)
|
||||||
|
12 => 3, // '^L' (FF)
|
||||||
|
13 => 3, // '^M' (CR) [3,4]
|
||||||
|
27 => 3, // '^[' (ESC)
|
||||||
|
28 => 3, // '^\' (FS)
|
||||||
|
29 => 3, // '^]' (GS)
|
||||||
|
30 => 3, // '^^' (RS)
|
||||||
|
31 => 3, // '^_' (US)
|
||||||
|
32 => 0, // ' ' [0,1,2]
|
||||||
|
33 => 4, // '!'
|
||||||
|
34 => 4, // '"'
|
||||||
|
35 => 4, // '#'
|
||||||
|
36 => 4, // '$'
|
||||||
|
37 => 4, // '%'
|
||||||
|
38 => 4, // '&'
|
||||||
|
39 => 4, // '''
|
||||||
|
40 => 4, // '('
|
||||||
|
41 => 4, // ')'
|
||||||
|
42 => 4, // '*'
|
||||||
|
43 => 4, // '+'f
|
||||||
|
44 => 2, // ',' [2,4]
|
||||||
|
45 => 4, // '-'
|
||||||
|
46 => 2, // '.' [2,4]
|
||||||
|
47 => 4, // '/'
|
||||||
|
48 => 2, // '0'
|
||||||
|
49 => 2, // '1'
|
||||||
|
50 => 2, // '2'
|
||||||
|
51 => 2, // '3'
|
||||||
|
52 => 2, // '4'
|
||||||
|
53 => 2, // '5'
|
||||||
|
54 => 2, // '6'
|
||||||
|
55 => 2, // '7'
|
||||||
|
56 => 2, // '8'
|
||||||
|
57 => 2, // '9'
|
||||||
|
58 => 4, // ':'
|
||||||
|
59 => 4, // ';'
|
||||||
|
60 => 4, // '<'
|
||||||
|
61 => 4, // '='
|
||||||
|
62 => 4, // '>'
|
||||||
|
63 => 4, // '?'
|
||||||
|
64 => 3, // '@'
|
||||||
|
65 => 0, // 'A'
|
||||||
|
66 => 0, // 'B'
|
||||||
|
67 => 0, // 'C'
|
||||||
|
68 => 0, // 'D'
|
||||||
|
69 => 0, // 'E'
|
||||||
|
70 => 0, // 'F'
|
||||||
|
71 => 0, // 'G'
|
||||||
|
72 => 0, // 'H'
|
||||||
|
73 => 0, // 'I'
|
||||||
|
74 => 0, // 'J'
|
||||||
|
75 => 0, // 'K'
|
||||||
|
76 => 0, // 'L'
|
||||||
|
77 => 0, // 'M'
|
||||||
|
78 => 0, // 'N'
|
||||||
|
79 => 0, // 'O'
|
||||||
|
80 => 0, // 'P'
|
||||||
|
81 => 0, // 'Q'
|
||||||
|
82 => 0, // 'R'
|
||||||
|
83 => 0, // 'S'
|
||||||
|
84 => 0, // 'T'
|
||||||
|
85 => 0, // 'U'
|
||||||
|
86 => 0, // 'V'
|
||||||
|
87 => 0, // 'W'
|
||||||
|
88 => 0, // 'X'
|
||||||
|
89 => 0, // 'Y'
|
||||||
|
90 => 0, // 'Z'
|
||||||
|
91 => 4, // '['
|
||||||
|
92 => 3, // '\'
|
||||||
|
93 => 4, // ']'
|
||||||
|
94 => 3, // '^'
|
||||||
|
95 => 3, // '_'
|
||||||
|
96 => 3, // '`'
|
||||||
|
97 => 1, // 'a'
|
||||||
|
98 => 1, // 'b'
|
||||||
|
99 => 1, // 'c'
|
||||||
|
100 => 1, // 'd'
|
||||||
|
101 => 1, // 'e'
|
||||||
|
102 => 1, // 'f'
|
||||||
|
103 => 1, // 'g'
|
||||||
|
104 => 1, // 'h'
|
||||||
|
105 => 1, // 'i'
|
||||||
|
106 => 1, // 'j'
|
||||||
|
107 => 1, // 'k'
|
||||||
|
108 => 1, // 'l'
|
||||||
|
109 => 1, // 'm'
|
||||||
|
110 => 1, // 'n'
|
||||||
|
111 => 1, // 'o'
|
||||||
|
112 => 1, // 'p'
|
||||||
|
113 => 1, // 'q'
|
||||||
|
114 => 1, // 'r'
|
||||||
|
115 => 1, // 's'
|
||||||
|
116 => 1, // 't'
|
||||||
|
117 => 1, // 'u'
|
||||||
|
118 => 1, // 'v'
|
||||||
|
119 => 1, // 'w'
|
||||||
|
120 => 1, // 'x'
|
||||||
|
121 => 1, // 'y'
|
||||||
|
122 => 1, // 'z'
|
||||||
|
123 => 4, // '{'
|
||||||
|
124 => 3, // '|'
|
||||||
|
125 => 4, // '}'
|
||||||
|
126 => 3, // '~'
|
||||||
|
127 => 3, // '^?' (DEL)
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Latch map for changing character encoding mode.
|
||||||
|
* Numbers represent: [number of bits to change, latch code value].
|
||||||
|
*
|
||||||
|
* @var array<int, array<int, array<array{int, int}>>>
|
||||||
|
*/
|
||||||
|
public const LATCH_MAP = [
|
||||||
|
// MODE_UPPER
|
||||||
|
0 => [
|
||||||
|
1 => [[5, 28]], // -> LOWER
|
||||||
|
2 => [[5, 30]], // -> DIGIT
|
||||||
|
3 => [[5, 29]], // -> MIXED
|
||||||
|
4 => [[5, 29], [5, 30]], // -> MIXED -> PUNCT
|
||||||
|
],
|
||||||
|
// MODE_LOWER
|
||||||
|
1 => [
|
||||||
|
0 => [[5, 30], [4, 14]], // -> DIGIT -> UPPER
|
||||||
|
2 => [[5, 30]], // -> DIGIT
|
||||||
|
3 => [[5, 29]], // -> MIXED
|
||||||
|
4 => [[5, 29], [5, 30]], // -> MIXED -> PUNCT
|
||||||
|
],
|
||||||
|
// MODE_DIGIT
|
||||||
|
2 => [
|
||||||
|
0 => [[4, 14]], // -> UPPER
|
||||||
|
1 => [[4, 14], [5, 28]], // -> UPPER -> LOWER
|
||||||
|
3 => [[4, 14], [5, 29]], // -> UPPER -> MIXED
|
||||||
|
4 => [[4, 14], [5, 29], [5, 30]], // -> UPPER -> MIXED -> PUNCT
|
||||||
|
],
|
||||||
|
// MODE_MIXED
|
||||||
|
3 => [
|
||||||
|
0 => [[5, 29]], // -> UPPER
|
||||||
|
1 => [[5, 28]], // -> LOWER
|
||||||
|
2 => [[5, 29], [5, 30]], // -> UPPER -> DIGIT
|
||||||
|
4 => [[5, 30]], // -> PUNCT
|
||||||
|
],
|
||||||
|
// MODE_PUNCT
|
||||||
|
4 => [
|
||||||
|
0 => [[5, 31]], // -> UPPER
|
||||||
|
1 => [[5, 31], [5, 28]], // -> UPPER -> LOWER
|
||||||
|
2 => [[5, 31], [5, 30]], // -> UPPER -> DIGIT
|
||||||
|
3 => [[5, 31], [5, 29]], // -> UPPER -> MIXED
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shift map for changing character encoding mode.
|
||||||
|
* Numbers represent: [number of bits to change, shift code value].
|
||||||
|
*
|
||||||
|
* @var array<int, array<int, array<array{int, int}>>>
|
||||||
|
*/
|
||||||
|
public const SHIFT_MAP = [
|
||||||
|
// MODE_UPPER
|
||||||
|
0 => [
|
||||||
|
1 => [],
|
||||||
|
2 => [],
|
||||||
|
3 => [],
|
||||||
|
4 => [[5, 0]], // -> PUNCT
|
||||||
|
5 => [[5, 31]], // -> BINARY
|
||||||
|
],
|
||||||
|
// MODE_LOWER
|
||||||
|
1 => [
|
||||||
|
0 => [[5, 28]], // -> UPPER
|
||||||
|
2 => [],
|
||||||
|
3 => [],
|
||||||
|
4 => [[5, 0]], // -> PUNCT
|
||||||
|
5 => [[5, 31]], // -> BINARY
|
||||||
|
],
|
||||||
|
// MODE_DIGIT
|
||||||
|
2 => [
|
||||||
|
0 => [[4, 15]], // -> UPPER
|
||||||
|
1 => [],
|
||||||
|
3 => [],
|
||||||
|
4 => [[4, 0]], // -> PUNCT
|
||||||
|
5 => [[4, 14], [5, 31]], // -> LATCH UPPER -> BINARY
|
||||||
|
],
|
||||||
|
// MODE_MIXED
|
||||||
|
3 => [
|
||||||
|
0 => [],
|
||||||
|
1 => [],
|
||||||
|
2 => [],
|
||||||
|
4 => [[5, 0]], // -> PUNCT
|
||||||
|
5 => [[5, 31]], // -> BINARY
|
||||||
|
],
|
||||||
|
// MODE_PUNCT
|
||||||
|
4 => [
|
||||||
|
0 => [],
|
||||||
|
1 => [],
|
||||||
|
2 => [],
|
||||||
|
3 => [],
|
||||||
|
5 => [[5, 31], [5, 31]], // -> LATCH UPPER -> BINARY
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extended Channel Interpretation (ECI) codes.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
public const ECI = [
|
||||||
|
0 => 'FNC1', // Function 1 character
|
||||||
|
2 => 'Cp437', // Code page 437
|
||||||
|
3 => 'ISO-8859-1', // ISO/IEC 8859-1 - Latin-1 (Default encoding)
|
||||||
|
4 => 'ISO-8859-2', // ISO/IEC 8859-2 - Latin-2
|
||||||
|
5 => 'ISO-8859-3', // ISO/IEC 8859-3 - Latin-3
|
||||||
|
6 => 'ISO-8859-4', // ISO/IEC 8859-4 - Latin-4
|
||||||
|
7 => 'ISO-8859-5', // ISO/IEC 8859-5 - Latin/Cyrillic
|
||||||
|
8 => 'ISO-8859-6', // ISO/IEC 8859-6 - Latin/Arabic
|
||||||
|
9 => 'ISO-8859-7', // ISO/IEC 8859-7 - Latin/Greek
|
||||||
|
10 => 'ISO-8859-8', // ISO/IEC 8859-8 - Latin/Hebrew
|
||||||
|
11 => 'ISO-8859-9', // ISO/IEC 8859-9 - Latin-5
|
||||||
|
12 => 'ISO-8859-10', // ISO/IEC 8859-10 - Latin-6
|
||||||
|
13 => 'ISO-8859-11', // ISO/IEC 8859-11 - Latin/Thai
|
||||||
|
15 => 'ISO-8859-13', // ISO/IEC 8859-13 - Latin-7
|
||||||
|
16 => 'ISO-8859-14', // ISO/IEC 8859-14 - Latin-8 (Celtic)
|
||||||
|
17 => 'ISO-8859-15', // ISO/IEC 8859-15 - Latin-9
|
||||||
|
18 => 'ISO-8859-16', // ISO/IEC 8859-16 - Latin-10
|
||||||
|
20 => 'Shift JIS', //
|
||||||
|
21 => 'Cp1250', // Windows-1250 - Superset of Latin-2
|
||||||
|
22 => 'Cp1251', // Windows-1251 - Latin/Cyrillic
|
||||||
|
23 => 'Cp1252', // Windows-1252 - Superset of Latin-1
|
||||||
|
24 => 'Cp1256', // Windows-1256 - Arabic
|
||||||
|
25 => 'UTF-16BE', // UnicodeBig, UnicodeBigUnmarked
|
||||||
|
26 => 'UTF-8', //
|
||||||
|
27 => 'US-ASCII', //
|
||||||
|
28 => 'Big5', //
|
||||||
|
29 => 'GB18030', // GB2312, EUC_CN, GBK
|
||||||
|
30 => 'EUC-KR', //
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Size and capacities of Aztec Compact Code symbols by number of layers.
|
||||||
|
* The array entries are:
|
||||||
|
* - 0: symbol x size;
|
||||||
|
* - 1: codeword count;
|
||||||
|
* - 2: codeword size;
|
||||||
|
* - 3: symbol bit capacity;
|
||||||
|
* - 4: symbol data digits capacity;
|
||||||
|
* - 5: symbol data text capacity;
|
||||||
|
* - 6: symbol data bytes capacity.
|
||||||
|
*
|
||||||
|
* @var array<int, array{int, int, int, int, int, int, int}>
|
||||||
|
*/
|
||||||
|
public const SIZE_COMPACT = [
|
||||||
|
1 => [15, 17, 6, 102, 13, 12, 6],
|
||||||
|
2 => [19, 40, 6, 240, 40, 33, 19],
|
||||||
|
3 => [23, 51, 8, 408, 70, 57, 33],
|
||||||
|
4 => [27, 76, 8, 608, 110, 89, 53],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Size and capacities of Aztec Full-range Code symbols by number of layers.
|
||||||
|
* The array entries are:
|
||||||
|
* - 0: symbol x size;
|
||||||
|
* - 1: codeword count;
|
||||||
|
* - 2: codeword size;
|
||||||
|
* - 3: symbol bit capacity;
|
||||||
|
* - 4: symbol data digits capacity;
|
||||||
|
* - 5: symbol data text capacity;
|
||||||
|
* - 6: symbol data bytes capacity.
|
||||||
|
*
|
||||||
|
* @var array<int, array{int, int, int, int, int, int, int}>
|
||||||
|
*/
|
||||||
|
public const SIZE_FULL = [
|
||||||
|
1 => [19, 21, 6, 126, 18, 15, 8],
|
||||||
|
2 => [23, 48, 6, 288, 49, 40, 24],
|
||||||
|
3 => [27, 60, 8, 480, 84, 68, 40],
|
||||||
|
4 => [31, 88, 8, 704, 128, 104, 62],
|
||||||
|
5 => [37, 120, 8, 960, 178, 144, 87],
|
||||||
|
6 => [41, 156, 8, 1248, 232, 187, 114],
|
||||||
|
7 => [45, 196, 8, 1568, 294, 236, 145],
|
||||||
|
8 => [49, 240, 8, 1920, 362, 291, 179],
|
||||||
|
9 => [53, 230, 10, 2300, 433, 348, 214],
|
||||||
|
10 => [57, 272, 10, 2720, 516, 414, 256],
|
||||||
|
11 => [61, 316, 10, 3160, 601, 482, 298],
|
||||||
|
12 => [67, 364, 10, 3640, 691, 554, 343],
|
||||||
|
13 => [71, 416, 10, 4160, 793, 636, 394],
|
||||||
|
14 => [75, 470, 10, 4700, 896, 718, 446],
|
||||||
|
15 => [79, 528, 10, 5280, 1008, 808, 502],
|
||||||
|
16 => [83, 588, 10, 5880, 1123, 900, 559],
|
||||||
|
17 => [87, 652, 10, 6520, 1246, 998, 621],
|
||||||
|
18 => [91, 720, 10, 7200, 1378, 1104, 687],
|
||||||
|
19 => [95, 790, 10, 7900, 1511, 1210, 753],
|
||||||
|
20 => [101, 864, 10, 8640, 1653, 1324, 824],
|
||||||
|
21 => [105, 940, 10, 9400, 1801, 1442, 898],
|
||||||
|
22 => [109, 1020, 10, 10200, 1956, 1566, 976],
|
||||||
|
23 => [113, 920, 12, 11040, 2116, 1694, 1056],
|
||||||
|
24 => [117, 992, 12, 11904, 2281, 1826, 1138],
|
||||||
|
25 => [121, 1066, 12, 12792, 2452, 1963, 1224],
|
||||||
|
26 => [125, 1144, 12, 13728, 2632, 2107, 1314],
|
||||||
|
27 => [131, 1224, 12, 14688, 2818, 2256, 1407],
|
||||||
|
28 => [135, 1306, 12, 15672, 3007, 2407, 1501],
|
||||||
|
29 => [139, 1392, 12, 16704, 3205, 2565, 1600],
|
||||||
|
30 => [143, 1480, 12, 17760, 3409, 2728, 1702],
|
||||||
|
31 => [147, 1570, 12, 18840, 3616, 2894, 1806],
|
||||||
|
32 => [151, 1664, 12, 19968, 3832, 3067, 1914],
|
||||||
|
];
|
||||||
|
}
|
||||||
364
vendor/tecnickcom/tc-lib-barcode/src/Type/Square/Aztec/Encode.php
vendored
Normal file
364
vendor/tecnickcom/tc-lib-barcode/src/Type/Square/Aztec/Encode.php
vendored
Normal file
@@ -0,0 +1,364 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode.php
|
||||||
|
*
|
||||||
|
* @since 2023-10-13
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2023-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Square\Aztec;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Square\Aztec\Encode
|
||||||
|
*
|
||||||
|
* Encode for Aztec Barcode type class
|
||||||
|
*
|
||||||
|
* @since 2023-10-13
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2023-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class Encode extends \Com\Tecnick\Barcode\Type\Square\Aztec\Bitstream
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bidimensional grid containing the encoded data.
|
||||||
|
*
|
||||||
|
* @var array<int, array<int>>
|
||||||
|
*/
|
||||||
|
protected array $grid = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Coordinate of the grid center.
|
||||||
|
*/
|
||||||
|
protected int $gridcenter = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aztec main encoder.
|
||||||
|
*
|
||||||
|
* @param string $code The code to encode.
|
||||||
|
* @param int $ecc The error correction code percentage of error check words.
|
||||||
|
* @param int $eci The ECI mode to use.
|
||||||
|
* @param string $hint The mode to use.
|
||||||
|
* @param string $mode The mode to use (A = Automatic; F = Full Range mode).
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
string $code,
|
||||||
|
int $ecc = 33,
|
||||||
|
int $eci = 0,
|
||||||
|
string $hint = 'A',
|
||||||
|
string $mode = 'A'
|
||||||
|
) {
|
||||||
|
$this->highLevelEncoding($code, $eci, $hint);
|
||||||
|
if (! $this->sizeAndBitStuffing($ecc, $mode)) {
|
||||||
|
throw new BarcodeException('Data too long');
|
||||||
|
}
|
||||||
|
|
||||||
|
$wsize = $this->layer[2];
|
||||||
|
$nbits = $this->layer[3];
|
||||||
|
$numcdw = $this->addCheckWords($this->bitstream, $this->totbits, $nbits, $wsize);
|
||||||
|
$this->setGrid();
|
||||||
|
$this->drawMode($numcdw);
|
||||||
|
$this->drawData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the bidimensional grid containing the encoded data.
|
||||||
|
*
|
||||||
|
* @return array<int, array<int>>
|
||||||
|
*/
|
||||||
|
public function getGrid(): array
|
||||||
|
{
|
||||||
|
return $this->grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Check Codewords array for the given data words.
|
||||||
|
*
|
||||||
|
* @param array<int> $bitstream Array of bits.
|
||||||
|
* @param int $totbits Number of bits in the bitstream.
|
||||||
|
* @param int $nbits Number of bits per layer.
|
||||||
|
* @param int $wsize Word size.
|
||||||
|
*
|
||||||
|
* @return int The number of data codewords.
|
||||||
|
*/
|
||||||
|
protected function addCheckWords(
|
||||||
|
array &$bitstream,
|
||||||
|
int &$totbits,
|
||||||
|
int $nbits,
|
||||||
|
int $wsize
|
||||||
|
): int {
|
||||||
|
$cdw = $this->bitstreamToWords($bitstream, $totbits, $wsize);
|
||||||
|
$numcdw = count($cdw);
|
||||||
|
$totwords = (int) ($nbits / $wsize);
|
||||||
|
$eccwords = ($totwords - $numcdw);
|
||||||
|
$errorCorrection = new ErrorCorrection($wsize);
|
||||||
|
$checkwords = $errorCorrection->checkwords($cdw, $eccwords);
|
||||||
|
// append check codewords
|
||||||
|
foreach ($checkwords as $checkword) {
|
||||||
|
$this->appendWordToBitstream($bitstream, $totbits, $wsize, $checkword);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $numcdw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the grid with all patterns.
|
||||||
|
*/
|
||||||
|
protected function setGrid(): void
|
||||||
|
{
|
||||||
|
// initialize grid
|
||||||
|
$size = $this->layer[0];
|
||||||
|
$row = array_fill(0, $size, 0);
|
||||||
|
$this->grid = array_fill(0, $size, $row);
|
||||||
|
// draw center
|
||||||
|
$center = (int) (($size - 1) / 2);
|
||||||
|
$this->gridcenter = $center;
|
||||||
|
$this->grid[$center][$center] = 1;
|
||||||
|
// draw finder pattern (bulls-eye)
|
||||||
|
$bewidth = $this->compact ? 11 : 15;
|
||||||
|
$bemid = (int) (($bewidth - 1) / 2);
|
||||||
|
for ($rng = 2; $rng < $bemid; $rng += 2) {
|
||||||
|
// center cross points
|
||||||
|
$this->grid[($center + $rng)][($center)] = 1;
|
||||||
|
$this->grid[($center - $rng)][($center)] = 1;
|
||||||
|
$this->grid[($center)][($center + $rng)] = 1;
|
||||||
|
$this->grid[($center)][($center - $rng)] = 1;
|
||||||
|
// corner points
|
||||||
|
$this->grid[($center + $rng)][($center + $rng)] = 1;
|
||||||
|
$this->grid[($center + $rng)][($center - $rng)] = 1;
|
||||||
|
$this->grid[($center - $rng)][($center + $rng)] = 1;
|
||||||
|
$this->grid[($center - $rng)][($center - $rng)] = 1;
|
||||||
|
for ($pos = 1; $pos < $rng; ++$pos) {
|
||||||
|
// horizontal points
|
||||||
|
$this->grid[($center + $rng)][($center + $pos)] = 1;
|
||||||
|
$this->grid[($center + $rng)][($center - $pos)] = 1;
|
||||||
|
$this->grid[($center - $rng)][($center + $pos)] = 1;
|
||||||
|
$this->grid[($center - $rng)][($center - $pos)] = 1;
|
||||||
|
// vertical points
|
||||||
|
$this->grid[($center + $pos)][($center + $rng)] = 1;
|
||||||
|
$this->grid[($center + $pos)][($center - $rng)] = 1;
|
||||||
|
$this->grid[($center - $pos)][($center + $rng)] = 1;
|
||||||
|
$this->grid[($center - $pos)][($center - $rng)] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// draw orientation patterns
|
||||||
|
$this->grid[($center - $bemid)][($center - $bemid)] = 1; // TL
|
||||||
|
$this->grid[($center - $bemid)][($center - $bemid + 1)] = 1; // TL-R
|
||||||
|
$this->grid[($center - $bemid + 1)][($center - $bemid)] = 1; // TL-B
|
||||||
|
$this->grid[($center - $bemid)][($center + $bemid)] = 1; // TR-T
|
||||||
|
$this->grid[($center - $bemid + 1)][($center + $bemid)] = 1; // TR-B
|
||||||
|
$this->grid[($center + $bemid - 1)][($center + $bemid)] = 1; // BR
|
||||||
|
if ($this->compact) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// draw reference grid for full mode
|
||||||
|
$halfsize = (int) (($size - 1) / 2);
|
||||||
|
// central cross
|
||||||
|
for ($pos = 8; $pos <= $halfsize; $pos += 2) {
|
||||||
|
// horizontal
|
||||||
|
$this->grid[($center)][($center - $pos)] = 1;
|
||||||
|
$this->grid[($center)][($center + $pos)] = 1;
|
||||||
|
// vertical
|
||||||
|
$this->grid[($center - $pos)][($center)] = 1;
|
||||||
|
$this->grid[($center + $pos)][($center)] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// grid lines
|
||||||
|
for ($pos = 2; $pos <= $halfsize; $pos += 2) {
|
||||||
|
for ($ref = 16; $ref <= $halfsize; $ref += 16) {
|
||||||
|
// horizontal
|
||||||
|
$this->grid[($center - $ref)][($center - $pos)] = 1;
|
||||||
|
$this->grid[($center - $ref)][($center + $pos)] = 1;
|
||||||
|
$this->grid[($center + $ref)][($center - $pos)] = 1;
|
||||||
|
$this->grid[($center + $ref)][($center + $pos)] = 1;
|
||||||
|
// vertical
|
||||||
|
$this->grid[($center - $pos)][($center - $ref)] = 1;
|
||||||
|
$this->grid[($center - $pos)][($center + $ref)] = 1;
|
||||||
|
$this->grid[($center + $pos)][($center - $ref)] = 1;
|
||||||
|
$this->grid[($center + $pos)][($center + $ref)] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the mode message to the grid.
|
||||||
|
*
|
||||||
|
* @param int $numcdw Number of data codewords.
|
||||||
|
*
|
||||||
|
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
|
||||||
|
* @SuppressWarnings("PHPMD.NPathComplexity")
|
||||||
|
*/
|
||||||
|
protected function drawMode(int $numcdw): void
|
||||||
|
{
|
||||||
|
$modebs = [];
|
||||||
|
$nbits = 0;
|
||||||
|
$center = $this->gridcenter;
|
||||||
|
$modebits = 40;
|
||||||
|
$layersbits = 5;
|
||||||
|
$codewordsbits = 11;
|
||||||
|
$sidelen = 10;
|
||||||
|
$srow = -7;
|
||||||
|
$scol = -5;
|
||||||
|
if ($this->compact) {
|
||||||
|
$modebits = 28;
|
||||||
|
$layersbits = 2;
|
||||||
|
$codewordsbits = 6;
|
||||||
|
$sidelen = 7;
|
||||||
|
$srow = -5;
|
||||||
|
$scol = -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->appendWordToBitstream($modebs, $nbits, $layersbits, ($this->numlayers - 1));
|
||||||
|
$this->appendWordToBitstream($modebs, $nbits, $codewordsbits, ($numcdw - 1));
|
||||||
|
$this->addCheckWords($modebs, $nbits, $modebits, 4);
|
||||||
|
// draw the mode message in the grid clockwise starting from the top left corner
|
||||||
|
$bit = 0;
|
||||||
|
// top
|
||||||
|
$ypos = ($center + $srow);
|
||||||
|
$xpos = ($center + $scol);
|
||||||
|
for ($pos = 0; $pos < $sidelen; ++$pos) {
|
||||||
|
$xpos += $this->skipModeRefGrid($pos);
|
||||||
|
$this->grid[$ypos][$xpos] = (empty($modebs[$bit++]) ? 0 : 1);
|
||||||
|
++$xpos;
|
||||||
|
}
|
||||||
|
|
||||||
|
// right
|
||||||
|
$ypos += 2;
|
||||||
|
++$xpos;
|
||||||
|
for ($pos = 0; $pos < $sidelen; ++$pos) {
|
||||||
|
$ypos += $this->skipModeRefGrid($pos);
|
||||||
|
$this->grid[$ypos][$xpos] = (empty($modebs[$bit++]) ? 0 : 1);
|
||||||
|
++$ypos;
|
||||||
|
}
|
||||||
|
|
||||||
|
// bottom
|
||||||
|
++$ypos;
|
||||||
|
$xpos -= 2;
|
||||||
|
for ($pos = 0; $pos < $sidelen; ++$pos) {
|
||||||
|
$xpos -= $this->skipModeRefGrid($pos);
|
||||||
|
$this->grid[$ypos][$xpos] = (empty($modebs[$bit++]) ? 0 : 1);
|
||||||
|
--$xpos;
|
||||||
|
}
|
||||||
|
|
||||||
|
// left
|
||||||
|
$ypos -= 2;
|
||||||
|
--$xpos;
|
||||||
|
for ($pos = 0; $pos < $sidelen; ++$pos) {
|
||||||
|
$ypos -= $this->skipModeRefGrid($pos);
|
||||||
|
$this->grid[$ypos][$xpos] = (empty($modebs[$bit++]) ? 0 : 1);
|
||||||
|
--$ypos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a bit from the end of the bitstream and update the index.
|
||||||
|
*
|
||||||
|
* @param int $bit Index of the bit to pop.
|
||||||
|
*/
|
||||||
|
protected function popBit(int &$bit): int
|
||||||
|
{
|
||||||
|
return (empty($this->bitstream[$bit--]) ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 1 if the current position must be skipped in Full mode.
|
||||||
|
*
|
||||||
|
* @param int $pos Position in the grid.
|
||||||
|
*/
|
||||||
|
protected function skipModeRefGrid(int $pos): int
|
||||||
|
{
|
||||||
|
return (int) ((! $this->compact) && ($pos == 5));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the offset for the specified position to skip the reference grid.
|
||||||
|
*
|
||||||
|
* @param int $pos Position in the grid.
|
||||||
|
*/
|
||||||
|
protected function skipRefGrid(int $pos): int
|
||||||
|
{
|
||||||
|
return (int) ((! $this->compact) && (($pos % 16) == 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw the data bitstream in the grid in Full mode.
|
||||||
|
*/
|
||||||
|
protected function drawData(): void
|
||||||
|
{
|
||||||
|
$center = $this->gridcenter;
|
||||||
|
$llen = 16; // width of the first layer side
|
||||||
|
$srow = -8; // start top row offset from the center (LSB)
|
||||||
|
$scol = -7; // start top column offset from the center (LSB)
|
||||||
|
if ($this->compact) {
|
||||||
|
$llen = 13;
|
||||||
|
$srow = -6;
|
||||||
|
$scol = -5;
|
||||||
|
}
|
||||||
|
|
||||||
|
$skip = 0; // skip reference grid while drwaing dominoes
|
||||||
|
$bit = ($this->totbits - 1); // index of last bitstream bit (first to draw)
|
||||||
|
for ($layer = 0; $layer < $this->numlayers; ++$layer) {
|
||||||
|
// top
|
||||||
|
$ypos = ($center + $srow);
|
||||||
|
$xpos = ($center + $scol);
|
||||||
|
for ($pos = 0; $pos < $llen; ++$pos) {
|
||||||
|
$xpos += $this->skipRefGrid($xpos - $center); // skip reference grid
|
||||||
|
$this->grid[$ypos][$xpos] = $this->popBit($bit);
|
||||||
|
$this->grid[($ypos - 1 - $skip)][$xpos] = $this->popBit($bit);
|
||||||
|
++$xpos;
|
||||||
|
}
|
||||||
|
|
||||||
|
// right
|
||||||
|
++$ypos;
|
||||||
|
$xpos -= (2 + $skip);
|
||||||
|
for ($pos = 0; $pos < $llen; ++$pos) {
|
||||||
|
$ypos += $this->skipRefGrid($ypos - $center); // skip reference grid
|
||||||
|
$this->grid[$ypos][$xpos] = $this->popBit($bit);
|
||||||
|
$this->grid[$ypos][($xpos + 1 + $skip)] = $this->popBit($bit);
|
||||||
|
++$ypos;
|
||||||
|
}
|
||||||
|
|
||||||
|
// bottom
|
||||||
|
$ypos -= (2 + $skip);
|
||||||
|
--$xpos;
|
||||||
|
for ($pos = 0; $pos < $llen; ++$pos) {
|
||||||
|
$xpos -= $this->skipRefGrid($xpos - $center); // skip reference grid
|
||||||
|
$this->grid[$ypos][$xpos] = $this->popBit($bit);
|
||||||
|
$this->grid[($ypos + 1 + $skip)][$xpos] = $this->popBit($bit);
|
||||||
|
--$xpos;
|
||||||
|
}
|
||||||
|
|
||||||
|
// left
|
||||||
|
--$ypos;
|
||||||
|
$xpos += (2 + $skip);
|
||||||
|
for ($pos = 0; $pos < $llen; ++$pos) {
|
||||||
|
$ypos -= $this->skipRefGrid($ypos - $center); // skip reference grid
|
||||||
|
$this->grid[$ypos][$xpos] = $this->popBit($bit);
|
||||||
|
$this->grid[$ypos][($xpos - 1 - $skip)] = $this->popBit($bit);
|
||||||
|
--$ypos;
|
||||||
|
}
|
||||||
|
|
||||||
|
$llen += 4;
|
||||||
|
$srow = ($ypos - $center);
|
||||||
|
$srow -= $this->skipRefGrid($srow);
|
||||||
|
$scol = ($xpos - 1 - $center);
|
||||||
|
$scol -= $this->skipRefGrid($scol);
|
||||||
|
$skip = $this->skipRefGrid($srow - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
266
vendor/tecnickcom/tc-lib-barcode/src/Type/Square/Aztec/ErrorCorrection.php
vendored
Normal file
266
vendor/tecnickcom/tc-lib-barcode/src/Type/Square/Aztec/ErrorCorrection.php
vendored
Normal file
@@ -0,0 +1,266 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ErrorCorrection.php
|
||||||
|
*
|
||||||
|
* @since 2023-10-13
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2023-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Square\Aztec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Square\Aztec\ErrorCorrection
|
||||||
|
*
|
||||||
|
* ErrorCorrection for Aztec Barcode type class
|
||||||
|
*
|
||||||
|
* @since 2023-10-13
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2023-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class ErrorCorrection
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Galois Field primitive by word size.
|
||||||
|
*
|
||||||
|
* @var array<int>
|
||||||
|
*/
|
||||||
|
protected const GF = [
|
||||||
|
4 => 19, // 10011 GF(16) (x^4 + x + 1) Mode message
|
||||||
|
6 => 67, // 1000011 GF(64) (x^6 + x + 1) 01–02 layers
|
||||||
|
8 => 301, // 100101101 GF(256) (x^8 + x^5 + x^3 + x^2 + 1) 03–08 layers
|
||||||
|
10 => 1033, // 10000001001 GF(1024) (x^10 + x^3 + 1) 09–22 layers
|
||||||
|
12 => 4201, // 1000001101001 GF(4096) (x^12 + x^6 + x^5 + x^3 + 1) 23–32 layers
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map the log and exp (inverse log) tables by word size.
|
||||||
|
* NOTE: It is equal to 2^word_size.
|
||||||
|
*
|
||||||
|
* @var array<int>
|
||||||
|
*/
|
||||||
|
protected const TSIZE = [
|
||||||
|
4 => 16,
|
||||||
|
6 => 64,
|
||||||
|
8 => 256,
|
||||||
|
10 => 1024,
|
||||||
|
12 => 4096,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log table.
|
||||||
|
*
|
||||||
|
* @var array<int>
|
||||||
|
*/
|
||||||
|
protected array $tlog = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exponential (inverse log) table.
|
||||||
|
*
|
||||||
|
* @var array<int>
|
||||||
|
*/
|
||||||
|
protected array $texp = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Size of the log and exp tables.
|
||||||
|
*/
|
||||||
|
protected int $tsize = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the the Reed-Solomon Error Correction.
|
||||||
|
*
|
||||||
|
* @param int $wsize Size of a word in bits.
|
||||||
|
*/
|
||||||
|
public function __construct(int $wsize)
|
||||||
|
{
|
||||||
|
$this->genTables($wsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Reed-Solomon Error Correction Codewords added to the input data.
|
||||||
|
*
|
||||||
|
* @param array<int> $data Array of data codewords to process.
|
||||||
|
* @param int $necc Number of error correction bytes.
|
||||||
|
*
|
||||||
|
* @return array<int>
|
||||||
|
*/
|
||||||
|
public function checkwords(array $data, int $necc): array
|
||||||
|
{
|
||||||
|
$coeff = $this->getCoefficients($data, $necc);
|
||||||
|
return array_pad($coeff, -$necc, 0); // @phpstan-ignore return.type
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates log and exp (inverse log) tables.
|
||||||
|
*
|
||||||
|
* @param int $wsize Size of the word in bits.
|
||||||
|
*/
|
||||||
|
protected function genTables(int $wsize): void
|
||||||
|
{
|
||||||
|
$this->tsize = self::TSIZE[$wsize];
|
||||||
|
$this->tlog = array_fill(0, $this->tsize, 0);
|
||||||
|
$this->texp = $this->tlog;
|
||||||
|
$primitive = self::GF[$wsize];
|
||||||
|
$val = 1;
|
||||||
|
$sizeminusone = ($this->tsize - 1);
|
||||||
|
for ($idx = 0; $idx < $this->tsize; ++$idx) {
|
||||||
|
$this->texp[$idx] = $val;
|
||||||
|
$val <<= 1; // multiply by 2
|
||||||
|
if ($val >= $this->tsize) {
|
||||||
|
$val ^= $primitive;
|
||||||
|
$val &= $sizeminusone;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($idx = 0; $idx < $this->tsize - 1; ++$idx) {
|
||||||
|
$this->tlog[$this->texp[$idx]] = $idx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the coefficients of the error correction polynomial.
|
||||||
|
*
|
||||||
|
* @param array<int> $data Array of data codewords to process.
|
||||||
|
* @param int $necc Number of error correction bytes.
|
||||||
|
*
|
||||||
|
* @return array<int> Array of coefficients.
|
||||||
|
*/
|
||||||
|
protected function getCoefficients(array $data, int $necc): array
|
||||||
|
{
|
||||||
|
$gen = [1];
|
||||||
|
for ($idx = 1; $idx <= $necc; ++$idx) {
|
||||||
|
$gen = $this->multiplyCoeff([1, $this->texp[$idx]], $gen);
|
||||||
|
}
|
||||||
|
|
||||||
|
$deg = ($necc + 1);
|
||||||
|
$coeff = $this->multiplyByMonomial($data, 1, $necc);
|
||||||
|
$len = count($coeff);
|
||||||
|
while (($len >= $deg) && ($coeff[0] != 0)) {
|
||||||
|
$scale = $this->multiply($coeff[0], 1);
|
||||||
|
$largercoeffs = $this->multiplyByMonomial($gen, $scale, ($len - $deg));
|
||||||
|
$coeff = $this->addOrSubtract($coeff, $largercoeffs);
|
||||||
|
$len = count($coeff);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $coeff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the product of two coefficient arrays.
|
||||||
|
*
|
||||||
|
* @param array<int> $acf First array of coefficients.
|
||||||
|
* @param array<int> $bcf Second array of coefficients.
|
||||||
|
*
|
||||||
|
* @return array<int> Array of coefficients.
|
||||||
|
*/
|
||||||
|
protected function multiplyCoeff(array $acf, array $bcf): array
|
||||||
|
{
|
||||||
|
$alen = count($acf);
|
||||||
|
$blen = count($bcf);
|
||||||
|
$coeff = array_fill(0, ($alen + $blen - 1), 0);
|
||||||
|
for ($aid = 0; $aid < $alen; ++$aid) {
|
||||||
|
for ($bid = 0; $bid < $blen; ++$bid) {
|
||||||
|
$coeff[$aid + $bid] ^= ($this->multiply($acf[$aid], $bcf[$bid]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->trimCoefficients($coeff);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the product of $aval and $bval in GF(size).
|
||||||
|
*
|
||||||
|
* @param int $aval First value.
|
||||||
|
* @param int $bval Second value.
|
||||||
|
*/
|
||||||
|
protected function multiply(int $aval, int $bval): int
|
||||||
|
{
|
||||||
|
if ($aval == 0 || $bval == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->texp[($this->tlog[$aval] + $this->tlog[$bval]) % ($this->tsize - 1)];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Left-trim coefficients array.
|
||||||
|
*
|
||||||
|
* @param array<int> $coeff Array of coefficients.
|
||||||
|
*
|
||||||
|
* @return array<int> Array of coefficients.
|
||||||
|
*/
|
||||||
|
protected function trimCoefficients(array $coeff): array
|
||||||
|
{
|
||||||
|
while ($coeff !== [] && $coeff[0] == 0) {
|
||||||
|
array_shift($coeff);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $coeff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the product of a polynomial by a monomial.
|
||||||
|
*
|
||||||
|
* @param array<int> $coeff Array of polynomial coefficients.
|
||||||
|
* @param int $mon Monomial.
|
||||||
|
* @param int $deg Degree of the monomial.
|
||||||
|
*
|
||||||
|
* @return array<int> Array of coefficients.
|
||||||
|
*/
|
||||||
|
protected function multiplyByMonomial(array $coeff, int $mon, int $deg): array
|
||||||
|
{
|
||||||
|
// if ($mon == 0) {
|
||||||
|
// return array(0);
|
||||||
|
// }
|
||||||
|
$ncf = count($coeff);
|
||||||
|
$prod = array_fill(0, ($ncf + $deg), 0);
|
||||||
|
for ($idx = 0; $idx < $ncf; ++$idx) {
|
||||||
|
$prod[$idx] = $this->multiply($coeff[$idx], $mon);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->trimCoefficients($prod);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds or subtracts two coefficient arrays.
|
||||||
|
*
|
||||||
|
* @param array<int> $smaller The smaller array of coefficients.
|
||||||
|
* @param array<int> $larger The larger array of coefficients.
|
||||||
|
*
|
||||||
|
* @return array<int> Array of coefficients.
|
||||||
|
*/
|
||||||
|
protected function addOrSubtract(array $smaller, array $larger): array
|
||||||
|
{
|
||||||
|
// if ($smaller[0] == 0) {
|
||||||
|
// return $larger;
|
||||||
|
// }
|
||||||
|
// if ($larger[0] == 0) {
|
||||||
|
// return $smaller;
|
||||||
|
// }
|
||||||
|
$slen = count($smaller);
|
||||||
|
$llen = count($larger);
|
||||||
|
// if ($slen > $llen) {
|
||||||
|
// // swap arrays
|
||||||
|
// list($smaller, $larger) = array($larger, $smaller);
|
||||||
|
// list($slen, $llen) = array($llen, $slen);
|
||||||
|
// }
|
||||||
|
$lendiff = ($llen - $slen);
|
||||||
|
$coeff = array_slice($larger, 0, $lendiff);
|
||||||
|
for ($idx = $lendiff; $idx < $llen; ++$idx) {
|
||||||
|
$coeff[$idx] = ($smaller[($idx - $lendiff)] ^ $larger[$idx]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->trimCoefficients($coeff);
|
||||||
|
}
|
||||||
|
}
|
||||||
163
vendor/tecnickcom/tc-lib-barcode/src/Type/Square/Aztec/Layers.php
vendored
Normal file
163
vendor/tecnickcom/tc-lib-barcode/src/Type/Square/Aztec/Layers.php
vendored
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Layers.php
|
||||||
|
*
|
||||||
|
* @since 2023-10-13
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2023-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Square\Aztec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Square\Aztec\Layers
|
||||||
|
*
|
||||||
|
* Layers for Aztec Barcode type class
|
||||||
|
*
|
||||||
|
* @since 2023-10-13
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2023-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
abstract class Layers extends \Com\Tecnick\Barcode\Type\Square\Aztec\Codeword
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* True for compact mode (up to 4 layers), false for full-range mode (up to 32 layers).
|
||||||
|
*/
|
||||||
|
protected bool $compact = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of data layers.
|
||||||
|
*/
|
||||||
|
protected int $numlayers = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Size data for the selected layer.
|
||||||
|
*
|
||||||
|
* @var array{int, int, int, int, int, int, int}
|
||||||
|
*/
|
||||||
|
protected array $layer = [0, 0, 0, 0, 0, 0, 0];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the minimum number of layers required.
|
||||||
|
*
|
||||||
|
* @param array<int, array{int, int, int, int, int, int, int}> $data
|
||||||
|
* Either the Data::SIZE_COMPACT or Data::SIZE_FULL array.
|
||||||
|
* @param int $numbits The number of bits to encode.
|
||||||
|
*/
|
||||||
|
protected function getMinLayers(array $data, int $numbits): int
|
||||||
|
{
|
||||||
|
if ($numbits <= $data[count($data)][3]) {
|
||||||
|
foreach ($data as $numlayers => $size) {
|
||||||
|
if ($numbits <= $size[3]) {
|
||||||
|
return $numlayers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select the layer by the number of bits to encode.
|
||||||
|
*
|
||||||
|
* @param int $numbits The number of bits to encode.
|
||||||
|
* @param string $mode The mode to use (A = Automatic; F = Full Range mode).
|
||||||
|
*
|
||||||
|
* @return bool Returns true if the size computation was successful, false otherwise.
|
||||||
|
*/
|
||||||
|
protected function setLayerByBits(int $numbits, string $mode = 'A'): bool
|
||||||
|
{
|
||||||
|
$this->numlayers = 0;
|
||||||
|
if ($mode == 'A') {
|
||||||
|
$this->compact = true;
|
||||||
|
$this->numlayers = $this->getMinLayers(Data::SIZE_COMPACT, $numbits);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->numlayers == 0) {
|
||||||
|
$this->compact = false;
|
||||||
|
$this->numlayers = $this->getMinLayers(Data::SIZE_FULL, $numbits);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->numlayers == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->layer = $this->compact ? Data::SIZE_COMPACT[$this->numlayers] : Data::SIZE_FULL[$this->numlayers];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes the type and number of required layers and performs bit stuffing
|
||||||
|
*
|
||||||
|
* @param int $ecc The error correction level.
|
||||||
|
* @param string $mode The mode to use (A = Automatic; F = Full Range mode).
|
||||||
|
*
|
||||||
|
* @return bool Returns true if the size computation was successful, false otherwise.
|
||||||
|
*/
|
||||||
|
protected function sizeAndBitStuffing(int $ecc, string $mode = 'A'): bool
|
||||||
|
{
|
||||||
|
$nsbits = 0;
|
||||||
|
$eccbits = (11 + (int) (($this->totbits * $ecc) / 100));
|
||||||
|
do {
|
||||||
|
if (! $this->setLayerByBits(($this->totbits + $nsbits + $eccbits), $mode)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nsbits = $this->bitStuffing();
|
||||||
|
} while (($nsbits + $eccbits) > $this->layer[3]);
|
||||||
|
|
||||||
|
$this->bitstream = [];
|
||||||
|
$this->totbits = 0;
|
||||||
|
$this->mergeTmpCwdRaw();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bit-stuffing the bitstream into Reed–Solomon codewords.
|
||||||
|
* The resulting codewords are stored in the temporary tmpCdws array.
|
||||||
|
*
|
||||||
|
* @return int The number of bits in the bitstream after bit stuffing.
|
||||||
|
*/
|
||||||
|
protected function bitStuffing(): int
|
||||||
|
{
|
||||||
|
$nsbits = 0;
|
||||||
|
$wsize = $this->layer[2];
|
||||||
|
$mask = ((1 << $wsize) - 2); // b-1 bits at 1 and last bit at 0
|
||||||
|
$this->tmpCdws = [];
|
||||||
|
for ($wid = 0; $wid < $this->totbits; $wid += $wsize) {
|
||||||
|
$word = 0;
|
||||||
|
for ($idx = 0; $idx < $wsize; ++$idx) {
|
||||||
|
$bid = ($wid + $idx);
|
||||||
|
if (($bid >= $this->totbits) || ($this->bitstream[$bid] == 1)) {
|
||||||
|
$word |= (1 << ($wsize - 1 - $idx)); // the first bit is MSB
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the first b−1 bits of a code word have the same value,
|
||||||
|
// an extra bit with the complementary value is inserted into the data stream.
|
||||||
|
if (($word & $mask) === $mask) {
|
||||||
|
$word &= $mask;
|
||||||
|
--$wid;
|
||||||
|
} elseif (($word & $mask) == 0) {
|
||||||
|
$word |= 1;
|
||||||
|
--$wid;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->tmpCdws[] = [$wsize, $word];
|
||||||
|
$nsbits += $wsize;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $nsbits;
|
||||||
|
}
|
||||||
|
}
|
||||||
322
vendor/tecnickcom/tc-lib-barcode/src/Type/Square/Datamatrix.php
vendored
Normal file
322
vendor/tecnickcom/tc-lib-barcode/src/Type/Square/Datamatrix.php
vendored
Normal file
@@ -0,0 +1,322 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Datamatrix.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Square;
|
||||||
|
|
||||||
|
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||||
|
use Com\Tecnick\Barcode\Type\Square\Datamatrix\Data;
|
||||||
|
use Com\Tecnick\Barcode\Type\Square\Datamatrix\Encode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Square\Datamatrix
|
||||||
|
*
|
||||||
|
* Datamatrix Barcode type class
|
||||||
|
* DATAMATRIX (ISO/IEC 16022)
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2010-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class Datamatrix extends \Com\Tecnick\Barcode\Type\Square
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Barcode format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected const FORMAT = 'DATAMATRIX';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of codewords.
|
||||||
|
*
|
||||||
|
* @var array<int, int>
|
||||||
|
*/
|
||||||
|
protected array $cdw = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Binary grid
|
||||||
|
*
|
||||||
|
* @var array<int, array<int, int>>
|
||||||
|
*/
|
||||||
|
protected array $grid = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Datamatrix Encoding object
|
||||||
|
*/
|
||||||
|
protected Encode $dmx;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Datamatrix shape key (S=square, R=rectangular)
|
||||||
|
*/
|
||||||
|
protected string $shape = 'S';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Datamatrix variant (N=default, GS1=FNC1 codeword in first place)
|
||||||
|
*/
|
||||||
|
protected bool $gsonemode = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Datamatrix default encoding.
|
||||||
|
* See Data::SWITCHCDW for valid values.
|
||||||
|
*/
|
||||||
|
protected int $defenc = Data::ENC_ASCII;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set extra (optional) parameters:
|
||||||
|
* 1: SHAPE: S=square (default), R=rectangular.
|
||||||
|
* 2: MODE: N=default, GS1 = the FNC1 codeword is added in the first position of Data Matrix ECC 200 version.
|
||||||
|
* 3: ENCODING: ASCII (default), C40, TXT, X12, EDIFACT, BASE256.
|
||||||
|
*/
|
||||||
|
protected function setParameters(): void
|
||||||
|
{
|
||||||
|
parent::setParameters();
|
||||||
|
|
||||||
|
// shape
|
||||||
|
if (isset($this->params[0]) && ($this->params[0] === 'R')) {
|
||||||
|
$this->shape = 'R';
|
||||||
|
}
|
||||||
|
|
||||||
|
// mode
|
||||||
|
$this->gsonemode = (isset($this->params[1]) && ($this->params[1] === 'GS1'));
|
||||||
|
|
||||||
|
// encoding
|
||||||
|
if (isset($this->params[2])) {
|
||||||
|
$this->defenc = Data::ENCOPTS[$this->params[2]] ?? Data::ENC_ASCII;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add padding codewords
|
||||||
|
*
|
||||||
|
* @param int $size Max barcode size in codewords
|
||||||
|
* @param int $ncw Number of codewords
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function addPadding(int $size, int $ncw): void
|
||||||
|
{
|
||||||
|
if ($size <= $ncw) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($this->dmx->last_enc != Data::ENC_ASCII) && ($this->dmx->last_enc != Data::ENC_BASE256)) {
|
||||||
|
// return to ASCII encodation before padding
|
||||||
|
$this->cdw[] = $this->dmx->last_enc == Data::ENC_EDF ? 124 : 254;
|
||||||
|
|
||||||
|
++$ncw;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($size > $ncw) {
|
||||||
|
// add first pad
|
||||||
|
$this->cdw[] = 129;
|
||||||
|
++$ncw;
|
||||||
|
// add remaining pads
|
||||||
|
for ($i = $ncw; $i < $size; ++$i) {
|
||||||
|
$this->cdw[] = $this->dmx->get253StateCodeword(129, $i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the codewords
|
||||||
|
*
|
||||||
|
* @return array{int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int} params
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function getCodewords(): array
|
||||||
|
{
|
||||||
|
if (strlen((string) $this->code) == 0) {
|
||||||
|
throw new BarcodeException('Empty input');
|
||||||
|
}
|
||||||
|
|
||||||
|
// get data codewords
|
||||||
|
$this->cdw = $this->getHighLevelEncoding($this->code);
|
||||||
|
|
||||||
|
// number of data codewords
|
||||||
|
$ncw = count($this->cdw);
|
||||||
|
|
||||||
|
// check size
|
||||||
|
if ($ncw > 1560) {
|
||||||
|
throw new BarcodeException('the input is too large to fit the barcode');
|
||||||
|
}
|
||||||
|
|
||||||
|
// get minimum required matrix size.
|
||||||
|
$params = Data::getPaddingSize($this->shape, $ncw);
|
||||||
|
$this->addPadding($params[11], $ncw);
|
||||||
|
|
||||||
|
$errorCorrection = new \Com\Tecnick\Barcode\Type\Square\Datamatrix\ErrorCorrection();
|
||||||
|
$this->cdw = $errorCorrection->getErrorCorrection($this->cdw, $params[13], $params[14], $params[15]);
|
||||||
|
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the grid
|
||||||
|
*
|
||||||
|
* @param int $idx Index
|
||||||
|
* @param array<int, int> $places Places
|
||||||
|
* @param int $row Row
|
||||||
|
* @param int $col Column
|
||||||
|
* @param int $rdx Region data row index
|
||||||
|
* @param int $cdx Region data column index
|
||||||
|
* @param int $rdri Region data row max index
|
||||||
|
* @param int $rdci Region data column max index
|
||||||
|
*/
|
||||||
|
protected function setGrid(
|
||||||
|
int &$idx,
|
||||||
|
array &$places,
|
||||||
|
int &$row,
|
||||||
|
int &$col,
|
||||||
|
int &$rdx,
|
||||||
|
int &$cdx,
|
||||||
|
int &$rdri,
|
||||||
|
int &$rdci
|
||||||
|
): void {
|
||||||
|
// braw bits by case
|
||||||
|
if ($rdx == 0) {
|
||||||
|
// top finder pattern
|
||||||
|
$this->grid[$row][$col] = (int) (($cdx % 2) == 0);
|
||||||
|
} elseif ($rdx == $rdri) {
|
||||||
|
// bottom finder pattern
|
||||||
|
$this->grid[$row][$col] = 1;
|
||||||
|
} elseif ($cdx == 0) {
|
||||||
|
// left finder pattern
|
||||||
|
$this->grid[$row][$col] = 1;
|
||||||
|
} elseif ($cdx == $rdci) {
|
||||||
|
// right finder pattern
|
||||||
|
$this->grid[$row][$col] = (int) (($rdx % 2) > 0);
|
||||||
|
} else {
|
||||||
|
// data bit
|
||||||
|
if ($places[$idx] < 2) {
|
||||||
|
$this->grid[$row][$col] = $places[$idx];
|
||||||
|
} else {
|
||||||
|
// codeword ID
|
||||||
|
$cdw_id = (floor($places[$idx] / 10) - 1);
|
||||||
|
// codeword BIT mask
|
||||||
|
$cdw_bit = 2 ** (8 - ($places[$idx] % 10));
|
||||||
|
$this->grid[$row][$col] = (($this->cdw[$cdw_id] & $cdw_bit) == 0) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
++$idx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get high level encoding using the minimum symbol data characters for ECC 200
|
||||||
|
*
|
||||||
|
* @param string $data data to encode
|
||||||
|
*
|
||||||
|
* @return array<int, int> Codewords
|
||||||
|
*
|
||||||
|
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
|
||||||
|
*/
|
||||||
|
protected function getHighLevelEncoding(string $data): array
|
||||||
|
{
|
||||||
|
// STEP A. Start in predefined encodation.
|
||||||
|
$enc = $this->defenc; // current encoding mode
|
||||||
|
$this->dmx->last_enc = $enc; // last used encoding
|
||||||
|
$pos = 0; // current position
|
||||||
|
$cdw = []; // array of codewords to be returned
|
||||||
|
$cdw_num = 0; // number of data codewords
|
||||||
|
$data_length = strlen($data); // number of chars
|
||||||
|
$field_length = 0; // number of chars in current field
|
||||||
|
|
||||||
|
// Switch to predefined encoding (no action needed if ASCII because it's the default encoding)
|
||||||
|
if ($this->defenc !== Data::ENC_ASCII) {
|
||||||
|
$cdw[] = $this->dmx->getSwitchEncodingCodeword($this->defenc);
|
||||||
|
++$cdw_num;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ($pos < $data_length) {
|
||||||
|
// Determine if current char is FNC1 (don't encode it, just pass it through)
|
||||||
|
if ($this->gsonemode && ($data[$pos] == chr(232))) {
|
||||||
|
$cdw[] = 232;
|
||||||
|
++$pos;
|
||||||
|
++$cdw_num;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($enc) {
|
||||||
|
case Data::ENC_ASCII:
|
||||||
|
// STEP B. While in ASCII encodation
|
||||||
|
$this->dmx->encodeASCII($cdw, $cdw_num, $pos, $data_length, $data, $enc);
|
||||||
|
break;
|
||||||
|
case Data::ENC_C40:
|
||||||
|
// Upper-case alphanumeric
|
||||||
|
case Data::ENC_TXT:
|
||||||
|
// Lower-case alphanumeric
|
||||||
|
case Data::ENC_X12:
|
||||||
|
// ANSI X12
|
||||||
|
$this->dmx->encodeTXT($cdw, $cdw_num, $pos, $data_length, $data, $enc);
|
||||||
|
break;
|
||||||
|
case Data::ENC_EDF:
|
||||||
|
// F. While in EDIFACT (EDF) encodation
|
||||||
|
$this->dmx->encodeEDF($cdw, $cdw_num, $pos, $data_length, $field_length, $data, $enc);
|
||||||
|
break;
|
||||||
|
case Data::ENC_BASE256:
|
||||||
|
// G. While in Base 256 (B256) encodation
|
||||||
|
$this->dmx->encodeBase256($cdw, $cdw_num, $pos, $data_length, $field_length, $data, $enc);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->dmx->last_enc = $enc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $cdw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the bars array
|
||||||
|
*
|
||||||
|
* @throws BarcodeException in case of error
|
||||||
|
*/
|
||||||
|
protected function setBars(): void
|
||||||
|
{
|
||||||
|
$this->dmx = new Encode($this->shape);
|
||||||
|
$params = $this->getCodewords();
|
||||||
|
// get placement map
|
||||||
|
$places = $this->dmx->getPlacementMap($params[2], $params[3]);
|
||||||
|
// fill the grid with data
|
||||||
|
$this->grid = [];
|
||||||
|
$idx = 0;
|
||||||
|
// region data row max index
|
||||||
|
$rdri = ($params[4] - 1);
|
||||||
|
// region data column max index
|
||||||
|
$rdci = ($params[5] - 1);
|
||||||
|
// for each horizontal region
|
||||||
|
for ($hr = 0; $hr < $params[8]; ++$hr) {
|
||||||
|
// for each row on region
|
||||||
|
for ($rdx = 0; $rdx < $params[4]; ++$rdx) {
|
||||||
|
$row = (($hr * $params[4]) + $rdx);
|
||||||
|
// for each vertical region
|
||||||
|
for ($vr = 0; $vr < $params[9]; ++$vr) {
|
||||||
|
// for each column on region
|
||||||
|
for ($cdx = 0; $cdx < $params[5]; ++$cdx) {
|
||||||
|
$col = (($vr * $params[5]) + $cdx);
|
||||||
|
$this->setGrid($idx, $places, $row, $col, $rdx, $cdx, $rdri, $rdci);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->processBinarySequence($this->grid);
|
||||||
|
}
|
||||||
|
}
|
||||||
1027
vendor/tecnickcom/tc-lib-barcode/src/Type/Square/Datamatrix/Data.php
vendored
Normal file
1027
vendor/tecnickcom/tc-lib-barcode/src/Type/Square/Datamatrix/Data.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
286
vendor/tecnickcom/tc-lib-barcode/src/Type/Square/Datamatrix/Encode.php
vendored
Normal file
286
vendor/tecnickcom/tc-lib-barcode/src/Type/Square/Datamatrix/Encode.php
vendored
Normal file
@@ -0,0 +1,286 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode.php
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2015-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*
|
||||||
|
* This file is part of tc-lib-barcode software library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Com\Tecnick\Barcode\Type\Square\Datamatrix;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Com\Tecnick\Barcode\Type\Square\Datamatrix\Encode
|
||||||
|
*
|
||||||
|
* Datamatrix Barcode type class
|
||||||
|
* DATAMATRIX (ISO/IEC 16022)
|
||||||
|
*
|
||||||
|
* @since 2015-02-21
|
||||||
|
* @category Library
|
||||||
|
* @package Barcode
|
||||||
|
* @author Nicola Asuni <info@tecnick.com>
|
||||||
|
* @copyright 2015-2024 Nicola Asuni - Tecnick.com LTD
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||||
|
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||||
|
*/
|
||||||
|
class Encode extends \Com\Tecnick\Barcode\Type\Square\Datamatrix\EncodeTxt
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Initialize a new encode object
|
||||||
|
*
|
||||||
|
* @param string $shape Datamatrix shape key (S=square, R=rectangular)
|
||||||
|
*/
|
||||||
|
public function __construct(string $shape = 'S')
|
||||||
|
{
|
||||||
|
$this->shape = $shape;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode ASCII
|
||||||
|
*
|
||||||
|
* @param array<int, int> $cdw Codewords array
|
||||||
|
* @param int $cdw_num Codewords number
|
||||||
|
* @param int $pos Current position
|
||||||
|
* @param int $data_length Data length
|
||||||
|
* @param string $data Data string
|
||||||
|
* @param int $enc Current encoding
|
||||||
|
*/
|
||||||
|
public function encodeASCII(
|
||||||
|
array &$cdw,
|
||||||
|
int &$cdw_num,
|
||||||
|
int &$pos,
|
||||||
|
int &$data_length,
|
||||||
|
string &$data,
|
||||||
|
int &$enc
|
||||||
|
): void {
|
||||||
|
if (
|
||||||
|
($data_length > 1)
|
||||||
|
&& ($pos < ($data_length - 1))
|
||||||
|
&& (
|
||||||
|
$this->isCharMode(ord($data[$pos]), Data::ENC_ASCII_NUM)
|
||||||
|
&& $this->isCharMode(ord($data[$pos + 1]), Data::ENC_ASCII_NUM)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
// 1. If the next data sequence is at least 2 consecutive digits,
|
||||||
|
// encode the next two digits as a double digit in ASCII mode.
|
||||||
|
$cdw[] = ((int) substr($data, $pos, 2) + 130);
|
||||||
|
++$cdw_num;
|
||||||
|
$pos += 2;
|
||||||
|
} else {
|
||||||
|
// 2. If the look-ahead test (starting at step J) indicates another mode, switch to that mode.
|
||||||
|
$newenc = $this->lookAheadTest($data, $pos, $enc);
|
||||||
|
if ($newenc !== $enc) {
|
||||||
|
// switch to new encoding
|
||||||
|
$enc = $newenc;
|
||||||
|
$cdw[] = $this->getSwitchEncodingCodeword($enc);
|
||||||
|
++$cdw_num;
|
||||||
|
} else {
|
||||||
|
// get new byte
|
||||||
|
$chr = ord($data[$pos]);
|
||||||
|
++$pos;
|
||||||
|
if ($this->isCharMode($chr, Data::ENC_ASCII_EXT)) {
|
||||||
|
// 3. If the next data character is extended ASCII (greater than 127)
|
||||||
|
// encode it in ASCII mode first using the Upper Shift (value 235) character.
|
||||||
|
$cdw[] = 235;
|
||||||
|
$cdw[] = ($chr - 127);
|
||||||
|
$cdw_num += 2;
|
||||||
|
} else {
|
||||||
|
// 4. Otherwise process the next data character in ASCII encodation.
|
||||||
|
$cdw[] = ($chr + 1);
|
||||||
|
++$cdw_num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode EDF4
|
||||||
|
*
|
||||||
|
* @param int $epos Current position
|
||||||
|
* @param array<int, int> $cdw Codewords array
|
||||||
|
* @param int $cdw_num Codewords number
|
||||||
|
* @param int $pos Current position
|
||||||
|
* @param int $data_length Data length
|
||||||
|
* @param int $field_length Field length
|
||||||
|
* @param int $enc Current encoding
|
||||||
|
* @param array<int, int> $temp_cw Temporary codewords array
|
||||||
|
*
|
||||||
|
* @return bool true to break the loop
|
||||||
|
*/
|
||||||
|
public function encodeEDFfour(
|
||||||
|
int $epos,
|
||||||
|
array &$cdw,
|
||||||
|
int &$cdw_num,
|
||||||
|
int &$pos,
|
||||||
|
int &$data_length,
|
||||||
|
int &$field_length,
|
||||||
|
int &$enc,
|
||||||
|
array &$temp_cw
|
||||||
|
): bool {
|
||||||
|
if (($epos === $data_length)) {
|
||||||
|
$enc = Data::ENC_ASCII;
|
||||||
|
$params = Data::getPaddingSize($this->shape, ($cdw_num + $field_length));
|
||||||
|
if (($params[11] - $cdw_num) > 2) {
|
||||||
|
$cdw[] = $this->getSwitchEncodingCodeword($enc);
|
||||||
|
++$cdw_num;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($field_length < 4) {
|
||||||
|
$enc = Data::ENC_ASCII;
|
||||||
|
$this->last_enc = $enc;
|
||||||
|
$params = Data::getPaddingSize($this->shape, ($cdw_num + $field_length + ($data_length - $epos)));
|
||||||
|
if (($params[11] - $cdw_num) > 2) {
|
||||||
|
// set unlatch character
|
||||||
|
$temp_cw[] = 0x1f;
|
||||||
|
++$field_length;
|
||||||
|
// fill empty characters
|
||||||
|
for ($i = $field_length; $i < 4; ++$i) {
|
||||||
|
$temp_cw[] = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// encodes four data characters in three codewords
|
||||||
|
$cdw[] = (($temp_cw[0] & 0x3F) << 2) + (($temp_cw[1] & 0x30) >> 4);
|
||||||
|
++$cdw_num;
|
||||||
|
if ($field_length > 1) {
|
||||||
|
$cdw[] = (($temp_cw[1] & 0x0F) << 4) + (($temp_cw[2] & 0x3C) >> 2);
|
||||||
|
++$cdw_num;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($field_length > 2) {
|
||||||
|
$cdw[] = (($temp_cw[2] & 0x03) << 6) + ($temp_cw[3] & 0x3F);
|
||||||
|
++$cdw_num;
|
||||||
|
}
|
||||||
|
|
||||||
|
$temp_cw = [];
|
||||||
|
$pos = $epos;
|
||||||
|
$field_length = 0;
|
||||||
|
if ($enc == Data::ENC_ASCII) {
|
||||||
|
return true; // exit from EDIFACT mode
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode EDF
|
||||||
|
*
|
||||||
|
* @param array<int, int> $cdw Codewords array
|
||||||
|
* @param int $cdw_num Codewords number
|
||||||
|
* @param int $pos Current position
|
||||||
|
* @param int $data_length Data length
|
||||||
|
* @param int $field_length Field length
|
||||||
|
* @param string $data Data string
|
||||||
|
* @param int $enc Current encoding
|
||||||
|
*/
|
||||||
|
public function encodeEDF(
|
||||||
|
array &$cdw,
|
||||||
|
int &$cdw_num,
|
||||||
|
int &$pos,
|
||||||
|
int &$data_length,
|
||||||
|
int &$field_length,
|
||||||
|
string &$data,
|
||||||
|
int &$enc
|
||||||
|
): void {
|
||||||
|
// initialize temporary array with 0 length
|
||||||
|
$temp_cw = [];
|
||||||
|
$epos = $pos;
|
||||||
|
$field_length = 0;
|
||||||
|
do {
|
||||||
|
// 2. process the next character in EDIFACT encodation.
|
||||||
|
$chr = ord($data[$epos]);
|
||||||
|
if ($this->isCharMode($chr, Data::ENC_EDF)) {
|
||||||
|
++$epos;
|
||||||
|
$temp_cw[] = $chr;
|
||||||
|
++$field_length;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
(($field_length == 4)
|
||||||
|
|| ($epos == $data_length)
|
||||||
|
|| ! $this->isCharMode($chr, Data::ENC_EDF))
|
||||||
|
&& $this->encodeEDFfour(
|
||||||
|
$epos,
|
||||||
|
$cdw,
|
||||||
|
$cdw_num,
|
||||||
|
$pos,
|
||||||
|
$data_length,
|
||||||
|
$field_length,
|
||||||
|
$enc,
|
||||||
|
$temp_cw
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while ($epos < $data_length);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode Base256
|
||||||
|
*
|
||||||
|
* @param array<int, int> $cdw Codewords array
|
||||||
|
* @param int $cdw_num Codewords number
|
||||||
|
* @param int $pos Current position
|
||||||
|
* @param int $data_length Data length
|
||||||
|
* @param int $field_length Field length
|
||||||
|
* @param string $data Data string
|
||||||
|
* @param int $enc Current encoding
|
||||||
|
*/
|
||||||
|
public function encodeBase256(
|
||||||
|
array &$cdw,
|
||||||
|
int &$cdw_num,
|
||||||
|
int &$pos,
|
||||||
|
int &$data_length,
|
||||||
|
int &$field_length,
|
||||||
|
string &$data,
|
||||||
|
int &$enc
|
||||||
|
): void {
|
||||||
|
// initialize temporary array with 0 length
|
||||||
|
$temp_cw = [];
|
||||||
|
$field_length = 0;
|
||||||
|
while (($pos < $data_length) && ($field_length <= 1555)) {
|
||||||
|
$newenc = $this->lookAheadTest($data, $pos, $enc);
|
||||||
|
if ($newenc !== $enc) {
|
||||||
|
// 1. If the look-ahead test (starting at step J)
|
||||||
|
// indicates another mode, switch to that mode.
|
||||||
|
$enc = $newenc;
|
||||||
|
break; // exit from B256 mode
|
||||||
|
} else {
|
||||||
|
// 2. Otherwise, process the next character in Base 256 encodation.
|
||||||
|
$chr = ord($data[$pos]);
|
||||||
|
++$pos;
|
||||||
|
$temp_cw[] = $chr;
|
||||||
|
++$field_length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set field length
|
||||||
|
if ($field_length <= 249) {
|
||||||
|
$cdw[] = $this->get255StateCodeword($field_length, ($cdw_num + 1));
|
||||||
|
++$cdw_num;
|
||||||
|
} else {
|
||||||
|
$cdw[] = $this->get255StateCodeword(((int) floor($field_length / 250) + 249), ($cdw_num + 1));
|
||||||
|
$cdw[] = $this->get255StateCodeword(($field_length % 250), ($cdw_num + 2));
|
||||||
|
$cdw_num += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add B256 field
|
||||||
|
foreach ($temp_cw as $cht) {
|
||||||
|
$cdw[] = $this->get255StateCodeword($cht, ($cdw_num + 1));
|
||||||
|
++$cdw_num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user