diff --git a/system/modules/multicolumnwizard/MultiColumnWizard.php b/system/modules/multicolumnwizard/MultiColumnWizard.php index de9a1fb..39b1abf 100644 --- a/system/modules/multicolumnwizard/MultiColumnWizard.php +++ b/system/modules/multicolumnwizard/MultiColumnWizard.php @@ -409,6 +409,8 @@ public function generate() foreach ($this->columnFields as $strKey => $arrField) { + $fullName = $this->strName . '__' . $strKey; + // Store unique fields if ($arrField['eval']['unique']) { diff --git a/system/modules/multicolumnwizard/config/autoload.php b/system/modules/multicolumnwizard/config/autoload.php index de7ce75..0d839bf 100644 --- a/system/modules/multicolumnwizard/config/autoload.php +++ b/system/modules/multicolumnwizard/config/autoload.php @@ -2,21 +2,25 @@ /** * Contao Open Source CMS - * + * * Copyright (C) 2005-2013 Leo Feyer - * + * * @package Multicolumnwizard * @link https://contao.org * @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL */ - /** * Register the classes */ ClassLoader::addClasses(array ( - 'MultiColumnWizardHelper' => 'system/modules/multicolumnwizard/MultiColumnWizardHelper.php', - 'MultiColumnWizard' => 'system/modules/multicolumnwizard/MultiColumnWizard.php', - 'MenAtWork\MultiColumnWizard\Event\GetOptionsEvent' => 'system/modules/multicolumnwizard/src/Event/GetOptionsEvent.php', + // Basic classes. + 'MultiColumnWizardHelper' => 'system/modules/multicolumnwizard/MultiColumnWizardHelper.php', + 'MultiColumnWizard' => 'system/modules/multicolumnwizard/MultiColumnWizard.php', + // Src Folder - MAW (Deprecated) + 'MenAtWork\MultiColumnWizard\Event\GetOptionsEvent' => 'system/modules/multicolumnwizard/src/MenAtWork/Event/GetOptionsEvent.php', + // Src Folder - MCW + 'MultiColumnWizard\Event\GetOptionsEvent' => 'system/modules/multicolumnwizard/src/MultiColumnWizard/Event/GetOptionsEvent.php', + 'MultiColumnWizard\DcGeneral\UpdateDataDefinition' => 'system/modules/multicolumnwizard/src/MultiColumnWizard/DcGeneral/UpdateDataDefinition.php', )); diff --git a/system/modules/multicolumnwizard/config/event_listeners.php b/system/modules/multicolumnwizard/config/event_listeners.php new file mode 100644 index 0000000..694387a --- /dev/null +++ b/system/modules/multicolumnwizard/config/event_listeners.php @@ -0,0 +1,23 @@ + array( + array( + array(new UpdateDataDefinition(), 'addMcwFields'), + UpdateDataDefinition::PRIORITY + ) + ) +); \ No newline at end of file diff --git a/system/modules/multicolumnwizard/src/MenAtWork/Event/GetOptionsEvent.php b/system/modules/multicolumnwizard/src/MenAtWork/Event/GetOptionsEvent.php new file mode 100644 index 0000000..d2fdb85 --- /dev/null +++ b/system/modules/multicolumnwizard/src/MenAtWork/Event/GetOptionsEvent.php @@ -0,0 +1,23 @@ + + * @copyright CyberSpectrum 2014 + * @package MultiColumnWizard + * @license LGPL-3+ + * @filesource + */ + +namespace MenAtWork\MultiColumnWizard\Event; + +/** + * This event is fired when a MultiColumnWizard wants to retrieve the options for a sub widget in dc-general context. + * + * @deprecated Use the \MultiColumnWizard\Event\GetOptionsEvent class. + */ +class GetOptionsEvent extends \MultiColumnWizard\Event\GetOptionsEvent +{ + +} diff --git a/system/modules/multicolumnwizard/src/MultiColumnWizard/DcGeneral/UpdateDataDefinition.php b/system/modules/multicolumnwizard/src/MultiColumnWizard/DcGeneral/UpdateDataDefinition.php new file mode 100644 index 0000000..d3fc425 --- /dev/null +++ b/system/modules/multicolumnwizard/src/MultiColumnWizard/DcGeneral/UpdateDataDefinition.php @@ -0,0 +1,131 @@ +getContainer(); + $properties = $container->getPropertiesDefinition(); + + /** @var DefaultProperty $property */ + foreach ($properties as $property) { + // Only run for mcw. + if ('multiColumnWizard' !== $property->getWidgetType()) { + continue; + } + + // Get the extra and make an own field from it. + $config = $property->getExtra(); + + // If we have no data here, go to the next. + if(empty($config['columnFields']) || !is_array($config['columnFields'])){ + continue; + } + + foreach ($config['columnFields'] as $fieldKey => $fieldConfig) { + // Build the default name. + $name = sprintf('%s__%s', $property->getName(), $fieldKey); + + // Make a new field and fill it with the data from the config. + $subProperty = new DefaultProperty($name); + foreach ($fieldConfig as $key => $value) { + switch ($key) { + case 'label': + $subProperty->setLabel($value); + break; + + case 'description': + if (!$subProperty->getDescription()) { + $subProperty->setDescription($value); + } + break; + + case 'default': + if (!$subProperty->getDefaultValue()) { + $subProperty->setDefaultValue($value); + } + break; + + case 'exclude': + $subProperty->setExcluded((bool)$value); + break; + + case 'search': + $subProperty->setSearchable((bool)$value); + break; + + case 'filter': + $subProperty->setFilterable((bool)$value); + break; + + case 'inputType': + $subProperty->setWidgetType($value); + break; + + case 'options': + $subProperty->setOptions($value); + break; + + case 'explanation': + $subProperty->setExplanation($value); + break; + + case 'eval': + $subProperty->setExtra( + array_merge( + (array) $subProperty->getExtra(), + (array) $value + ) + ); + break; + + case 'reference': + $subProperty->setExtra( + array_merge( + (array) $subProperty->getExtra(), + array('reference' => &$value['reference']) + ) + ); + break; + + default: + } + } + + // Add all to the current list. + $properties->addProperty($subProperty); + } + } + + } +} \ No newline at end of file diff --git a/system/modules/multicolumnwizard/src/Event/GetOptionsEvent.php b/system/modules/multicolumnwizard/src/MultiColumnWizard/Event/GetOptionsEvent.php similarity index 98% rename from system/modules/multicolumnwizard/src/Event/GetOptionsEvent.php rename to system/modules/multicolumnwizard/src/MultiColumnWizard/Event/GetOptionsEvent.php index 54dd43d..15ba58a 100644 --- a/system/modules/multicolumnwizard/src/Event/GetOptionsEvent.php +++ b/system/modules/multicolumnwizard/src/MultiColumnWizard/Event/GetOptionsEvent.php @@ -1,4 +1,5 @@