diff --git a/assets/css/be_main.css b/assets/css/be_main.css index 8a4220b..2e4bea9 100644 --- a/assets/css/be_main.css +++ b/assets/css/be_main.css @@ -1,16 +1,35 @@ fieldset.collapsed fieldset, -fieldset.collapsed p.rsce_list_description { +fieldset.collapsed p.rsce_list_description, +fieldset.collapsed p.rsce_group_description { display: none !important; } +fieldset.rsce_group_no_legend { + padding-top: 0; + border-top: 0; +} +fieldset.rsce_group_no_legend:last-of-type { + padding-bottom: 0 +} +.rsce_list_item fieldset.rsce_list, +.rsce_list_item fieldset.rsce_group { + margin: 0; +} +.rsce_list_item fieldset.rsce_group:last-of-type:not(.collapsed) { + padding-bottom: 0; +} fieldset.rsce_list { position: relative; - margin-top: 26px; padding-right: 10px; - padding-bottom: 0; +} +.rsce_list_inner { + margin-bottom: -12px; } p.rsce_list_description { margin: 5px 10px 10px; } +p.rsce_group_description { + margin: 5px 0; +} .rsce_list_item { position: relative; display: inline-block; diff --git a/config/autoload.php b/config/autoload.php index 23921fe..8dc9d66 100644 --- a/config/autoload.php +++ b/config/autoload.php @@ -22,11 +22,13 @@ 'MadeYourDay\\Contao\\Widget\\ListStop' => 'system/modules/rocksolid-custom-elements/src/MadeYourDay/Contao/Widget/ListStop.php', 'MadeYourDay\\Contao\\Widget\\ListItemStart' => 'system/modules/rocksolid-custom-elements/src/MadeYourDay/Contao/Widget/ListItemStart.php', 'MadeYourDay\\Contao\\Widget\\ListItemStop' => 'system/modules/rocksolid-custom-elements/src/MadeYourDay/Contao/Widget/ListItemStop.php', + 'MadeYourDay\\Contao\\Widget\\GroupStart' => 'system/modules/rocksolid-custom-elements/src/MadeYourDay/Contao/Widget/GroupStart.php', 'MadeYourDay\\Contao\\Widget\\Hidden' => 'system/modules/rocksolid-custom-elements/src/MadeYourDay/Contao/Widget/Hidden.php', )); TemplateLoader::addFiles(array( 'be_rsce_list' => 'system/modules/rocksolid-custom-elements/templates', + 'be_rsce_group' => 'system/modules/rocksolid-custom-elements/templates', 'be_rsce_hidden' => 'system/modules/rocksolid-custom-elements/templates', 'be_rsce_convert' => 'system/modules/rocksolid-custom-elements/templates', )); diff --git a/config/config.php b/config/config.php index be11bf1..a99f580 100644 --- a/config/config.php +++ b/config/config.php @@ -18,6 +18,7 @@ $GLOBALS['BE_FFL']['rsce_list_stop'] = 'MadeYourDay\\Contao\\Widget\\ListStop'; $GLOBALS['BE_FFL']['rsce_list_item_start'] = 'MadeYourDay\\Contao\\Widget\\ListItemStart'; $GLOBALS['BE_FFL']['rsce_list_item_stop'] = 'MadeYourDay\\Contao\\Widget\\ListItemStop'; +$GLOBALS['BE_FFL']['rsce_group_start'] = 'MadeYourDay\\Contao\\Widget\\GroupStart'; $GLOBALS['BE_FFL']['rsce_list_hidden'] = 'MadeYourDay\\Contao\\Widget\\Hidden'; $GLOBALS['TL_MAINTENANCE'][] = 'MadeYourDay\\Contao\\CustomElementsConvert'; diff --git a/src/MadeYourDay/Contao/CustomElements.php b/src/MadeYourDay/Contao/CustomElements.php index f635e07..edf30a4 100644 --- a/src/MadeYourDay/Contao/CustomElements.php +++ b/src/MadeYourDay/Contao/CustomElements.php @@ -436,6 +436,9 @@ protected function createDca($dc, $type, $createFromPost = false, $tmpField = nu */ protected function createDcaItem($fieldPrefix, $fieldName, $fieldConfig, &$paletteFields, $dc, $createFromPost) { + if (!is_string($fieldConfig) && !is_array($fieldConfig)) { + throw new \Exception('Field config must be of type array or string.'); + } if (strpos($fieldName, '__') !== false) { throw new \Exception('Field name must not include "__" (' . $this->getDcaFieldValue($dc, 'type') . ': ' . $fieldName . ').'); } @@ -446,6 +449,17 @@ protected function createDcaItem($fieldPrefix, $fieldName, $fieldConfig, &$palet throw new \Exception('Field name must not start or end with "_" (' . $this->getDcaFieldValue($dc, 'type') . ': ' . $fieldName . ').'); } + if (!is_string($fieldName)) { + $fieldName = 'unnamed_' . $fieldName; + } + + if (is_string($fieldConfig)) { + $fieldConfig = array( + 'inputType' => 'group', + 'label' => array($fieldConfig, ''), + ); + } + if (isset($fieldConfig['label'])) { $fieldConfig['label'] = static::getLabelTranslated($fieldConfig['label']); } @@ -464,7 +478,7 @@ protected function createDcaItem($fieldPrefix, $fieldName, $fieldConfig, &$palet $hasFields = false; foreach ($fieldConfig['fields'] as $fieldConfig2) { - if ($fieldConfig2['inputType'] !== 'list') { + if (isset($fieldConfig2['inputType']) && $fieldConfig2['inputType'] !== 'list') { $hasFields = true; } } @@ -543,6 +557,14 @@ protected function createDcaItem($fieldPrefix, $fieldName, $fieldConfig, &$palet } + } + else if ($fieldConfig['inputType'] === 'group') { + + $fieldConfig['inputType'] = 'rsce_group_start'; + + $GLOBALS['TL_DCA'][$dc->table]['fields'][$fieldPrefix . $fieldName] = $fieldConfig; + $paletteFields[] = $fieldPrefix . $fieldName; + } else { @@ -790,8 +812,17 @@ protected static function generatePalette($table, array $paletteFields = array() } } - $palette .= ';{rsce_legend},'; - $palette .= implode(',', $paletteFields); + if ( + isset($paletteFields[0]) + && $paletteFields[0] !== 'rsce_data' + && isset($GLOBALS['TL_DCA'][$table]['fields'][$paletteFields[0]]['inputType']) + && $GLOBALS['TL_DCA'][$table]['fields'][$paletteFields[0]]['inputType'] !== 'rsce_group_start' + && $GLOBALS['TL_DCA'][$table]['fields'][$paletteFields[0]]['inputType'] !== 'rsce_list_start' + ) { + $palette .= ';{rsce_legend}'; + } + + $palette .= ',' . implode(',', $paletteFields); if ($table === 'tl_content' && in_array('image', $standardFields)) { $palette .= ';{image_legend},addImage'; diff --git a/src/MadeYourDay/Contao/Widget/GroupStart.php b/src/MadeYourDay/Contao/Widget/GroupStart.php new file mode 100644 index 0000000..3076534 --- /dev/null +++ b/src/MadeYourDay/Contao/Widget/GroupStart.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace MadeYourDay\Contao\Widget; + +/** + * Group start widget + * + * @author Martin Auswöger + */ +class GroupStart extends \Widget +{ + /** + * @var boolean Submit user input + */ + protected $blnSubmitInput = false; + + /** + * @var string Template + */ + protected $strTemplate = 'be_rsce_group'; + + /** + * Generate the widget and return it as string + * + * @return string + */ + public function generate() + { + $this->loadLanguageFile('rocksolid_custom_elements'); + + $fs = $this->Session->get('fieldset_states'); + + return '' + . '
' + . '' + . '' . $this->strLabel + . '' + . ($this->description ? '

' . $this->description . '

' : ''); + } +} diff --git a/src/MadeYourDay/Contao/Widget/ListItemStart.php b/src/MadeYourDay/Contao/Widget/ListItemStart.php index 429a5f0..7f93751 100644 --- a/src/MadeYourDay/Contao/Widget/ListItemStart.php +++ b/src/MadeYourDay/Contao/Widget/ListItemStart.php @@ -48,6 +48,7 @@ public function generate() . (empty($this->arrConfiguration['tl_class']) ? '' : ' ' . $this->arrConfiguration['tl_class']) . '" data-rsce-name="' . $fieldName . '">' . ($this->strLabel ? '
' . $this->strLabel . '
' : '') - . $toolbar; + . $toolbar + . '
'; } } diff --git a/src/MadeYourDay/Contao/Widget/ListItemStop.php b/src/MadeYourDay/Contao/Widget/ListItemStop.php index 754e94a..1af6ae6 100644 --- a/src/MadeYourDay/Contao/Widget/ListItemStop.php +++ b/src/MadeYourDay/Contao/Widget/ListItemStop.php @@ -32,6 +32,6 @@ class ListItemStop extends \Widget */ public function generate() { - return ''; + return '
'; } } diff --git a/src/MadeYourDay/Contao/Widget/ListStart.php b/src/MadeYourDay/Contao/Widget/ListStart.php index 03c0f58..6cbbdd3 100644 --- a/src/MadeYourDay/Contao/Widget/ListStart.php +++ b/src/MadeYourDay/Contao/Widget/ListStart.php @@ -41,7 +41,8 @@ public function generate() $fs = $this->Session->get('fieldset_states'); - return '
' + return '' + . '
' . '' - . ''; } diff --git a/templates/be_rsce_group.html5 b/templates/be_rsce_group.html5 new file mode 100644 index 0000000..afdf2f0 --- /dev/null +++ b/templates/be_rsce_group.html5 @@ -0,0 +1,5 @@ + + +generate() ?> + +