src/Document/Areabrick/Wysiwyg.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Document\Areabrick;
  3. use Pimcore\Extension\Document\Areabrick\EditableDialogBoxConfiguration;
  4. use Pimcore\Extension\Document\Areabrick\EditableDialogBoxInterface;
  5. use Pimcore\Model\Document\Editable;
  6. use Pimcore\Model\Document\Editable\Area\Info;
  7. use Pimcore\Translation\Translator;
  8. class Wysiwyg extends BaseAreabrick implements EditableDialogBoxInterface
  9. {
  10.     public function __construct(Translator $translator)
  11.     {
  12.         $this->translator = $translator;
  13.     }
  14.     public function getName(): string
  15.     {
  16.         return $this->translator->trans('WYSIWYG Area', [], 'admin');
  17.     }
  18.     public function action(Info $info): void
  19.     {
  20.         $enableAccordion = $info->getEditable('enable_accordion');
  21.         if ($enableAccordion && $enableAccordion->getValue()) {
  22.             
  23.             // Pass the style to the view
  24.             $accordionStyle = $info->getEditable('accordion_style');
  25.             $style = $accordionStyle ? $accordionStyle->getData() : 'default';
  26.             $info->setParam('accordionStyle', $style);
  27.         }
  28.     }
  29.     public function getEditableDialogBoxConfiguration(Editable $area, ?Info $info): EditableDialogBoxConfiguration
  30.     {
  31.         $config = new EditableDialogBoxConfiguration();
  32.         $config->setWidth(800);
  33.         $config->setHeight(500);
  34.         $config->setItems([
  35.             'type' => 'panel',
  36.             'title' => $this->translator->trans('WYSIWYG Settings', [], 'admin'),
  37.             'items' => [
  38.                 [
  39.                     'type' => 'fieldset',
  40.                     'title' => $this->translator->trans('Layout Settings', [], 'admin'),
  41.                     'collapsible' => false,
  42.                     'items' => [
  43.                         [
  44.                             'type' => 'checkbox',
  45.                             'name' => 'enable_accordion',
  46.                             'label' => $this->translator->trans('Als Akkordeon darstellen', [], 'admin'),
  47.                             'description' => $this->translator->trans('Zeigt den Inhalt als aufklappbares Akkordeon an', [], 'admin')
  48.                         ],
  49.                         [
  50.                             'type' => 'input',
  51.                             'name' => 'accordion_title',
  52.                             'label' => $this->translator->trans('Akkordeon Titel', [], 'admin'),
  53.                             'description' => $this->translator->trans('Titel für das Akkordeon (optional)', [], 'admin'),
  54.                             'conditions' => [
  55.                                 'visible' => [
  56.                                     'type' => 'editableRenderer',
  57.                                     'config' => [
  58.                                         'renderlet' => 'enable_accordion',
  59.                                         'operator' => '==',
  60.                                         'value' => true
  61.                                     ]
  62.                                 ]
  63.                             ]
  64.                         ],
  65.                         [
  66.                             'type' => 'select',
  67.                             'name' => 'title_font_size',
  68.                             'label' => $this->translator->trans('Titel Schriftgröße', [], 'admin'),
  69.                             'config' => [
  70.                                 'defaultValue' => 'default',
  71.                                 'store' => [
  72.                                     ['default', $this->translator->trans('Standard (16px)', [], 'admin')],
  73.                                     ['small', $this->translator->trans('Klein (14px)', [], 'admin')],
  74.                                     ['medium', $this->translator->trans('Mittel (18px)', [], 'admin')],
  75.                                     ['large', $this->translator->trans('Groß (20px)', [], 'admin')],
  76.                                     ['xlarge', $this->translator->trans('Sehr Groß (24px)', [], 'admin')]
  77.                                 ]
  78.                             ],
  79.                             'conditions' => [
  80.                                 'visible' => [
  81.                                     'type' => 'editableRenderer',
  82.                                     'config' => [
  83.                                         'renderlet' => 'enable_accordion',
  84.                                         'operator' => '==',
  85.                                         'value' => true
  86.                                     ]
  87.                                 ]
  88.                             ]
  89.                         ],
  90.                         [
  91.                             'type' => 'select',
  92.                             'name' => 'accordion_style',
  93.                             'label' => $this->translator->trans('Akkordeon Style', [], 'admin'),
  94.                             'config' => [
  95.                                 'defaultValue' => 'minimal',
  96.                                 'store' => [
  97.                                     ['minimal', $this->translator->trans('Minimal', [], 'admin')],
  98.                                     ['card', $this->translator->trans('Card', [], 'admin')],
  99.                                     ['bordered', $this->translator->trans('Bordered', [], 'admin')]
  100.                                 ]
  101.                             ],
  102.                             'conditions' => [
  103.                                 'visible' => [
  104.                                     'type' => 'editableRenderer',
  105.                                     'config' => [
  106.                                         'renderlet' => 'enable_accordion',
  107.                                         'operator' => '==',
  108.                                         'value' => true
  109.                                     ]
  110.                                 ]
  111.                             ]
  112.                         ],
  113.                         [
  114.                             'type' => 'checkbox',
  115.                             'name' => 'single_expansion',
  116.                             'label' => $this->translator->trans('Einzelmodus', [], 'admin'),
  117.                             'description' => $this->translator->trans('Nur ein Akkordeon kann gleichzeitig geöffnet sein', [], 'admin'),
  118.                             'conditions' => [
  119.                                 'visible' => [
  120.                                     'type' => 'editableRenderer',
  121.                                     'config' => [
  122.                                         'renderlet' => 'enable_accordion',
  123.                                         'operator' => '==',
  124.                                         'value' => true
  125.                                     ]
  126.                                 ]
  127.                             ]
  128.                         ],
  129.                         [
  130.                             'type' => 'checkbox',
  131.                             'name' => 'initially_expanded',
  132.                             'label' => $this->translator->trans('Initial geöffnet', [], 'admin'),
  133.                             'description' => $this->translator->trans('Akkordeon ist beim Laden der Seite bereits geöffnet', [], 'admin'),
  134.                             'conditions' => [
  135.                                 'visible' => [
  136.                                     'type' => 'editableRenderer',
  137.                                     'config' => [
  138.                                         'renderlet' => 'enable_accordion',
  139.                                         'operator' => '==',
  140.                                         'value' => true
  141.                                     ]
  142.                                 ]
  143.                             ]
  144.                         ]
  145.                     ]
  146.                 ]
  147.             ]
  148.         ]);
  149.         $config->setReloadOnClose(true);
  150.         return $config;
  151.     }
  152.     public function getHtmlTagOpen(Info $info): string
  153.     {
  154.         return '';
  155.     }
  156.     public function getHtmlTagClose(Info $info): string
  157.     {
  158.         return '';
  159.     }
  160. }