diff --git a/src/new/assets/images/changelog/screen1.png b/src/new/assets/images/changelog/screen1.png new file mode 100644 index 000000000..6347021c4 Binary files /dev/null and b/src/new/assets/images/changelog/screen1.png differ diff --git a/src/new/assets/images/changelog/screen2.png b/src/new/assets/images/changelog/screen2.png new file mode 100644 index 000000000..cdbaea98f Binary files /dev/null and b/src/new/assets/images/changelog/screen2.png differ diff --git a/src/new/config/bundles.php b/src/new/config/bundles.php index 85f9e742e..b14f73add 100755 --- a/src/new/config/bundles.php +++ b/src/new/config/bundles.php @@ -27,6 +27,7 @@ return [ PSC\Backend\DashboardBundle\PSCBackendDashboardBundle::class => ['all' => true], PSC\Shop\SettingsBundle\PSCShopSettingsBundle::class => ['all' => true], PSC\System\SettingsBundle\PSCSystemSettingsBundle::class => ['all' => true], + PSC\System\ContentEngineBundle\PSCSystemContentEngineBundle::class => ['all' => true], PSC\Backend\ToolsBundle\PSCBackendToolsBundle::class => ['all' => true], PSC\Shop\OrderBundle\PSCShopOrderBundle::class => ['all' => true], PSC\Shop\ContactBundle\PSCShopContactBundle::class => ['all' => true], diff --git a/src/new/config/routes.php b/src/new/config/routes.php index 476bb621b..071c47ef4 100755 --- a/src/new/config/routes.php +++ b/src/new/config/routes.php @@ -49,6 +49,8 @@ return static function (RoutingConfigurator $routingConfigurator): void { $routingConfigurator->import('@PSCSystemSettingsBundle/Resources/config/routing.yml'); + $routingConfigurator->import('@PSCSystemContentEngineBundle/Resources/config/routing.yml'); + $routingConfigurator->import('@PSCSystemUpdateBundle/Resources/config/routing.yml'); $routingConfigurator->import('@PSCShopPaymentBundle/Resources/config/routing.yml'); diff --git a/src/new/src/PSC/Shop/SettingsBundle/Resources/views/backend/settings/index.html.twig b/src/new/src/PSC/Shop/SettingsBundle/Resources/views/backend/settings/index.html.twig index b193a0a2c..3ec8cb032 100755 --- a/src/new/src/PSC/Shop/SettingsBundle/Resources/views/backend/settings/index.html.twig +++ b/src/new/src/PSC/Shop/SettingsBundle/Resources/views/backend/settings/index.html.twig @@ -2603,9 +2603,11 @@
+ {{ position.count }} {{ position.obj.priceAllNetto|number_format(2, ',', '.') }}€ diff --git a/src/new/src/PSC/System/ContentEngineBundle/Api/Config.php b/src/new/src/PSC/System/ContentEngineBundle/Api/Config.php new file mode 100644 index 000000000..0ee82c4e7 --- /dev/null +++ b/src/new/src/PSC/System/ContentEngineBundle/Api/Config.php @@ -0,0 +1,49 @@ +contentResolver->loadXml($data->module, $data->id); + + if (empty(trim($xml))) { + $xml = ''; + } + + $engine = new Engine(); + $engine->loadString($xml); + + $output = new ContentOutput(); + $output->json = $engine->generateJson(); + $output->xml = $engine->generateXML(); + + return $this->json($output); + } +} diff --git a/src/new/src/PSC/System/ContentEngineBundle/Api/Design.php b/src/new/src/PSC/System/ContentEngineBundle/Api/Design.php new file mode 100644 index 000000000..3c818a374 --- /dev/null +++ b/src/new/src/PSC/System/ContentEngineBundle/Api/Design.php @@ -0,0 +1,46 @@ +loadJson(json_encode($data->json)); + $engine->setVariables($data->values); + $engine->calc(); + + $output = new ContentOutput(); + $output->json = $engine->generateJson(); + $output->xml = $engine->generateXML(); + $output->jsonGraph = json_decode($engine->getCalcGraph()->generateJsonGraph(), true); + + return $this->json($output); + } +} diff --git a/src/new/src/PSC/System/ContentEngineBundle/Api/Preview.php b/src/new/src/PSC/System/ContentEngineBundle/Api/Preview.php new file mode 100644 index 000000000..fe90e2054 --- /dev/null +++ b/src/new/src/PSC/System/ContentEngineBundle/Api/Preview.php @@ -0,0 +1,149 @@ +loadJson(json_encode($data->json)); + $engine->setVariables($data->values); + + $output = new PreviewOutput(); + + /** @var Base $option */ + foreach ($engine->getArticle()->getOptions() as $option) { + $output->elements[] = $this->parseOption($option); + } + + return $this->json($output); + } + + private function parseOption(Base $option): Element + { + $element = new Element(); + if ($option->getName()) { + $element->name = $option->getName(); + } + $element->required = $option->isRequire(); + if (is_array($option->getRawValue())) { + $element->rawValues = $option->getRawValue(); + } else { + $element->rawValue = (string) $option->getRawValue(); + } + if ($option->getDefault()) { + $element->defaultValue = $option->getDefault(); + } + $element->value = $option->getValue(); + $element->help = $option->getHelp(); + $element->helpLink = $option->getHelpLink(); + $element->id = $option->getId(); + $element->valid = $option->isValid(); + $element->htmlType = $option->type; + $element->displayGroup = $option->getDisplayGroup(); + + if ($option->type == 'select' || $option->type == 'checkbox' || $option->type == 'radio') { + foreach ($option->getOptions() as $opt) { + $elementSelected = array_find((array) $option->getSelectedOptions(), function (Opt $o1) use ($opt) { + return $o1->getId() === $opt->getId(); + }); + + if ($option instanceof DeliverySelect) { + $tmpOpt = new Option(); + $tmpOpt->id = $opt->getId(); + $tmpOpt->name = $opt->getLabel(); + $tmpOpt->valid = $opt->isValid(); + $tmpOpt->selected = $elementSelected ? true : false; + $tmpOpt->info = $opt->getInfo(); + $tmpOpt->deliveryDate = $opt->getDeliveryDateAsString(); + } else { + $tmpOpt = new Option(); + $tmpOpt->id = $opt->getId(); + $tmpOpt->name = $opt->getLabel(); + $tmpOpt->valid = $opt->isValid(); + $tmpOpt->selected = $elementSelected ? true : false; + } + $element->options[] = $tmpOpt; + } + } + + if ($option->type == 'input') { + $element->minValue = $option->getMinValue(); + $element->maxValue = $option->getMaxValue(); + $element->placeHolder = $option->getPlaceHolder(); + $element->pattern = $option->getPattern(); + foreach ($option->getValidationErrors() as $error) { + if ($error instanceof PSCMin) { + $element->validationErrors[] = [ + 'type' => 'min', + 'value' => $element->value, + 'min' => $option->getMinValue(), + ]; + } + if ($error instanceof Max) { + $element->validationErrors[] = [ + 'type' => 'max', + 'value' => $element->value, + 'max' => $option->getMaxValue(), + ]; + } + } + } + + if ($option->type == 'row') { + foreach ($option->getColumns() as $column) { + $element->elements[] = $this->parseOption($column); + } + } + if ($option->type == 'column') { + foreach ($option->getOptions() as $opt) { + $element->elements[] = $this->parseOption($opt); + } + } + + return $element; + } + + private function parseOpt(Opt $opt, ?array $selectedOptions): Option + { + $selected = $selectedOptions ? array_find($selectedOptions, fn(Opt $o) => $o->getId() === $opt->getId()) : null; + + $option = new Option(); + $option->id = $opt->getId(); + $option->name = $opt->getLabel(); + $option->prefix = $opt->getPrefix() ?? ''; + $option->suffix = $opt->getSuffix() ?? ''; + $option->valid = $opt->isValid(); + $option->selected = $selected !== null; + + return $option; + } +} diff --git a/src/new/src/PSC/System/ContentEngineBundle/Api/Save.php b/src/new/src/PSC/System/ContentEngineBundle/Api/Save.php new file mode 100644 index 000000000..c60a3e42f --- /dev/null +++ b/src/new/src/PSC/System/ContentEngineBundle/Api/Save.php @@ -0,0 +1,34 @@ +contentResolver->saveXml($data->module, $data->id, $data->xml); + + return $this->json(['success' => true]); + } +} diff --git a/src/new/src/PSC/System/ContentEngineBundle/Api/Xml.php b/src/new/src/PSC/System/ContentEngineBundle/Api/Xml.php new file mode 100644 index 000000000..ad0bfe65e --- /dev/null +++ b/src/new/src/PSC/System/ContentEngineBundle/Api/Xml.php @@ -0,0 +1,45 @@ +loadString($data->xml); + $engine->calc(); + + $output = new ContentOutput(); + $output->json = json_decode($engine->generateJson(), true); + $output->xml = $engine->generateXML(true); + $output->jsonGraph = json_decode($engine->getCalcGraph()->generateJsonGraph(), true); + + return $this->json($output); + } +} diff --git a/src/new/src/PSC/System/ContentEngineBundle/DependencyInjection/Configuration.php b/src/new/src/PSC/System/ContentEngineBundle/DependencyInjection/Configuration.php new file mode 100644 index 000000000..993b85444 --- /dev/null +++ b/src/new/src/PSC/System/ContentEngineBundle/DependencyInjection/Configuration.php @@ -0,0 +1,18 @@ +processConfiguration($configuration, $configs); + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); + $loader->load('services.yml'); + } +} diff --git a/src/new/src/PSC/System/ContentEngineBundle/Dto/Input/ConfigInput.php b/src/new/src/PSC/System/ContentEngineBundle/Dto/Input/ConfigInput.php new file mode 100644 index 000000000..6e66a94a6 --- /dev/null +++ b/src/new/src/PSC/System/ContentEngineBundle/Dto/Input/ConfigInput.php @@ -0,0 +1,14 @@ +resolveEntity($module, $id); + + return match ($module) { + 'cms' => $entity->getText() ?? '', + default => throw new \InvalidArgumentException("Unknown module: $module"), + }; + } + + public function saveXml(string $module, int $id, string $xml): void + { + $entity = $this->resolveEntity($module, $id); + + match ($module) { + 'cms' => $entity->setText($xml), + default => throw new \InvalidArgumentException("Unknown module: $module"), + }; + + $this->entityManager->persist($entity); + $this->entityManager->flush(); + } + + private function resolveEntity(string $module, int $id): object + { + $entity = match ($module) { + 'cms' => $this->entityManager->getRepository(Cms::class)->find($id), + default => throw new \InvalidArgumentException("Unknown module: $module"), + }; + + if (!$entity) { + throw new \RuntimeException("Entity not found for module '$module' with id '$id'"); + } + + return $entity; + } +} diff --git a/src/new/src/PSC/System/SettingsBundle/Resources/views/backend/version/changelog.html.twig b/src/new/src/PSC/System/SettingsBundle/Resources/views/backend/version/changelog.html.twig index 608795f39..4d20a9323 100644 --- a/src/new/src/PSC/System/SettingsBundle/Resources/views/backend/version/changelog.html.twig +++ b/src/new/src/PSC/System/SettingsBundle/Resources/views/backend/version/changelog.html.twig @@ -35,13 +35,28 @@ {{ entry.datum }} -