autofixes

This commit is contained in:
Dennis Eichhorn 2023-08-30 12:08:10 +00:00
parent 7ae1545978
commit 57d83ba9d9
13 changed files with 248 additions and 239 deletions

View File

@ -14,7 +14,6 @@ declare(strict_types=1);
namespace Modules\Labeling\Admin\Install; namespace Modules\Labeling\Admin\Install;
use Modules\Labeling\Models\SettingsEnum;
use phpOMS\Application\ApplicationAbstract; use phpOMS\Application\ApplicationAbstract;
/** /**

View File

@ -1,9 +1,9 @@
<?php <?php declare(strict_types=1);
use Modules\Labeling\Models\Label;
use Modules\Labeling\Models\Text;
use Modules\Labeling\Models\Shape;
use Modules\Labeling\Models\Image; use Modules\Labeling\Models\Image;
use Modules\Labeling\Models\Label;
use Modules\Labeling\Models\Shape;
use Modules\Labeling\Models\Text;
use phpOMS\Utils\Barcode\Datamatrix; use phpOMS\Utils\Barcode\Datamatrix;
use phpOMS\Utils\Barcode\QR; use phpOMS\Utils\Barcode\QR;

View File

@ -20,9 +20,7 @@ use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse; use phpOMS\Message\Http\HttpResponse;
use phpOMS\Module\InstallerAbstract; use phpOMS\Module\InstallerAbstract;
use phpOMS\Module\ModuleInfo; use phpOMS\Module\ModuleInfo;
use phpOMS\System\MimeType;
use phpOMS\Uri\HttpUri; use phpOMS\Uri\HttpUri;
use phpOMS\Utils\TestUtils;
/** /**
* Installer class. * Installer class.

View File

@ -16,9 +16,9 @@ declare(strict_types=1);
namespace Modules\Labeling\Controller; namespace Modules\Labeling\Controller;
use Modules\Labeling\Models\LabelLayoutMapper;
use Modules\Labeling\Models\LabelLayout; use Modules\Labeling\Models\LabelLayout;
use Modules\Labeling\Models\LabelLayoutL11nMapper; use Modules\Labeling\Models\LabelLayoutL11nMapper;
use Modules\Labeling\Models\LabelLayoutMapper;
use Modules\Media\Models\CollectionMapper; use Modules\Media\Models\CollectionMapper;
use phpOMS\Localization\BaseStringL11n; use phpOMS\Localization\BaseStringL11n;
use phpOMS\Localization\ISO639x1Enum; use phpOMS\Localization\ISO639x1Enum;

View File

@ -17,13 +17,18 @@ namespace Modules\Labeling\Models;
class Image class Image
{ {
public int $x = 0; public int $x = 0;
public int $y = 0; public int $y = 0;
public float $ratio = 0.0; public float $ratio = 0.0;
public int $x2 = 0; public int $x2 = 0;
public int $y2 = 0; public int $y2 = 0;
public string $src = ''; public string $src = '';
public $resource = null; public $resource = null;
public int $color = 0; public int $color = 0;
} }

View File

@ -73,9 +73,7 @@ class Label
); );
} }
} elseif ($element->type === 3) { } elseif ($element->type === 3) {
} elseif ($element->type === 4) { } elseif ($element->type === 4) {
} }
} elseif ($element instanceof Text) { } elseif ($element instanceof Text) {
\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);
@ -117,7 +115,6 @@ class Label
$in = $newIn; $in = $newIn;
} }
$cut = \imagecreatetruecolor($srcW, $srcH); $cut = \imagecreatetruecolor($srcW, $srcH);
\imagecopy($cut, $im, 0, 0, $element->x, $element->y, $srcW, $srcH); \imagecopy($cut, $im, 0, 0, $element->x, $element->y, $srcW, $srcH);
@ -133,7 +130,6 @@ class Label
\imagedestroy($in); \imagedestroy($in);
\imagedestroy($cut); \imagedestroy($cut);
} else { } else {
} }
} }

View File

@ -17,13 +17,17 @@ namespace Modules\Labeling\Models;
class Shape class Shape
{ {
public int $x = 0; public int $x = 0;
public int $y = 0; public int $y = 0;
public int $x2 = 0; public int $x2 = 0;
public int $y2 = 0; public int $y2 = 0;
public int $type = ShapeType::RECTANGLE; public int $type = ShapeType::RECTANGLE;
public int $color = 0; public int $color = 0;
public int $borderThickness = 1; public int $borderThickness = 1;
public int $fillColor = -1; public int $fillColor = -1;

View File

@ -17,22 +17,29 @@ namespace Modules\Labeling\Models;
class Text class Text
{ {
public int $x = 0; public int $x = 0;
public int $y = 0; public int $y = 0;
public int $x2 = 0; public int $x2 = 0;
public int $y2 = 0; public int $y2 = 0;
public int $size = 11; public int $size = 11;
public string $font = __DIR__ . '/../../../Resources/fonts/lato/Lato-Regular.ttf'; public string $font = __DIR__ . '/../../../Resources/fonts/lato/Lato-Regular.ttf';
public string $text = ''; public string $text = '';
public int $color = 0; public int $color = 0;
// align (-1 = start, 0 = middle, 1 = end) // align (-1 = start, 0 = middle, 1 = end)
public int $alignX = -1; public int $alignX = -1;
public int $alignY = -1; public int $alignY = -1;
public bool $bold = false; public bool $bold = false;
public bool $underline = false; public bool $underline = false;
public bool $italic = false; public bool $italic = false;
} }

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
$layout = $this->data['layout']; $layout = $this->data['layout'];
$template = \reset($layout->template->sources); $template = \reset($layout->template->sources);

View File

@ -23,11 +23,11 @@ $item = $this->data['item'];
$layout = include_once $template->getAbsolutePath(); $layout = include_once $template->getAbsolutePath();
ob_start(); \ob_start();
\imagepng($layout->render()); \imagepng($layout->render());
$imageData = ob_get_clean(); $imageData = \ob_get_clean();
$imageBase64 = base64_encode($imageData); $imageBase64 = \base64_encode($imageData);
// Get the image MIME type // Get the image MIME type
$imageType = 'image/png'; // Assuming JPEG format in this example $imageType = 'image/png'; // Assuming JPEG format in this example