Skip to content

Commit e1ad8ff

Browse files
committed
Merge tag '3.6.12'
2 parents 982d206 + e021f97 commit e1ad8ff

File tree

1 file changed

+30
-36
lines changed

1 file changed

+30
-36
lines changed

src/Contao/Widgets/MultiColumnWizard.php

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* This file is part of menatwork/contao-multicolumnwizard-bundle.
55
*
6-
* (c) 2012-2024 MEN AT WORK.
6+
* (c) 2012-2025 MEN AT WORK.
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.
@@ -43,7 +43,7 @@
4343
* @author David Greminger <david.greminger@1up.io>
4444
* @copyright 2011 Andreas Schempp
4545
* @copyright 2011 certo web & design GmbH
46-
* @copyright 2013-2024 MEN AT WORK
46+
* @copyright 2013-2025 MEN AT WORK
4747
* @license https://github.com/menatwork/contao-multicolumnwizard-bundle/blob/master/LICENSE LGPL-3.0-or-later
4848
* @filesource
4949
*/
@@ -690,7 +690,7 @@ protected function validator($varInput)
690690

691691
// Convert binary UUIDs for DC_File driver (see contao#6893)
692692
if (
693-
$arrField['inputType'] == 'fileTree'
693+
$arrField['inputType'] === 'fileTree'
694694
&& 'DC_' . $GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer'] === DC_File::class
695695
) {
696696
$varValue = StringUtil::deserialize($varValue);
@@ -709,7 +709,7 @@ protected function validator($varInput)
709709
// store the errors
710710
$this->arrWidgetErrors[$strKey][$i] = $objWidget->getErrors();
711711

712-
$blnHasError = Input::post('SUBMIT_TYPE') != 'auto';
712+
$blnHasError = Input::post('SUBMIT_TYPE') !== 'auto';
713713
}
714714
}
715715
}
@@ -772,10 +772,10 @@ protected function validator($varInput)
772772
public function generate($overwriteRowCurrentRow = null, $onlyRows = false)
773773
{
774774
$this->strCommand = 'cmd_' . $this->strField;
775-
$arrUnique = array();
776-
$arrDatepicker = array();
777-
$arrColorpicker = array();
778-
$arrTinyMCE = array();
775+
$arrUnique = [];
776+
$arrDatepicker = [];
777+
$arrColorpicker = [];
778+
$arrTinyMCE = [];
779779

780780
foreach ($this->columnFields as $strKey => $arrField) {
781781
// Store unique fields
@@ -813,7 +813,7 @@ public function generate($overwriteRowCurrentRow = null, $onlyRows = false)
813813
}
814814

815815
$intNumberOfRows = max(count($this->varValue), 1);
816-
$useDefaultValue = (0 == count($this->varValue));
816+
$useDefaultValue = (0 === count($this->varValue));
817817
if ($useDefaultValue && !empty($this->defaultValue)) {
818818
$intNumberOfRows = count($this->defaultValue);
819819
}
@@ -823,11 +823,11 @@ public function generate($overwriteRowCurrentRow = null, $onlyRows = false)
823823
$intNumberOfRows = $this->minCount;
824824
}
825825

826-
$arrItems = array();
827-
$arrHiddenHeader = array();
826+
$arrItems = [];
827+
$arrHiddenHeader = [];
828828

829829
if ($overwriteRowCurrentRow !== null) {
830-
$i = \intval($overwriteRowCurrentRow);
830+
$i = (int) $overwriteRowCurrentRow;
831831
$intNumberOfRows = ($i + 1);
832832
} else {
833833
$i = 0;
@@ -992,9 +992,9 @@ function ($value) {
992992
} else {
993993
$arrItems[$i][$strKey] = [
994994
'entry' => $strWidget,
995-
'valign' => $arrField['eval']['valign'] ?? null,
996-
'tl_class' => $arrField['eval']['tl_class'] ?? null,
997-
'wrapper_style' => $arrField['eval']['wrapper_style'] ?? null,
995+
'valign' => ($arrField['eval']['valign'] ?? ''),
996+
'tl_class' => ($arrField['eval']['tl_class'] ?? ''),
997+
'wrapper_style' => ($arrField['eval']['wrapper_style'] ?? ''),
998998
'hide' => $blnHiddenBody
999999
];
10001000
}
@@ -1072,7 +1072,7 @@ protected function initializeWidget(&$arrField, $intRow, $strKey, $varValue)
10721072
}
10731073

10741074
// Toggle line wrap (textarea)
1075-
if (($arrField['inputType'] ?? null) == 'textarea' && empty($arrField['eval']['rte'])) {
1075+
if (($arrField['inputType'] ?? null) === 'textarea' && empty($arrField['eval']['rte'])) {
10761076
$xlabel .= ' '
10771077
. Image::getHtml(
10781078
'wrap.gif',
@@ -1108,7 +1108,7 @@ protected function initializeWidget(&$arrField, $intRow, $strKey, $varValue)
11081108
}
11091109

11101110
// Add the popup file manager
1111-
if (($arrField['inputType'] ?? null) == 'fileTree' || ($arrField['inputType'] ?? null) == 'pageTree') {
1111+
if (($arrField['inputType'] ?? null) === 'fileTree' || ($arrField['inputType'] ?? null) === 'pageTree') {
11121112
$path = '';
11131113

11141114
if (isset($arrField['eval']['path'])) {
@@ -1129,8 +1129,8 @@ protected function initializeWidget(&$arrField, $intRow, $strKey, $varValue)
11291129

11301130
// Add title at modal window.
11311131
$GLOBALS['TL_DCA'][$this->strTable]['fields'][$arrField['strField']]['label'][0] =
1132-
(is_array($arrField['label']) && $arrField['label'][0] != '') ? $arrField['label'][0] : $strKey;
1133-
} elseif (($arrField['inputType'] ?? null) == 'tableWizard') {
1132+
(is_array($arrField['label']) && $arrField['label'][0] !== '') ? $arrField['label'][0] : $strKey;
1133+
} elseif (($arrField['inputType'] ?? null) === 'tableWizard') {
11341134
// Add the table import wizard
11351135
$xlabel .= ' <a href="'
11361136
. $this->addToUrl('key=table')
@@ -1242,7 +1242,7 @@ protected function initializeWidget(&$arrField, $intRow, $strKey, $varValue)
12421242
// Convert date formats into timestamps (check the eval setting first -> #3063)
12431243
$rgxp = ($arrField['eval']['rgxp'] ?? '');
12441244
$dateFormatErrorMsg = '';
1245-
if (($rgxp == 'date' || $rgxp == 'time' || $rgxp == 'datim') && $varValue != '') {
1245+
if (($rgxp === 'date' || $rgxp === 'time' || $rgxp === 'datim') && $varValue !== '') {
12461246
try {
12471247
$objDate = new Date($varValue, $this->getNumericDateFormat($rgxp));
12481248
} catch (\Exception $e) {
@@ -1258,6 +1258,7 @@ protected function initializeWidget(&$arrField, $intRow, $strKey, $varValue)
12581258
$arrField['id'] = $this->strId . '_row' . $intRow . '_' . $strKey;
12591259
$arrField['value'] = ((null !== $varValue) ? $varValue : ($arrField['default'] ?? null));
12601260
$arrField['eval']['tableless'] = true;
1261+
$arrField['eval']['style'] = $this->cspUnsafeInlineStyle($arrField['eval']['style'] ?? '');
12611262

12621263
$arrData = $this->handleDcGeneral($arrField, $strKey);
12631264

@@ -1519,7 +1520,7 @@ protected function generateTable(
15191520
' data-name="%s"' .
15201521
' id="ctrl_%s"' .
15211522
' class="tl_modulewizard multicolumnwizard">',
1522-
(($this->style) ? (\sprintf('style="%s"', $this->style)) : ('')),
1523+
(($this->style) ? (\sprintf('style="%s"', $this->cspUnsafeInlineStyle($this->style))) : ('')),
15231524
($this->maxCount ? $this->maxCount : '0'),
15241525
($this->minCount ? $this->minCount : '0'),
15251526
implode(',', $arrUnique),
@@ -1548,7 +1549,9 @@ protected function generateTable(
15481549
$return .= '<td'
15491550
. ($itemValue['valign'] !== '' ? ' valign="' . $itemValue['valign'] . '"' : '')
15501551
. ($itemValue['tl_class'] !== '' ? ' class="' . $itemValue['tl_class'] . '"' : '')
1551-
. ($itemValue['wrapper_style'] !== '' ? ' style="' . $itemValue['wrapper_style'] . '"' : '')
1552+
. ($itemValue['wrapper_style'] !== ''
1553+
? ' style="' . $this->cspUnsafeInlineStyle($itemValue['wrapper_style']) . '"'
1554+
: '')
15521555
. '>'
15531556
. $itemValue['entry']
15541557
. '</td>';
@@ -1578,17 +1581,14 @@ protected function generateTable(
15781581
* Generates the javascript block for the mcw.
15791582
*
15801583
* @param string $strId The html id of the element.
1581-
*
15821584
* @param int $maxCount The max amount of rows.
1583-
*
15841585
* @param int $minCount The min amount of rows.
15851586
*
15861587
* @return string
15871588
*/
15881589
protected function generateScriptBlock($strId, $maxCount, $minCount)
15891590
{
15901591
$script = <<<SCRIPT
1591-
15921592
<script>
15931593
window.addEvent("domready", function() {
15941594
window["MCW_" + %s] = new MultiColumnWizard({
@@ -1601,13 +1601,7 @@ protected function generateScriptBlock($strId, $maxCount, $minCount)
16011601
</script>
16021602
SCRIPT;
16031603

1604-
return sprintf(
1605-
$script,
1606-
json_encode($strId),
1607-
json_encode($strId),
1608-
intval($maxCount),
1609-
intval($minCount)
1610-
);
1604+
return sprintf($script, json_encode($strId), json_encode($strId), (int) $maxCount, (int) $minCount);
16111605
}
16121606

16131607
/**
@@ -1683,7 +1677,7 @@ protected function generateDiv(
16831677
}
16841678

16851679
$return = '<div'
1686-
. (($this->style) ? (' style="' . $this->style . '"') : '')
1680+
. (($this->style) ? (' style="' . $this->cspUnsafeInlineStyle($this->style) . '"') : '')
16871681
. ' data-operations="maxCount['
16881682
. ($this->maxCount ? $this->maxCount : '0')
16891683
. '] minCount['
@@ -1722,7 +1716,8 @@ protected function generateDiv(
17221716
? ' class="' . $itemValue['tl_class'] . '"'
17231717
: '')
17241718
. ($itemValue['wrapper_style'] !== ''
1725-
? ' style="' . $itemValue['wrapper_style'] . '"'
1719+
? ' style="' . $this->cspUnsafeInlineStyle($itemValue['wrapper_style'])
1720+
. '"'
17261721
: '')
17271722
. '>'
17281723
. $itemValue['entry']
@@ -1760,8 +1755,7 @@ protected function generateButtonString($level = 0)
17601755
$btnName = \sprintf('tw_r%s', StringUtil::specialchars($button));
17611756
$return .=
17621757
\sprintf(
1763-
'<a data-operations="%s" href="%s" class="widgetImage op-%s" title="%s"
1764-
onclick="return false;">%s</a>',
1758+
'<a data-operations="%s" href="%s" class="widgetImage op-%s" title="%s">%s</a>',
17651759
$button,
17661760
$this->addToUrl(
17671761
\sprintf(

0 commit comments

Comments
 (0)