This commit is contained in:
Thomas Peterson 2025-12-17 19:32:50 +01:00
parent 7e7628bbd3
commit 1ff03906c2
22 changed files with 478 additions and 316 deletions

View File

@ -64,10 +64,10 @@ server {
try_files $uri @sfFront; try_files $uri @sfFront;
} }
# location /w2p/ { location /w2p/ {
# proxy_pass http://tp:8080/w2p/; proxy_pass http://tp:8080/w2p/;
# proxy_temp_path /tmp/proxy; proxy_temp_path /tmp/proxy;
#} }
location @sfFront { # Symfony location @sfFront { # Symfony
if ($request_method = 'OPTIONS') { if ($request_method = 'OPTIONS') {

View File

@ -474,7 +474,7 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator;
* datetime?: array{ * datetime?: array{
* default_format?: scalar|null, // Default: "Y-m-d\\TH:i:sP" * default_format?: scalar|null, // Default: "Y-m-d\\TH:i:sP"
* default_deserialization_formats?: list<scalar|null>, * default_deserialization_formats?: list<scalar|null>,
* default_timezone?: scalar|null, // Default: "UTC" * default_timezone?: scalar|null, // Default: "Europe/Berlin"
* cdata?: scalar|null, // Default: true * cdata?: scalar|null, // Default: true
* }, * },
* array_collection?: array{ * array_collection?: array{
@ -574,7 +574,7 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator;
* datetime?: array{ * datetime?: array{
* default_format?: scalar|null, // Default: "Y-m-d\\TH:i:sP" * default_format?: scalar|null, // Default: "Y-m-d\\TH:i:sP"
* default_deserialization_formats?: list<scalar|null>, * default_deserialization_formats?: list<scalar|null>,
* default_timezone?: scalar|null, // Default: "UTC" * default_timezone?: scalar|null, // Default: "Europe/Berlin"
* cdata?: scalar|null, // Default: true * cdata?: scalar|null, // Default: true
* }, * },
* array_collection?: array{ * array_collection?: array{
@ -2457,7 +2457,7 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator;
* length?: scalar|null, // Default: 5 * length?: scalar|null, // Default: 5
* width?: scalar|null, // Default: 130 * width?: scalar|null, // Default: 130
* height?: scalar|null, // Default: 50 * height?: scalar|null, // Default: 50
* font?: scalar|null, // Default: "/application/src/new/vendor/gregwar/captcha-bundle/DependencyInjection/../Generator/Font/captcha.ttf" * font?: scalar|null, // Default: "/data/www/new/vendor/gregwar/captcha-bundle/DependencyInjection/../Generator/Font/captcha.ttf"
* keep_value?: scalar|null, // Default: false * keep_value?: scalar|null, // Default: false
* charset?: scalar|null, // Default: "abcdefhjkmnprstuvwxyz23456789" * charset?: scalar|null, // Default: "abcdefhjkmnprstuvwxyz23456789"
* as_file?: scalar|null, // Default: false * as_file?: scalar|null, // Default: false

View File

@ -8,6 +8,7 @@ use LogicException;
use Port\Csv\CsvWriter; use Port\Csv\CsvWriter;
use Port\Reader\ArrayReader; use Port\Reader\ArrayReader;
use PSC\Backend\ToolsBundle\Export\Writer\ExcelWriter; use PSC\Backend\ToolsBundle\Export\Writer\ExcelWriter;
use PSC\Backend\ToolsBundle\Interfaces\ConfigurableElementInterface;
use PSC\Backend\ToolsBundle\Interfaces\ExporterInterface; use PSC\Backend\ToolsBundle\Interfaces\ExporterInterface;
use PSC\Backend\ToolsBundle\Service\ExporterRegistry; use PSC\Backend\ToolsBundle\Service\ExporterRegistry;
use PSC\Shop\EntityBundle\Entity\Contact; use PSC\Shop\EntityBundle\Entity\Contact;
@ -22,15 +23,19 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
use Symfony\Component\Validator\Constraints\Date; use Symfony\Component\Validator\Constraints\Date;
use Symfony\Component\Validator\Constraints\DateTime; use Symfony\Component\Validator\Constraints\DateTime;
class ContactExporter implements ExporterInterface class ContactExporter implements ExporterInterface, ConfigurableElementInterface
{ {
private $_formFactory = null; private $_formFactory = null;
private $_entityManager = null; private $_entityManager = null;
private $_shopService = null; private $_shopService = null;
/** @var Form */ /** @var Form */
private $_form = null; private $_form = null;
public function __construct(FormFactoryInterface $formFactory, EntityManagerInterface $entityManager, Shop $shopService)
{ public function __construct(
FormFactoryInterface $formFactory,
EntityManagerInterface $entityManager,
Shop $shopService,
) {
$this->_formFactory = $formFactory; $this->_formFactory = $formFactory;
$this->_entityManager = $entityManager; $this->_entityManager = $entityManager;
$this->_shopService = $shopService; $this->_shopService = $shopService;
@ -51,6 +56,11 @@ class ContactExporter implements ExporterInterface
public function getForm(FormBuilderInterface $builder, $form_options) public function getForm(FormBuilderInterface $builder, $form_options)
{ {
$builder->add('fotos', CheckboxType::class, ['required' => false, 'label' => 'Fotos mit exportieren?']);
$builder->add('fotosFolder', TextType::class, [
'required' => false,
'label' => 'Pfad für die Fotos z.B.: /data/www/old/data/packages/fotos/{{ media.uuid }}.{{media.extension}}',
]);
} }
public function getGroup() public function getGroup()
@ -68,9 +78,12 @@ class ContactExporter implements ExporterInterface
*/ */
public function export() public function export()
{ {
$rows = $this->_entityManager->getRepository('PSC\Shop\EntityBundle\Entity\Contact')->getContactsByShop($this->_shopService->getSelectedShop()); $formData = $this->_form->getData();
$temp = array(); $rows = $this->_entityManager
$temp[] = array( ->getRepository('PSC\Shop\EntityBundle\Entity\Contact')
->getContactsByShop($this->_shopService->getSelectedShop());
$temp = [];
$temp[] = [
'id' => 'id', 'id' => 'id',
'uid' => 'uid', 'uid' => 'uid',
'account_id' => 'account_id', 'account_id' => 'account_id',
@ -108,19 +121,21 @@ class ContactExporter implements ExporterInterface
'alternativAppendix' => 'alternativAppendix', 'alternativAppendix' => 'alternativAppendix',
'alternativ' => 'alternativ', 'alternativ' => 'alternativ',
'alternativType' => 'alternativType', 'alternativType' => 'alternativType',
'birthday' => 'birthday' 'birthday' => 'birthday',
); 'image1' => 'image1',
'image2' => 'image2',
];
foreach ($rows as $row) { foreach ($rows as $row) {
/** @var Contact $contact */ /** @var Contact $contact */
$contact = $row->getContact(); $contact = $row->getContact();
$temp[] = array( $temp[] = [
'id' => $contact->getId(), 'id' => $contact->getId(),
'uid' => $contact->getId(), 'uid' => $contact->getId(),
'account_id' => ($contact->getAccount() ? (string)$contact->getAccount()->getId() : 0), 'account_id' => $contact->getAccount() ? ((string) $contact->getAccount()->getId()) : 0,
'account_title' => ($contact->getAccount() ? (string)$contact->getAccount()->getTitle() : 0), 'account_title' => $contact->getAccount() ? ((string) $contact->getAccount()->getTitle()) : 0,
'enable' => (int)$contact->isEnable(), 'enable' => (int) $contact->isEnable(),
'locked' => (int)$contact->isLocked(), 'locked' => (int) $contact->isLocked(),
'virtual' => (int)$contact->isVirtual(), 'virtual' => (int) $contact->isVirtual(),
'username' => $contact->getUsername(), 'username' => $contact->getUsername(),
'firstname' => $contact->getFirstname(), 'firstname' => $contact->getFirstname(),
'lastname' => $contact->getLastname(), 'lastname' => $contact->getLastname(),
@ -151,15 +166,22 @@ class ContactExporter implements ExporterInterface
'alternativAppendix' => $contact->getAlternativAppendix(), 'alternativAppendix' => $contact->getAlternativAppendix(),
'alternativ' => $contact->getAlternativ(), 'alternativ' => $contact->getAlternativ(),
'alternativType' => $contact->getAlternativType(), 'alternativType' => $contact->getAlternativType(),
'birthday' => $contact->getBirthday() 'birthday' => $contact->getBirthday(),
); 'image1' => $contact->getImage1() ?? '',
'image2' => $contact->getImage2() ?? '',
];
if ($formData['fotos'] && $contact->getImage1() != '') {
$this->mediaManager->copyMediaToFolder($contact->getImage1(), $formData['fotosFolder']);
}
if ($formData['fotos'] && $contact->getImage2() != '') {
$this->mediaManager->copyMediaToFolder($contact->getImage2(), $formData['fotosFolder']);
}
} }
$reader = new ArrayReader($temp); $reader = new ArrayReader($temp);
$writer = new CsvWriter(); $writer = new CsvWriter();
$writer->setStream(fopen('php://output', 'w')); $writer->setStream(fopen('php://output', 'w'));
$response = new StreamedResponse(function () use ($reader, $writer) { $response = new StreamedResponse(function () use ($reader, $writer) {
foreach ($reader as $row) { foreach ($reader as $row) {
$writer->writeItem($row); $writer->writeItem($row);
} }

View File

@ -4,19 +4,25 @@ namespace PSC\Backend\ToolsBundle\Exporter\Excel;
use Doctrine\ODM\MongoDB\DocumentManager; use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use MongoDB\BSON\ObjectId;
use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PSC\Backend\ToolsBundle\Interfaces\ConfigurableElementInterface;
use PSC\Backend\ToolsBundle\Interfaces\ExporterInterface; use PSC\Backend\ToolsBundle\Interfaces\ExporterInterface;
use PSC\Backend\ToolsBundle\Service\ExporterRegistry; use PSC\Backend\ToolsBundle\Service\ExporterRegistry;
use PSC\Shop\EntityBundle\Document\Contact as PSCContact; use PSC\Shop\EntityBundle\Document\Contact as PSCContact;
use PSC\Shop\EntityBundle\Entity\Contact; use PSC\Shop\EntityBundle\Entity\Contact;
use PSC\Shop\MediaBundle\Document\Media;
use PSC\Shop\MediaBundle\Service\MediaManager;
use PSC\System\SettingsBundle\Service\Shop; use PSC\System\SettingsBundle\Service\Shop;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Form; use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\BinaryFileResponse;
class ContactExporter implements ExporterInterface class ContactExporter implements ExporterInterface, ConfigurableElementInterface
{ {
/** @var Form */ /** @var Form */
private $_form = null; private $_form = null;
@ -25,6 +31,7 @@ class ContactExporter implements ExporterInterface
private FormFactoryInterface $formFactory, private FormFactoryInterface $formFactory,
private EntityManagerInterface $entityManager, private EntityManagerInterface $entityManager,
private DocumentManager $mongoManager, private DocumentManager $mongoManager,
private MediaManager $mediaManager,
private Shop $shopService, private Shop $shopService,
) {} ) {}
@ -43,6 +50,11 @@ class ContactExporter implements ExporterInterface
public function getForm(FormBuilderInterface $builder, $form_options) public function getForm(FormBuilderInterface $builder, $form_options)
{ {
$builder->add('fotos', CheckboxType::class, ['required' => false, 'label' => 'Fotos mit exportieren?']);
$builder->add('fotosFolder', TextType::class, [
'required' => false,
'label' => 'Pfad für die Fotos z.B.: /data/www/old/data/packages/fotos/{{ media.uuid }}.{{media.extension}}',
]);
} }
public function getGroup() public function getGroup()
@ -60,6 +72,7 @@ class ContactExporter implements ExporterInterface
*/ */
public function export() public function export()
{ {
$formData = $this->_form->getData();
$rows = $this->entityManager $rows = $this->entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Contact') ->getRepository('PSC\Shop\EntityBundle\Entity\Contact')
->getContactsByShop($this->shopService->getSelectedShop()); ->getContactsByShop($this->shopService->getSelectedShop());
@ -128,6 +141,8 @@ class ContactExporter implements ExporterInterface
'custom22' => $shop->getCustomerFieldName22(), 'custom22' => $shop->getCustomerFieldName22(),
'custom23' => $shop->getCustomerFieldName23(), 'custom23' => $shop->getCustomerFieldName23(),
'custom24' => $shop->getCustomerFieldName24(), 'custom24' => $shop->getCustomerFieldName24(),
'image1' => 'image1',
'image2' => 'image2',
]; ];
foreach ($rows as $row) { foreach ($rows as $row) {
/** @var Contact $contact */ /** @var Contact $contact */
@ -200,9 +215,17 @@ class ContactExporter implements ExporterInterface
'custom22' => $contactDoc ? $contactDoc->getCustom22() : '', 'custom22' => $contactDoc ? $contactDoc->getCustom22() : '',
'custom23' => $contactDoc ? $contactDoc->getCustom23() : '', 'custom23' => $contactDoc ? $contactDoc->getCustom23() : '',
'custom24' => $contactDoc ? $contactDoc->getCustom24() : '', 'custom24' => $contactDoc ? $contactDoc->getCustom24() : '',
'image1' => $contact->getImage1() ?? '',
'image2' => $contact->getImage2() ?? '',
]; ];
}
if ($formData['fotos'] && $contact->getImage1() != '') {
$this->mediaManager->copyMediaToFolder($contact->getImage1(), $formData['fotosFolder']);
}
if ($formData['fotos'] && $contact->getImage2() != '') {
$this->mediaManager->copyMediaToFolder($contact->getImage2(), $formData['fotosFolder']);
}
}
$spreadsheet = new Spreadsheet(); $spreadsheet = new Spreadsheet();
$spreadsheet->getActiveSheet()->fromArray( $spreadsheet->getActiveSheet()->fromArray(

View File

@ -2,15 +2,15 @@
namespace PSC\Backend\ToolsBundle\Exporter\Excel; namespace PSC\Backend\ToolsBundle\Exporter\Excel;
require_once(__DIR__ . '/../../../../Shop/EntityBundle/Lagacy/TP_Basket_Item.php'); require_once __DIR__ . '/../../../../Shop/EntityBundle/Lagacy/TP_Basket_Item.php';
use Doctrine\ODM\MongoDB\DocumentManager; use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PSC\Backend\ToolsBundle\Interfaces\ConfigurableElementInterface;
use PSC\Backend\ToolsBundle\Interfaces\ExporterInterface; use PSC\Backend\ToolsBundle\Interfaces\ExporterInterface;
use PSC\Backend\ToolsBundle\Service\ExporterRegistry; use PSC\Backend\ToolsBundle\Service\ExporterRegistry;
use PSC\Backend\ToolsBundle\Interfaces\ConfigurableElementInterface;
use PSC\Library\Calc\Engine; use PSC\Library\Calc\Engine;
use PSC\Library\Calc\PaperContainer; use PSC\Library\Calc\PaperContainer;
use PSC\Shop\EntityBundle\Document\Position; use PSC\Shop\EntityBundle\Document\Position;
@ -25,24 +25,31 @@ use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\BinaryFileResponse;
class PositionExporter implements ExporterInterface, ConfigurableElementInterface class PositionExporter implements ExporterInterface, ConfigurableElementInterface
{ {
private $_formFactory = null; private $_formFactory = null;
private $_entityManager = null; private $_entityManager = null;
private $_securityContext = null; private $_securityContext = null;
private $_shopService = null; private $_shopService = null;
/** @var Form */ /** @var Form */
private $_form = null; private $_form = null;
/** /**
* @var PaperDB * @var PaperDB
*/ */
private PaperDB $_paperDbService; private PaperDB $_paperDbService;
/** /**
* @var DocumentManager * @var DocumentManager
*/ */
private DocumentManager $_mongoDb; private DocumentManager $_mongoDb;
function __construct(FormFactoryInterface $formFactory, EntityManagerInterface $entityManager, Shop $shopService, PaperDB $paperDbService, DocumentManager $mongodb)
{ function __construct(
FormFactoryInterface $formFactory,
EntityManagerInterface $entityManager,
Shop $shopService,
PaperDB $paperDbService,
DocumentManager $mongodb,
) {
$this->_formFactory = $formFactory; $this->_formFactory = $formFactory;
$this->_entityManager = $entityManager; $this->_entityManager = $entityManager;
$this->_shopService = $shopService; $this->_shopService = $shopService;
@ -68,8 +75,8 @@ class PositionExporter implements ExporterInterface, ConfigurableElementInterfac
$builder->add('product', EntityType::class, array( $builder->add('product', EntityType::class, array(
'class' => Product::class, 'class' => Product::class,
'query_builder' => function (EntityRepository $er) { 'query_builder' => function (EntityRepository $er) {
return $er
return $er->createQueryBuilder('g') ->createQueryBuilder('g')
->andWhere('g.shop = :shop and g.originalProduct = 0') ->andWhere('g.shop = :shop and g.originalProduct = 0')
->setParameter('shop', $this->_shopService->getSelectedShop()->getUid()) ->setParameter('shop', $this->_shopService->getSelectedShop()->getUid())
->orderBy('g.title', 'ASC'); ->orderBy('g.title', 'ASC');
@ -77,11 +84,15 @@ class PositionExporter implements ExporterInterface, ConfigurableElementInterfac
'choice_label' => 'title', 'choice_label' => 'title',
'required' => false, 'required' => false,
'placeholder' => 'Alle', 'placeholder' => 'Alle',
'label' => 'Vorgänger' 'label' => 'Vorgänger',
));
$builder->add('from', DateType::class, array('label' => 'Von', 'attr' => array('class' => 'form-element')));
$builder->add('to', DateType::class, array('label' => 'Bis', 'attr' => array('class' => 'form-element')));
$builder->add('calc_options', TextType::class, array(
'label' => 'Kalkulationsoptionen (auflage,papier)',
'required' => false,
'attr' => array('class' => 'form-element'),
)); ));
$builder->add("from", DateType::class, array('label' => 'Von', 'attr' => array('class' => 'form-element')));
$builder->add("to", DateType::class, array('label' => 'Bis', 'attr' => array('class' => 'form-element')));
$builder->add("calc_options", TextType::class, array('label' => 'Kalkulationsoptionen (auflage,papier)', 'required' => false, 'attr' => array('class' => 'form-element')));
} }
public function getGroup() public function getGroup()
@ -102,15 +113,17 @@ class PositionExporter implements ExporterInterface, ConfigurableElementInterfac
$formData = $this->_form->getData(); $formData = $this->_form->getData();
$orderRepository = $this->_entityManager->getRepository('PSC\Shop\EntityBundle\Entity\Orderpos'); $orderRepository = $this->_entityManager->getRepository('PSC\Shop\EntityBundle\Entity\Orderpos');
if ($formData['product'] === null) { if ($formData['product'] === null) {
$qb = $orderRepository->createQueryBuilder('o') $qb = $orderRepository
->where("o.createdDate >= :from and o.createdDate <= :to and o.shop = :shop") ->createQueryBuilder('o')
->where('o.createdDate >= :from and o.createdDate <= :to and o.shop = :shop')
->setParameter('from', $formData['from']) ->setParameter('from', $formData['from'])
->setParameter('to', $formData['to']) ->setParameter('to', $formData['to'])
->setParameter('shop', $this->_shopService->getSelectedShop()->getId()) ->setParameter('shop', $this->_shopService->getSelectedShop()->getId())
->getQuery(); ->getQuery();
} else { } else {
$qb = $orderRepository->createQueryBuilder('o') $qb = $orderRepository
->where("o.createdDate >= :from and o.createdDate <= :to and o.shop = :shop AND o.product = :product") ->createQueryBuilder('o')
->where('o.createdDate >= :from and o.createdDate <= :to and o.shop = :shop AND o.product = :product')
->setParameter('from', $formData['from']) ->setParameter('from', $formData['from'])
->setParameter('to', $formData['to']) ->setParameter('to', $formData['to'])
->setParameter('shop', $this->_shopService->getSelectedShop()->getId()) ->setParameter('shop', $this->_shopService->getSelectedShop()->getId())
@ -119,7 +132,7 @@ class PositionExporter implements ExporterInterface, ConfigurableElementInterfac
} }
$rows = $qb->getResult(); $rows = $qb->getResult();
$calcOptions = explode(",", $formData['calc_options']); $calcOptions = explode(',', $formData['calc_options']);
$data[] = array(); $data[] = array();
$temp = array( $temp = array(
'order' => 'order', 'order' => 'order',
@ -144,7 +157,7 @@ class PositionExporter implements ExporterInterface, ConfigurableElementInterfac
'productId' => 'articleId', 'productId' => 'articleId',
'productTitle' => 'articleName', 'productTitle' => 'articleName',
'weight' => 'weight', 'weight' => 'weight',
'articleName' => 'articleName' 'articleName' => 'articleName',
); );
foreach ($calcOptions as $key) { foreach ($calcOptions as $key) {
$temp[$key] = $key; $temp[$key] = $key;
@ -152,26 +165,32 @@ class PositionExporter implements ExporterInterface, ConfigurableElementInterfac
$data[] = $temp; $data[] = $temp;
$paperContainer = new PaperContainer(); $paperContainer = new PaperContainer();
$paperContainer->parse(simplexml_load_string($this->_shopService->getSelectedShop()->getInstall()->getPaperContainer())); $paperContainer->parse(simplexml_load_string(
$this->_shopService
->getSelectedShop()
->getInstall()
->getPaperContainer(),
));
$engine = new Engine(); $engine = new Engine();
$engine->setPaperRepository($this->_paperDbService); $engine->setPaperRepository($this->_paperDbService);
$engine->setPaperContainer($paperContainer); $engine->setPaperContainer($paperContainer);
if ($this->_shopService->getSelectedShop()->getInstall()->getCalcTemplates()) { if ($this->_shopService->getSelectedShop()->getInstall()->getCalcTemplates()) {
$engine->setTemplates('<root>' . $this->_shopService->getSelectedShop()->getInstall()->getCalcTemplates() . '</root>'); $engine->setTemplates('<root>' . $this->_shopService
->getSelectedShop()
->getInstall()
->getCalcTemplates() . '</root>');
} }
/** @var Orderpos $row */ /** @var Orderpos $row */
foreach ($rows as $row) { foreach ($rows as $row) {
/** @var Position $objDoc */ /** @var Position $objDoc */
$objDoc = $this->_mongoDb $objDoc = $this->_mongoDb->getRepository(Position::class)->findOneBy(['uid' => (string) $row->getId()]);
->getRepository(Position::class)
->findOneBy(['uid' => (string)$row->getId()]);
$temp = array( $temp = array(
'order' => (string)$row->getOrder()->getAlias(), 'order' => (string) $row->getOrder()->getAlias(),
'pos' => (string)$row->getPos(), 'pos' => (string) $row->getPos(),
'created' => (string)$row->getOrder()->getCreated()->format('d.m.Y H:i:s'), 'created' => (string) $row->getOrder()->getCreated()->format('d.m.Y H:i:s'),
'brutto' => (string)$row->getOrder()->getBrutto(), 'brutto' => (string) $row->getOrder()->getBrutto(),
'contact' => (string)$row->getOrder()->getContact()->getEmail(), 'contact' => (string) $row->getOrder()->getContact()->getEmail(),
'invoice_company' => $row->getOrder()->getInvoiceAddress()->getCompany(), 'invoice_company' => $row->getOrder()->getInvoiceAddress()->getCompany(),
'invoice_firstname' => $row->getOrder()->getInvoiceAddress()->getFirstname(), 'invoice_firstname' => $row->getOrder()->getInvoiceAddress()->getFirstname(),
'invoice_lastname' => $row->getOrder()->getInvoiceAddress()->getLastname(), 'invoice_lastname' => $row->getOrder()->getInvoiceAddress()->getLastname(),
@ -186,11 +205,11 @@ class PositionExporter implements ExporterInterface, ConfigurableElementInterfac
'delivery_house_number' => $row->getOrder()->getDeliveryAddress()->getHouseNumber(), 'delivery_house_number' => $row->getOrder()->getDeliveryAddress()->getHouseNumber(),
'delivery_zip' => $row->getOrder()->getDeliveryAddress()->getZip(), 'delivery_zip' => $row->getOrder()->getDeliveryAddress()->getZip(),
'delivery_city' => $row->getOrder()->getDeliveryAddress()->getCity(), 'delivery_city' => $row->getOrder()->getDeliveryAddress()->getCity(),
'productId' => (string)$row->getProduct()->getId(), 'productId' => (string) $row->getProduct()->getId(),
'productTitle' => (string)$row->getProduct()->getTitle(), 'productTitle' => (string) $row->getProduct()->getTitle(),
'weight' => (string)$row->getWeight(), 'weight' => (string) $row->getWeight(),
); );
$objPosition = unserialize(($row->getData())); $objPosition = unserialize($row->getData());
if ($row->hasCalcXml()) { if ($row->hasCalcXml()) {
$engine->loadString($row->getCalcXml()); $engine->loadString($row->getCalcXml());
$engine->setVariables($objPosition->getOptions()); $engine->setVariables($objPosition->getOptions());
@ -207,16 +226,16 @@ class PositionExporter implements ExporterInterface, ConfigurableElementInterfac
$articleCalc = new \PSC\Library\Calc\Article($objPosition->getOptions()['kalk_artikel']); $articleCalc = new \PSC\Library\Calc\Article($objPosition->getOptions()['kalk_artikel']);
$temp['articleName'] = $objPosition->getOptions()['kalk_artikel']; $temp['articleName'] = $objPosition->getOptions()['kalk_artikel'];
} else { } else {
$articleCalc = new \PSC\Library\Calc\Article("test"); $articleCalc = new \PSC\Library\Calc\Article('test');
$temp['articleName'] = ''; $temp['articleName'] = '';
} }
} }
foreach ($calcOptions as $key) { foreach ($calcOptions as $key) {
if ($articleCalc->getOptionById($key)) { if ($articleCalc->getOptionById($key)) {
$temp[$key] = (string)$articleCalc->getOptionById($key)->getValue(); $temp[$key] = (string) $articleCalc->getOptionById($key)->getValue();
} else { } else {
$temp[$key] = ""; $temp[$key] = '';
} }
} }
@ -225,11 +244,10 @@ class PositionExporter implements ExporterInterface, ConfigurableElementInterfac
$spreadsheet = new Spreadsheet(); $spreadsheet = new Spreadsheet();
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()->fromArray(
->fromArray(
$data, // The data to set $data, // The data to set
NULL, // Array values with this value will not be set null, // Array values with this value will not be set
'A1' // Top left coordinate of the worksheet range where 'A1', // Top left coordinate of the worksheet range where
// we want to set these values (default is A1) // we want to set these values (default is A1)
); );

View File

@ -87,6 +87,16 @@ class Media
return $this->variants; return $this->variants;
} }
public function getCompletePath(): string
{
return '/data/www/new/web' . $this->url;
}
public function getExtension(): string
{
return pathinfo($this->url, PATHINFO_EXTENSION);
}
public function getVariant(string $settings): Media|Variant public function getVariant(string $settings): Media|Variant
{ {
foreach ($this->variants as $variant) { foreach ($this->variants as $variant) {

View File

@ -4,21 +4,34 @@ namespace PSC\Shop\MediaBundle\Service;
use Doctrine\ODM\MongoDB\DocumentManager; use Doctrine\ODM\MongoDB\DocumentManager;
use Liip\ImagineBundle\Imagine\Cache\CacheManager; use Liip\ImagineBundle\Imagine\Cache\CacheManager;
use PSC\Shop\MediaBundle\Document\Media;
use MongoDB\BSON\ObjectId; use MongoDB\BSON\ObjectId;
use PSC\Shop\EntityBundle\Entity\Contact;
use PSC\Shop\MediaBundle\Document\Media;
use PSC\Shop\MediaBundle\Model\Media as AliasedMedia; use PSC\Shop\MediaBundle\Model\Media as AliasedMedia;
use PSC\Shop\MediaBundle\Transformer\Media as PSCMedia; use PSC\Shop\MediaBundle\Transformer\Media as PSCMedia;
use PSC\System\SettingsBundle\Document\LogEntry;
use PSC\System\SettingsBundle\Service\Log;
use PSC\System\SettingsBundle\Service\Shop;
use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
use Symfony\Component\Filesystem\Filesystem;
class MediaManager readonly class MediaManager
{ {
public function __construct(private readonly DocumentManager $mongoDb, private readonly CacheManager $cacheManager, private readonly PSCMedia $mediaTransformer) public function __construct(
{ private DocumentManager $mongoDb,
} private CacheManager $cacheManager,
private PSCMedia $mediaTransformer,
private \Twig\Environment $template,
private Filesystem $filesystem,
private Shop $shopService,
private Log $logService,
) {}
public function getMedia($id) public function getMedia($id): null|Media
{ {
/** @var Media $media */ /** @var Media $media */
$media = $this->mongoDb->getRepository('PSC\Shop\MediaBundle\Document\Media') $media = $this->mongoDb
->getRepository('PSC\Shop\MediaBundle\Document\Media')
->findOneBy(['_id' => new ObjectId($id)]); ->findOneBy(['_id' => new ObjectId($id)]);
return $media; return $media;
@ -39,4 +52,31 @@ class MediaManager
return $resolvedPath; return $resolvedPath;
} }
public function copyMediaToFolder(string $mediaId, string $folder): void
{
$media = $this->getModelByUuid($mediaId);
$folder = $this->template->createTemplate($folder);
if ($media) {
$target = $folder->render(['media' => $media]);
try {
$this->filesystem->mkdir(\dirname($target));
$this->filesystem->copy($media->getCompletePath(), $target, true);
} catch (IOExceptionInterface $e) {
$this->logService->createLogEntry(
$this->shopService->getSelectedShop(),
new Contact(),
LogEntry::INFO,
self::class,
$media->getUUId(),
'copy error',
[
'from' => $media->getCompletePath(),
'to' => $target,
],
);
}
}
}
} }

View File

@ -5,15 +5,15 @@ namespace Plugin\Custom\PSC\FormBuilder\Controller\Backend;
use Gesdinet\JWTRefreshTokenBundle\Generator\RefreshTokenGeneratorInterface; use Gesdinet\JWTRefreshTokenBundle\Generator\RefreshTokenGeneratorInterface;
use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenManagerInterface; use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenManagerInterface;
use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface; use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Bridge\Twig\Attribute\Template; use Symfony\Bridge\Twig\Attribute\Template;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
#[Route('/product')] #[Route('/product')]
class ProductController extends AbstractController class ProductController extends AbstractController
{ {
#[Template('@PluginCustomPSCFormBuilderControllerBackend/product/edit.html.twig')] #[Template('@PluginCustomPSCFormBuilder/backend/product/edit.html.twig')]
#[IsGranted('ROLE_USER')] #[IsGranted('ROLE_USER')]
#[Route(path: '/edit', name: 'psc_plugin_formbuilder_edit')] #[Route(path: '/edit', name: 'psc_plugin_formbuilder_edit')]
public function edit( public function edit(

View File

@ -1,15 +1,6 @@
<?php <?php
/**
* PrintshopCreator Suite namespace Plugin\Custom\PSC\FormLayouter\Controller\Backend;
*
* PHP Version 5.3
*
* @author Thomas Peterson <info@thomas-peterson.de>
* @copyright 2012-2013 PrintshopCreator GmbH
* @license Private
* @link http://www.printshopcreator.de
*/
namespace Plugin\System\PSC\FormLayouter\Controller\Backend;
use Doctrine\ODM\MongoDB\DocumentManager; use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
@ -19,32 +10,37 @@ use PSC\Shop\EntityBundle\Entity\Account;
use PSC\Shop\EntityBundle\Entity\Product; use PSC\Shop\EntityBundle\Entity\Product;
use PSC\Shop\EntityBundle\Entity\Stockbooking; use PSC\Shop\EntityBundle\Entity\Stockbooking;
use PSC\Shop\ProductBundle\Form\Backend\ProductType; use PSC\Shop\ProductBundle\Form\Backend\ProductType;
use Symfony\Bridge\Twig\Attribute\Template;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bridge\Twig\Attribute\Template;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class XmlController extends AbstractController class XmlController extends AbstractController
{ {
#[Template]
#[Template()]
#[Route(path: '/xml/edit/{uuid}', name: 'psc_plugin_formlayouter_backend_xml_edit')] #[Route(path: '/xml/edit/{uuid}', name: 'psc_plugin_formlayouter_backend_xml_edit')]
public function editAction(Request $request, \PSC\System\SettingsBundle\Service\Shop $shopService, DocumentManager $documentManager, EntityManagerInterface $entityManager, $uuid) public function editAction(
{ Request $request,
\PSC\System\SettingsBundle\Service\Shop $shopService,
DocumentManager $documentManager,
EntityManagerInterface $entityManager,
$uuid,
) {
$selectedShop = $shopService->getSelectedShop(); $selectedShop = $shopService->getSelectedShop();
/** @var Product $product */ /** @var Product $product */
$product = $entityManager $product = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Product')->findOneBy(array('uuid' => $uuid, 'shop' => $selectedShop)); ->getRepository('PSC\Shop\EntityBundle\Entity\Product')
->findOneBy(['uuid' => $uuid, 'shop' => $selectedShop]);
/** @var \PSC\Shop\EntityBundle\Document\Product $productDoc */ /** @var \PSC\Shop\EntityBundle\Document\Product $productDoc */
$productDoc = $documentManager $productDoc = $documentManager
->getRepository('PSC\Shop\EntityBundle\Document\Product') ->getRepository('PSC\Shop\EntityBundle\Document\Product')
->findOneBy(array('uid' => (string)$product->getUid())); ->findOneBy(['uid' => (string) $product->getUid()]);
$data = ['uuid' => $product->getUUid(), 'xml' => $productDoc->getPluginSettingModule('formlayouter', 'xml')]; $data = ['uuid' => $product->getUUid(), 'xml' => $productDoc->getPluginSettingModule('formlayouter', 'xml')];
@ -54,14 +50,14 @@ class XmlController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData(); $data = $form->getData();
dump($data);
$productDoc->setPluginSettingModule('formlayouter', 'xml', $data['xml']); $productDoc->setPluginSettingModule('formlayouter', 'xml', $data['xml']);
$documentManager->persist($productDoc); $documentManager->persist($productDoc);
$documentManager->flush(); $documentManager->flush();
} }
return array( return [
'form' => $form->createView(), 'form' => $form->createView(),
'product' => $product 'product' => $product,
); ];
} }
} }

View File

@ -1,5 +1,6 @@
<?php <?php
namespace Plugin\System\PSC\FormLayouter\Controller;
namespace Plugin\Custom\PSC\FormLayouter\Controller;
use Doctrine\ODM\MongoDB\DocumentManager; use Doctrine\ODM\MongoDB\DocumentManager;
use MongoDB\BSON\ObjectId; use MongoDB\BSON\ObjectId;
@ -12,7 +13,6 @@ use Symfony\Component\Routing\Annotation\Route;
#[Route('/image')] #[Route('/image')]
class ImageController extends AbstractController class ImageController extends AbstractController
{ {
#[Route('/info/{id}', name: 'psc_plugin_formlayouter_image_info')] #[Route('/info/{id}', name: 'psc_plugin_formlayouter_image_info')]
public function infoAction(Request $request, DocumentManager $documentManager, $id) public function infoAction(Request $request, DocumentManager $documentManager, $id)
{ {
@ -28,15 +28,14 @@ class ImageController extends AbstractController
'width' => $image->getCropWidth(), 'width' => $image->getCropWidth(),
'height' => $image->getCropHeight(), 'height' => $image->getCropHeight(),
'x' => $image->getCropX(), 'x' => $image->getCropX(),
'y' => $image->getCropY() 'y' => $image->getCropY(),
] ],
]); ]);
} }
#[Route('/original/{id}/{width}/{height}', name: 'psc_plugin_formlayouter_image_original')] #[Route('/original/{id}/{width}/{height}', name: 'psc_plugin_formlayouter_image_original')]
public function imageAction(Request $request, DocumentManager $documentManager, $id, $width = 400, $height = 400) public function imageAction(Request $request, DocumentManager $documentManager, $id, $width = 400, $height = 400)
{ {
$width = round($width); $width = round($width);
$height = round($height); $height = round($height);
@ -45,29 +44,32 @@ class ImageController extends AbstractController
->getRepository('Plugin\System\PSC\FormLayouter\Document\Image') ->getRepository('Plugin\System\PSC\FormLayouter\Document\Image')
->findOneBy(['_id' => new ObjectId($id)]); ->findOneBy(['_id' => new ObjectId($id)]);
$outfilename = "temp/".md5($id); $outfilename = 'temp/' . md5($id);
$im = new \imagick("/data/www/new/web/market/motive/" . $image->getFileName()); $im = new \imagick('/data/www/new/web/market/motive/' . $image->getFileName());
if($im->getImageWidth() < $width) { if ($im->getImageWidth() < $width) {
$width = $im->getImageWidth(); $width = $im->getImageWidth();
} }
$im->setResolution(300,300); $im->setResolution(300, 300);
$im->thumbnailimage($width, $height, true); $im->thumbnailimage($width, $height, true);
$im->writeimage($outfilename.".png"); $im->writeimage($outfilename . '.png');
$response = new Response(); $response = new Response();
$response->headers->set('Cache-Control', 'private'); $response->headers->set('Cache-Control', 'private');
$response->headers->set('Content-type', mime_content_type($outfilename.".png")); $response->headers->set('Content-type', mime_content_type($outfilename . '.png'));
$response->headers->set('Content-Disposition', 'attachment; filename="' . basename($outfilename.".png") . '"'); $response->headers->set(
'Content-Disposition',
'attachment; filename="' . basename($outfilename . '.png') . '"',
);
$response->sendHeaders(); $response->sendHeaders();
$response->setContent(readfile($outfilename.".png")); $response->setContent(readfile($outfilename . '.png'));
unlink($outfilename); unlink($outfilename);
return $response; return $response;
} }
} }

View File

@ -1,5 +1,6 @@
<?php <?php
namespace Plugin\System\PSC\FormLayouter\Controller;
namespace Plugin\Custom\PSC\FormLayouter\Controller;
use Doctrine\ODM\MongoDB\DocumentManager; use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
@ -14,23 +15,27 @@ use Symfony\Component\HttpFoundation\Response;
#[Route('/pdf')] #[Route('/pdf')]
class PdfController extends AbstractController class PdfController extends AbstractController
{ {
#[Route('/pdf/preview/{productId}', name: 'psc_plugin_formlayouter_pdf_preview')] #[Route('/pdf/preview/{productId}', name: 'psc_plugin_formlayouter_pdf_preview')]
public function previewAction(Request $request, EntityManagerInterface $entityManager, DocumentManager $documentManager, Layouter $formLayouter, Pdf $renderer, $productId) public function previewAction(
{ Request $request,
EntityManagerInterface $entityManager,
DocumentManager $documentManager,
Layouter $formLayouter,
Pdf $renderer,
$productId,
) {
/** @var Product $product */ /** @var Product $product */
$product = $entityManager $product = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Product') ->getRepository('PSC\Shop\EntityBundle\Entity\Product')
->findOneBy(array('uuid' => $productId)); ->findOneBy(['uuid' => $productId]);
/** @var \PSC\Shop\EntityBundle\Document\Product $productDoc */ /** @var \PSC\Shop\EntityBundle\Document\Product $productDoc */
$productDoc = $documentManager $productDoc = $documentManager
->getRepository('PSC\Shop\EntityBundle\Document\Product') ->getRepository('PSC\Shop\EntityBundle\Document\Product')
->findOneBy(array('uid' => (string)$product->getUid())); ->findOneBy(['uid' => (string) $product->getUid()]);
$session = new FormLayouter(); $session = new FormLayouter();
if($request->getSession()->has('formlayouter')) { if ($request->getSession()->has('formlayouter')) {
$session = $request->getSession()->get('formlayouter'); $session = $request->getSession()->get('formlayouter');
} }
@ -38,10 +43,10 @@ class PdfController extends AbstractController
$config = $formLayouter->getConfig(); $config = $formLayouter->getConfig();
$outfilename = "temp/".uniqid().".pdf"; $outfilename = 'temp/' . uniqid() . '.pdf';
$session = new FormLayouter(); $session = new FormLayouter();
if($request->getSession()->has('formlayouter')) { if ($request->getSession()->has('formlayouter')) {
$session = $request->getSession()->get('formlayouter'); $session = $request->getSession()->get('formlayouter');
} }
@ -63,25 +68,29 @@ class PdfController extends AbstractController
unlink($outfilename); unlink($outfilename);
return $response; return $response;
} }
#[Route('/pdf/print/{productId}', name: 'psc_plugin_formlayouter_pdf_print')] #[Route('/pdf/print/{productId}', name: 'psc_plugin_formlayouter_pdf_print')]
public function printAction(Request $request, EntityManagerInterface $entityManager, DocumentManager $documentManager, Layouter $formLayouter, Pdf $renderer, $productId) public function printAction(
{ Request $request,
EntityManagerInterface $entityManager,
DocumentManager $documentManager,
Layouter $formLayouter,
Pdf $renderer,
$productId,
) {
/** @var Product $product */ /** @var Product $product */
$product = $entityManager $product = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Product') ->getRepository('PSC\Shop\EntityBundle\Entity\Product')
->findOneBy(array('uuid' => $productId)); ->findOneBy(['uuid' => $productId]);
/** @var \PSC\Shop\EntityBundle\Document\Product $productDoc */ /** @var \PSC\Shop\EntityBundle\Document\Product $productDoc */
$productDoc = $documentManager $productDoc = $documentManager
->getRepository('PSC\Shop\EntityBundle\Document\Product') ->getRepository('PSC\Shop\EntityBundle\Document\Product')
->findOneBy(array('uid' => (string)$product->getUid())); ->findOneBy(['uid' => (string) $product->getUid()]);
$session = new FormLayouter(); $session = new FormLayouter();
if($request->getSession()->has('formlayouter')) { if ($request->getSession()->has('formlayouter')) {
$session = $request->getSession()->get('formlayouter'); $session = $request->getSession()->get('formlayouter');
} }
@ -89,10 +98,10 @@ class PdfController extends AbstractController
$config = $formLayouter->getConfig(); $config = $formLayouter->getConfig();
$outfilename = "temp/".uniqid().".pdf"; $outfilename = 'temp/' . uniqid() . '.pdf';
$session = new FormLayouter(); $session = new FormLayouter();
if($request->getSession()->has('formlayouter')) { if ($request->getSession()->has('formlayouter')) {
$session = $request->getSession()->get('formlayouter'); $session = $request->getSession()->get('formlayouter');
} }
@ -113,6 +122,6 @@ class PdfController extends AbstractController
unlink($outfilename); unlink($outfilename);
return $response; return $response;
} }
} }

View File

@ -1,5 +1,6 @@
<?php <?php
namespace Plugin\System\PSC\FormLayouter\Controller;
namespace Plugin\Custom\PSC\FormLayouter\Controller;
use Doctrine\ODM\MongoDB\DocumentManager; use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
@ -14,26 +15,33 @@ use Symfony\Component\HttpFoundation\Response;
#[Route('/preview')] #[Route('/preview')]
class PreviewController extends AbstractController class PreviewController extends AbstractController
{ {
#[Route('/image/{productId}/{site}/{width}/{height}', name: 'psc_plugin_formlayouter_preview_image')] #[Route('/image/{productId}/{site}/{width}/{height}', name: 'psc_plugin_formlayouter_preview_image')]
public function imageAction(Request $request, EntityManagerInterface $entityManager, DocumentManager $documentManager, Layouter $formLayouter, Pdf $renderer, $productId, $site = 1, $width = 400, $height = 900) public function imageAction(
{ Request $request,
EntityManagerInterface $entityManager,
DocumentManager $documentManager,
Layouter $formLayouter,
Pdf $renderer,
$productId,
$site = 1,
$width = 400,
$height = 900,
) {
$width = round($width); $width = round($width);
$height = round($height); $height = round($height);
/** @var Product $product */ /** @var Product $product */
$product = $entityManager $product = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Product') ->getRepository('PSC\Shop\EntityBundle\Entity\Product')
->findOneBy(array('uuid' => $productId)); ->findOneBy(['uuid' => $productId]);
/** @var \PSC\Shop\EntityBundle\Document\Product $productDoc */ /** @var \PSC\Shop\EntityBundle\Document\Product $productDoc */
$productDoc = $documentManager $productDoc = $documentManager
->getRepository('PSC\Shop\EntityBundle\Document\Product') ->getRepository('PSC\Shop\EntityBundle\Document\Product')
->findOneBy(array('uid' => (string)$product->getUid())); ->findOneBy(['uid' => (string) $product->getUid()]);
$session = new FormLayouter(); $session = new FormLayouter();
if($request->getSession()->has('formlayouter')) { if ($request->getSession()->has('formlayouter')) {
$session = $request->getSession()->get('formlayouter'); $session = $request->getSession()->get('formlayouter');
} }
@ -42,10 +50,10 @@ class PreviewController extends AbstractController
$actSite = $formLayouter->getSite($site); $actSite = $formLayouter->getSite($site);
$config = $formLayouter->getConfig(); $config = $formLayouter->getConfig();
$outfilename = "temp/".uniqid().".pdf"; $outfilename = 'temp/' . uniqid() . '.pdf';
$session = new FormLayouter(); $session = new FormLayouter();
if($request->getSession()->has('formlayouter')) { if ($request->getSession()->has('formlayouter')) {
$session = $request->getSession()->get('formlayouter'); $session = $request->getSession()->get('formlayouter');
} }
@ -58,87 +66,100 @@ class PreviewController extends AbstractController
$im->setCompressionQuality(89); $im->setCompressionQuality(89);
$im->setResolution(300,300); $im->setResolution(300, 300);
$im->readImage($outfilename."[0]"); $im->readImage($outfilename . '[0]');
$im->thumbnailimage($width, $height, true); $im->thumbnailimage($width, $height, true);
$im->mergeImageLayers(\imagick::LAYERMETHOD_FLATTEN); $im->mergeImageLayers(\imagick::LAYERMETHOD_FLATTEN);
// $im->setImageAlphaChannel(\imagick::ALPHACHANNEL_REMOVE); // $im->setImageAlphaChannel(\imagick::ALPHACHANNEL_REMOVE);
$im->writeimage($outfilename.".jpeg"); $im->writeimage($outfilename . '.jpeg');
unlink($outfilename); unlink($outfilename);
$response = new Response(); $response = new Response();
$response->headers->set('Cache-Control', 'private'); $response->headers->set('Cache-Control', 'private');
$response->headers->set('Content-type', mime_content_type($outfilename.".jpeg")); $response->headers->set('Content-type', mime_content_type($outfilename . '.jpeg'));
$response->headers->set('Content-Disposition', 'attachment; filename="' . basename($outfilename.".jpeg") . '"'); $response->headers->set(
'Content-Disposition',
'attachment; filename="' . basename($outfilename . '.jpeg') . '"',
);
$response->sendHeaders(); $response->sendHeaders();
$response->setContent(readfile($outfilename.".jpeg")); $response->setContent(readfile($outfilename . '.jpeg'));
unlink($outfilename.".jpeg"); unlink($outfilename . '.jpeg');
return $response; return $response;
} }
#[Route('/layouter/{layouterId}/{site}/{width}/{height}', name: 'psc_plugin_formlayouter_preview_layouter')] #[Route('/layouter/{layouterId}/{site}/{width}/{height}', name: 'psc_plugin_formlayouter_preview_layouter')]
public function layouterAction(Request $request, EntityManagerInterface $entityManager, DocumentManager $documentManager, Layouter $formLayouter, Pdf $renderer, $layouterId, $site = 1, $width = 400, $height = 900) public function layouterAction(
{ Request $request,
EntityManagerInterface $entityManager,
DocumentManager $documentManager,
Layouter $formLayouter,
Pdf $renderer,
$layouterId,
$site = 1,
$width = 400,
$height = 900,
) {
$width = round($width); $width = round($width);
$height = round($height); $height = round($height);
/** @var Layoutdesigndata $layoutDesignData */ /** @var Layoutdesigndata $layoutDesignData */
$layoutDesignData = $entityManager $layoutDesignData = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Layoutdesigndata')->findOneBy(array('uuid' => $layouterId)); ->getRepository('PSC\Shop\EntityBundle\Entity\Layoutdesigndata')
->findOneBy(['uuid' => $layouterId]);
/** @var Product $product */ /** @var Product $product */
$product = $documentManager $product = $documentManager
->getRepository('PSC\Shop\EntityBundle\Entity\Product') ->getRepository('PSC\Shop\EntityBundle\Entity\Product')
->findOneBy(array('uuid' => $layoutDesignData->getArticleUuid())); ->findOneBy(['uuid' => $layoutDesignData->getArticleUuid()]);
/** @var \PSC\Shop\EntityBundle\Document\Product $productDoc */ /** @var \PSC\Shop\EntityBundle\Document\Product $productDoc */
$productDoc = $documentManager $productDoc = $documentManager
->getRepository('PSC\Shop\EntityBundle\Document\Product') ->getRepository('PSC\Shop\EntityBundle\Document\Product')
->findOneBy(array('uid' => (string)$product->getUid())); ->findOneBy(['uid' => (string) $product->getUid()]);
$formLayouter->setXml($productDoc->getPluginSetting('formlayouter', 'xml')); $formLayouter->setXml($productDoc->getPluginSetting('formlayouter', 'xml'));
$actSite = $formLayouter->getSite($site); $actSite = $formLayouter->getSite($site);
$config = $formLayouter->getConfig(); $config = $formLayouter->getConfig();
$outfilename = "temp/".uniqid().".pdf"; $outfilename = 'temp/' . uniqid() . '.pdf';
$renderer->setSite($actSite); $renderer->setSite($actSite);
$renderer->setConfig($config); $renderer->setConfig($config);
$renderer->setOptions($layoutDesignData->getDesign()); $renderer->setOptions($layoutDesignData->getDesign());
$renderer->renderStep($outfilename); $renderer->renderStep($outfilename);
$im = new \imagick($outfilename."[0]"); $im = new \imagick($outfilename . '[0]');
if($im->getImageWidth() < $width) { if ($im->getImageWidth() < $width) {
$width = $im->getImageWidth(); $width = $im->getImageWidth();
} }
$im->setResolution(300,300); $im->setResolution(300, 300);
$im->thumbnailimage($width, $height, true); $im->thumbnailimage($width, $height, true);
$im->writeimage($outfilename.".png"); $im->writeimage($outfilename . '.png');
unlink($outfilename); unlink($outfilename);
$response = new Response(); $response = new Response();
$response->headers->set('Cache-Control', 'private'); $response->headers->set('Cache-Control', 'private');
$response->headers->set('Content-type', mime_content_type($outfilename.".png")); $response->headers->set('Content-type', mime_content_type($outfilename . '.png'));
$response->headers->set('Content-Disposition', 'attachment; filename="' . basename($outfilename.".png") . '"'); $response->headers->set(
'Content-Disposition',
'attachment; filename="' . basename($outfilename . '.png') . '"',
);
$response->sendHeaders(); $response->sendHeaders();
$response->setContent(readfile($outfilename.".png")); $response->setContent(readfile($outfilename . '.png'));
unlink($outfilename.".png"); unlink($outfilename . '.png');
return $response; return $response;
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Plugin\System\PSC\FormLayouter\Controller;
namespace Plugin\Custom\PSC\FormLayouter\Controller;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Plugin\System\PSC\FormLayouter\Session\FormLayouter; use Plugin\System\PSC\FormLayouter\Session\FormLayouter;
@ -12,19 +12,17 @@ use Symfony\Component\Routing\Annotation\Route;
#[Route('/store')] #[Route('/store')]
class StoreController extends AbstractController class StoreController extends AbstractController
{ {
#[Route('/save', name: 'psc_plugin_formlayouter_store_save')] #[Route('/save', name: 'psc_plugin_formlayouter_store_save')]
public function saveAction(Request $request, EntityManagerInterface $entityManager) public function saveAction(Request $request, EntityManagerInterface $entityManager)
{ {
$uuid = $request->get('layouter');
$uuid = $request->get("layouter"); $articleUuid = $request->get('article');
$articleUuid = $request->get("article");
$layoutDesignData = new Layoutdesigndata(); $layoutDesignData = new Layoutdesigndata();
$layoutDesignData->setUuid($uuid); $layoutDesignData->setUuid($uuid);
$layoutDesignData->setArticleUuid($articleUuid); $layoutDesignData->setArticleUuid($articleUuid);
$session = new FormLayouter(); $session = new FormLayouter();
if($request->getSession()->has('formlayouter')) { if ($request->getSession()->has('formlayouter')) {
$session = $request->getSession()->get('formlayouter'); $session = $request->getSession()->get('formlayouter');
} }
$layoutDesignData->setDesign($session->getOptions($articleUuid)); $layoutDesignData->setDesign($session->getOptions($articleUuid));
@ -33,7 +31,7 @@ class StoreController extends AbstractController
$entityManager->flush(); $entityManager->flush();
$json = new JsonResponse(); $json = new JsonResponse();
$json->setContent(json_encode(array('success' => true))); $json->setContent(json_encode(['success' => true]));
return $json; return $json;
} }
@ -41,16 +39,15 @@ class StoreController extends AbstractController
#[Route('/update', name: 'psc_plugin_formlayouter_store_update')] #[Route('/update', name: 'psc_plugin_formlayouter_store_update')]
public function updateAction(Request $request, EntityManagerInterface $entityManager) public function updateAction(Request $request, EntityManagerInterface $entityManager)
{ {
$uuid = $request->get('layouter');
$uuid = $request->get("layouter"); $articleUuid = $request->get('article');
$articleUuid = $request->get("article");
$layoutDesignData = $entityManager $layoutDesignData = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Layoutdesigndata')->findOneBy(array('uuid' => $uuid)); ->getRepository('PSC\Shop\EntityBundle\Entity\Layoutdesigndata')
->findOneBy(['uuid' => $uuid]);
$session = new FormLayouter(); $session = new FormLayouter();
if($request->getSession()->has('formlayouter')) { if ($request->getSession()->has('formlayouter')) {
$session = $request->getSession()->get('formlayouter'); $session = $request->getSession()->get('formlayouter');
} }
@ -60,8 +57,9 @@ class StoreController extends AbstractController
$entityManager->flush(); $entityManager->flush();
$json = new JsonResponse(); $json = new JsonResponse();
$json->setContent(json_encode(array('success' => true))); $json->setContent(json_encode(['success' => true]));
return $json; return $json;
} }
} }

View File

@ -1,5 +1,6 @@
<?php <?php
namespace Plugin\System\PSC\FormLayouter\Controller;
namespace Plugin\Custom\PSC\FormLayouter\Controller;
use Doctrine\ODM\MongoDB\DocumentManager; use Doctrine\ODM\MongoDB\DocumentManager;
use Gaufrette\Filesystem; use Gaufrette\Filesystem;
@ -19,36 +20,39 @@ class UploadController extends AbstractController
#[Route('/single', name: 'psc_plugin_formlayouter_upload_single')] #[Route('/single', name: 'psc_plugin_formlayouter_upload_single')]
public function singleAction(Request $request, DocumentManager $documentManager, FilesystemMap $filesystemMap) public function singleAction(Request $request, DocumentManager $documentManager, FilesystemMap $filesystemMap)
{ {
if ($request->files->has("file")) { if ($request->files->has('file')) {
$file = $request->files->get("file"); $file = $request->files->get('file');
if($file instanceof UploadedFile) { if ($file instanceof UploadedFile) {
$filename = sprintf(
'%s/%s/%s/%s.%s',
$filename = sprintf('%s/%s/%s/%s.%s', date('Y'), date('m'), date('d'), uniqid(), $file->getClientOriginalExtension()); date('Y'),
date('m'),
date('d'),
uniqid(),
$file->getClientOriginalExtension(),
);
/** @var Filesystem $fileContainer */ /** @var Filesystem $fileContainer */
$fileContainer = $filesystemMap->get('steplayouter_motiv'); $fileContainer = $filesystemMap->get('steplayouter_motiv');
if( if (
$file->getMimeType() == "image/png" || $file->getMimeType() == 'image/png' ||
$file->getMimeType() == "image/jpg" || $file->getMimeType() == 'image/jpg' ||
$file->getMimeType() == "image/jpeg" $file->getMimeType() == 'image/jpeg'
){ ) {
$filename = sprintf('%s/%s/%s/%s.%s', date('Y'), date('m'), date('d'), uniqid(), "jpg"); $filename = sprintf('%s/%s/%s/%s.%s', date('Y'), date('m'), date('d'), uniqid(), 'jpg');
$filenameTemp = sprintf('/tmp/%s.%s', uniqid(), "jpg"); $filenameTemp = sprintf('/tmp/%s.%s', uniqid(), 'jpg');
exec("convert ".$file->getPathname()." -colorspace cmyk -auto-orient ".$filenameTemp); exec('convert ' . $file->getPathname() . ' -colorspace cmyk -auto-orient ' . $filenameTemp);
$fileContainer->write($filename, file_get_contents($filenameTemp)); $fileContainer->write($filename, file_get_contents($filenameTemp));
unlink($filenameTemp); unlink($filenameTemp);
} else {
}else{
$fileContainer->write($filename, file_get_contents($file->getPathname())); $fileContainer->write($filename, file_get_contents($file->getPathname()));
} }
$image = new Image(); $image = new Image();
$image->setSessionId($request->getSession()->getId()); $image->setSessionId($request->getSession()->getId());
$image->setFileName($fileContainer->get($filename)->getKey()); $image->setFileName($fileContainer->get($filename)->getKey());
@ -93,10 +97,16 @@ class UploadController extends AbstractController
->getRepository('Plugin\System\PSC\FormLayouter\Document\Image') ->getRepository('Plugin\System\PSC\FormLayouter\Document\Image')
->findOneBy(['_id' => new ObjectId($id)]); ->findOneBy(['_id' => new ObjectId($id)]);
exec(
exec("convert /data/www/new/web/market/motive/" . $image->getFileName()." -rotate ".($request->get('rotate'))." /data/www/new/web/market/motive/" . $image->getFileName()); 'convert /data/www/new/web/market/motive/' .
$image->getFileName() .
' -rotate ' .
$request->get('rotate') .
' /data/www/new/web/market/motive/' .
$image->getFileName(),
);
return new JsonResponse(['success' => true]); return new JsonResponse(['success' => true]);
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Plugin\System\PSC\FormLayouter\Form\Field; namespace Plugin\Custom\PSC\FormLayouter\Form\Field;
use PSC\System\PluginBundle\Form\Interfaces\Field; use PSC\System\PluginBundle\Form\Interfaces\Field;
use PSC\System\SettingsBundle\Service\Status; use PSC\System\SettingsBundle\Service\Status;
@ -11,7 +11,6 @@ use Symfony\Component\Form\FormEvent;
class BackendFields extends \PSC\System\PluginBundle\Form\Field implements Field class BackendFields extends \PSC\System\PluginBundle\Form\Field implements Field
{ {
protected $tab = 'uploads'; protected $tab = 'uploads';
private $statusService; private $statusService;
@ -23,7 +22,7 @@ class BackendFields extends \PSC\System\PluginBundle\Form\Field implements Fiel
public function getTemplate() public function getTemplate()
{ {
return '@PluginSystemPSCFormLayouter/form/field/backend.html.twig'; return '@PluginCustomPSCFormLayouter/form/field/backend.html.twig';
} }
public function getModule() public function getModule()
@ -36,28 +35,25 @@ class BackendFields extends \PSC\System\PluginBundle\Form\Field implements Fiel
*/ */
public function formPreSubmit(FormEvent $event) public function formPreSubmit(FormEvent $event)
{ {
} }
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$builder->add('formlayouter', CheckboxType::class, [
$builder->add('formlayouter', CheckboxType::class, array(
'label' => 'Step Layouter aktivieren', 'label' => 'Step Layouter aktivieren',
'required' => false 'required' => false,
)) ->add("formlayouter2InitalStatus", ChoiceType::class, array( ])->add('formlayouter2InitalStatus', ChoiceType::class, [
'label' => 'Initalstatus', 'label' => 'Initalstatus',
'choices' => $this->statusService->getPositionStatusAsArray(), 'choices' => $this->statusService->getPositionStatusAsArray(),
'translation_domain' => 'posstatus' 'translation_domain' => 'posstatus',
)); ]);
return $builder; return $builder;
} }
public function getGroup() public function getGroup()
{ {
return "formlayouter"; return 'formlayouter';
} }
public function formPostSetData(FormEvent $event) public function formPostSetData(FormEvent $event)
@ -79,3 +75,4 @@ class BackendFields extends \PSC\System\PluginBundle\Form\Field implements Fiel
{ {
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Plugin\System\PSC\FormLayouter\Form\Field; namespace Plugin\Custom\PSC\FormLayouter\Form\Field;
use DirectoryIterator; use DirectoryIterator;
use Plugin\System\PSC\FormLayouter\Form\Group\FormLayouterEditor; use Plugin\System\PSC\FormLayouter\Form\Group\FormLayouterEditor;
@ -11,10 +11,9 @@ use Symfony\Component\Form\FormEvent;
class EnableEditor implements Field class EnableEditor implements Field
{ {
public function getTemplate() public function getTemplate()
{ {
return '@PluginSystemPSCFormLayouter/form/field/enable_editor.html.twig'; return '@PluginCustomPSCFormLayouter/form/field/enable_editor.html.twig';
} }
public function getModule() public function getModule()
@ -27,14 +26,12 @@ class EnableEditor implements Field
*/ */
public function formPreSubmit(FormEvent $event) public function formPreSubmit(FormEvent $event)
{ {
} }
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$txtheader = ""; $txtheader = '';
$txtfooter = ""; $txtfooter = '';
$this->options = $options; $this->options = $options;
/** @var Shop $shopEntity */ /** @var Shop $shopEntity */
@ -42,66 +39,89 @@ class EnableEditor implements Field
$tempLayouts = []; $tempLayouts = [];
if ($shopEntity->isCustomTemplates() == 1) { if ($shopEntity->isCustomTemplates() == 1) {
foreach (new DirectoryIterator('/data/www/old/application/design/vorlagen') as $file) { foreach (new DirectoryIterator('/data/www/old/application/design/vorlagen') as $file) {
if ($file == '.' || $file == '..' || $file == 'config' || $file == '.svn' || $file == 'datapacks' || $file == '.DS_Store') { if (
$file == '.' ||
$file == '..' ||
$file == 'config' ||
$file == '.svn' ||
$file == 'datapacks' ||
$file == '.DS_Store'
) {
continue; continue;
} }
$tempLayouts[$file->getFileName()] = $file->getFileName(); $tempLayouts[$file->getFileName()] = $file->getFileName();
} }
} else { } else {
if (file_exists('/data/www/old/application/design/clients/' . $shopEntity->getUID())) { if (file_exists('/data/www/old/application/design/clients/' . $shopEntity->getUID())) {
foreach (new DirectoryIterator('/data/www/old/application/design/clients/' . $shopEntity->getUID()) as $file) { foreach (new DirectoryIterator('/data/www/old/application/design/clients/' .
if ($file == '.' || $file == '..' || $file == 'config' || $file == '.svn' || $file == 'datapacks' || $file == '.DS_Store') { $shopEntity->getUID()) as $file) {
if (
$file == '.' ||
$file == '..' ||
$file == 'config' ||
$file == '.svn' ||
$file == 'datapacks' ||
$file == '.DS_Store'
) {
continue; continue;
} }
$tempLayouts[$file->getFileName()] = $file->getFileName(); $tempLayouts[$file->getFileName()] = $file->getFileName();
} }
} }
} }
if(isset($_POST["settings"]["bootstrap3Images"]["layout"])) { if (isset($_POST['settings']['bootstrap3Images']['layout'])) {
header('location: /apps/backend/theme/settings'); header('location: /apps/backend/theme/settings');
//die(); //die();
} else { } else {
if (!file_exists("/data/www/old/application/design/vorlagen/" . $shopEntity->getLayout() . "/step_layouter")) { if (
mkdir("/data/www/old/application/design/vorlagen/" . $shopEntity->getLayout() . "/step_layouter", 0777); !file_exists('/data/www/old/application/design/vorlagen/' . $shopEntity->getLayout() . '/step_layouter')
) {
mkdir(
'/data/www/old/application/design/vorlagen/' . $shopEntity->getLayout() . '/step_layouter',
0o777,
);
} }
$filenameheader = "/data/www/old/application/design/vorlagen/" . $shopEntity->getLayout() . "/step_layouter/header.html.twig"; $filenameheader =
$filenamefooter = "/data/www/old/application/design/vorlagen/" . $shopEntity->getLayout() . "/step_layouter/footer.html.twig"; '/data/www/old/application/design/vorlagen/' .
$shopEntity->getLayout() .
'/step_layouter/header.html.twig';
$filenamefooter =
'/data/www/old/application/design/vorlagen/' .
$shopEntity->getLayout() .
'/step_layouter/footer.html.twig';
if (!file_exists($filenameheader)) { if (!file_exists($filenameheader)) {
touch($filenameheader); touch($filenameheader);
chmod($filenameheader, 0777); chmod($filenameheader, 0o777);
} }
if (!file_exists($filenamefooter)) { if (!file_exists($filenamefooter)) {
touch($filenamefooter); touch($filenamefooter);
chmod($filenamefooter, 0777); chmod($filenamefooter, 0o777);
} }
$handleheader = fopen($filenameheader, 'r'); $handleheader = fopen($filenameheader, 'r');
if(filesize($filenameheader)>0) { if (filesize($filenameheader) > 0) {
$txtheader = fread($handleheader, filesize($filenameheader)); $txtheader = fread($handleheader, filesize($filenameheader));
fclose($handleheader); fclose($handleheader);
} }
$handlefooter = fopen($filenamefooter, 'r'); $handlefooter = fopen($filenamefooter, 'r');
if(filesize($filenamefooter)) { if (filesize($filenamefooter)) {
$txtfooter = fread($handlefooter, filesize($filenamefooter)); $txtfooter = fread($handlefooter, filesize($filenamefooter));
fclose($handlefooter); fclose($handlefooter);
} }
} }
$builder->add('header', TextareaType::class, [
$builder->add('header', TextareaType::class, array(
'label' => 'Header', 'label' => 'Header',
'data' => $txtheader, 'data' => $txtheader,
'required' => false, 'required' => false,
'attr' => array('rows' => 50) 'attr' => ['rows' => 50],
)) ])->add('footer', TextareaType::class, [
->add('footer', TextareaType::class, array(
'label' => 'Footer', 'label' => 'Footer',
'data' => $txtfooter, 'data' => $txtfooter,
'required' => false, 'required' => false,
'attr' => array('rows' => 50) 'attr' => ['rows' => 50],
)); ]);
;
return $builder; return $builder;
} }
@ -118,7 +138,6 @@ class EnableEditor implements Field
public function formPostSubmit(FormEvent $event) public function formPostSubmit(FormEvent $event)
{ {
} }
public function formPreSetData(FormEvent $event) public function formPreSetData(FormEvent $event)
@ -128,16 +147,23 @@ class EnableEditor implements Field
public function formSubmit(FormEvent $event) public function formSubmit(FormEvent $event)
{ {
$filename = "/data/www/old/application/design/vorlagen/" . $_POST["settings"]["bootstrap3General"]["layout"] . "/step_layouter/header.html.twig"; $filename =
'/data/www/old/application/design/vorlagen/' .
$_POST['settings']['bootstrap3General']['layout'] .
'/step_layouter/header.html.twig';
$handle = fopen($filename, 'w'); $handle = fopen($filename, 'w');
fputs($handle, $event->getForm()->get('formlayoutereditor')->get('header')->getData()); \fwrite($handle, $event->getForm()->get('formlayoutereditor')->get('header')->getData());
fclose($handle); fclose($handle);
$filename = "/data/www/old/application/design/vorlagen/" . $_POST["settings"]["bootstrap3General"]["layout"] . "/step_layouter/footer.html.twig"; $filename =
'/data/www/old/application/design/vorlagen/' .
$_POST['settings']['bootstrap3General']['layout'] .
'/step_layouter/footer.html.twig';
$handle = fopen($filename, 'w'); $handle = fopen($filename, 'w');
fputs($handle, $event->getForm()->get('formlayoutereditor')->get('footer')->getData()); \fwrite($handle, $event->getForm()->get('formlayoutereditor')->get('footer')->getData());
fclose($handle); fclose($handle);
// TODO: Implement formPostSubmit() method. // TODO: Implement formPostSubmit() method.
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Plugin\System\PSC\FormLayouter\Form; namespace Plugin\Custom\PSC\FormLayouter\Form;
use Plugin\System\PSC\FormLayouter\Model\Steps\Step; use Plugin\System\PSC\FormLayouter\Model\Steps\Step;
use Plugin\System\PSC\FormLayouter\Session\FormLayouter; use Plugin\System\PSC\FormLayouter\Session\FormLayouter;
@ -27,7 +27,6 @@ class FormDesigner extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
/** @var FormLayouter $session */ /** @var FormLayouter $session */
$session = $options['session']; $session = $options['session'];
@ -36,16 +35,16 @@ class FormDesigner extends AbstractType
/** @var Step $step */ /** @var Step $step */
$step = $options['step']; $step = $options['step'];
foreach($step->getColumns() as $column) { foreach ($step->getColumns() as $column) {
foreach($column->getOptions() as $option) { foreach ($column->getOptions() as $option) {
if($option->isInForm()) { if ($option->isInForm()) {
$option->renderForm($builder, $this->mediaManager); $option->renderForm($builder, $this->mediaManager);
} }
} }
} }
foreach($builder->all() as $opt) { foreach ($builder->all() as $opt) {
if($session->hasOption($productId, $opt->getName())) { if ($session->hasOption($productId, $opt->getName())) {
$opt->setData($session->getOption($productId, $opt->getName())); $opt->setData($session->getOption($productId, $opt->getName()));
} }
} }
@ -58,10 +57,11 @@ class FormDesigner extends AbstractType
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefaults(array( $resolver->setDefaults([
'step' => null, 'step' => null,
'session' => null, 'session' => null,
'productId' => null, 'productId' => null,
)); ]);
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Plugin\System\PSC\FormLayouter\Form\Group; namespace Plugin\Custom\PSC\FormLayouter\Form\Group;
use PSC\Shop\EntityBundle\Entity\Cms; use PSC\Shop\EntityBundle\Entity\Cms;
use PSC\System\PluginBundle\Form\Group; use PSC\System\PluginBundle\Form\Group;
@ -29,3 +29,4 @@ class FormLayouter extends Group
return self::GROUP_ID; return self::GROUP_ID;
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Plugin\System\PSC\FormLayouter\Form\Group; namespace Plugin\Custom\PSC\FormLayouter\Form\Group;
use PSC\Shop\EntityBundle\Entity\Cms; use PSC\Shop\EntityBundle\Entity\Cms;
use PSC\System\PluginBundle\Form\Group; use PSC\System\PluginBundle\Form\Group;
@ -29,3 +29,4 @@ class FormLayouterEditor extends Group
return self::GROUP_ID; return self::GROUP_ID;
} }
} }

View File

@ -1,15 +1,6 @@
<?php <?php
/**
* PrintshopCreator Suite namespace Plugin\Custom\PSC\FormLayouter\Form\XML;
*
* PHP Version 5.3
*
* @author Thomas Peterson <info@thomas-peterson.de>
* @copyright 2012-2013 PrintshopCreator GmbH
* @license Private
* @link http://www.printshopcreator.de
*/
namespace Plugin\System\PSC\FormLayouter\Form\XML;
use PSC\Libraries\AceEditorBundle\Form\Extension\AceEditorType; use PSC\Libraries\AceEditorBundle\Form\Extension\AceEditorType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
@ -22,10 +13,8 @@ class EditType extends AbstractType
{ {
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$builder $builder->add('uuid', TextType::class, ['disabled' => true])->add('xml', AceEditorType::class, [
->add('uuid', TextType::class, array('disabled' => true)) 'wrapper_attr' => [], // aceeditor wrapper html attributes.
->add('xml', AceEditorType::class, array(
'wrapper_attr' => array(), // aceeditor wrapper html attributes.
'width' => '100%', 'width' => '100%',
'height' => '500', 'height' => '500',
'font_size' => 14, 'font_size' => 14,
@ -37,9 +26,8 @@ class EditType extends AbstractType
'use_wrap_mode' => null, 'use_wrap_mode' => null,
'show_print_margin' => null, 'show_print_margin' => null,
'required' => false, 'required' => false,
'highlight_active_line' => null 'highlight_active_line' => null,
)) ])->add('save', SubmitType::class, ['label' => 'Speichern']);
->add('save', SubmitType::class, array('label' => 'Speichern'));
} }
public function getName() public function getName()
@ -49,6 +37,6 @@ class EditType extends AbstractType
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
} }
} }

View File

@ -1,5 +1,5 @@
psc_shop_plugin_custom_formlayouter_frontend: psc_shop_plugin_custom_formlayouter_frontend:
resource: "@PluginCutomPSCFormLayouter/Controller" resource: "@PluginCustomPSCFormLayouter/Controller"
type: attribute type: attribute
prefix: /plugin/formlayouter/api prefix: /plugin/formlayouter/api