Fase 3 v1: new qr types, svg export, clipboard, frame text, batch CSV
New static qr types: - App Link: Android intent:// links (with package + optional browser fallback) or a generic custom-scheme URI. iOS Universal Links need no special encoding (they're just plain https:// URLs). - Bluetooth: device name + MAC address. Purely informational, since unlike WIFI:/vCard there's no OS-native "scan to pair" convention. SVG export: already worked (format whitelist/dropdown existed since Fase 1), verified rather than reimplemented. Copy-to-clipboard button next to the download button on both qr list tables, using the Clipboard API against a fetched blob. Optional frame text label rendered below the qr code via GD after generation (raster formats only, no-op for svg/eps). Batch CSV upload (batch_qrcode.php): filename,link rows create dynamic qr codes with sane defaults, downloadable as a zip. Required refactoring Qrcode-intchil.php's generation path (previously always redirected/exited via failure()/success(), which can't run in a loop) into a private renderAndStore() that throws instead, shared by addQrcode() and the new addQrcodeBatch(). Qrcode.php's addQrcodeBatch() is a separate, deliberately duplicated implementation instead, since its generation logic is small enough that duplication carries less risk than refactoring the working external-API code path. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -75,10 +75,49 @@ class DynamicQrcode {
|
||||
|
||||
$this->qrcode_instance->addQrcode($input_data, $data_to_db, $data_to_qrcode);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Batch-safe variant used by batch_qrcode.php: creates one dynamic qr code from a
|
||||
* CSV row (filename + link) with sane defaults, returning a result array
|
||||
* (['ok' => bool, 'id'|'error' => ...]) instead of redirecting/exiting.
|
||||
*/
|
||||
public function addQrcodeBatchRow($filename, $link, $id_owner) {
|
||||
$filename = trim((string) $filename);
|
||||
$link = trim((string) $link);
|
||||
|
||||
if ($filename === '') {
|
||||
return ['ok' => false, 'error' => 'Filename is required.'];
|
||||
}
|
||||
|
||||
if ($link === '' || strlen($link) > 500) {
|
||||
return ['ok' => false, 'error' => 'Link is required and must be at most 500 characters.'];
|
||||
}
|
||||
|
||||
$data_to_db['id_owner'] = $id_owner !== '' ? $id_owner : NULL;
|
||||
$data_to_db['filename'] = htmlspecialchars($filename, ENT_QUOTES, 'UTF-8');
|
||||
$data_to_db['created_at'] = date('Y-m-d H:i:s');
|
||||
$data_to_db['link'] = htmlspecialchars($link, ENT_QUOTES, 'UTF-8');
|
||||
$data_to_db['created_by'] = $_SESSION['user_id'];
|
||||
$data_to_db['format'] = 'png';
|
||||
$data_to_db['identifier'] = randomString(rand(5, 8));
|
||||
$data_to_db['qrcode'] = $data_to_db['filename'].'.'.$data_to_db['format'];
|
||||
|
||||
$data_to_qrcode = READ_PATH.$data_to_db['identifier'];
|
||||
|
||||
$input_data = [
|
||||
'level' => 'L',
|
||||
'size' => 200,
|
||||
'foreground' => '#000000',
|
||||
'background' => '#ffffff',
|
||||
'frame_text' => '',
|
||||
];
|
||||
|
||||
return $this->qrcode_instance->addQrcodeBatch($input_data, $data_to_db, $data_to_qrcode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit qr code
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function editQrcode($input_data) {
|
||||
$this->validateLink($input_data['link'] ?? '');
|
||||
|
||||
Reference in New Issue
Block a user