mirror of
https://github.com/Karaka-Management/oms-Labeling.git
synced 2026-02-12 07:38:42 +00:00
fix tests
This commit is contained in:
parent
57d83ba9d9
commit
0b2aab5278
|
|
@ -11,6 +11,8 @@ $margin = 50;
|
||||||
|
|
||||||
$l = new Label();
|
$l = new Label();
|
||||||
|
|
||||||
|
/** @var \Modules\ItemManagement\Models\Item $item */
|
||||||
|
|
||||||
// top
|
// top
|
||||||
$text = new Text();
|
$text = new Text();
|
||||||
$text->text = $item->getL11n('name1')->content;
|
$text->text = $item->getL11n('name1')->content;
|
||||||
|
|
|
||||||
|
|
@ -47,13 +47,13 @@ final class Installer extends InstallerAbstract
|
||||||
{
|
{
|
||||||
parent::install($app, $info, $cfgHandler);
|
parent::install($app, $info, $cfgHandler);
|
||||||
|
|
||||||
/* Bill types */
|
/* Label layouts */
|
||||||
$fileContent = \file_get_contents(__DIR__ . '/Install/layouts.json');
|
$fileContent = \file_get_contents(__DIR__ . '/Install/layouts.json');
|
||||||
if ($fileContent === false) {
|
if ($fileContent === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var array $types */
|
/** @var array $layouts */
|
||||||
$layouts = \json_decode($fileContent, true);
|
$layouts = \json_decode($fileContent, true);
|
||||||
if ($layouts === false) {
|
if ($layouts === false) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ final class BackendController extends Controller
|
||||||
$view->setTemplate('/Modules/Labeling/Theme/Backend/layout-list');
|
$view->setTemplate('/Modules/Labeling/Theme/Backend/layout-list');
|
||||||
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005701001, $request, $response);
|
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005701001, $request, $response);
|
||||||
|
|
||||||
/** @var \Modules\Attribute\Models\AttributeType[] $attributes */
|
/** @var \Modules\Labeling\Models\LabelLayout[] $layouts */
|
||||||
$layouts = LabelLayoutMapper::getAll()
|
$layouts = LabelLayoutMapper::getAll()
|
||||||
->with('l11n')
|
->with('l11n')
|
||||||
->with('template')
|
->with('template')
|
||||||
|
|
@ -125,15 +125,16 @@ final class BackendController extends Controller
|
||||||
|
|
||||||
$view->data['item'] = $item;
|
$view->data['item'] = $item;
|
||||||
|
|
||||||
/** @var \Modules\Attribute\Models\AttributeType[] $attributes */
|
/** @var \Modules\Labeling\Models\LabelLayout[] $layout */
|
||||||
$layouts = LabelLayoutMapper::getAll()
|
$layout = LabelLayoutMapper::get()
|
||||||
->with('l11n')
|
->with('l11n')
|
||||||
->with('template')
|
->with('template')
|
||||||
->with('template/sources')
|
->with('template/sources')
|
||||||
->where('l11n/language', $response->header->l11n->language)
|
->where('l11n/language', $response->header->l11n->language)
|
||||||
|
->where('id', (int) $request->getData('id'))
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$view->data['layouts'] = $layouts;
|
$view->data['layout'] = $layout;
|
||||||
|
|
||||||
return $view;
|
return $view;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class Image
|
||||||
|
|
||||||
public string $src = '';
|
public string $src = '';
|
||||||
|
|
||||||
public $resource = null;
|
public ?\GdImage $resource = null;
|
||||||
|
|
||||||
public int $color = 0;
|
public int $color = 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,18 @@ class Label
|
||||||
|
|
||||||
public array $elements = [];
|
public array $elements = [];
|
||||||
|
|
||||||
public function render()
|
public function render() : ?\GdImage
|
||||||
{
|
{
|
||||||
$im = \imagecreatetruecolor((int) (37.8 * $this->width), (int) (37.8 * $this->height));
|
$im = \imagecreatetruecolor((int) (37.8 * $this->width), (int) (37.8 * $this->height));
|
||||||
|
if ($im === false) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$bg = \imagecolorallocatealpha($im, 255, 255, 255, 0);
|
$bg = \imagecolorallocatealpha($im, 255, 255, 255, 0);
|
||||||
|
if ($bg === false) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
\imagefill($im, 0, 0, $bg);
|
\imagefill($im, 0, 0, $bg);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -79,6 +87,9 @@ class Label
|
||||||
\imagettftext($im, $element->size, 0, $element->x, $element->y, $color, $element->font, $element->text);
|
\imagettftext($im, $element->size, 0, $element->x, $element->y, $color, $element->font, $element->text);
|
||||||
} elseif ($element instanceof Image) {
|
} elseif ($element instanceof Image) {
|
||||||
$in = $element->resource === null ? \imagecreatefrompng(__DIR__ . '/../../..' . $element->src) : $element->resource;
|
$in = $element->resource === null ? \imagecreatefrompng(__DIR__ . '/../../..' . $element->src) : $element->resource;
|
||||||
|
if ($in === false) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$srcW = \imagesx($in);
|
$srcW = \imagesx($in);
|
||||||
$srcH = \imagesy($in);
|
$srcH = \imagesy($in);
|
||||||
|
|
@ -95,6 +106,10 @@ class Label
|
||||||
$newH = (int) ($srcH * $ratio);
|
$newH = (int) ($srcH * $ratio);
|
||||||
|
|
||||||
$newIn = \imagecreatetruecolor($newW, $newH);
|
$newIn = \imagecreatetruecolor($newW, $newH);
|
||||||
|
if ($newIn === false) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
\imagecolortransparent($newIn, \imagecolorallocatealpha($newIn, 0, 0, 0, 127));
|
\imagecolortransparent($newIn, \imagecolorallocatealpha($newIn, 0, 0, 0, 127));
|
||||||
\imagealphablending($newIn, false);
|
\imagealphablending($newIn, false);
|
||||||
\imagesavealpha($newIn, true);
|
\imagesavealpha($newIn, true);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user