Skip to content

Commit 5faaad9

Browse files
committed
Add another check to avoid overwriting similar class names.
1 parent 98261fb commit 5faaad9

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

README.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Allows you to add your own groups of CSS classes provided in layouts, pages, art
55
This plugin is designed to simplify theme customizations without the need for customers to manually add classes or create new layouts.
66

77
### Overview
8-
- Many possibilities of use (grid, designs, animations, content properties, ...)
8+
- Many possibilities of use (grid, animations, content properties, ...)
99
- Clear representation in the backend
1010
- Groups and Categories
1111
- Available for
@@ -21,6 +21,13 @@ This plugin is designed to simplify theme customizations without the need for cu
2121
2222
---
2323

24+
### Install
25+
```
26+
composer require oveleon/contao-component-style-manager
27+
```
28+
29+
---
30+
2431
### Examples
2532
#### Admin:
2633
##### List-View: Groups
@@ -31,7 +38,7 @@ This plugin is designed to simplify theme customizations without the need for cu
3138
![Admin View: Mask](https://www.oveleon.de/share/github-assets/contao-component-style-manager/content-elements-120.png)
3239

3340
#### Customer:
34-
##### Article
41+
##### Content Elements
3542
![Customer View: Article](https://www.oveleon.de/share/github-assets/contao-component-style-manager/customer-120.png)
3643

3744
---
@@ -48,18 +55,7 @@ Use the callback function `onloadCallback` in your custom element configuration
4855

4956
---
5057

51-
### Latest Updates
52-
#### 1.2.0
53-
- Categories
54-
- Better visualization in the backend
55-
- Rocksolid CustomElement Support
56-
- Further availability for
57-
- Layouts
58-
- Forms
59-
- Form-Fields
60-
- Modules
61-
62-
##### Fixes
58+
### Latest Fixes
6359
- Multiple editing in the backend
6460
- Additional security - classes remain after deleting groups or their values
6561
- Alias has been removed from the palette and is created dynamically

src/Resources/contao/classes/StyleManager.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class StyleManager
1111
{
1212
/**
13-
* Valid CSS-Class fields in tables
13+
* Valid CSS-Class fields
1414
*
1515
* field => size
1616
*
@@ -46,7 +46,13 @@ public function clearStyleManager($varValue, $dc)
4646

4747
if(count($arrValues))
4848
{
49-
$varValue = str_replace($arrValues, '', $varValue);
49+
foreach ($arrValues as $k => $v)
50+
{
51+
$arrValues[ $k ] = ' ' . $v . ' ';
52+
}
53+
54+
$varValue = ' ' . $varValue . ' ';
55+
$varValue = str_replace($arrValues, ' ', $varValue);
5056
$varValue = trim(preg_replace('#\s+#', ' ', $varValue));
5157
}
5258

@@ -77,6 +83,7 @@ public function updateStyleManager($varValue, $dc)
7783
$varValues = \StringUtil::deserialize($dc->activeRecord->styleManager, true);
7884
$varValues = array_filter($varValues);
7985
$varValue .= ($varValue ? ' ' : '') . (count($varValues) ? implode(' ', $varValues) : '');
86+
$varValue = trim($varValue);
8087

8188
if($this->isMultipleField($dc->field))
8289
{
@@ -105,7 +112,6 @@ private function resetStyleManagerClasses($varValue, $dc, $strTable)
105112

106113
$objStyles = StyleManagerModel::findByTable($strTable);
107114
$arrStyles = array();
108-
$varValue = ' ' . $varValue . ' ';
109115

110116
if($objStyles !== null)
111117
{
@@ -124,6 +130,8 @@ private function resetStyleManagerClasses($varValue, $dc, $strTable)
124130

125131
if(count($arrStyles))
126132
{
133+
$varValue = ' ' . $varValue . ' ';
134+
127135
$varValue = str_replace($arrStyles, ' ', $varValue);
128136
$varValue = trim(preg_replace('#\s+#', ' ', $varValue));
129137
}

0 commit comments

Comments
 (0)