From 52b39c5fce0d41823a4c10785173534007a1cb51 Mon Sep 17 00:00:00 2001 From: Ralf Baussenwein Date: Tue, 7 Feb 2023 17:13:08 +0100 Subject: [PATCH 01/17] Move tl_form_field to the correct dca folder --- {dca => src/Resources/contao/dca}/tl_form_field.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {dca => src/Resources/contao/dca}/tl_form_field.php (100%) diff --git a/dca/tl_form_field.php b/src/Resources/contao/dca/tl_form_field.php similarity index 100% rename from dca/tl_form_field.php rename to src/Resources/contao/dca/tl_form_field.php From fa2ed151919e692f380bdfe04b0d0f832e65780e Mon Sep 17 00:00:00 2001 From: Ralf Baussenwein Date: Tue, 7 Feb 2023 17:20:51 +0100 Subject: [PATCH 02/17] Refactor deprecations of config tl_form_field --- src/Resources/contao/dca/tl_form_field.php | 32 +++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/Resources/contao/dca/tl_form_field.php b/src/Resources/contao/dca/tl_form_field.php index 330e068..5702705 100644 --- a/src/Resources/contao/dca/tl_form_field.php +++ b/src/Resources/contao/dca/tl_form_field.php @@ -12,18 +12,22 @@ * @author Martin Auswöger */ -if (TL_MODE === 'BE') { - $GLOBALS['TL_CSS'][] = 'system/modules/rocksolid-columns/assets/css/be_main.css'; +use Contao\System; +use MadeYourDay\RockSolidColumns\Columns; +use Symfony\Component\HttpFoundation\Request; + +if (System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest(System::getContainer()->get('request_stack')->getCurrentRequest() ?? Request::create(''))) { + $GLOBALS['TL_CSS'][] = 'bundles/rocksolidcolumns/css/be_main.css'; // Load content language file - $this->loadLanguageFile('tl_content'); + System::loadLanguageFile('tl_content'); } -$GLOBALS['TL_DCA']['tl_form_field']['config']['onsubmit_callback'][] = array('MadeYourDay\\Contao\\Columns', 'onsubmitCallback'); +$GLOBALS['TL_DCA']['tl_form_field']['config']['onsubmit_callback'][] = array(Columns::class, 'onsubmitCallback'); -$GLOBALS['TL_DCA']['tl_form_field']['palettes']['rs_columns_start'] = '{type_legend},type;{rs_columns_legend},rs_columns_xlarge,rs_columns_large,rs_columns_medium,rs_columns_small,rs_columns_xsmall,rs_columns_gutter,rs_columns_outside_gutters,rs_columns_equal_height;{expert_legend:hide},class'; -$GLOBALS['TL_DCA']['tl_form_field']['palettes']['rs_columns_stop'] = '{type_legend},type'; -$GLOBALS['TL_DCA']['tl_form_field']['palettes']['rs_column_start'] = '{type_legend},type;{rs_column_background_legend},rs_column_color_inverted,rs_column_background;{expert_legend:hide},class'; -$GLOBALS['TL_DCA']['tl_form_field']['palettes']['rs_column_stop'] = '{type_legend},type'; +$GLOBALS['TL_DCA']['tl_form_field']['palettes']['rs_columns_start'] = '{type_legend},type;{rs_columns_legend},rs_columns_xlarge,rs_columns_large,rs_columns_medium,rs_columns_small,rs_columns_xsmall,rs_columns_gutter,rs_columns_outside_gutters,rs_columns_equal_height;{expert_legend:hide},class;{invisible_legend:hide},invisible'; +$GLOBALS['TL_DCA']['tl_form_field']['palettes']['rs_columns_stop'] = '{type_legend},type;{invisible_legend:hide},invisible'; +$GLOBALS['TL_DCA']['tl_form_field']['palettes']['rs_column_start'] = '{type_legend},type;{rs_column_background_legend},rs_column_color_inverted,rs_column_background;{expert_legend:hide},class;{invisible_legend:hide},invisible'; +$GLOBALS['TL_DCA']['tl_form_field']['palettes']['rs_column_stop'] = '{type_legend},type;{invisible_legend:hide},invisible'; $GLOBALS['TL_DCA']['tl_form_field']['palettes']['__selector__'][] = 'rs_column_background'; $GLOBALS['TL_DCA']['tl_form_field']['subpalettes']['rs_column_background'] = 'rs_column_background_color,rs_column_background_image,rs_column_background_image_size,rs_column_background_size,rs_column_background_position,rs_column_background_repeat'; @@ -81,7 +85,7 @@ 'reference' => &$GLOBALS['TL_LANG']['tl_content']['rs_columns_gutters'], 'eval' => array( 'includeBlankOption' => true, - 'tl_class' => 'clr', + 'tl_class' => 'clr rs_columns_w33', ), 'sql' => "varchar(255) NOT NULL default ''", ); @@ -90,7 +94,7 @@ 'label' => &$GLOBALS['TL_LANG']['tl_content']['rs_columns_outside_gutters'], 'exclude' => true, 'eval' => array( - 'tl_class' => 'w50 m12 clr', + 'tl_class' => 'rs_columns_w33 m12', ), 'sql' => "char(1) NOT NULL default ''", ); @@ -99,7 +103,7 @@ 'label' => &$GLOBALS['TL_LANG']['tl_content']['rs_columns_equal_height'], 'exclude' => true, 'eval' => array( - 'tl_class' => 'w50 m12', + 'tl_class' => 'rs_columns_w33 m12', ), 'sql' => "char(1) NOT NULL default ''", ); @@ -147,7 +151,7 @@ 'multiple' => false, 'fieldType' => 'radio', 'filesOnly' => true, - 'extensions' => \Config::get('validImageTypes'), + 'extensions' => implode(',', System::getContainer()->getParameter('contao.image.valid_extensions')), ), 'sql' => "binary(16) NULL", ); @@ -155,7 +159,9 @@ 'label' => &$GLOBALS['TL_LANG']['tl_content']['rs_column_background_image_size'], 'exclude' => true, 'inputType' => 'imageSize', - 'options' => version_compare(VERSION, '3.4', '<') ? $GLOBALS['TL_CROP'] : System::getImageSizes(), + 'options_callback' => static function () { + return System::getContainer()->get('contao.image.sizes')->getAllOptions(); + }, 'reference' => &$GLOBALS['TL_LANG']['MSC'], 'eval' => array( 'rgxp' => 'digit', From 4d4b8d8e9b1cb046a2ea6e3fe36cc82106c8c8ba Mon Sep 17 00:00:00 2001 From: Ralf Baussenwein Date: Tue, 7 Feb 2023 17:33:15 +0100 Subject: [PATCH 03/17] Add missing translations for tl_form_field --- .../contao/languages/de/tl_form_field.php | 16 ++++++++++++++++ .../contao/languages/en/tl_form_field.php | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/Resources/contao/languages/de/tl_form_field.php create mode 100644 src/Resources/contao/languages/en/tl_form_field.php diff --git a/src/Resources/contao/languages/de/tl_form_field.php b/src/Resources/contao/languages/de/tl_form_field.php new file mode 100644 index 0000000..7236b80 --- /dev/null +++ b/src/Resources/contao/languages/de/tl_form_field.php @@ -0,0 +1,16 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * RockSolid Columns category translations + * + * @author Martin Auswöger + */ + +$GLOBALS['TL_LANG']['tl_form_field']['rs_columns_legend'] = 'Spaltenkonfiguration'; +$GLOBALS['TL_LANG']['tl_form_field']['rs_column_background_legend'] = 'Hintergrund der Spalte'; diff --git a/src/Resources/contao/languages/en/tl_form_field.php b/src/Resources/contao/languages/en/tl_form_field.php new file mode 100644 index 0000000..1c2574a --- /dev/null +++ b/src/Resources/contao/languages/en/tl_form_field.php @@ -0,0 +1,16 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * RockSolid Columns category translations + * + * @author Martin Auswöger + */ + +$GLOBALS['TL_LANG']['tl_form_field']['rs_columns_legend'] = 'Column configuration'; +$GLOBALS['TL_LANG']['tl_form_field']['rs_column_background_legend'] = 'Background of the column'; From b8f9064e1c881c3529574acccbc5f77e13e9cecc Mon Sep 17 00:00:00 2001 From: Ralf Baussenwein Date: Tue, 7 Feb 2023 17:42:12 +0100 Subject: [PATCH 04/17] Refactor class usages --- src/Resources/contao/config/config.php | 27 ++++++++++++++++--------- src/Resources/contao/dca/tl_content.php | 3 ++- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/Resources/contao/config/config.php b/src/Resources/contao/config/config.php index 24ba456..395b3c5 100644 --- a/src/Resources/contao/config/config.php +++ b/src/Resources/contao/config/config.php @@ -12,18 +12,25 @@ * @author Martin Auswöger */ -$GLOBALS['TL_HOOKS']['generatePage'][] = array('MadeYourDay\\RockSolidColumns\\Columns', 'generatePageHook'); -$GLOBALS['TL_HOOKS']['getContentElement'][] = array('MadeYourDay\\RockSolidColumns\\Columns', 'getContentElementHook'); +use MadeYourDay\Contao\Form\ColumnsWidget; +use MadeYourDay\RockSolidColumns\Columns; +use MadeYourDay\RockSolidColumns\Element\ColumnsStart; +use MadeYourDay\RockSolidColumns\Element\ColumnsStop; +use MadeYourDay\RockSolidColumns\Element\ColumnStart; +use MadeYourDay\RockSolidColumns\Element\ColumnStop; -$GLOBALS['TL_CTE']['rs_columns']['rs_columns_start'] = 'MadeYourDay\\RockSolidColumns\\Element\\ColumnsStart'; -$GLOBALS['TL_CTE']['rs_columns']['rs_columns_stop'] = 'MadeYourDay\\RockSolidColumns\\Element\\ColumnsStop'; -$GLOBALS['TL_CTE']['rs_columns']['rs_column_start'] = 'MadeYourDay\\RockSolidColumns\\Element\\ColumnStart'; -$GLOBALS['TL_CTE']['rs_columns']['rs_column_stop'] = 'MadeYourDay\\RockSolidColumns\\Element\\ColumnStop'; +$GLOBALS['TL_HOOKS']['generatePage'][] = array(Columns::class, 'generatePageHook'); +$GLOBALS['TL_HOOKS']['getContentElement'][] = array(Columns::class, 'getContentElementHook'); -$GLOBALS['TL_FFL']['rs_columns_start'] = 'MadeYourDay\\Contao\\Form\\ColumnsWidget'; -$GLOBALS['TL_FFL']['rs_columns_stop'] = 'MadeYourDay\\Contao\\Form\\ColumnsWidget'; -$GLOBALS['TL_FFL']['rs_column_start'] = 'MadeYourDay\\Contao\\Form\\ColumnsWidget'; -$GLOBALS['TL_FFL']['rs_column_stop'] = 'MadeYourDay\\Contao\\Form\\ColumnsWidget'; +$GLOBALS['TL_CTE']['rs_columns']['rs_columns_start'] = ColumnsStart::class; +$GLOBALS['TL_CTE']['rs_columns']['rs_columns_stop'] = ColumnsStop::class; +$GLOBALS['TL_CTE']['rs_columns']['rs_column_start'] = ColumnStart::class; +$GLOBALS['TL_CTE']['rs_columns']['rs_column_stop'] = ColumnStop::class; + +$GLOBALS['TL_FFL']['rs_columns_start'] = ColumnsWidget::class; +$GLOBALS['TL_FFL']['rs_columns_stop'] = ColumnsWidget::class; +$GLOBALS['TL_FFL']['rs_column_start'] = ColumnsWidget::class; +$GLOBALS['TL_FFL']['rs_column_stop'] = ColumnsWidget::class; $GLOBALS['TL_WRAPPERS']['start'][] = 'rs_columns_start'; $GLOBALS['TL_WRAPPERS']['stop'][] = 'rs_columns_stop'; diff --git a/src/Resources/contao/dca/tl_content.php b/src/Resources/contao/dca/tl_content.php index 85030a7..7d05b50 100644 --- a/src/Resources/contao/dca/tl_content.php +++ b/src/Resources/contao/dca/tl_content.php @@ -13,13 +13,14 @@ */ use Contao\System; +use MadeYourDay\RockSolidColumns\Columns; use Symfony\Component\HttpFoundation\Request; if (System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest(System::getContainer()->get('request_stack')->getCurrentRequest() ?? Request::create(''))) { $GLOBALS['TL_CSS'][] = 'bundles/rocksolidcolumns/css/be_main.css'; } -$GLOBALS['TL_DCA']['tl_content']['config']['onsubmit_callback'][] = array('MadeYourDay\\RockSolidColumns\\Columns', 'onsubmitCallback'); +$GLOBALS['TL_DCA']['tl_content']['config']['onsubmit_callback'][] = array(Columns::class, 'onsubmitCallback'); $GLOBALS['TL_DCA']['tl_content']['palettes']['rs_columns_start'] = '{type_legend},type,headline;{rs_columns_legend},rs_columns_xlarge,rs_columns_large,rs_columns_medium,rs_columns_small,rs_columns_xsmall,rs_columns_gutter,rs_columns_outside_gutters,rs_columns_equal_height;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID;{invisible_legend:hide},invisible,start,stop'; $GLOBALS['TL_DCA']['tl_content']['palettes']['rs_columns_stop'] = '{type_legend},type;{protected_legend:hide},protected;{expert_legend:hide},guests;{invisible_legend:hide},invisible,start,stop'; From fe5a425ccf3b60e70ac24e31adea32bf97c08d08 Mon Sep 17 00:00:00 2001 From: Ralf Baussenwein Date: Tue, 7 Feb 2023 17:56:21 +0100 Subject: [PATCH 05/17] Add translations for cols + background config --- .../contao/languages/en/tl_content.php | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/Resources/contao/languages/en/tl_content.php b/src/Resources/contao/languages/en/tl_content.php index 5367749..10540ea 100644 --- a/src/Resources/contao/languages/en/tl_content.php +++ b/src/Resources/contao/languages/en/tl_content.php @@ -13,9 +13,45 @@ */ $GLOBALS['TL_LANG']['tl_content']['rs_columns_legend'] = 'Column configuration'; +$GLOBALS['TL_LANG']['tl_content']['rs_columns_large'][0] = 'Desktop XL columns'; +$GLOBALS['TL_LANG']['tl_content']['rs_columns_large'][1] = 'Example: 2, 3, 1-2-1, 1-3. Max. 12 cols. Explanation: The desired number of evenly distributed columns (e.g. 3) or a statement following the syntax 1-2-1 for 3 columns with a doubled middle column. Note: Per column you\'ll need one element. Single elements aren\'t split automatically.'; $GLOBALS['TL_LANG']['tl_content']['rs_columns_large'][0] = 'Desktop columns'; -$GLOBALS['TL_LANG']['tl_content']['rs_columns_large'][1] = 'Example: 2, 3, 1-2-1, 1-3. Max. 6 cols. Explanation: The desired number of evenly distributed columns (e.g. 3) or a statement following the syntax 1-2-1 for 3 columns with a doubled middle column. Note: Per column you\'ll need one element. Single elements aren\'t split automatically.'; +$GLOBALS['TL_LANG']['tl_content']['rs_columns_large'][1] = 'Example: 2, 3, 1-2-1, 1-3. Max. 12 cols. (optional)'; $GLOBALS['TL_LANG']['tl_content']['rs_columns_medium'][0] = 'Tablet columns'; $GLOBALS['TL_LANG']['tl_content']['rs_columns_medium'][1] = 'Example: 2, instead of 1-1-2 on desktop... number and distribution of the columns for visitors with smaller resolution (optional).'; $GLOBALS['TL_LANG']['tl_content']['rs_columns_small'][0] = 'Mobile columns'; $GLOBALS['TL_LANG']['tl_content']['rs_columns_small'][1] = 'Usually 1 or 2... the distribution for even smaller screens (optional, but recommended).'; +$GLOBALS['TL_LANG']['tl_content']['rs_columns_xsmall'][0] = 'Mobile XS columns'; +$GLOBALS['TL_LANG']['tl_content']['rs_columns_xsmall'][1] = 'Usually 1 or 2... the distribution for even smaller screens (optional, but recommended).'; +$GLOBALS['TL_LANG']['tl_content']['rs_columns_gutter'][0] = 'Columns gutter'; +$GLOBALS['TL_LANG']['tl_content']['rs_columns_gutter'][1] = 'Size of the gutter between the columns.'; +$GLOBALS['TL_LANG']['tl_content']['rs_columns_gutters']['none'] = 'None'; +$GLOBALS['TL_LANG']['tl_content']['rs_columns_gutters']['s'] = 'Small'; +$GLOBALS['TL_LANG']['tl_content']['rs_columns_gutters']['m'] = 'Medium'; +$GLOBALS['TL_LANG']['tl_content']['rs_columns_gutters']['l'] = 'Large'; +$GLOBALS['TL_LANG']['tl_content']['rs_columns_outside_gutters'][0] = 'Outside gutter'; +$GLOBALS['TL_LANG']['tl_content']['rs_columns_outside_gutters'][1] = 'Inserts a space before the first and after the last column.'; +$GLOBALS['TL_LANG']['tl_content']['rs_columns_equal_height'][0] = 'Equal column height'; +$GLOBALS['TL_LANG']['tl_content']['rs_columns_equal_height'][1] = 'Creates the same height for all columns in a row.'; + +$GLOBALS['TL_LANG']['tl_content']['rs_column_background_legend'] = 'Column background'; +$GLOBALS['TL_LANG']['tl_content']['rs_column_color_inverted'][0] = 'Text color inverted'; +$GLOBALS['TL_LANG']['tl_content']['rs_column_color_inverted'][1] = 'Light text color for dark backgrounds and photos.'; +$GLOBALS['TL_LANG']['tl_content']['rs_column_background'][0] = 'Enable column background'; +$GLOBALS['TL_LANG']['tl_content']['rs_column_background'][1] = 'Creates a colored background or background graphic.'; +$GLOBALS['TL_LANG']['tl_content']['rs_column_background_color'][0] = 'Color'; +$GLOBALS['TL_LANG']['tl_content']['rs_column_background_color'][1] = 'Color of the background. Leave this field empty for a transparent background.'; +$GLOBALS['TL_LANG']['tl_content']['rs_column_background_image'][0] = 'Image'; +$GLOBALS['TL_LANG']['tl_content']['rs_column_background_image'][1] = 'Background image.'; +$GLOBALS['TL_LANG']['tl_content']['rs_column_background_image_size'][0] = 'Image width and height'; +$GLOBALS['TL_LANG']['tl_content']['rs_column_background_image_size'][1] = 'Here you can set the dimensions of the image and the scaling mode.'; +$GLOBALS['TL_LANG']['tl_content']['rs_column_background_size'][0] = 'Background size'; +$GLOBALS['TL_LANG']['tl_content']['rs_column_background_size'][1] = 'Image display size.'; +$GLOBALS['TL_LANG']['tl_content']['rs_column_background_sizes']['cover'] = 'Cropped'; +$GLOBALS['TL_LANG']['tl_content']['rs_column_background_sizes']['contain'] = 'Proportional'; +$GLOBALS['TL_LANG']['tl_content']['rs_column_background_sizes']['100% 100%'] = 'Distorted'; +$GLOBALS['TL_LANG']['tl_content']['rs_column_background_sizes']['auto auto'] = 'Original size'; +$GLOBALS['TL_LANG']['tl_content']['rs_column_background_position'][0] = 'Background position'; +$GLOBALS['TL_LANG']['tl_content']['rs_column_background_position'][1] = 'Position of the background.'; +$GLOBALS['TL_LANG']['tl_content']['rs_column_background_repeat'][0] = 'Background repeat'; +$GLOBALS['TL_LANG']['tl_content']['rs_column_background_repeat'][1] = 'Repeat mode of the background image.'; From 3b765291efb00e3d83bf14508862fe93f00a6a60 Mon Sep 17 00:00:00 2001 From: Ralf Baussenwein Date: Wed, 8 Feb 2023 10:54:52 +0100 Subject: [PATCH 06/17] Add dependency injection --- .../RockSolidColumnsExtension.php | 24 +++++++++++++++++++ src/Resources/config/services.yaml | 8 +++++++ 2 files changed, 32 insertions(+) create mode 100644 src/DependencyInjection/RockSolidColumnsExtension.php create mode 100644 src/Resources/config/services.yaml diff --git a/src/DependencyInjection/RockSolidColumnsExtension.php b/src/DependencyInjection/RockSolidColumnsExtension.php new file mode 100644 index 0000000..74d9ffc --- /dev/null +++ b/src/DependencyInjection/RockSolidColumnsExtension.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace MadeYourDay\RockSolidColumns\DependencyInjection; + +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Extension\Extension; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; + +final class RockSolidColumnsExtension extends Extension +{ + public function load(array $configs, ContainerBuilder $container): void + { + (new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'))) + ->load('services.yaml') + ; + } +} diff --git a/src/Resources/config/services.yaml b/src/Resources/config/services.yaml new file mode 100644 index 0000000..70a4d15 --- /dev/null +++ b/src/Resources/config/services.yaml @@ -0,0 +1,8 @@ +services: + _defaults: + autowire: true + autoconfigure: true + + MadeYourDay\RockSolidColumns\: + resource: '../../*' + exclude: '../../{DependencyInjection,MadeYourDay,Resources}' From 83dd8e5e79496a33af98ea711e9a5682f9dd9749 Mon Sep 17 00:00:00 2001 From: Ralf Baussenwein Date: Wed, 8 Feb 2023 17:24:29 +0100 Subject: [PATCH 07/17] Refactor hooks + callbacks to event listeners --- src/Columns.php | 183 ------------------ .../AddColumnsClassesToContentListener.php | 53 +++++ .../AddFrontendAssetsListener.php | 27 +++ ...eateStopElementsSubmitCallbackListener.php | 112 +++++++++++ src/Resources/contao/config/config.php | 4 - src/Resources/contao/dca/tl_content.php | 3 - src/Resources/contao/dca/tl_form_field.php | 3 - 7 files changed, 192 insertions(+), 193 deletions(-) delete mode 100644 src/Columns.php create mode 100644 src/EventListener/AddColumnsClassesToContentListener.php create mode 100644 src/EventListener/AddFrontendAssetsListener.php create mode 100644 src/EventListener/DataContainer/CreateStopElementsSubmitCallbackListener.php diff --git a/src/Columns.php b/src/Columns.php deleted file mode 100644 index 63803a7..0000000 --- a/src/Columns.php +++ /dev/null @@ -1,183 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace MadeYourDay\RockSolidColumns; - -use Contao\Database; -use Contao\DataContainer; -use Contao\Encryption; -use Contao\LayoutModel; -use Contao\PageModel; -use Contao\PageRegular; - -/** - * RockSolid Columns DCA (tl_content and tl_module) - * - * Provide miscellaneous methods that are used by the data configuration arrays. - * - * @author Martin Auswöger - */ -class Columns -{ - /** - * generatePage hook - * - * @param PageModel $page - * @param LayoutModel $layout - * @param PageRegular $pageRegular - * @return void - */ - public function generatePageHook(PageModel $page, LayoutModel $layout, PageRegular $pageRegular) - { - if ($layout->rs_columns_load_css) { - $GLOBALS['TL_CSS'][] = 'bundles/rocksolidcolumns/css/columns.css||static'; - } - } - - /** - * getContentElement hook - * - * @param Object $row content element - * @param string $content html content - * @return string modified $content - */ - public function getContentElementHook($row, $content) - { - $parentKey = ($row->ptable ?: 'tl_article') . '__' . $row->pid; - - if ( - isset($GLOBALS['TL_RS_COLUMNS'][$parentKey]) - && $GLOBALS['TL_RS_COLUMNS'][$parentKey]['active'] - && $row->type !== 'rs_columns_start' - && $row->type !== 'rs_columns_stop' - && $row->type !== 'rs_column_start' - && $row->type !== 'rs_column_stop' - ) { - - $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']++; - $count = $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']; - - if ($count) { - - $classes = array('rs-column'); - foreach ($GLOBALS['TL_RS_COLUMNS'][$parentKey]['config'] as $name => $media) { - $classes = array_merge($classes, $media[($count - 1) % count($media)]); - if ($count - 1 < count($media)) { - $classes[] = '-' . $name . '-first-row'; - } - } - - return '
' . $content . '
'; - - } - - } - - return $content; - } - - /** - * tl_content and tl_form_field DCA onsubmit callback - * - * Creates a stop element after a start element was created - * - * @param DataContainer $dc Data container - * @return void - */ - public function onsubmitCallback($dc) - { - $activeRecord = $dc->activeRecord; - if (!$activeRecord) { - return; - } - - if ($activeRecord->type === 'rs_columns_start' || $activeRecord->type === 'rs_column_start') { - - if ($dc->table === 'tl_content') { - - // Find the next columns or column element - $nextElement = Database::getInstance() - ->prepare(' - SELECT type - FROM tl_content - WHERE pid = ? - AND (ptable = ? OR ptable = ?) - AND type IN (\'rs_column_start\', \'rs_column_stop\', \'rs_columns_start\', \'rs_columns_stop\') - AND sorting > ? - ORDER BY sorting ASC - LIMIT 1 - ') - ->execute( - $activeRecord->pid, - $activeRecord->ptable ?: 'tl_article', - $activeRecord->ptable === 'tl_article' ? '' : $activeRecord->ptable, - $activeRecord->sorting - ); - - } - else { - - // Find the next columns or column element - $nextElement = Database::getInstance() - ->prepare(' - SELECT type - FROM ' . $dc->table . ' - WHERE pid = ? - AND type IN (\'rs_column_start\', \'rs_column_stop\', \'rs_columns_start\', \'rs_columns_stop\') - AND sorting > ? - ORDER BY sorting ASC - LIMIT 1 - ') - ->execute( - $activeRecord->pid, - $activeRecord->sorting - ); - - } - - // Check if a stop element should be created - if ( - !$nextElement->type - || ($activeRecord->type === 'rs_columns_start' && $nextElement->type === 'rs_column_stop') - || ($activeRecord->type === 'rs_column_start' && ( - $nextElement->type === 'rs_column_start' || $nextElement->type === 'rs_columns_stop' - )) - ) { - $set = array(); - - // Get all default values for the new entry - foreach ($GLOBALS['TL_DCA'][$dc->table]['fields'] as $field => $config) { - if (array_key_exists('default', $config)) { - $set[$field] = \is_array($config['default']) ? serialize($config['default']) : $config['default']; - if ($GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['eval']['encrypt'] ?? false) { - $set[$field] = Encryption::encrypt($set[$field]); - } - } - } - - $set['pid'] = $activeRecord->pid; - $set['type'] = substr($activeRecord->type, 0, -5) . 'stop'; - $set['sorting'] = $activeRecord->sorting + 1; - $set['invisible'] = $activeRecord->invisible; - $set['tstamp'] = time(); - - if ($dc->table === 'tl_content') { - $set['ptable'] = $activeRecord->ptable ?: 'tl_article'; - $set['start'] = $activeRecord->start; - $set['stop'] = $activeRecord->stop; - } - - Database::getInstance() - ->prepare('INSERT INTO ' . $dc->table . ' %s') - ->set($set) - ->execute(); - } - - } - } -} diff --git a/src/EventListener/AddColumnsClassesToContentListener.php b/src/EventListener/AddColumnsClassesToContentListener.php new file mode 100644 index 0000000..ba6ea37 --- /dev/null +++ b/src/EventListener/AddColumnsClassesToContentListener.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace MadeYourDay\RockSolidColumns\EventListener; + +use Contao\ContentModel; +use Contao\CoreBundle\ServiceAnnotation\Hook; + +/** + * @Hook("getContentElement") + */ +class AddColumnsClassesToContentListener +{ + public function __invoke(ContentModel $contentModel, string $buffer, $element): string + { + $parentKey = ($contentModel->ptable ?: 'tl_article').'__'.$contentModel->pid; + + if ( + isset($GLOBALS['TL_RS_COLUMNS'][$parentKey]) + && $GLOBALS['TL_RS_COLUMNS'][$parentKey]['active'] + && $contentModel->type !== 'rs_columns_start' + && $contentModel->type !== 'rs_columns_stop' + && $contentModel->type !== 'rs_column_start' + && $contentModel->type !== 'rs_column_stop' + ) { + + $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']++; + $count = $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']; + + if ($count) { + + $classes = array('rs-column'); + foreach ($GLOBALS['TL_RS_COLUMNS'][$parentKey]['config'] as $name => $media) { + $classes = array_merge($classes, $media[($count - 1) % count($media)]); + if ($count - 1 < count($media)) { + $classes[] = '-'.$name.'-first-row'; + } + } + + return '
'.$buffer.'
'; + + } + + } + + return $buffer; + } +} diff --git a/src/EventListener/AddFrontendAssetsListener.php b/src/EventListener/AddFrontendAssetsListener.php new file mode 100644 index 0000000..39a651b --- /dev/null +++ b/src/EventListener/AddFrontendAssetsListener.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace MadeYourDay\RockSolidColumns\EventListener; + +use Contao\CoreBundle\ServiceAnnotation\Hook; +use Contao\PageRegular; +use Contao\LayoutModel; +use Contao\PageModel; + +/** + * @Hook("generatePage") + */ +class AddFrontendAssetsListener +{ + public function __invoke(PageModel $pageModel, LayoutModel $layout, PageRegular $pageRegular): void + { + if ($layout->rs_columns_load_css) { + $GLOBALS['TL_CSS'][] = 'bundles/rocksolidcolumns/css/columns.css||static'; + } + } +} diff --git a/src/EventListener/DataContainer/CreateStopElementsSubmitCallbackListener.php b/src/EventListener/DataContainer/CreateStopElementsSubmitCallbackListener.php new file mode 100644 index 0000000..d9b94b6 --- /dev/null +++ b/src/EventListener/DataContainer/CreateStopElementsSubmitCallbackListener.php @@ -0,0 +1,112 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace MadeYourDay\RockSolidColumns\EventListener\DataContainer; + +use Contao\CoreBundle\ServiceAnnotation\Callback; +use Contao\Database; +use Contao\DataContainer; +use Contao\Encryption; + +/** + * @Callback(table="tl_content", target="config.onsubmit") + * @Callback(table="tl_form_field", target="config.onsubmit") + */ +class CreateStopElementsSubmitCallbackListener +{ + public function __invoke(DataContainer $dc): void + { + $activeRecord = $dc->activeRecord; + if (!$activeRecord) { + return; + } + + if ($activeRecord->type === 'rs_columns_start' || $activeRecord->type === 'rs_column_start') { + + if ($dc->table === 'tl_content') { + + // Find the next columns or column element + $nextElement = Database::getInstance() + ->prepare(' + SELECT type + FROM tl_content + WHERE pid = ? + AND (ptable = ? OR ptable = ?) + AND type IN (\'rs_column_start\', \'rs_column_stop\', \'rs_columns_start\', \'rs_columns_stop\') + AND sorting > ? + ORDER BY sorting ASC + LIMIT 1 + ') + ->execute( + $activeRecord->pid, + $activeRecord->ptable ?: 'tl_article', + $activeRecord->ptable === 'tl_article' ? '' : $activeRecord->ptable, + $activeRecord->sorting + ); + + } + else { + + // Find the next columns or column element + $nextElement = Database::getInstance() + ->prepare(' + SELECT type + FROM ' . $dc->table . ' + WHERE pid = ? + AND type IN (\'rs_column_start\', \'rs_column_stop\', \'rs_columns_start\', \'rs_columns_stop\') + AND sorting > ? + ORDER BY sorting ASC + LIMIT 1 + ') + ->execute( + $activeRecord->pid, + $activeRecord->sorting + ); + + } + + // Check if a stop element should be created + if ( + !$nextElement->type + || ($activeRecord->type === 'rs_columns_start' && $nextElement->type === 'rs_column_stop') + || ($activeRecord->type === 'rs_column_start' && ( + $nextElement->type === 'rs_column_start' || $nextElement->type === 'rs_columns_stop' + )) + ) { + $set = array(); + + // Get all default values for the new entry + foreach ($GLOBALS['TL_DCA'][$dc->table]['fields'] as $field => $config) { + if (array_key_exists('default', $config)) { + $set[$field] = \is_array($config['default']) ? serialize($config['default']) : $config['default']; + if ($GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['eval']['encrypt'] ?? false) { + $set[$field] = Encryption::encrypt($set[$field]); + } + } + } + + $set['pid'] = $activeRecord->pid; + $set['type'] = substr($activeRecord->type, 0, -5) . 'stop'; + $set['sorting'] = $activeRecord->sorting + 1; + $set['invisible'] = $activeRecord->invisible; + $set['tstamp'] = time(); + + if ($dc->table === 'tl_content') { + $set['ptable'] = $activeRecord->ptable ?: 'tl_article'; + $set['start'] = $activeRecord->start; + $set['stop'] = $activeRecord->stop; + } + + Database::getInstance() + ->prepare('INSERT INTO ' . $dc->table . ' %s') + ->set($set) + ->execute(); + } + } + } +} diff --git a/src/Resources/contao/config/config.php b/src/Resources/contao/config/config.php index 395b3c5..4a598b6 100644 --- a/src/Resources/contao/config/config.php +++ b/src/Resources/contao/config/config.php @@ -13,15 +13,11 @@ */ use MadeYourDay\Contao\Form\ColumnsWidget; -use MadeYourDay\RockSolidColumns\Columns; use MadeYourDay\RockSolidColumns\Element\ColumnsStart; use MadeYourDay\RockSolidColumns\Element\ColumnsStop; use MadeYourDay\RockSolidColumns\Element\ColumnStart; use MadeYourDay\RockSolidColumns\Element\ColumnStop; -$GLOBALS['TL_HOOKS']['generatePage'][] = array(Columns::class, 'generatePageHook'); -$GLOBALS['TL_HOOKS']['getContentElement'][] = array(Columns::class, 'getContentElementHook'); - $GLOBALS['TL_CTE']['rs_columns']['rs_columns_start'] = ColumnsStart::class; $GLOBALS['TL_CTE']['rs_columns']['rs_columns_stop'] = ColumnsStop::class; $GLOBALS['TL_CTE']['rs_columns']['rs_column_start'] = ColumnStart::class; diff --git a/src/Resources/contao/dca/tl_content.php b/src/Resources/contao/dca/tl_content.php index 7d05b50..ffea60f 100644 --- a/src/Resources/contao/dca/tl_content.php +++ b/src/Resources/contao/dca/tl_content.php @@ -13,15 +13,12 @@ */ use Contao\System; -use MadeYourDay\RockSolidColumns\Columns; use Symfony\Component\HttpFoundation\Request; if (System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest(System::getContainer()->get('request_stack')->getCurrentRequest() ?? Request::create(''))) { $GLOBALS['TL_CSS'][] = 'bundles/rocksolidcolumns/css/be_main.css'; } -$GLOBALS['TL_DCA']['tl_content']['config']['onsubmit_callback'][] = array(Columns::class, 'onsubmitCallback'); - $GLOBALS['TL_DCA']['tl_content']['palettes']['rs_columns_start'] = '{type_legend},type,headline;{rs_columns_legend},rs_columns_xlarge,rs_columns_large,rs_columns_medium,rs_columns_small,rs_columns_xsmall,rs_columns_gutter,rs_columns_outside_gutters,rs_columns_equal_height;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID;{invisible_legend:hide},invisible,start,stop'; $GLOBALS['TL_DCA']['tl_content']['palettes']['rs_columns_stop'] = '{type_legend},type;{protected_legend:hide},protected;{expert_legend:hide},guests;{invisible_legend:hide},invisible,start,stop'; $GLOBALS['TL_DCA']['tl_content']['palettes']['rs_column_start'] = '{type_legend},type,headline;{rs_column_background_legend},rs_column_color_inverted,rs_column_background;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID;{invisible_legend:hide},invisible,start,stop'; diff --git a/src/Resources/contao/dca/tl_form_field.php b/src/Resources/contao/dca/tl_form_field.php index 5702705..9fc6847 100644 --- a/src/Resources/contao/dca/tl_form_field.php +++ b/src/Resources/contao/dca/tl_form_field.php @@ -13,7 +13,6 @@ */ use Contao\System; -use MadeYourDay\RockSolidColumns\Columns; use Symfony\Component\HttpFoundation\Request; if (System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest(System::getContainer()->get('request_stack')->getCurrentRequest() ?? Request::create(''))) { @@ -22,8 +21,6 @@ System::loadLanguageFile('tl_content'); } -$GLOBALS['TL_DCA']['tl_form_field']['config']['onsubmit_callback'][] = array(Columns::class, 'onsubmitCallback'); - $GLOBALS['TL_DCA']['tl_form_field']['palettes']['rs_columns_start'] = '{type_legend},type;{rs_columns_legend},rs_columns_xlarge,rs_columns_large,rs_columns_medium,rs_columns_small,rs_columns_xsmall,rs_columns_gutter,rs_columns_outside_gutters,rs_columns_equal_height;{expert_legend:hide},class;{invisible_legend:hide},invisible'; $GLOBALS['TL_DCA']['tl_form_field']['palettes']['rs_columns_stop'] = '{type_legend},type;{invisible_legend:hide},invisible'; $GLOBALS['TL_DCA']['tl_form_field']['palettes']['rs_column_start'] = '{type_legend},type;{rs_column_background_legend},rs_column_color_inverted,rs_column_background;{expert_legend:hide},class;{invisible_legend:hide},invisible'; From f81071b2a769d7d8ce6f93ac5dfd8f1d4483e8e1 Mon Sep 17 00:00:00 2001 From: Ralf Baussenwein Date: Wed, 8 Feb 2023 18:27:29 +0100 Subject: [PATCH 08/17] Refactor content elements to controller --- .../ContentElement/ColumnStartController.php | 116 +++++++++++++++ .../ContentElement/ColumnStopController.php | 54 +++++++ .../ColumnsStartController.php} | 81 ++++------- .../ContentElement/ColumnsStopController.php | 67 +++++++++ src/Element/ColumnStart.php | 132 ------------------ src/Element/ColumnStop.php | 68 --------- src/Element/ColumnsStop.php | 80 ----------- src/Resources/contao/config/config.php | 9 -- 8 files changed, 268 insertions(+), 339 deletions(-) create mode 100644 src/Controller/ContentElement/ColumnStartController.php create mode 100644 src/Controller/ContentElement/ColumnStopController.php rename src/{Element/ColumnsStart.php => Controller/ContentElement/ColumnsStartController.php} (60%) create mode 100644 src/Controller/ContentElement/ColumnsStopController.php delete mode 100644 src/Element/ColumnStart.php delete mode 100644 src/Element/ColumnStop.php delete mode 100644 src/Element/ColumnsStop.php diff --git a/src/Controller/ContentElement/ColumnStartController.php b/src/Controller/ContentElement/ColumnStartController.php new file mode 100644 index 0000000..5413818 --- /dev/null +++ b/src/Controller/ContentElement/ColumnStartController.php @@ -0,0 +1,116 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace MadeYourDay\RockSolidColumns\Controller\ContentElement; + +use Contao\BackendTemplate; +use Contao\ContentModel; +use Contao\Controller; +use Contao\CoreBundle\Controller\ContentElement\AbstractContentElementController; +use Contao\CoreBundle\Routing\ScopeMatcher; +use Contao\CoreBundle\ServiceAnnotation\ContentElement; +use Contao\File; +use Contao\FilesModel; +use Contao\StringUtil; +use Contao\Template; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; + +/** + * Column start content element + * + * @author Martin Auswöger + * + * @ContentElement("rs_column_start", category="rs_columns") + */ +class ColumnStartController extends AbstractContentElementController +{ + private ScopeMatcher $scopeMatcher; + + public function __construct(ScopeMatcher $scopeMatcher) + { + $this->scopeMatcher = $scopeMatcher; + } + + protected function getResponse(Template $template, ContentModel $model, Request $request): ?Response + { + if ($this->scopeMatcher->isBackendRequest($request)) { + $backendTemplate = new BackendTemplate('be_wildcard'); + $backendTemplate->title = $template->headline; + return new Response($backendTemplate->parse()); + } + + $classes = array('rs-column'); + $styles = array(); + $parentKey = ($model->ptable ?: 'tl_article') . '__' . $model->pid; + + if (isset($GLOBALS['TL_RS_COLUMNS'][$parentKey]) && $GLOBALS['TL_RS_COLUMNS'][$parentKey]['active']) { + + $GLOBALS['TL_RS_COLUMNS'][$parentKey]['active'] = false; + $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']++; + + $count = $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']; + foreach ($GLOBALS['TL_RS_COLUMNS'][$parentKey]['config'] as $name => $media) { + $classes = array_merge($classes, $media[($count - 1) % count($media)]); + if ($count - 1 < count($media)) { + $classes[] = '-' . $name . '-first-row'; + } + } + + } + else { + trigger_error('Missing column wrapper start element before column start element ID ' . $model->id . '.', E_USER_WARNING); + } + + if ($model->rs_column_color_inverted) { + $classes[] = '-color-inverted'; + } + + if ($model->rs_column_background) { + + $backgroundColor = StringUtil::deserialize($model->rs_column_background_color); + if (is_array($backgroundColor) && $backgroundColor[0]) { + $styles[] = 'background-color: #' . $backgroundColor[0] . ';'; + } + + if (trim($model->rs_column_background_image)) { + $image = FilesModel::findByPk($model->rs_column_background_image); + if (null !== $image) { + $file = new File($image->path); + $imageObject = new \stdClass(); + Controller::addImageToTemplate($imageObject, array( + 'id' => $image->id, + 'uuid' => $image->uuid ?? null, + 'name' => $file->basename, + 'singleSRC' => $image->path, + 'size' => $model->rs_column_background_image_size, + )); + $styles[] = 'background-image: url("' . $imageObject->src . '");'; + } + } + + if ($model->rs_column_background_size) { + $styles[] = 'background-size: ' . $model->rs_column_background_size . ';'; + } + + if ($model->rs_column_background_position) { + $styles[] = 'background-position: ' . $model->rs_column_background_position . ';'; + } + + if ($model->rs_column_background_repeat) { + $styles[] = 'background-repeat: ' . $model->rs_column_background_repeat . ';'; + } + + } + + $template->class .= ' ' . implode(' ', $classes); + $template->style = implode(' ', $styles); + + return new Response($template->parse()); + } +} diff --git a/src/Controller/ContentElement/ColumnStopController.php b/src/Controller/ContentElement/ColumnStopController.php new file mode 100644 index 0000000..ef34c6a --- /dev/null +++ b/src/Controller/ContentElement/ColumnStopController.php @@ -0,0 +1,54 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace MadeYourDay\RockSolidColumns\Controller\ContentElement; + +use Contao\BackendTemplate; +use Contao\ContentModel; +use Contao\CoreBundle\Controller\ContentElement\AbstractContentElementController; +use Contao\CoreBundle\Routing\ScopeMatcher; +use Contao\CoreBundle\ServiceAnnotation\ContentElement; +use Contao\Template; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; + +/** + * Column stop content element + * + * @author Martin Auswöger + * + * @ContentElement("rs_column_stop", category="rs_columns") + */ +class ColumnStopController extends AbstractContentElementController +{ + private ScopeMatcher $scopeMatcher; + + public function __construct(ScopeMatcher $scopeMatcher) + { + $this->scopeMatcher = $scopeMatcher; + } + + protected function getResponse(Template $template, ContentModel $model, Request $request): ?Response + { + if ($this->scopeMatcher->isBackendRequest($request)) { + $backendTemplate = new BackendTemplate('be_wildcard'); + return new Response($backendTemplate->parse()); + } + + $parentKey = ($model->ptable ?: 'tl_article') . '__' . $model->pid; + + if (isset($GLOBALS['TL_RS_COLUMNS'][$parentKey]) && !$GLOBALS['TL_RS_COLUMNS'][$parentKey]['active']) { + $GLOBALS['TL_RS_COLUMNS'][$parentKey]['active'] = true; + } + else { + trigger_error('Missing column start element before column stop element ID ' . $model->id . '.', E_USER_WARNING); + } + + return new Response($template->parse()); + } +} diff --git a/src/Element/ColumnsStart.php b/src/Controller/ContentElement/ColumnsStartController.php similarity index 60% rename from src/Element/ColumnsStart.php rename to src/Controller/ContentElement/ColumnsStartController.php index 49538ad..586b29f 100644 --- a/src/Element/ColumnsStart.php +++ b/src/Controller/ContentElement/ColumnsStartController.php @@ -6,38 +6,42 @@ * file that was distributed with this source code. */ -namespace MadeYourDay\RockSolidColumns\Element; +namespace MadeYourDay\RockSolidColumns\Controller\ContentElement; use Contao\BackendTemplate; -use Contao\ContentElement; -use Contao\FrontendTemplate; -use Contao\System; +use Contao\ContentModel; +use Contao\CoreBundle\Controller\ContentElement\AbstractContentElementController; +use Contao\CoreBundle\Routing\ScopeMatcher; +use Contao\CoreBundle\ServiceAnnotation\ContentElement; +use Contao\Template; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; /** * Columns start content element * * @author Martin Auswöger + * + * @ContentElement("rs_columns_start", category="rs_columns") */ -class ColumnsStart extends ContentElement +class ColumnsStartController extends AbstractContentElementController { - /** - * @var string Template - */ - protected $strTemplate = 'ce_rs_columns_start'; + private ScopeMatcher $scopeMatcher; - /** - * Parse the template - * - * @return string Parsed element - */ - public function generate() + public function __construct(ScopeMatcher $scopeMatcher) + { + $this->scopeMatcher = $scopeMatcher; + } + + protected function getResponse(Template $template, ContentModel $model, Request $request): ?Response { - if (System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest(System::getContainer()->get('request_stack')->getCurrentRequest() ?? Request::create(''))) { - return parent::generate(); + if ($this->scopeMatcher->isBackendRequest($request)) { + $backendTemplate = new BackendTemplate('be_wildcard'); + $backendTemplate->title = $template->headline; + return new Response($backendTemplate->parse()); } - $parentKey = ($this->arrData['ptable'] ?: 'tl_article') . '__' . $this->arrData['pid']; + $parentKey = ($model->ptable ?: 'tl_article') . '__' . $model->pid; $htmlPrefix = ''; @@ -70,15 +74,12 @@ public function generate() $GLOBALS['TL_RS_COLUMNS'][$parentKey] = array( 'active' => true, 'count' => 0, - 'config' => static::getColumnsConfiguration($this->arrData), + 'config' => static::getColumnsConfiguration($model->row()), ); - if (!is_array($this->cssID)) { - $this->cssID = array('', ''); - } - $this->arrData['cssID'][1] .= ' ' . static::getWrapperClassName($this->arrData); + $template->class .= ' ' . static::getWrapperClassName($model->row()); - return $htmlPrefix . parent::generate(); + return new Response($htmlPrefix . $template->parse()); } /** @@ -87,7 +88,7 @@ public function generate() * @param array $data Data array * @return array Columns configuration */ - public static function getColumnsConfiguration(array $data) + public static function getColumnsConfiguration(array $data): array { $config = array(); $lastColumns = null; @@ -99,15 +100,13 @@ public static function getColumnsConfiguration(array $data) foreach (array('xlarge', 'large', 'medium', 'small', 'xsmall') as $media) { - $columns = isset($data['rs_columns_' . $media]) - ? $data['rs_columns_' . $media] - : null; + $columns = $data['rs_columns_'.$media] ?? null; if (!$columns) { $columns = $lastColumns ?: '2'; } $lastColumns = $columns; - $columns = array_map(function($value) { + $columns = array_map(static function($value) { return (int)$value ?: 1; }, explode('-', $columns)); @@ -115,11 +114,11 @@ public static function getColumnsConfiguration(array $data) $columns = array_fill(0, (int)$columns[0], '1'); } - $columnsTotal = array_reduce($columns, function($a, $b) { + $columnsTotal = array_reduce($columns, static function($a, $b) { return $a + $b; }); $classes = array(); - foreach ($columns as $key => $column) { + foreach ($columns as $column) { $classes[] = array('-' . $media . '-col-' . $columnsTotal . '-' . $column); } $classes[0][] = '-' . $media . '-first'; @@ -137,7 +136,7 @@ public static function getColumnsConfiguration(array $data) * @param array $data Data array * @return string Wrapper class name */ - public static function getWrapperClassName(array $data) + public static function getWrapperClassName(array $data): string { $classes = array('rs-columns'); @@ -155,22 +154,4 @@ public static function getWrapperClassName(array $data) return implode(' ', $classes); } - - /** - * Compile the content element - * - * @return void - */ - public function compile() - { - if (System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest(System::getContainer()->get('request_stack')->getCurrentRequest() ?? Request::create(''))) { - $this->strTemplate = 'be_wildcard'; - $this->Template = new BackendTemplate($this->strTemplate); - $this->Template->title = $this->headline; - } - else { - $this->Template = new FrontendTemplate($this->strTemplate); - $this->Template->setData($this->arrData); - } - } } diff --git a/src/Controller/ContentElement/ColumnsStopController.php b/src/Controller/ContentElement/ColumnsStopController.php new file mode 100644 index 0000000..38657a7 --- /dev/null +++ b/src/Controller/ContentElement/ColumnsStopController.php @@ -0,0 +1,67 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace MadeYourDay\RockSolidColumns\Controller\ContentElement; + +use Contao\BackendTemplate; +use Contao\ContentModel; +use Contao\CoreBundle\Controller\ContentElement\AbstractContentElementController; +use Contao\CoreBundle\Routing\ScopeMatcher; +use Contao\CoreBundle\ServiceAnnotation\ContentElement; +use Contao\Template; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; + +/** + * Columns stop content element + * + * @author Martin Auswöger + * + * @ContentElement("rs_columns_stop", category="rs_columns") + */ +class ColumnsStopController extends AbstractContentElementController +{ + private ScopeMatcher $scopeMatcher; + + public function __construct(ScopeMatcher $scopeMatcher) + { + $this->scopeMatcher = $scopeMatcher; + } + + protected function getResponse(Template $template, ContentModel $model, Request $request): ?Response + { + if ($this->scopeMatcher->isBackendRequest($request)) { + $backendTemplate = new BackendTemplate('be_wildcard'); + return new Response($backendTemplate->parse()); + } + + $parentKey = ($model->ptable ?: 'tl_article') . '__' . $model->pid; + + if (isset($GLOBALS['TL_RS_COLUMNS'][$parentKey])) { + if (!$GLOBALS['TL_RS_COLUMNS'][$parentKey]['active']) { + trigger_error('Missing column stop element before column wrapper stop element ID ' . $model->id . '.', E_USER_WARNING); + } + unset($GLOBALS['TL_RS_COLUMNS'][$parentKey]); + } + else { + trigger_error('Missing column wrapper start element before column wrapper stop element ID ' . $model->id . '.', E_USER_WARNING); + } + + $htmlSuffix = ''; + + if (!empty($GLOBALS['TL_RS_COLUMNS_STACK'][$parentKey])) { + $GLOBALS['TL_RS_COLUMNS'][$parentKey] = array_pop($GLOBALS['TL_RS_COLUMNS_STACK'][$parentKey]); + if ($GLOBALS['TL_RS_COLUMNS'][$parentKey]['active']) { + $htmlSuffix .= ''; + } + } + + return new Response($template->parse() . $htmlSuffix); + } + +} diff --git a/src/Element/ColumnStart.php b/src/Element/ColumnStart.php deleted file mode 100644 index 09ef3e9..0000000 --- a/src/Element/ColumnStart.php +++ /dev/null @@ -1,132 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace MadeYourDay\RockSolidColumns\Element; - -use Contao\BackendTemplate; -use Contao\ContentElement; -use Contao\File; -use Contao\FilesModel; -use Contao\FrontendTemplate; -use Contao\StringUtil; -use Contao\System; -use Symfony\Component\HttpFoundation\Request; - -/** - * Column start content element - * - * @author Martin Auswöger - */ -class ColumnStart extends ContentElement -{ - /** - * @var string Template - */ - protected $strTemplate = 'ce_rs_column_start'; - - /** - * Parse the template - * - * @return string Parsed element - */ - public function generate() - { - if (System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest(System::getContainer()->get('request_stack')->getCurrentRequest() ?? Request::create(''))) { - return parent::generate(); - } - - $classes = array('rs-column'); - $parentKey = ($this->arrData['ptable'] ?: 'tl_article') . '__' . $this->arrData['pid']; - - if (isset($GLOBALS['TL_RS_COLUMNS'][$parentKey]) && $GLOBALS['TL_RS_COLUMNS'][$parentKey]['active']) { - - $GLOBALS['TL_RS_COLUMNS'][$parentKey]['active'] = false; - $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']++; - - $count = $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']; - foreach ($GLOBALS['TL_RS_COLUMNS'][$parentKey]['config'] as $name => $media) { - $classes = array_merge($classes, $media[($count - 1) % count($media)]); - if ($count - 1 < count($media)) { - $classes[] = '-' . $name . '-first-row'; - } - } - - } - else { - trigger_error('Missing column wrapper start element before column start element ID ' . $this->id . '.', E_USER_WARNING); - } - - if ($this->rs_column_color_inverted) { - $classes[] = '-color-inverted'; - } - - if ($this->rs_column_background) { - - $backgroundColor = StringUtil::deserialize($this->rs_column_background_color); - if (is_array($backgroundColor) && $backgroundColor[0]) { - $this->arrStyle[] = 'background-color: #' . $backgroundColor[0] . ';'; - } - - if (trim($this->rs_column_background_image)) { - $image = FilesModel::findByPk($this->rs_column_background_image); - $file = new File($image->path, true); - $imageObject = new \stdClass(); - $this->addImageToTemplate($imageObject, array( - 'id' => $image->id, - 'uuid' => isset($image->uuid) ? $image->uuid : null, - 'name' => $file->basename, - 'singleSRC' => $image->path, - 'size' => $this->rs_column_background_image_size, - )); - $this->arrStyle[] = 'background-image: url("' . $imageObject->src . '");'; - } - - if ($this->rs_column_background_size) { - $this->arrStyle[] = 'background-size: ' . $this->rs_column_background_size . ';'; - } - - if ($this->rs_column_background_position) { - $this->arrStyle[] = 'background-position: ' . $this->rs_column_background_position . ';'; - } - - if ($this->rs_column_background_repeat) { - $this->arrStyle[] = 'background-repeat: ' . $this->rs_column_background_repeat . ';'; - } - - } - - if (!is_array($this->cssID)) { - $this->cssID = array('', ''); - } - else { - $this->cssID = $this->cssID + array('', ''); - } - - $this->arrData['cssID'][1] .= ' ' . implode(' ', $classes); - - return parent::generate(); - } - - /** - * Compile the content element - * - * @return void - */ - public function compile() - { - if (System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest(System::getContainer()->get('request_stack')->getCurrentRequest() ?? Request::create(''))) { - $this->strTemplate = 'be_wildcard'; - $this->Template = new BackendTemplate($this->strTemplate); - $this->Template->title = $this->headline; - } - else { - $this->Template = new FrontendTemplate($this->strTemplate); - $this->Template->setData($this->arrData); - } - } -} diff --git a/src/Element/ColumnStop.php b/src/Element/ColumnStop.php deleted file mode 100644 index 1693e5c..0000000 --- a/src/Element/ColumnStop.php +++ /dev/null @@ -1,68 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace MadeYourDay\RockSolidColumns\Element; - -use Contao\BackendTemplate; -use Contao\ContentElement; -use Contao\FrontendTemplate; -use Contao\System; -use Symfony\Component\HttpFoundation\Request; - -/** - * Column stop content element - * - * @author Martin Auswöger - */ -class ColumnStop extends ContentElement -{ - /** - * @var string Template - */ - protected $strTemplate = 'ce_rs_column_stop'; - - /** - * Parse the template - * - * @return string Parsed element - */ - public function generate() - { - if (System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest(System::getContainer()->get('request_stack')->getCurrentRequest() ?? Request::create(''))) { - return parent::generate(); - } - - $parentKey = ($this->arrData['ptable'] ?: 'tl_article') . '__' . $this->arrData['pid']; - if (isset($GLOBALS['TL_RS_COLUMNS'][$parentKey]) && !$GLOBALS['TL_RS_COLUMNS'][$parentKey]['active']) { - $GLOBALS['TL_RS_COLUMNS'][$parentKey]['active'] = true; - } - else { - trigger_error('Missing column start element before column stop element ID ' . $this->id . '.', E_USER_WARNING); - } - - return parent::generate(); - } - - /** - * Compile the content element - * - * @return void - */ - public function compile() - { - if (System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest(System::getContainer()->get('request_stack')->getCurrentRequest() ?? Request::create(''))) { - $this->strTemplate = 'be_wildcard'; - $this->Template = new BackendTemplate($this->strTemplate); - $this->Template->title = $this->headline; - } - else { - $this->Template = new FrontendTemplate($this->strTemplate); - $this->Template->setData($this->arrData); - } - } -} diff --git a/src/Element/ColumnsStop.php b/src/Element/ColumnsStop.php deleted file mode 100644 index c0ed107..0000000 --- a/src/Element/ColumnsStop.php +++ /dev/null @@ -1,80 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace MadeYourDay\RockSolidColumns\Element; - -use Contao\BackendTemplate; -use Contao\ContentElement; -use Contao\FrontendTemplate; -use Contao\System; -use Symfony\Component\HttpFoundation\Request; - -/** - * Columns stop content element - * - * @author Martin Auswöger - */ -class ColumnsStop extends ContentElement -{ - /** - * @var string Template - */ - protected $strTemplate = 'ce_rs_columns_stop'; - - /** - * Parse the template - * - * @return string Parsed element - */ - public function generate() - { - if (System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest(System::getContainer()->get('request_stack')->getCurrentRequest() ?? Request::create(''))) { - return parent::generate(); - } - - $parentKey = ($this->arrData['ptable'] ?: 'tl_article') . '__' . $this->arrData['pid']; - if (isset($GLOBALS['TL_RS_COLUMNS'][$parentKey])) { - if (!$GLOBALS['TL_RS_COLUMNS'][$parentKey]['active']) { - trigger_error('Missing column stop element before column wrapper stop element ID ' . $this->id . '.', E_USER_WARNING); - } - unset($GLOBALS['TL_RS_COLUMNS'][$parentKey]); - } - else { - trigger_error('Missing column wrapper start element before column wrapper stop element ID ' . $this->id . '.', E_USER_WARNING); - } - - $htmlSuffix = ''; - - if (!empty($GLOBALS['TL_RS_COLUMNS_STACK'][$parentKey])) { - $GLOBALS['TL_RS_COLUMNS'][$parentKey] = array_pop($GLOBALS['TL_RS_COLUMNS_STACK'][$parentKey]); - if ($GLOBALS['TL_RS_COLUMNS'][$parentKey]['active']) { - $htmlSuffix .= ''; - } - } - - return parent::generate() . $htmlSuffix; - } - - /** - * Compile the content element - * - * @return void - */ - public function compile() - { - if (System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest(System::getContainer()->get('request_stack')->getCurrentRequest() ?? Request::create(''))) { - $this->strTemplate = 'be_wildcard'; - $this->Template = new BackendTemplate($this->strTemplate); - $this->Template->title = $this->headline; - } - else { - $this->Template = new FrontendTemplate($this->strTemplate); - $this->Template->setData($this->arrData); - } - } -} diff --git a/src/Resources/contao/config/config.php b/src/Resources/contao/config/config.php index 4a598b6..18390c5 100644 --- a/src/Resources/contao/config/config.php +++ b/src/Resources/contao/config/config.php @@ -13,15 +13,6 @@ */ use MadeYourDay\Contao\Form\ColumnsWidget; -use MadeYourDay\RockSolidColumns\Element\ColumnsStart; -use MadeYourDay\RockSolidColumns\Element\ColumnsStop; -use MadeYourDay\RockSolidColumns\Element\ColumnStart; -use MadeYourDay\RockSolidColumns\Element\ColumnStop; - -$GLOBALS['TL_CTE']['rs_columns']['rs_columns_start'] = ColumnsStart::class; -$GLOBALS['TL_CTE']['rs_columns']['rs_columns_stop'] = ColumnsStop::class; -$GLOBALS['TL_CTE']['rs_columns']['rs_column_start'] = ColumnStart::class; -$GLOBALS['TL_CTE']['rs_columns']['rs_column_stop'] = ColumnStop::class; $GLOBALS['TL_FFL']['rs_columns_start'] = ColumnsWidget::class; $GLOBALS['TL_FFL']['rs_columns_stop'] = ColumnsWidget::class; From 2778555fee2765d3811e4e276a84939520c0c830 Mon Sep 17 00:00:00 2001 From: Ralf Baussenwein Date: Wed, 8 Feb 2023 19:49:45 +0100 Subject: [PATCH 09/17] Refactor excluded content elements --- src/EventListener/AddColumnsClassesToContentListener.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/EventListener/AddColumnsClassesToContentListener.php b/src/EventListener/AddColumnsClassesToContentListener.php index ba6ea37..e4a484e 100644 --- a/src/EventListener/AddColumnsClassesToContentListener.php +++ b/src/EventListener/AddColumnsClassesToContentListener.php @@ -19,14 +19,12 @@ class AddColumnsClassesToContentListener public function __invoke(ContentModel $contentModel, string $buffer, $element): string { $parentKey = ($contentModel->ptable ?: 'tl_article').'__'.$contentModel->pid; + $excludeElements = ['rs_columns_start', 'rs_columns_stop', 'rs_column_start', 'rs_column_stop']; if ( isset($GLOBALS['TL_RS_COLUMNS'][$parentKey]) && $GLOBALS['TL_RS_COLUMNS'][$parentKey]['active'] - && $contentModel->type !== 'rs_columns_start' - && $contentModel->type !== 'rs_columns_stop' - && $contentModel->type !== 'rs_column_start' - && $contentModel->type !== 'rs_column_stop' + && !\in_array($contentModel->type, $excludeElements, true) ) { $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']++; From d8316345f809d942906faaa6113b3892e5ebdcfc Mon Sep 17 00:00:00 2001 From: Ralf Baussenwein Date: Wed, 8 Feb 2023 19:51:13 +0100 Subject: [PATCH 10/17] Add support for columns in form fields --- .../AddColumnsClassesToFormListener.php | 53 +++++++++++++++++++ .../Contao => }/Model/DummyColumnsModel.php | 9 ++-- src/Resources/config/services.yaml | 2 +- src/Resources/contao/config/config.php | 2 +- .../templates}/form_rs_columns_plain.html5 | 0 .../Frontend}/ColumnsWidget.php | 15 +++--- 6 files changed, 70 insertions(+), 11 deletions(-) create mode 100644 src/EventListener/AddColumnsClassesToFormListener.php rename src/{MadeYourDay/Contao => }/Model/DummyColumnsModel.php (63%) rename {templates => src/Resources/contao/templates}/form_rs_columns_plain.html5 (100%) rename src/{MadeYourDay/Contao/Form => Widget/Frontend}/ColumnsWidget.php (74%) diff --git a/src/EventListener/AddColumnsClassesToFormListener.php b/src/EventListener/AddColumnsClassesToFormListener.php new file mode 100644 index 0000000..17f3a67 --- /dev/null +++ b/src/EventListener/AddColumnsClassesToFormListener.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace MadeYourDay\RockSolidColumns\EventListener; + +use Contao\CoreBundle\ServiceAnnotation\Hook; +use Contao\Form; +use Contao\Widget; + +/** + * @Hook("loadFormField") + */ +class AddColumnsClassesToFormListener +{ + public function __invoke(Widget $widget, string $formId, array $data, Form $form): Widget + { + $parentKey = 'tl_form__'.$widget->pid; + $excludeWidgets = ['rs_columns_start', 'rs_columns_stop', 'rs_column_start', 'rs_column_stop']; + + if (isset($GLOBALS['TL_RS_COLUMNS'][$parentKey]) + && $GLOBALS['TL_RS_COLUMNS'][$parentKey]['active'] + && !\in_array($widget->type, $excludeWidgets, true) + ) { + + $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']++; + $count = $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']; + + if ($count) { + + $classes = array('rs-column'); + foreach ($GLOBALS['TL_RS_COLUMNS'][$parentKey]['config'] as $name => $media) { + $classes = array_merge($classes, $media[($count - 1) % count($media)]); + if ($count - 1 < count($media)) { + $classes[] = '-'.$name.'-first-row'; + } + } + + if ('fieldsetStart' === $widget->type || 'submit' === $widget->type) { + $widget->class .= ' '.implode(' ', $classes); + } else { + $widget->prefix .= ' '.implode(' ', $classes); + } + } + } + + return $widget; + } +} diff --git a/src/MadeYourDay/Contao/Model/DummyColumnsModel.php b/src/Model/DummyColumnsModel.php similarity index 63% rename from src/MadeYourDay/Contao/Model/DummyColumnsModel.php rename to src/Model/DummyColumnsModel.php index 1a96160..3443fdd 100644 --- a/src/MadeYourDay/Contao/Model/DummyColumnsModel.php +++ b/src/Model/DummyColumnsModel.php @@ -6,19 +6,22 @@ * file that was distributed with this source code. */ -namespace MadeYourDay\Contao\Model; +namespace MadeYourDay\RockSolidColumns\Model; + +use Contao\ContentModel; +use Contao\Database\Result; /** * Dummy columns model * * @author Martin Auswöger */ -class DummyColumnsModel extends \Model +class DummyColumnsModel extends ContentModel { /** * {@inheritdoc} */ - public function __construct(\Database\Result $objResult = null, $data = array()) + public function __construct(Result $objResult = null, $data = array()) { $this->arrModified = array(); $this->setRow($data); diff --git a/src/Resources/config/services.yaml b/src/Resources/config/services.yaml index 70a4d15..f819815 100644 --- a/src/Resources/config/services.yaml +++ b/src/Resources/config/services.yaml @@ -5,4 +5,4 @@ services: MadeYourDay\RockSolidColumns\: resource: '../../*' - exclude: '../../{DependencyInjection,MadeYourDay,Resources}' + exclude: '../../{DependencyInjection,Resources}' diff --git a/src/Resources/contao/config/config.php b/src/Resources/contao/config/config.php index 18390c5..825a996 100644 --- a/src/Resources/contao/config/config.php +++ b/src/Resources/contao/config/config.php @@ -12,7 +12,7 @@ * @author Martin Auswöger */ -use MadeYourDay\Contao\Form\ColumnsWidget; +use MadeYourDay\RockSolidColumns\Widget\Frontend\ColumnsWidget; $GLOBALS['TL_FFL']['rs_columns_start'] = ColumnsWidget::class; $GLOBALS['TL_FFL']['rs_columns_stop'] = ColumnsWidget::class; diff --git a/templates/form_rs_columns_plain.html5 b/src/Resources/contao/templates/form_rs_columns_plain.html5 similarity index 100% rename from templates/form_rs_columns_plain.html5 rename to src/Resources/contao/templates/form_rs_columns_plain.html5 diff --git a/src/MadeYourDay/Contao/Form/ColumnsWidget.php b/src/Widget/Frontend/ColumnsWidget.php similarity index 74% rename from src/MadeYourDay/Contao/Form/ColumnsWidget.php rename to src/Widget/Frontend/ColumnsWidget.php index edf447a..67276a1 100644 --- a/src/MadeYourDay/Contao/Form/ColumnsWidget.php +++ b/src/Widget/Frontend/ColumnsWidget.php @@ -6,17 +6,18 @@ * file that was distributed with this source code. */ -namespace MadeYourDay\Contao\Form; +namespace MadeYourDay\RockSolidColumns\Widget\Frontend; -use MadeYourDay\Contao\Model\DummyColumnsModel; -use MadeYourDay\Contao\Columns; +use Contao\ContentElement; +use Contao\Widget; +use MadeYourDay\RockSolidColumns\Model\DummyColumnsModel; /** * Custom form widget * * @author Martin Auswöger */ -class ColumnsWidget extends \Widget +class ColumnsWidget extends Widget { /** * @var string Template @@ -24,7 +25,7 @@ class ColumnsWidget extends \Widget protected $strTemplate = 'form_rs_columns_plain'; /** - * @var \ContentElement + * @var ContentElement */ private $contentElement; @@ -37,7 +38,9 @@ public function __construct($data = null) $data['cssID'] = serialize(array('', $data['class'])); } - $class = \ContentElement::findClass($data['type']); + $data['ptable'] = 'tl_form'; + + $class = ContentElement::findClass($data['type']); $this->contentElement = new $class(new DummyColumnsModel(null, $data)); From 09885fe4f087f6fb75e5ececa0f8a30dec43c7a1 Mon Sep 17 00:00:00 2001 From: Ralf Baussenwein Date: Wed, 8 Feb 2023 20:55:42 +0100 Subject: [PATCH 11/17] Add backend assets via event listener --- .../AddBackendAssetsListener.php | 48 +++++++++++++++++++ src/Resources/contao/dca/tl_content.php | 5 -- src/Resources/contao/dca/tl_form_field.php | 7 --- 3 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 src/EventListener/DataContainer/AddBackendAssetsListener.php diff --git a/src/EventListener/DataContainer/AddBackendAssetsListener.php b/src/EventListener/DataContainer/AddBackendAssetsListener.php new file mode 100644 index 0000000..137d23e --- /dev/null +++ b/src/EventListener/DataContainer/AddBackendAssetsListener.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace MadeYourDay\RockSolidColumns\EventListener\DataContainer; + +use Contao\CoreBundle\Routing\ScopeMatcher; +use Contao\CoreBundle\ServiceAnnotation\Hook; +use Contao\System; +use Symfony\Component\HttpFoundation\RequestStack; + +/** + * @Hook("loadDataContainer") + */ +class AddBackendAssetsListener +{ + private RequestStack $requestStack; + private ScopeMatcher $scopeMatcher; + + public function __construct(RequestStack $requestStack, ScopeMatcher $scopeMatcher) + { + $this->requestStack = $requestStack; + $this->scopeMatcher = $scopeMatcher; + } + + public function __invoke(string $table): void + { + if ('tl_content' !== $table && 'tl_form_field' !== $table) { + return; + } + + $request = $this->requestStack->getCurrentRequest(); + + if (null === $request || !$this->scopeMatcher->isBackendRequest($request)) { + return; + } + + $GLOBALS['TL_CSS'][] = 'bundles/rocksolidcolumns/css/be_main.css'; + + if ('tl_form_field' === $table) { + System::loadLanguageFile('tl_content'); + } + } +} diff --git a/src/Resources/contao/dca/tl_content.php b/src/Resources/contao/dca/tl_content.php index ffea60f..2c5a758 100644 --- a/src/Resources/contao/dca/tl_content.php +++ b/src/Resources/contao/dca/tl_content.php @@ -13,11 +13,6 @@ */ use Contao\System; -use Symfony\Component\HttpFoundation\Request; - -if (System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest(System::getContainer()->get('request_stack')->getCurrentRequest() ?? Request::create(''))) { - $GLOBALS['TL_CSS'][] = 'bundles/rocksolidcolumns/css/be_main.css'; -} $GLOBALS['TL_DCA']['tl_content']['palettes']['rs_columns_start'] = '{type_legend},type,headline;{rs_columns_legend},rs_columns_xlarge,rs_columns_large,rs_columns_medium,rs_columns_small,rs_columns_xsmall,rs_columns_gutter,rs_columns_outside_gutters,rs_columns_equal_height;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID;{invisible_legend:hide},invisible,start,stop'; $GLOBALS['TL_DCA']['tl_content']['palettes']['rs_columns_stop'] = '{type_legend},type;{protected_legend:hide},protected;{expert_legend:hide},guests;{invisible_legend:hide},invisible,start,stop'; diff --git a/src/Resources/contao/dca/tl_form_field.php b/src/Resources/contao/dca/tl_form_field.php index 9fc6847..4479bdc 100644 --- a/src/Resources/contao/dca/tl_form_field.php +++ b/src/Resources/contao/dca/tl_form_field.php @@ -13,13 +13,6 @@ */ use Contao\System; -use Symfony\Component\HttpFoundation\Request; - -if (System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest(System::getContainer()->get('request_stack')->getCurrentRequest() ?? Request::create(''))) { - $GLOBALS['TL_CSS'][] = 'bundles/rocksolidcolumns/css/be_main.css'; - // Load content language file - System::loadLanguageFile('tl_content'); -} $GLOBALS['TL_DCA']['tl_form_field']['palettes']['rs_columns_start'] = '{type_legend},type;{rs_columns_legend},rs_columns_xlarge,rs_columns_large,rs_columns_medium,rs_columns_small,rs_columns_xsmall,rs_columns_gutter,rs_columns_outside_gutters,rs_columns_equal_height;{expert_legend:hide},class;{invisible_legend:hide},invisible'; $GLOBALS['TL_DCA']['tl_form_field']['palettes']['rs_columns_stop'] = '{type_legend},type;{invisible_legend:hide},invisible'; From 6140809018ca53b9c8d74f5e0fa3a25e2b2608c6 Mon Sep 17 00:00:00 2001 From: Ralf Baussenwein Date: Thu, 16 Feb 2023 11:36:11 +0100 Subject: [PATCH 12/17] Add migrations for xlarge + xsmall --- src/Migration/ColumnsXLargeMigration.php | 53 ++++++++++++++++++++++++ src/Migration/ColumnsXSmallMigration.php | 53 ++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 src/Migration/ColumnsXLargeMigration.php create mode 100644 src/Migration/ColumnsXSmallMigration.php diff --git a/src/Migration/ColumnsXLargeMigration.php b/src/Migration/ColumnsXLargeMigration.php new file mode 100644 index 0000000..84010c9 --- /dev/null +++ b/src/Migration/ColumnsXLargeMigration.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace MadeYourDay\RockSolidColumns\Migration; + +use Contao\CoreBundle\Migration\AbstractMigration; +use Contao\CoreBundle\Migration\MigrationResult; +use Doctrine\DBAL\Connection; + +class ColumnsXLargeMigration extends AbstractMigration +{ + private Connection $connection; + + public function __construct(Connection $connection) + { + $this->connection = $connection; + } + + public function shouldRun(): bool + { + $schemaManager = $this->connection->createSchemaManager(); + + if (!$schemaManager->tablesExist(['tl_content'])) { + return false; + } + + $columns = $schemaManager->listTableColumns('tl_content'); + + if (!isset($columns['rs_columns_large'])) { + return false; + } + + return !isset($columns['rs_columns_xlarge']); + } + + public function run(): MigrationResult + { + $schemaManager = $this->connection->createSchemaManager(); + $columns = $schemaManager->listTableColumns('tl_content'); + + if (!isset($columns['rs_columns_xlarge'])) { + $this->connection->executeStatement("ALTER TABLE tl_content ADD rs_columns_xlarge VARCHAR(255) DEFAULT '' NOT NULL"); + $this->connection->executeStatement("UPDATE tl_content SET rs_columns_xlarge = rs_columns_large WHERE rs_columns_large != ''"); + } + + return $this->createResult(true); + } +} diff --git a/src/Migration/ColumnsXSmallMigration.php b/src/Migration/ColumnsXSmallMigration.php new file mode 100644 index 0000000..4b08119 --- /dev/null +++ b/src/Migration/ColumnsXSmallMigration.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace MadeYourDay\RockSolidColumns\Migration; + +use Contao\CoreBundle\Migration\AbstractMigration; +use Contao\CoreBundle\Migration\MigrationResult; +use Doctrine\DBAL\Connection; + +class ColumnsXSmallMigration extends AbstractMigration +{ + private Connection $connection; + + public function __construct(Connection $connection) + { + $this->connection = $connection; + } + + public function shouldRun(): bool + { + $schemaManager = $this->connection->createSchemaManager(); + + if (!$schemaManager->tablesExist(['tl_content'])) { + return false; + } + + $columns = $schemaManager->listTableColumns('tl_content'); + + if (!isset($columns['rs_columns_small'])) { + return false; + } + + return !isset($columns['rs_columns_xsmall']); + } + + public function run(): MigrationResult + { + $schemaManager = $this->connection->createSchemaManager(); + $columns = $schemaManager->listTableColumns('tl_content'); + + if (!isset($columns['rs_columns_xsmall'])) { + $this->connection->executeStatement("ALTER TABLE tl_content ADD rs_columns_xsmall VARCHAR(255) DEFAULT '' NOT NULL"); + $this->connection->executeStatement("UPDATE tl_content SET rs_columns_xsmall = rs_columns_small WHERE rs_columns_small != ''"); + } + + return $this->createResult(true); + } +} From a3378cd054c0ea5fbdbb2f28e97e03e813e09e3f Mon Sep 17 00:00:00 2001 From: Ralf Baussenwein Date: Wed, 10 May 2023 11:51:13 +0200 Subject: [PATCH 13/17] Remove migration for xsmall --- src/Migration/ColumnsXSmallMigration.php | 53 ------------------------ 1 file changed, 53 deletions(-) delete mode 100644 src/Migration/ColumnsXSmallMigration.php diff --git a/src/Migration/ColumnsXSmallMigration.php b/src/Migration/ColumnsXSmallMigration.php deleted file mode 100644 index 4b08119..0000000 --- a/src/Migration/ColumnsXSmallMigration.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace MadeYourDay\RockSolidColumns\Migration; - -use Contao\CoreBundle\Migration\AbstractMigration; -use Contao\CoreBundle\Migration\MigrationResult; -use Doctrine\DBAL\Connection; - -class ColumnsXSmallMigration extends AbstractMigration -{ - private Connection $connection; - - public function __construct(Connection $connection) - { - $this->connection = $connection; - } - - public function shouldRun(): bool - { - $schemaManager = $this->connection->createSchemaManager(); - - if (!$schemaManager->tablesExist(['tl_content'])) { - return false; - } - - $columns = $schemaManager->listTableColumns('tl_content'); - - if (!isset($columns['rs_columns_small'])) { - return false; - } - - return !isset($columns['rs_columns_xsmall']); - } - - public function run(): MigrationResult - { - $schemaManager = $this->connection->createSchemaManager(); - $columns = $schemaManager->listTableColumns('tl_content'); - - if (!isset($columns['rs_columns_xsmall'])) { - $this->connection->executeStatement("ALTER TABLE tl_content ADD rs_columns_xsmall VARCHAR(255) DEFAULT '' NOT NULL"); - $this->connection->executeStatement("UPDATE tl_content SET rs_columns_xsmall = rs_columns_small WHERE rs_columns_small != ''"); - } - - return $this->createResult(true); - } -} From 07b915d047f45fa553fe9972bf5f8cf2aff0b1d6 Mon Sep 17 00:00:00 2001 From: Ralf Baussenwein Date: Wed, 10 May 2023 11:54:24 +0200 Subject: [PATCH 14/17] Remove encryption --- .../CreateStopElementsSubmitCallbackListener.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/EventListener/DataContainer/CreateStopElementsSubmitCallbackListener.php b/src/EventListener/DataContainer/CreateStopElementsSubmitCallbackListener.php index d9b94b6..90e0f33 100644 --- a/src/EventListener/DataContainer/CreateStopElementsSubmitCallbackListener.php +++ b/src/EventListener/DataContainer/CreateStopElementsSubmitCallbackListener.php @@ -11,7 +11,6 @@ use Contao\CoreBundle\ServiceAnnotation\Callback; use Contao\Database; use Contao\DataContainer; -use Contao\Encryption; /** * @Callback(table="tl_content", target="config.onsubmit") @@ -84,9 +83,6 @@ public function __invoke(DataContainer $dc): void foreach ($GLOBALS['TL_DCA'][$dc->table]['fields'] as $field => $config) { if (array_key_exists('default', $config)) { $set[$field] = \is_array($config['default']) ? serialize($config['default']) : $config['default']; - if ($GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['eval']['encrypt'] ?? false) { - $set[$field] = Encryption::encrypt($set[$field]); - } } } From 6ed97c0b585ee38c7933b578a601001bc8a8ca48 Mon Sep 17 00:00:00 2001 From: Ralf Baussenwein Date: Wed, 10 May 2023 12:52:17 +0200 Subject: [PATCH 15/17] Refactor background image with studio --- .../ContentElement/ColumnStartController.php | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/Controller/ContentElement/ColumnStartController.php b/src/Controller/ContentElement/ColumnStartController.php index 5413818..666072f 100644 --- a/src/Controller/ContentElement/ColumnStartController.php +++ b/src/Controller/ContentElement/ColumnStartController.php @@ -10,12 +10,10 @@ use Contao\BackendTemplate; use Contao\ContentModel; -use Contao\Controller; use Contao\CoreBundle\Controller\ContentElement\AbstractContentElementController; +use Contao\CoreBundle\Image\Studio\Studio; use Contao\CoreBundle\Routing\ScopeMatcher; use Contao\CoreBundle\ServiceAnnotation\ContentElement; -use Contao\File; -use Contao\FilesModel; use Contao\StringUtil; use Contao\Template; use Symfony\Component\HttpFoundation\Request; @@ -31,11 +29,13 @@ class ColumnStartController extends AbstractContentElementController { private ScopeMatcher $scopeMatcher; + private Studio $studio; - public function __construct(ScopeMatcher $scopeMatcher) + public function __construct(ScopeMatcher $scopeMatcher, Studio $studio) { $this->scopeMatcher = $scopeMatcher; - } + $this->studio = $studio; + } protected function getResponse(Template $template, ContentModel $model, Request $request): ?Response { @@ -79,18 +79,15 @@ protected function getResponse(Template $template, ContentModel $model, Request } if (trim($model->rs_column_background_image)) { - $image = FilesModel::findByPk($model->rs_column_background_image); - if (null !== $image) { - $file = new File($image->path); - $imageObject = new \stdClass(); - Controller::addImageToTemplate($imageObject, array( - 'id' => $image->id, - 'uuid' => $image->uuid ?? null, - 'name' => $file->basename, - 'singleSRC' => $image->path, - 'size' => $model->rs_column_background_image_size, - )); - $styles[] = 'background-image: url("' . $imageObject->src . '");'; + $figure = $this->studio + ->createFigureBuilder() + ->fromUuid($model->rs_column_background_image ?: '') + ->setSize($model->rs_column_background_image_size) + ->enableLightbox(false) + ->buildIfResourceExists() + ; + if (null !== $figure) { + $styles[] = 'background-image: url("' . $figure->getImage()->getImageSrc(true) . '");'; } } From a92b26d76cd43f0a801b43d4ed5b2491605a7414 Mon Sep 17 00:00:00 2001 From: Ralf Baussenwein Date: Wed, 10 May 2023 12:59:44 +0200 Subject: [PATCH 16/17] Add suggestions from review --- src/Resources/contao/dca/tl_content.php | 3 ++- src/Resources/contao/dca/tl_form_field.php | 3 ++- src/Resources/contao/languages/en/tl_content.php | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Resources/contao/dca/tl_content.php b/src/Resources/contao/dca/tl_content.php index 2c5a758..79430ec 100644 --- a/src/Resources/contao/dca/tl_content.php +++ b/src/Resources/contao/dca/tl_content.php @@ -13,6 +13,7 @@ */ use Contao\System; +use Contao\BackendUser; $GLOBALS['TL_DCA']['tl_content']['palettes']['rs_columns_start'] = '{type_legend},type,headline;{rs_columns_legend},rs_columns_xlarge,rs_columns_large,rs_columns_medium,rs_columns_small,rs_columns_xsmall,rs_columns_gutter,rs_columns_outside_gutters,rs_columns_equal_height;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID;{invisible_legend:hide},invisible,start,stop'; $GLOBALS['TL_DCA']['tl_content']['palettes']['rs_columns_stop'] = '{type_legend},type;{protected_legend:hide},protected;{expert_legend:hide},guests;{invisible_legend:hide},invisible,start,stop'; @@ -150,7 +151,7 @@ 'exclude' => true, 'inputType' => 'imageSize', 'options_callback' => static function () { - return System::getContainer()->get('contao.image.sizes')->getAllOptions(); + return System::getContainer()->get('contao.image.sizes')->getOptionsForUser(BackendUser::getInstance()); }, 'reference' => &$GLOBALS['TL_LANG']['MSC'], 'eval' => array( diff --git a/src/Resources/contao/dca/tl_form_field.php b/src/Resources/contao/dca/tl_form_field.php index 4479bdc..8349ca2 100644 --- a/src/Resources/contao/dca/tl_form_field.php +++ b/src/Resources/contao/dca/tl_form_field.php @@ -13,6 +13,7 @@ */ use Contao\System; +use Contao\BackendUser; $GLOBALS['TL_DCA']['tl_form_field']['palettes']['rs_columns_start'] = '{type_legend},type;{rs_columns_legend},rs_columns_xlarge,rs_columns_large,rs_columns_medium,rs_columns_small,rs_columns_xsmall,rs_columns_gutter,rs_columns_outside_gutters,rs_columns_equal_height;{expert_legend:hide},class;{invisible_legend:hide},invisible'; $GLOBALS['TL_DCA']['tl_form_field']['palettes']['rs_columns_stop'] = '{type_legend},type;{invisible_legend:hide},invisible'; @@ -150,7 +151,7 @@ 'exclude' => true, 'inputType' => 'imageSize', 'options_callback' => static function () { - return System::getContainer()->get('contao.image.sizes')->getAllOptions(); + return System::getContainer()->get('contao.image.sizes')->getOptionsForUser(BackendUser::getInstance()); }, 'reference' => &$GLOBALS['TL_LANG']['MSC'], 'eval' => array( diff --git a/src/Resources/contao/languages/en/tl_content.php b/src/Resources/contao/languages/en/tl_content.php index 10540ea..78e9b2e 100644 --- a/src/Resources/contao/languages/en/tl_content.php +++ b/src/Resources/contao/languages/en/tl_content.php @@ -29,6 +29,7 @@ $GLOBALS['TL_LANG']['tl_content']['rs_columns_gutters']['s'] = 'Small'; $GLOBALS['TL_LANG']['tl_content']['rs_columns_gutters']['m'] = 'Medium'; $GLOBALS['TL_LANG']['tl_content']['rs_columns_gutters']['l'] = 'Large'; +$GLOBALS['TL_LANG']['tl_content']['rs_columns_gutters']['h'] = 'Huge'; $GLOBALS['TL_LANG']['tl_content']['rs_columns_outside_gutters'][0] = 'Outside gutter'; $GLOBALS['TL_LANG']['tl_content']['rs_columns_outside_gutters'][1] = 'Inserts a space before the first and after the last column.'; $GLOBALS['TL_LANG']['tl_content']['rs_columns_equal_height'][0] = 'Equal column height'; From c833c3962607d1709a7a9d5e39683c9245924ce4 Mon Sep 17 00:00:00 2001 From: Ralf Baussenwein Date: Wed, 10 May 2023 13:06:49 +0200 Subject: [PATCH 17/17] CS --- .../ContentElement/ColumnStartController.php | 28 +- .../ContentElement/ColumnsStartController.php | 4 +- .../RockSolidColumnsExtension.php | 12 +- .../AddColumnsClassesToContentListener.php | 48 +- .../AddColumnsClassesToFormListener.php | 66 +- .../AddFrontendAssetsListener.php | 12 +- .../AddBackendAssetsListener.php | 42 +- ...eateStopElementsSubmitCallbackListener.php | 118 ++-- src/Migration/ColumnsXLargeMigration.php | 54 +- src/Resources/contao/dca/tl_content.php | 2 +- src/Resources/contao/dca/tl_form_field.php | 4 +- src/Resources/public/css/be_main.css | 8 +- src/Resources/public/css/columns.css | 640 +++++++++--------- 13 files changed, 519 insertions(+), 519 deletions(-) diff --git a/src/Controller/ContentElement/ColumnStartController.php b/src/Controller/ContentElement/ColumnStartController.php index 666072f..7e7aaff 100644 --- a/src/Controller/ContentElement/ColumnStartController.php +++ b/src/Controller/ContentElement/ColumnStartController.php @@ -29,13 +29,13 @@ class ColumnStartController extends AbstractContentElementController { private ScopeMatcher $scopeMatcher; - private Studio $studio; + private Studio $studio; - public function __construct(ScopeMatcher $scopeMatcher, Studio $studio) + public function __construct(ScopeMatcher $scopeMatcher, Studio $studio) { $this->scopeMatcher = $scopeMatcher; - $this->studio = $studio; - } + $this->studio = $studio; + } protected function getResponse(Template $template, ContentModel $model, Request $request): ?Response { @@ -79,16 +79,16 @@ protected function getResponse(Template $template, ContentModel $model, Request } if (trim($model->rs_column_background_image)) { - $figure = $this->studio - ->createFigureBuilder() - ->fromUuid($model->rs_column_background_image ?: '') - ->setSize($model->rs_column_background_image_size) - ->enableLightbox(false) - ->buildIfResourceExists() - ; - if (null !== $figure) { - $styles[] = 'background-image: url("' . $figure->getImage()->getImageSrc(true) . '");'; - } + $figure = $this->studio + ->createFigureBuilder() + ->fromUuid($model->rs_column_background_image ?: '') + ->setSize($model->rs_column_background_image_size) + ->enableLightbox(false) + ->buildIfResourceExists() + ; + if (null !== $figure) { + $styles[] = 'background-image: url("' . $figure->getImage()->getImageSrc(true) . '");'; + } } if ($model->rs_column_background_size) { diff --git a/src/Controller/ContentElement/ColumnsStartController.php b/src/Controller/ContentElement/ColumnsStartController.php index 586b29f..dad65ef 100644 --- a/src/Controller/ContentElement/ColumnsStartController.php +++ b/src/Controller/ContentElement/ColumnsStartController.php @@ -86,7 +86,7 @@ protected function getResponse(Template $template, ContentModel $model, Request * Generate the columns configuration * * @param array $data Data array - * @return array Columns configuration + * @return array Columns configuration */ public static function getColumnsConfiguration(array $data): array { @@ -134,7 +134,7 @@ public static function getColumnsConfiguration(array $data): array * Generate the wrapper class name * * @param array $data Data array - * @return string Wrapper class name + * @return string Wrapper class name */ public static function getWrapperClassName(array $data): string { diff --git a/src/DependencyInjection/RockSolidColumnsExtension.php b/src/DependencyInjection/RockSolidColumnsExtension.php index 74d9ffc..2f01b83 100644 --- a/src/DependencyInjection/RockSolidColumnsExtension.php +++ b/src/DependencyInjection/RockSolidColumnsExtension.php @@ -15,10 +15,10 @@ final class RockSolidColumnsExtension extends Extension { - public function load(array $configs, ContainerBuilder $container): void - { - (new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'))) - ->load('services.yaml') - ; - } + public function load(array $configs, ContainerBuilder $container): void + { + (new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'))) + ->load('services.yaml') + ; + } } diff --git a/src/EventListener/AddColumnsClassesToContentListener.php b/src/EventListener/AddColumnsClassesToContentListener.php index e4a484e..6be4864 100644 --- a/src/EventListener/AddColumnsClassesToContentListener.php +++ b/src/EventListener/AddColumnsClassesToContentListener.php @@ -16,36 +16,36 @@ */ class AddColumnsClassesToContentListener { - public function __invoke(ContentModel $contentModel, string $buffer, $element): string - { - $parentKey = ($contentModel->ptable ?: 'tl_article').'__'.$contentModel->pid; - $excludeElements = ['rs_columns_start', 'rs_columns_stop', 'rs_column_start', 'rs_column_stop']; + public function __invoke(ContentModel $contentModel, string $buffer, $element): string + { + $parentKey = ($contentModel->ptable ?: 'tl_article').'__'.$contentModel->pid; + $excludeElements = ['rs_columns_start', 'rs_columns_stop', 'rs_column_start', 'rs_column_stop']; - if ( - isset($GLOBALS['TL_RS_COLUMNS'][$parentKey]) - && $GLOBALS['TL_RS_COLUMNS'][$parentKey]['active'] - && !\in_array($contentModel->type, $excludeElements, true) - ) { + if ( + isset($GLOBALS['TL_RS_COLUMNS'][$parentKey]) + && $GLOBALS['TL_RS_COLUMNS'][$parentKey]['active'] + && !\in_array($contentModel->type, $excludeElements, true) + ) { - $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']++; - $count = $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']; + $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']++; + $count = $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']; - if ($count) { + if ($count) { - $classes = array('rs-column'); - foreach ($GLOBALS['TL_RS_COLUMNS'][$parentKey]['config'] as $name => $media) { - $classes = array_merge($classes, $media[($count - 1) % count($media)]); - if ($count - 1 < count($media)) { - $classes[] = '-'.$name.'-first-row'; - } - } + $classes = array('rs-column'); + foreach ($GLOBALS['TL_RS_COLUMNS'][$parentKey]['config'] as $name => $media) { + $classes = array_merge($classes, $media[($count - 1) % count($media)]); + if ($count - 1 < count($media)) { + $classes[] = '-'.$name.'-first-row'; + } + } - return '
'.$buffer.'
'; + return '
'.$buffer.'
'; - } + } - } + } - return $buffer; - } + return $buffer; + } } diff --git a/src/EventListener/AddColumnsClassesToFormListener.php b/src/EventListener/AddColumnsClassesToFormListener.php index 17f3a67..02bab77 100644 --- a/src/EventListener/AddColumnsClassesToFormListener.php +++ b/src/EventListener/AddColumnsClassesToFormListener.php @@ -17,37 +17,37 @@ */ class AddColumnsClassesToFormListener { - public function __invoke(Widget $widget, string $formId, array $data, Form $form): Widget - { - $parentKey = 'tl_form__'.$widget->pid; - $excludeWidgets = ['rs_columns_start', 'rs_columns_stop', 'rs_column_start', 'rs_column_stop']; - - if (isset($GLOBALS['TL_RS_COLUMNS'][$parentKey]) - && $GLOBALS['TL_RS_COLUMNS'][$parentKey]['active'] - && !\in_array($widget->type, $excludeWidgets, true) - ) { - - $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']++; - $count = $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']; - - if ($count) { - - $classes = array('rs-column'); - foreach ($GLOBALS['TL_RS_COLUMNS'][$parentKey]['config'] as $name => $media) { - $classes = array_merge($classes, $media[($count - 1) % count($media)]); - if ($count - 1 < count($media)) { - $classes[] = '-'.$name.'-first-row'; - } - } - - if ('fieldsetStart' === $widget->type || 'submit' === $widget->type) { - $widget->class .= ' '.implode(' ', $classes); - } else { - $widget->prefix .= ' '.implode(' ', $classes); - } - } - } - - return $widget; - } + public function __invoke(Widget $widget, string $formId, array $data, Form $form): Widget + { + $parentKey = 'tl_form__'.$widget->pid; + $excludeWidgets = ['rs_columns_start', 'rs_columns_stop', 'rs_column_start', 'rs_column_stop']; + + if (isset($GLOBALS['TL_RS_COLUMNS'][$parentKey]) + && $GLOBALS['TL_RS_COLUMNS'][$parentKey]['active'] + && !\in_array($widget->type, $excludeWidgets, true) + ) { + + $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']++; + $count = $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']; + + if ($count) { + + $classes = array('rs-column'); + foreach ($GLOBALS['TL_RS_COLUMNS'][$parentKey]['config'] as $name => $media) { + $classes = array_merge($classes, $media[($count - 1) % count($media)]); + if ($count - 1 < count($media)) { + $classes[] = '-'.$name.'-first-row'; + } + } + + if ('fieldsetStart' === $widget->type || 'submit' === $widget->type) { + $widget->class .= ' '.implode(' ', $classes); + } else { + $widget->prefix .= ' '.implode(' ', $classes); + } + } + } + + return $widget; + } } diff --git a/src/EventListener/AddFrontendAssetsListener.php b/src/EventListener/AddFrontendAssetsListener.php index 39a651b..f9e8ad6 100644 --- a/src/EventListener/AddFrontendAssetsListener.php +++ b/src/EventListener/AddFrontendAssetsListener.php @@ -18,10 +18,10 @@ */ class AddFrontendAssetsListener { - public function __invoke(PageModel $pageModel, LayoutModel $layout, PageRegular $pageRegular): void - { - if ($layout->rs_columns_load_css) { - $GLOBALS['TL_CSS'][] = 'bundles/rocksolidcolumns/css/columns.css||static'; - } - } + public function __invoke(PageModel $pageModel, LayoutModel $layout, PageRegular $pageRegular): void + { + if ($layout->rs_columns_load_css) { + $GLOBALS['TL_CSS'][] = 'bundles/rocksolidcolumns/css/columns.css||static'; + } + } } diff --git a/src/EventListener/DataContainer/AddBackendAssetsListener.php b/src/EventListener/DataContainer/AddBackendAssetsListener.php index 137d23e..230d612 100644 --- a/src/EventListener/DataContainer/AddBackendAssetsListener.php +++ b/src/EventListener/DataContainer/AddBackendAssetsListener.php @@ -18,31 +18,31 @@ */ class AddBackendAssetsListener { - private RequestStack $requestStack; - private ScopeMatcher $scopeMatcher; + private RequestStack $requestStack; + private ScopeMatcher $scopeMatcher; - public function __construct(RequestStack $requestStack, ScopeMatcher $scopeMatcher) - { - $this->requestStack = $requestStack; - $this->scopeMatcher = $scopeMatcher; - } + public function __construct(RequestStack $requestStack, ScopeMatcher $scopeMatcher) + { + $this->requestStack = $requestStack; + $this->scopeMatcher = $scopeMatcher; + } - public function __invoke(string $table): void - { - if ('tl_content' !== $table && 'tl_form_field' !== $table) { - return; - } + public function __invoke(string $table): void + { + if ('tl_content' !== $table && 'tl_form_field' !== $table) { + return; + } - $request = $this->requestStack->getCurrentRequest(); + $request = $this->requestStack->getCurrentRequest(); - if (null === $request || !$this->scopeMatcher->isBackendRequest($request)) { - return; - } + if (null === $request || !$this->scopeMatcher->isBackendRequest($request)) { + return; + } - $GLOBALS['TL_CSS'][] = 'bundles/rocksolidcolumns/css/be_main.css'; + $GLOBALS['TL_CSS'][] = 'bundles/rocksolidcolumns/css/be_main.css'; - if ('tl_form_field' === $table) { - System::loadLanguageFile('tl_content'); - } - } + if ('tl_form_field' === $table) { + System::loadLanguageFile('tl_content'); + } + } } diff --git a/src/EventListener/DataContainer/CreateStopElementsSubmitCallbackListener.php b/src/EventListener/DataContainer/CreateStopElementsSubmitCallbackListener.php index 90e0f33..387071d 100644 --- a/src/EventListener/DataContainer/CreateStopElementsSubmitCallbackListener.php +++ b/src/EventListener/DataContainer/CreateStopElementsSubmitCallbackListener.php @@ -18,20 +18,20 @@ */ class CreateStopElementsSubmitCallbackListener { - public function __invoke(DataContainer $dc): void - { - $activeRecord = $dc->activeRecord; - if (!$activeRecord) { - return; - } + public function __invoke(DataContainer $dc): void + { + $activeRecord = $dc->activeRecord; + if (!$activeRecord) { + return; + } - if ($activeRecord->type === 'rs_columns_start' || $activeRecord->type === 'rs_column_start') { + if ($activeRecord->type === 'rs_columns_start' || $activeRecord->type === 'rs_column_start') { - if ($dc->table === 'tl_content') { + if ($dc->table === 'tl_content') { - // Find the next columns or column element - $nextElement = Database::getInstance() - ->prepare(' + // Find the next columns or column element + $nextElement = Database::getInstance() + ->prepare(' SELECT type FROM tl_content WHERE pid = ? @@ -41,19 +41,19 @@ public function __invoke(DataContainer $dc): void ORDER BY sorting ASC LIMIT 1 ') - ->execute( - $activeRecord->pid, - $activeRecord->ptable ?: 'tl_article', - $activeRecord->ptable === 'tl_article' ? '' : $activeRecord->ptable, - $activeRecord->sorting - ); + ->execute( + $activeRecord->pid, + $activeRecord->ptable ?: 'tl_article', + $activeRecord->ptable === 'tl_article' ? '' : $activeRecord->ptable, + $activeRecord->sorting + ); - } - else { + } + else { - // Find the next columns or column element - $nextElement = Database::getInstance() - ->prepare(' + // Find the next columns or column element + $nextElement = Database::getInstance() + ->prepare(' SELECT type FROM ' . $dc->table . ' WHERE pid = ? @@ -62,47 +62,47 @@ public function __invoke(DataContainer $dc): void ORDER BY sorting ASC LIMIT 1 ') - ->execute( - $activeRecord->pid, - $activeRecord->sorting - ); + ->execute( + $activeRecord->pid, + $activeRecord->sorting + ); - } + } - // Check if a stop element should be created - if ( - !$nextElement->type - || ($activeRecord->type === 'rs_columns_start' && $nextElement->type === 'rs_column_stop') - || ($activeRecord->type === 'rs_column_start' && ( - $nextElement->type === 'rs_column_start' || $nextElement->type === 'rs_columns_stop' - )) - ) { - $set = array(); + // Check if a stop element should be created + if ( + !$nextElement->type + || ($activeRecord->type === 'rs_columns_start' && $nextElement->type === 'rs_column_stop') + || ($activeRecord->type === 'rs_column_start' && ( + $nextElement->type === 'rs_column_start' || $nextElement->type === 'rs_columns_stop' + )) + ) { + $set = array(); - // Get all default values for the new entry - foreach ($GLOBALS['TL_DCA'][$dc->table]['fields'] as $field => $config) { - if (array_key_exists('default', $config)) { - $set[$field] = \is_array($config['default']) ? serialize($config['default']) : $config['default']; - } - } + // Get all default values for the new entry + foreach ($GLOBALS['TL_DCA'][$dc->table]['fields'] as $field => $config) { + if (array_key_exists('default', $config)) { + $set[$field] = \is_array($config['default']) ? serialize($config['default']) : $config['default']; + } + } - $set['pid'] = $activeRecord->pid; - $set['type'] = substr($activeRecord->type, 0, -5) . 'stop'; - $set['sorting'] = $activeRecord->sorting + 1; - $set['invisible'] = $activeRecord->invisible; - $set['tstamp'] = time(); + $set['pid'] = $activeRecord->pid; + $set['type'] = substr($activeRecord->type, 0, -5) . 'stop'; + $set['sorting'] = $activeRecord->sorting + 1; + $set['invisible'] = $activeRecord->invisible; + $set['tstamp'] = time(); - if ($dc->table === 'tl_content') { - $set['ptable'] = $activeRecord->ptable ?: 'tl_article'; - $set['start'] = $activeRecord->start; - $set['stop'] = $activeRecord->stop; - } + if ($dc->table === 'tl_content') { + $set['ptable'] = $activeRecord->ptable ?: 'tl_article'; + $set['start'] = $activeRecord->start; + $set['stop'] = $activeRecord->stop; + } - Database::getInstance() - ->prepare('INSERT INTO ' . $dc->table . ' %s') - ->set($set) - ->execute(); - } - } - } + Database::getInstance() + ->prepare('INSERT INTO ' . $dc->table . ' %s') + ->set($set) + ->execute(); + } + } + } } diff --git a/src/Migration/ColumnsXLargeMigration.php b/src/Migration/ColumnsXLargeMigration.php index 84010c9..72a3e26 100644 --- a/src/Migration/ColumnsXLargeMigration.php +++ b/src/Migration/ColumnsXLargeMigration.php @@ -14,40 +14,40 @@ class ColumnsXLargeMigration extends AbstractMigration { - private Connection $connection; + private Connection $connection; - public function __construct(Connection $connection) - { - $this->connection = $connection; - } + public function __construct(Connection $connection) + { + $this->connection = $connection; + } - public function shouldRun(): bool - { - $schemaManager = $this->connection->createSchemaManager(); + public function shouldRun(): bool + { + $schemaManager = $this->connection->createSchemaManager(); - if (!$schemaManager->tablesExist(['tl_content'])) { - return false; - } + if (!$schemaManager->tablesExist(['tl_content'])) { + return false; + } - $columns = $schemaManager->listTableColumns('tl_content'); + $columns = $schemaManager->listTableColumns('tl_content'); - if (!isset($columns['rs_columns_large'])) { - return false; - } + if (!isset($columns['rs_columns_large'])) { + return false; + } - return !isset($columns['rs_columns_xlarge']); - } + return !isset($columns['rs_columns_xlarge']); + } - public function run(): MigrationResult - { - $schemaManager = $this->connection->createSchemaManager(); - $columns = $schemaManager->listTableColumns('tl_content'); + public function run(): MigrationResult + { + $schemaManager = $this->connection->createSchemaManager(); + $columns = $schemaManager->listTableColumns('tl_content'); - if (!isset($columns['rs_columns_xlarge'])) { - $this->connection->executeStatement("ALTER TABLE tl_content ADD rs_columns_xlarge VARCHAR(255) DEFAULT '' NOT NULL"); - $this->connection->executeStatement("UPDATE tl_content SET rs_columns_xlarge = rs_columns_large WHERE rs_columns_large != ''"); - } + if (!isset($columns['rs_columns_xlarge'])) { + $this->connection->executeStatement("ALTER TABLE tl_content ADD rs_columns_xlarge VARCHAR(255) DEFAULT '' NOT NULL"); + $this->connection->executeStatement("UPDATE tl_content SET rs_columns_xlarge = rs_columns_large WHERE rs_columns_large != ''"); + } - return $this->createResult(true); - } + return $this->createResult(true); + } } diff --git a/src/Resources/contao/dca/tl_content.php b/src/Resources/contao/dca/tl_content.php index 79430ec..a6e88d6 100644 --- a/src/Resources/contao/dca/tl_content.php +++ b/src/Resources/contao/dca/tl_content.php @@ -12,8 +12,8 @@ * @author Martin Auswöger */ -use Contao\System; use Contao\BackendUser; +use Contao\System; $GLOBALS['TL_DCA']['tl_content']['palettes']['rs_columns_start'] = '{type_legend},type,headline;{rs_columns_legend},rs_columns_xlarge,rs_columns_large,rs_columns_medium,rs_columns_small,rs_columns_xsmall,rs_columns_gutter,rs_columns_outside_gutters,rs_columns_equal_height;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID;{invisible_legend:hide},invisible,start,stop'; $GLOBALS['TL_DCA']['tl_content']['palettes']['rs_columns_stop'] = '{type_legend},type;{protected_legend:hide},protected;{expert_legend:hide},guests;{invisible_legend:hide},invisible,start,stop'; diff --git a/src/Resources/contao/dca/tl_form_field.php b/src/Resources/contao/dca/tl_form_field.php index 8349ca2..ffdf6ca 100644 --- a/src/Resources/contao/dca/tl_form_field.php +++ b/src/Resources/contao/dca/tl_form_field.php @@ -12,8 +12,8 @@ * @author Martin Auswöger */ -use Contao\System; use Contao\BackendUser; +use Contao\System; $GLOBALS['TL_DCA']['tl_form_field']['palettes']['rs_columns_start'] = '{type_legend},type;{rs_columns_legend},rs_columns_xlarge,rs_columns_large,rs_columns_medium,rs_columns_small,rs_columns_xsmall,rs_columns_gutter,rs_columns_outside_gutters,rs_columns_equal_height;{expert_legend:hide},class;{invisible_legend:hide},invisible'; $GLOBALS['TL_DCA']['tl_form_field']['palettes']['rs_columns_stop'] = '{type_legend},type;{invisible_legend:hide},invisible'; @@ -151,7 +151,7 @@ 'exclude' => true, 'inputType' => 'imageSize', 'options_callback' => static function () { - return System::getContainer()->get('contao.image.sizes')->getOptionsForUser(BackendUser::getInstance()); + return System::getContainer()->get('contao.image.sizes')->getOptionsForUser(BackendUser::getInstance()); }, 'reference' => &$GLOBALS['TL_LANG']['MSC'], 'eval' => array( diff --git a/src/Resources/public/css/be_main.css b/src/Resources/public/css/be_main.css index dfbab86..b57f33b 100644 --- a/src/Resources/public/css/be_main.css +++ b/src/Resources/public/css/be_main.css @@ -17,12 +17,12 @@ @media (max-width: 767px) { .rs_columns_w33, .rs_columns_w20 { - float: none; - width: calc(100% - 30px); - min-height: 0; + float: none; + width: calc(100% - 30px); + min-height: 0; } .rs_columns_w33.m12, .rs_columns_w20.m12 { - min-height: 0; + min-height: 0; } } diff --git a/src/Resources/public/css/columns.css b/src/Resources/public/css/columns.css index 737f2a4..76ba23c 100644 --- a/src/Resources/public/css/columns.css +++ b/src/Resources/public/css/columns.css @@ -314,969 +314,969 @@ } @media screen and (max-width: 1200px) { .rs-column.-xlarge-first { - clear: none; + clear: none; } .rs-column.-large-first { - clear: left; + clear: left; } .rs-column.-large-col-1-1 { - width: 100%; + width: 100%; } .rs-column.-large-col-2-1 { - width: 50%; + width: 50%; } .rs-column.-large-col-2-2 { - width: 100%; + width: 100%; } .rs-column.-large-col-3-1 { - width: 33.33333%; + width: 33.33333%; } .rs-column.-large-col-3-2 { - width: 66.66667%; + width: 66.66667%; } .rs-column.-large-col-3-3 { - width: 100%; + width: 100%; } .rs-column.-large-col-4-1 { - width: 25%; + width: 25%; } .rs-column.-large-col-4-2 { - width: 50%; + width: 50%; } .rs-column.-large-col-4-3 { - width: 75%; + width: 75%; } .rs-column.-large-col-4-4 { - width: 100%; + width: 100%; } .rs-column.-large-col-5-1 { - width: 20%; + width: 20%; } .rs-column.-large-col-5-2 { - width: 40%; + width: 40%; } .rs-column.-large-col-5-3 { - width: 60.0%; + width: 60.0%; } .rs-column.-large-col-5-4 { - width: 80%; + width: 80%; } .rs-column.-large-col-5-5 { - width: 100%; + width: 100%; } .rs-column.-large-col-6-1 { - width: 16.66667%; + width: 16.66667%; } .rs-column.-large-col-6-2 { - width: 33.33333%; + width: 33.33333%; } .rs-column.-large-col-6-3 { - width: 50%; + width: 50%; } .rs-column.-large-col-6-4 { - width: 66.66667%; + width: 66.66667%; } .rs-column.-large-col-6-5 { - width: 83.33333%; + width: 83.33333%; } .rs-column.-large-col-6-6 { - width: 100%; + width: 100%; } .rs-column.-large-col-7-1 { - width: 14.28571%; + width: 14.28571%; } .rs-column.-large-col-7-2 { - width: 28.57143%; + width: 28.57143%; } .rs-column.-large-col-7-3 { - width: 42.85714%; + width: 42.85714%; } .rs-column.-large-col-7-4 { - width: 57.14286%; + width: 57.14286%; } .rs-column.-large-col-7-5 { - width: 71.42857%; + width: 71.42857%; } .rs-column.-large-col-7-6 { - width: 85.71429%; + width: 85.71429%; } .rs-column.-large-col-7-7 { - width: 100%; + width: 100%; } .rs-column.-large-col-8-1 { - width: 12.5%; + width: 12.5%; } .rs-column.-large-col-8-2 { - width: 25%; + width: 25%; } .rs-column.-large-col-8-3 { - width: 37.5%; + width: 37.5%; } .rs-column.-large-col-8-4 { - width: 50%; + width: 50%; } .rs-column.-large-col-8-5 { - width: 62.5%; + width: 62.5%; } .rs-column.-large-col-8-6 { - width: 75%; + width: 75%; } .rs-column.-large-col-8-7 { - width: 87.5%; + width: 87.5%; } .rs-column.-large-col-8-8 { - width: 100%; + width: 100%; } .rs-column.-large-col-9-1 { - width: 11.11111%; + width: 11.11111%; } .rs-column.-large-col-9-2 { - width: 22.22222%; + width: 22.22222%; } .rs-column.-large-col-9-3 { - width: 33.33333%; + width: 33.33333%; } .rs-column.-large-col-9-4 { - width: 44.44444%; + width: 44.44444%; } .rs-column.-large-col-9-5 { - width: 55.55556%; + width: 55.55556%; } .rs-column.-large-col-9-6 { - width: 66.66667%; + width: 66.66667%; } .rs-column.-large-col-9-7 { - width: 77.77778%; + width: 77.77778%; } .rs-column.-large-col-9-8 { - width: 88.88889%; + width: 88.88889%; } .rs-column.-large-col-9-9 { - width: 100%; + width: 100%; } .rs-column.-large-col-10-1 { - width: 10%; + width: 10%; } .rs-column.-large-col-10-2 { - width: 20%; + width: 20%; } .rs-column.-large-col-10-3 { - width: 30.0%; + width: 30.0%; } .rs-column.-large-col-10-4 { - width: 40%; + width: 40%; } .rs-column.-large-col-10-5 { - width: 50%; + width: 50%; } .rs-column.-large-col-10-6 { - width: 60.0%; + width: 60.0%; } .rs-column.-large-col-10-7 { - width: 70%; + width: 70%; } .rs-column.-large-col-10-8 { - width: 80%; + width: 80%; } .rs-column.-large-col-10-9 { - width: 90%; + width: 90%; } .rs-column.-large-col-10-10 { - width: 100%; + width: 100%; } .rs-column.-large-col-11-1 { - width: 9.09091%; + width: 9.09091%; } .rs-column.-large-col-11-2 { - width: 18.18182%; + width: 18.18182%; } .rs-column.-large-col-11-3 { - width: 27.27273%; + width: 27.27273%; } .rs-column.-large-col-11-4 { - width: 36.36364%; + width: 36.36364%; } .rs-column.-large-col-11-5 { - width: 45.45455%; + width: 45.45455%; } .rs-column.-large-col-11-6 { - width: 54.54545%; + width: 54.54545%; } .rs-column.-large-col-11-7 { - width: 63.63636%; + width: 63.63636%; } .rs-column.-large-col-11-8 { - width: 72.72727%; + width: 72.72727%; } .rs-column.-large-col-11-9 { - width: 81.81818%; + width: 81.81818%; } .rs-column.-large-col-11-10 { - width: 90.90909%; + width: 90.90909%; } .rs-column.-large-col-11-11 { - width: 100%; + width: 100%; } .rs-column.-large-col-12-1 { - width: 8.33333%; + width: 8.33333%; } .rs-column.-large-col-12-2 { - width: 16.66667%; + width: 16.66667%; } .rs-column.-large-col-12-3 { - width: 25%; + width: 25%; } .rs-column.-large-col-12-4 { - width: 33.33333%; + width: 33.33333%; } .rs-column.-large-col-12-5 { - width: 41.66667%; + width: 41.66667%; } .rs-column.-large-col-12-6 { - width: 50%; + width: 50%; } .rs-column.-large-col-12-7 { - width: 58.33333%; + width: 58.33333%; } .rs-column.-large-col-12-8 { - width: 66.66667%; + width: 66.66667%; } .rs-column.-large-col-12-9 { - width: 75%; + width: 75%; } .rs-column.-large-col-12-10 { - width: 83.33333%; + width: 83.33333%; } .rs-column.-large-col-12-11 { - width: 91.66667%; + width: 91.66667%; } .rs-column.-large-col-12-12 { - width: 100%; + width: 100%; } } @media screen and (max-width: 900px) { .rs-column.-large-first { - clear: none; + clear: none; } .rs-column.-medium-first { - clear: left; + clear: left; } .rs-column.-medium-col-1-1 { - width: 100%; + width: 100%; } .rs-column.-medium-col-2-1 { - width: 50%; + width: 50%; } .rs-column.-medium-col-2-2 { - width: 100%; + width: 100%; } .rs-column.-medium-col-3-1 { - width: 33.33333%; + width: 33.33333%; } .rs-column.-medium-col-3-2 { - width: 66.66667%; + width: 66.66667%; } .rs-column.-medium-col-3-3 { - width: 100%; + width: 100%; } .rs-column.-medium-col-4-1 { - width: 25%; + width: 25%; } .rs-column.-medium-col-4-2 { - width: 50%; + width: 50%; } .rs-column.-medium-col-4-3 { - width: 75%; + width: 75%; } .rs-column.-medium-col-4-4 { - width: 100%; + width: 100%; } .rs-column.-medium-col-5-1 { - width: 20%; + width: 20%; } .rs-column.-medium-col-5-2 { - width: 40%; + width: 40%; } .rs-column.-medium-col-5-3 { - width: 60.0%; + width: 60.0%; } .rs-column.-medium-col-5-4 { - width: 80%; + width: 80%; } .rs-column.-medium-col-5-5 { - width: 100%; + width: 100%; } .rs-column.-medium-col-6-1 { - width: 16.66667%; + width: 16.66667%; } .rs-column.-medium-col-6-2 { - width: 33.33333%; + width: 33.33333%; } .rs-column.-medium-col-6-3 { - width: 50%; + width: 50%; } .rs-column.-medium-col-6-4 { - width: 66.66667%; + width: 66.66667%; } .rs-column.-medium-col-6-5 { - width: 83.33333%; + width: 83.33333%; } .rs-column.-medium-col-6-6 { - width: 100%; + width: 100%; } .rs-column.-medium-col-7-1 { - width: 14.28571%; + width: 14.28571%; } .rs-column.-medium-col-7-2 { - width: 28.57143%; + width: 28.57143%; } .rs-column.-medium-col-7-3 { - width: 42.85714%; + width: 42.85714%; } .rs-column.-medium-col-7-4 { - width: 57.14286%; + width: 57.14286%; } .rs-column.-medium-col-7-5 { - width: 71.42857%; + width: 71.42857%; } .rs-column.-medium-col-7-6 { - width: 85.71429%; + width: 85.71429%; } .rs-column.-medium-col-7-7 { - width: 100%; + width: 100%; } .rs-column.-medium-col-8-1 { - width: 12.5%; + width: 12.5%; } .rs-column.-medium-col-8-2 { - width: 25%; + width: 25%; } .rs-column.-medium-col-8-3 { - width: 37.5%; + width: 37.5%; } .rs-column.-medium-col-8-4 { - width: 50%; + width: 50%; } .rs-column.-medium-col-8-5 { - width: 62.5%; + width: 62.5%; } .rs-column.-medium-col-8-6 { - width: 75%; + width: 75%; } .rs-column.-medium-col-8-7 { - width: 87.5%; + width: 87.5%; } .rs-column.-medium-col-8-8 { - width: 100%; + width: 100%; } .rs-column.-medium-col-9-1 { - width: 11.11111%; + width: 11.11111%; } .rs-column.-medium-col-9-2 { - width: 22.22222%; + width: 22.22222%; } .rs-column.-medium-col-9-3 { - width: 33.33333%; + width: 33.33333%; } .rs-column.-medium-col-9-4 { - width: 44.44444%; + width: 44.44444%; } .rs-column.-medium-col-9-5 { - width: 55.55556%; + width: 55.55556%; } .rs-column.-medium-col-9-6 { - width: 66.66667%; + width: 66.66667%; } .rs-column.-medium-col-9-7 { - width: 77.77778%; + width: 77.77778%; } .rs-column.-medium-col-9-8 { - width: 88.88889%; + width: 88.88889%; } .rs-column.-medium-col-9-9 { - width: 100%; + width: 100%; } .rs-column.-medium-col-10-1 { - width: 10%; + width: 10%; } .rs-column.-medium-col-10-2 { - width: 20%; + width: 20%; } .rs-column.-medium-col-10-3 { - width: 30.0%; + width: 30.0%; } .rs-column.-medium-col-10-4 { - width: 40%; + width: 40%; } .rs-column.-medium-col-10-5 { - width: 50%; + width: 50%; } .rs-column.-medium-col-10-6 { - width: 60.0%; + width: 60.0%; } .rs-column.-medium-col-10-7 { - width: 70%; + width: 70%; } .rs-column.-medium-col-10-8 { - width: 80%; + width: 80%; } .rs-column.-medium-col-10-9 { - width: 90%; + width: 90%; } .rs-column.-medium-col-10-10 { - width: 100%; + width: 100%; } .rs-column.-medium-col-11-1 { - width: 9.09091%; + width: 9.09091%; } .rs-column.-medium-col-11-2 { - width: 18.18182%; + width: 18.18182%; } .rs-column.-medium-col-11-3 { - width: 27.27273%; + width: 27.27273%; } .rs-column.-medium-col-11-4 { - width: 36.36364%; + width: 36.36364%; } .rs-column.-medium-col-11-5 { - width: 45.45455%; + width: 45.45455%; } .rs-column.-medium-col-11-6 { - width: 54.54545%; + width: 54.54545%; } .rs-column.-medium-col-11-7 { - width: 63.63636%; + width: 63.63636%; } .rs-column.-medium-col-11-8 { - width: 72.72727%; + width: 72.72727%; } .rs-column.-medium-col-11-9 { - width: 81.81818%; + width: 81.81818%; } .rs-column.-medium-col-11-10 { - width: 90.90909%; + width: 90.90909%; } .rs-column.-medium-col-11-11 { - width: 100%; + width: 100%; } .rs-column.-medium-col-12-1 { - width: 8.33333%; + width: 8.33333%; } .rs-column.-medium-col-12-2 { - width: 16.66667%; + width: 16.66667%; } .rs-column.-medium-col-12-3 { - width: 25%; + width: 25%; } .rs-column.-medium-col-12-4 { - width: 33.33333%; + width: 33.33333%; } .rs-column.-medium-col-12-5 { - width: 41.66667%; + width: 41.66667%; } .rs-column.-medium-col-12-6 { - width: 50%; + width: 50%; } .rs-column.-medium-col-12-7 { - width: 58.33333%; + width: 58.33333%; } .rs-column.-medium-col-12-8 { - width: 66.66667%; + width: 66.66667%; } .rs-column.-medium-col-12-9 { - width: 75%; + width: 75%; } .rs-column.-medium-col-12-10 { - width: 83.33333%; + width: 83.33333%; } .rs-column.-medium-col-12-11 { - width: 91.66667%; + width: 91.66667%; } .rs-column.-medium-col-12-12 { - width: 100%; + width: 100%; } } @media screen and (max-width: 599px) { .rs-column.-medium-first { - clear: none; + clear: none; } .rs-column.-small-first { - clear: left; + clear: left; } .rs-column.-small-col-1-1 { - width: 100%; + width: 100%; } .rs-column.-small-col-2-1 { - width: 50%; + width: 50%; } .rs-column.-small-col-2-2 { - width: 100%; + width: 100%; } .rs-column.-small-col-3-1 { - width: 33.33333%; + width: 33.33333%; } .rs-column.-small-col-3-2 { - width: 66.66667%; + width: 66.66667%; } .rs-column.-small-col-3-3 { - width: 100%; + width: 100%; } .rs-column.-small-col-4-1 { - width: 25%; + width: 25%; } .rs-column.-small-col-4-2 { - width: 50%; + width: 50%; } .rs-column.-small-col-4-3 { - width: 75%; + width: 75%; } .rs-column.-small-col-4-4 { - width: 100%; + width: 100%; } .rs-column.-small-col-5-1 { - width: 20%; + width: 20%; } .rs-column.-small-col-5-2 { - width: 40%; + width: 40%; } .rs-column.-small-col-5-3 { - width: 60.0%; + width: 60.0%; } .rs-column.-small-col-5-4 { - width: 80%; + width: 80%; } .rs-column.-small-col-5-5 { - width: 100%; + width: 100%; } .rs-column.-small-col-6-1 { - width: 16.66667%; + width: 16.66667%; } .rs-column.-small-col-6-2 { - width: 33.33333%; + width: 33.33333%; } .rs-column.-small-col-6-3 { - width: 50%; + width: 50%; } .rs-column.-small-col-6-4 { - width: 66.66667%; + width: 66.66667%; } .rs-column.-small-col-6-5 { - width: 83.33333%; + width: 83.33333%; } .rs-column.-small-col-6-6 { - width: 100%; + width: 100%; } .rs-column.-small-col-7-1 { - width: 14.28571%; + width: 14.28571%; } .rs-column.-small-col-7-2 { - width: 28.57143%; + width: 28.57143%; } .rs-column.-small-col-7-3 { - width: 42.85714%; + width: 42.85714%; } .rs-column.-small-col-7-4 { - width: 57.14286%; + width: 57.14286%; } .rs-column.-small-col-7-5 { - width: 71.42857%; + width: 71.42857%; } .rs-column.-small-col-7-6 { - width: 85.71429%; + width: 85.71429%; } .rs-column.-small-col-7-7 { - width: 100%; + width: 100%; } .rs-column.-small-col-8-1 { - width: 12.5%; + width: 12.5%; } .rs-column.-small-col-8-2 { - width: 25%; + width: 25%; } .rs-column.-small-col-8-3 { - width: 37.5%; + width: 37.5%; } .rs-column.-small-col-8-4 { - width: 50%; + width: 50%; } .rs-column.-small-col-8-5 { - width: 62.5%; + width: 62.5%; } .rs-column.-small-col-8-6 { - width: 75%; + width: 75%; } .rs-column.-small-col-8-7 { - width: 87.5%; + width: 87.5%; } .rs-column.-small-col-8-8 { - width: 100%; + width: 100%; } .rs-column.-small-col-9-1 { - width: 11.11111%; + width: 11.11111%; } .rs-column.-small-col-9-2 { - width: 22.22222%; + width: 22.22222%; } .rs-column.-small-col-9-3 { - width: 33.33333%; + width: 33.33333%; } .rs-column.-small-col-9-4 { - width: 44.44444%; + width: 44.44444%; } .rs-column.-small-col-9-5 { - width: 55.55556%; + width: 55.55556%; } .rs-column.-small-col-9-6 { - width: 66.66667%; + width: 66.66667%; } .rs-column.-small-col-9-7 { - width: 77.77778%; + width: 77.77778%; } .rs-column.-small-col-9-8 { - width: 88.88889%; + width: 88.88889%; } .rs-column.-small-col-9-9 { - width: 100%; + width: 100%; } .rs-column.-small-col-10-1 { - width: 10%; + width: 10%; } .rs-column.-small-col-10-2 { - width: 20%; + width: 20%; } .rs-column.-small-col-10-3 { - width: 30.0%; + width: 30.0%; } .rs-column.-small-col-10-4 { - width: 40%; + width: 40%; } .rs-column.-small-col-10-5 { - width: 50%; + width: 50%; } .rs-column.-small-col-10-6 { - width: 60.0%; + width: 60.0%; } .rs-column.-small-col-10-7 { - width: 70%; + width: 70%; } .rs-column.-small-col-10-8 { - width: 80%; + width: 80%; } .rs-column.-small-col-10-9 { - width: 90%; + width: 90%; } .rs-column.-small-col-10-10 { - width: 100%; + width: 100%; } .rs-column.-small-col-11-1 { - width: 9.09091%; + width: 9.09091%; } .rs-column.-small-col-11-2 { - width: 18.18182%; + width: 18.18182%; } .rs-column.-small-col-11-3 { - width: 27.27273%; + width: 27.27273%; } .rs-column.-small-col-11-4 { - width: 36.36364%; + width: 36.36364%; } .rs-column.-small-col-11-5 { - width: 45.45455%; + width: 45.45455%; } .rs-column.-small-col-11-6 { - width: 54.54545%; + width: 54.54545%; } .rs-column.-small-col-11-7 { - width: 63.63636%; + width: 63.63636%; } .rs-column.-small-col-11-8 { - width: 72.72727%; + width: 72.72727%; } .rs-column.-small-col-11-9 { - width: 81.81818%; + width: 81.81818%; } .rs-column.-small-col-11-10 { - width: 90.90909%; + width: 90.90909%; } .rs-column.-small-col-11-11 { - width: 100%; + width: 100%; } .rs-column.-small-col-12-1 { - width: 8.33333%; + width: 8.33333%; } .rs-column.-small-col-12-2 { - width: 16.66667%; + width: 16.66667%; } .rs-column.-small-col-12-3 { - width: 25%; + width: 25%; } .rs-column.-small-col-12-4 { - width: 33.33333%; + width: 33.33333%; } .rs-column.-small-col-12-5 { - width: 41.66667%; + width: 41.66667%; } .rs-column.-small-col-12-6 { - width: 50%; + width: 50%; } .rs-column.-small-col-12-7 { - width: 58.33333%; + width: 58.33333%; } .rs-column.-small-col-12-8 { - width: 66.66667%; + width: 66.66667%; } .rs-column.-small-col-12-9 { - width: 75%; + width: 75%; } .rs-column.-small-col-12-10 { - width: 83.33333%; + width: 83.33333%; } .rs-column.-small-col-12-11 { - width: 91.66667%; + width: 91.66667%; } .rs-column.-small-col-12-12 { - width: 100%; + width: 100%; } } @media screen and (max-width: 399px) { .rs-column.-small-first { - clear: none; + clear: none; } .rs-column.-xsmall-first { - clear: left; + clear: left; } .rs-column.-xsmall-col-1-1 { - width: 100%; + width: 100%; } .rs-column.-xsmall-col-2-1 { - width: 50%; + width: 50%; } .rs-column.-xsmall-col-2-2 { - width: 100%; + width: 100%; } .rs-column.-xsmall-col-3-1 { - width: 33.33333%; + width: 33.33333%; } .rs-column.-xsmall-col-3-2 { - width: 66.66667%; + width: 66.66667%; } .rs-column.-xsmall-col-3-3 { - width: 100%; + width: 100%; } .rs-column.-xsmall-col-4-1 { - width: 25%; + width: 25%; } .rs-column.-xsmall-col-4-2 { - width: 50%; + width: 50%; } .rs-column.-xsmall-col-4-3 { - width: 75%; + width: 75%; } .rs-column.-xsmall-col-4-4 { - width: 100%; + width: 100%; } .rs-column.-xsmall-col-5-1 { - width: 20%; + width: 20%; } .rs-column.-xsmall-col-5-2 { - width: 40%; + width: 40%; } .rs-column.-xsmall-col-5-3 { - width: 60.0%; + width: 60.0%; } .rs-column.-xsmall-col-5-4 { - width: 80%; + width: 80%; } .rs-column.-xsmall-col-5-5 { - width: 100%; + width: 100%; } .rs-column.-xsmall-col-6-1 { - width: 16.66667%; + width: 16.66667%; } .rs-column.-xsmall-col-6-2 { - width: 33.33333%; + width: 33.33333%; } .rs-column.-xsmall-col-6-3 { - width: 50%; + width: 50%; } .rs-column.-xsmall-col-6-4 { - width: 66.66667%; + width: 66.66667%; } .rs-column.-xsmall-col-6-5 { - width: 83.33333%; + width: 83.33333%; } .rs-column.-xsmall-col-6-6 { - width: 100%; + width: 100%; } .rs-column.-xsmall-col-7-1 { - width: 14.28571%; + width: 14.28571%; } .rs-column.-xsmall-col-7-2 { - width: 28.57143%; + width: 28.57143%; } .rs-column.-xsmall-col-7-3 { - width: 42.85714%; + width: 42.85714%; } .rs-column.-xsmall-col-7-4 { - width: 57.14286%; + width: 57.14286%; } .rs-column.-xsmall-col-7-5 { - width: 71.42857%; + width: 71.42857%; } .rs-column.-xsmall-col-7-6 { - width: 85.71429%; + width: 85.71429%; } .rs-column.-xsmall-col-7-7 { - width: 100%; + width: 100%; } .rs-column.-xsmall-col-8-1 { - width: 12.5%; + width: 12.5%; } .rs-column.-xsmall-col-8-2 { - width: 25%; + width: 25%; } .rs-column.-xsmall-col-8-3 { - width: 37.5%; + width: 37.5%; } .rs-column.-xsmall-col-8-4 { - width: 50%; + width: 50%; } .rs-column.-xsmall-col-8-5 { - width: 62.5%; + width: 62.5%; } .rs-column.-xsmall-col-8-6 { - width: 75%; + width: 75%; } .rs-column.-xsmall-col-8-7 { - width: 87.5%; + width: 87.5%; } .rs-column.-xsmall-col-8-8 { - width: 100%; + width: 100%; } .rs-column.-xsmall-col-9-1 { - width: 11.11111%; + width: 11.11111%; } .rs-column.-xsmall-col-9-2 { - width: 22.22222%; + width: 22.22222%; } .rs-column.-xsmall-col-9-3 { - width: 33.33333%; + width: 33.33333%; } .rs-column.-xsmall-col-9-4 { - width: 44.44444%; + width: 44.44444%; } .rs-column.-xsmall-col-9-5 { - width: 55.55556%; + width: 55.55556%; } .rs-column.-xsmall-col-9-6 { - width: 66.66667%; + width: 66.66667%; } .rs-column.-xsmall-col-9-7 { - width: 77.77778%; + width: 77.77778%; } .rs-column.-xsmall-col-9-8 { - width: 88.88889%; + width: 88.88889%; } .rs-column.-xsmall-col-9-9 { - width: 100%; + width: 100%; } .rs-column.-xsmall-col-10-1 { - width: 10%; + width: 10%; } .rs-column.-xsmall-col-10-2 { - width: 20%; + width: 20%; } .rs-column.-xsmall-col-10-3 { - width: 30.0%; + width: 30.0%; } .rs-column.-xsmall-col-10-4 { - width: 40%; + width: 40%; } .rs-column.-xsmall-col-10-5 { - width: 50%; + width: 50%; } .rs-column.-xsmall-col-10-6 { - width: 60.0%; + width: 60.0%; } .rs-column.-xsmall-col-10-7 { - width: 70%; + width: 70%; } .rs-column.-xsmall-col-10-8 { - width: 80%; + width: 80%; } .rs-column.-xsmall-col-10-9 { - width: 90%; + width: 90%; } .rs-column.-xsmall-col-10-10 { - width: 100%; + width: 100%; } .rs-column.-xsmall-col-11-1 { - width: 9.09091%; + width: 9.09091%; } .rs-column.-xsmall-col-11-2 { - width: 18.18182%; + width: 18.18182%; } .rs-column.-xsmall-col-11-3 { - width: 27.27273%; + width: 27.27273%; } .rs-column.-xsmall-col-11-4 { - width: 36.36364%; + width: 36.36364%; } .rs-column.-xsmall-col-11-5 { - width: 45.45455%; + width: 45.45455%; } .rs-column.-xsmall-col-11-6 { - width: 54.54545%; + width: 54.54545%; } .rs-column.-xsmall-col-11-7 { - width: 63.63636%; + width: 63.63636%; } .rs-column.-xsmall-col-11-8 { - width: 72.72727%; + width: 72.72727%; } .rs-column.-xsmall-col-11-9 { - width: 81.81818%; + width: 81.81818%; } .rs-column.-xsmall-col-11-10 { - width: 90.90909%; + width: 90.90909%; } .rs-column.-xsmall-col-11-11 { - width: 100%; + width: 100%; } .rs-column.-xsmall-col-12-1 { - width: 8.33333%; + width: 8.33333%; } .rs-column.-xsmall-col-12-2 { - width: 16.66667%; + width: 16.66667%; } .rs-column.-xsmall-col-12-3 { - width: 25%; + width: 25%; } .rs-column.-xsmall-col-12-4 { - width: 33.33333%; + width: 33.33333%; } .rs-column.-xsmall-col-12-5 { - width: 41.66667%; + width: 41.66667%; } .rs-column.-xsmall-col-12-6 { - width: 50%; + width: 50%; } .rs-column.-xsmall-col-12-7 { - width: 58.33333%; + width: 58.33333%; } .rs-column.-xsmall-col-12-8 { - width: 66.66667%; + width: 66.66667%; } .rs-column.-xsmall-col-12-9 { - width: 75%; + width: 75%; } .rs-column.-xsmall-col-12-10 { - width: 83.33333%; + width: 83.33333%; } .rs-column.-xsmall-col-12-11 { - width: 91.66667%; + width: 91.66667%; } .rs-column.-xsmall-col-12-12 { - width: 100%; + width: 100%; } }