diff --git a/system/modules/multicolumnwizard/MultiColumnWizard.php b/system/modules/multicolumnwizard/MultiColumnWizard.php index f0d4df2..886a5e8 100644 --- a/system/modules/multicolumnwizard/MultiColumnWizard.php +++ b/system/modules/multicolumnwizard/MultiColumnWizard.php @@ -82,11 +82,13 @@ class MultiColumnWizard extends Widget implements uploadable * Buttons * @var array */ - protected $arrButtons = array('new' => 'new.gif', - 'copy' => 'copy.gif', - 'up' => 'up.gif', - 'down' => 'down.gif', - 'delete' => 'delete.gif'); + protected $arrButtons = array( + 'new' => 'new.gif', + 'copy' => 'copy.gif', + 'up' => 'up.gif', + 'down' => 'down.gif', + 'delete' => 'delete.gif' + ); /** * Initialize the object @@ -97,8 +99,7 @@ public function __construct($arrAttributes = false) parent::__construct($arrAttributes); $this->import('Database'); - if (TL_MODE == 'FE') - { + if (TL_MODE == 'FE') { $this->strTemplate = 'form_widget'; $this->loadDataContainer($arrAttributes['strTable']); } @@ -111,8 +112,7 @@ public function __construct($arrAttributes = false) */ public function __set($strKey, $varValue) { - switch ($strKey) - { + switch ($strKey) { case 'value': $this->varValue = deserialize($varValue, true); @@ -121,12 +121,10 @@ public function __set($strKey, $varValue) * from array[] = value * to array[]['fieldname'] = value */ - if ($this->flatArray) - { + if ($this->flatArray) { $arrNew = array(); - foreach ($this->varValue as $val) - { + foreach ($this->varValue as $val) { $arrNew[] = array(key($this->columnFields) => $val); } @@ -139,8 +137,7 @@ public function __set($strKey, $varValue) break; case 'columnsCallback': - if (!is_array($varValue)) - { + if (!is_array($varValue)) { throw new Exception('Parameter "columns" has to be an array: array(\'Class\', \'Method\')!'); } @@ -148,21 +145,18 @@ public function __set($strKey, $varValue) break; case 'buttons': - if (is_array($varValue)) - { + if (is_array($varValue)) { $this->arrButtons = array_merge($this->arrButtons, $varValue); } break; case 'hideButtons': - if ($varValue === true) - { + if ($varValue === true) { $this->arrButtons = array(); } case 'disableSorting': - if ($varValue == true) - { + if ($varValue == true) { unset($this->arrButtons['up']); unset($this->arrButtons['down']); unset($this->arrButtons['move']); @@ -197,8 +191,7 @@ public function __set($strKey, $varValue) public function __get($strKey) { - switch ($strKey) - { + switch ($strKey) { case 'value': /** * reformat array if we have only one field @@ -206,19 +199,15 @@ public function __get($strKey) * to array[] = value * so we have the same behavoir like multiple-checkbox fields */ - if ($this->flatArray) - { + if ($this->flatArray) { $arrNew = array(); - foreach ($this->varValue as $val) - { + foreach ($this->varValue as $val) { $arrNew[] = $val[key($this->columnFields)]; } return $arrNew; - } - else - { + } else { return parent::__get($strKey); } break; @@ -233,29 +222,24 @@ protected function validator($varInput) { $blnHasError = false; - for ($i = 0; $i < count($varInput); $i++) - { + for ($i = 0; $i < count($varInput); $i++) { $this->activeRow = $i; - if (!$this->columnFields) - { + if (!$this->columnFields) { continue; } // Walk every column - foreach ($this->columnFields as $strKey => $arrField) - { + foreach ($this->columnFields as $strKey => $arrField) { $objWidget = $this->initializeWidget($arrField, $i, $strKey, $varInput[$i][$strKey]); // can be null on error, or a string on input_field_callback - if (!is_object($objWidget)) - { + if (!is_object($objWidget)) { continue; } // hack for checkboxes - if ($arrField['inputType'] == 'checkbox' && isset($varInput[$i][$strKey])) - { + if ($arrField['inputType'] == 'checkbox' && isset($varInput[$i][$strKey])) { $_POST[$objWidget->name] = $varInput[$i][$strKey]; } @@ -265,25 +249,19 @@ protected function validator($varInput) // Convert date formats into timestamps (check the eval setting first -> #3063) $rgxp = $arrField['eval']['rgxp']; - if (!$objWidget->hasErrors() && ($rgxp == 'date' || $rgxp == 'time' || $rgxp == 'datim') && $varValue != '') - { - $objDate = new Date($varValue,$this->getNumericDateFormat($rgxp)); + if (!$objWidget->hasErrors() && ($rgxp == 'date' || $rgxp == 'time' || $rgxp == 'datim') && $varValue != '') { + $objDate = new Date($varValue, $this->getNumericDateFormat($rgxp)); $varValue = $objDate->tstamp; } // Save callback - if (is_array($arrField['save_callback'])) - { - foreach ($arrField['save_callback'] as $callback) - { + if (is_array($arrField['save_callback'])) { + foreach ($arrField['save_callback'] as $callback) { $this->import($callback[0]); - try - { + try { $varValue = $this->{$callback[0]}->{$callback[1]}($varValue, $this); - } - catch (Exception $e) - { + } catch (Exception $e) { $objWidget->class = 'error'; $objWidget->addError($e->getMessage()); } @@ -293,8 +271,7 @@ protected function validator($varInput) $varInput[$i][$strKey] = $varValue; // Do not submit if there are errors - if ($objWidget->hasErrors()) - { + if ($objWidget->hasErrors()) { // store the errors $this->arrWidgetErrors[$strKey][$i] = $objWidget->getErrors(); @@ -303,20 +280,17 @@ protected function validator($varInput) } } - if ($this->minCount > 0 && count($varInput) < $this->minCount) - { + if ($this->minCount > 0 && count($varInput) < $this->minCount) { $this->blnSubmitInput = false; $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['mcwMinCount'], $this->minCount)); } - if ($this->maxCount > 0 && count($varInput) > $this->maxCount) - { + if ($this->maxCount > 0 && count($varInput) > $this->maxCount) { $this->blnSubmitInput = false; $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['mcwMaxCount'], $this->maxCount)); } - if ($blnHasError) - { + if ($blnHasError) { $this->blnSubmitInput = false; $this->addError($GLOBALS['TL_LANG']['ERR']['general']); } @@ -331,8 +305,7 @@ protected function validator($varInput) public function generate() { // load the callback data if there's any (do not do this in __set() already because then we don't have access to currentRecord) - if (is_array($this->arrCallback)) - { + if (is_array($this->arrCallback)) { $this->import($this->arrCallback[0]); $this->columnFields = $this->{$this->arrCallback[0]}->{$this->arrCallback[1]}($this); } @@ -348,11 +321,9 @@ public function generate() $this->strCommand = 'cmd_' . $this->strField; // Change the order - if ($this->Input->get($this->strCommand) && is_numeric($this->Input->get('cid')) && $this->Input->get('id') == $this->currentRecord) - { + if ($this->Input->get($this->strCommand) && is_numeric($this->Input->get('cid')) && $this->Input->get('id') == $this->currentRecord) { - switch ($this->Input->get($this->strCommand)) - { + switch ($this->Input->get($this->strCommand)) { case 'copy': $this->varValue = array_duplicate($this->varValue, $this->Input->get('cid')); break; @@ -371,18 +342,15 @@ public function generate() } // Save in File - if ($GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer'] == 'File') - { + if ($GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer'] == 'File') { $this->Config->update(sprintf("\$GLOBALS['TL_CONFIG']['%s']", $this->strField), serialize($this->varValue)); // Reload the page $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($this->strCommand, '/') . '=[^&]*/i', '', Environment::get('request')))); } // Save in table - else if ($GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer'] == 'Table') - { - if (is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['save_callback'])) - { + else if ($GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer'] == 'Table') { + if (is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['save_callback'])) { $dataContainer = 'DC_' . $GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer']; $dc = new $dataContainer($this->strTable); @@ -390,25 +358,21 @@ public function generate() $dc->inputName = $this->strField; $dc->strInputName = $this->strField; - foreach ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['save_callback'] AS $callback) - { + foreach ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['save_callback'] as $callback) { $this->import($callback[0]); $this->{$callback[0]}->{$callback[1]}(serialize($this->varValue), $dc); } - } - else - { + } else { $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?") - ->execute(serialize($this->varValue), $this->currentRecord); + ->execute(serialize($this->varValue), $this->currentRecord); } // Reload the page $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($this->strCommand, '/') . '=[^&]*/i', '', Environment::get('request')))); } // Unknow - else - { - // What to do here? + else { + // What to do here? } } @@ -418,31 +382,26 @@ public function generate() $arrTinyMCE = array(); $arrHeaderItems = array(); - foreach ($this->columnFields as $strKey => $arrField) - { + foreach ($this->columnFields as $strKey => $arrField) { $fullName = $this->strName . '__' . $strKey; // Store unique fields - if ($arrField['eval']['unique']) - { + if ($arrField['eval']['unique'] ?? false) { $arrUnique[] = $strKey; } // Store date picker fields - if ($arrField['eval']['datepicker']) - { + if ($arrField['eval']['datepicker'] ?? false) { $arrDatepicker[] = $strKey; } // Store color picker fields - if ($arrField['eval']['colorpicker']) - { - $arrColorpicker[] = $strKey; + if ($arrField['eval']['colorpicker'] ?? false) { + $arrColorpicker[] = $strKey; } // Store tiny mce fields - if ($arrField['eval']['rte'] && strncmp($arrField['eval']['rte'], 'tiny', 4) === 0) - { + if ($arrField['eval']['rte'] ?? false && strncmp($arrField['eval']['rte'], 'tiny', 4) === 0) { foreach ($this->varValue as $row => $value) { $tinyId = 'ctrl_' . $this->strField . '_row' . $row . '_' . $strKey; @@ -456,8 +415,7 @@ public function generate() $arrTinyMCE[] = $strKey; } - if ($arrField['inputType'] == 'hidden') - { + if ($arrField['inputType'] == 'hidden') { continue; } } @@ -465,8 +423,7 @@ public function generate() $intNumberOfRows = max(count($this->varValue), 1); // always show the minimum number of rows if set - if ($this->minCount && ($intNumberOfRows < $this->minCount)) - { + if ($this->minCount && ($intNumberOfRows < $this->minCount)) { $intNumberOfRows = $this->minCount; } @@ -474,75 +431,57 @@ public function generate() $arrHiddenHeader = array(); // Add input fields - for ($i = 0; $i < $intNumberOfRows; $i++) - { + for ($i = 0; $i < $intNumberOfRows; $i++) { $this->activeRow = $i; $strHidden = ''; // Walk every column - foreach ($this->columnFields as $strKey => $arrField) - { + foreach ($this->columnFields as $strKey => $arrField) { $strWidget = ''; $blnHiddenBody = false; - if ($arrField['eval']['hideHead'] == true) - { + if ($arrField['eval']['hideHead'] ?? false == true) { $arrHiddenHeader[$strKey] = true; } // load row specific data (useful for example for default values in different rows) - if (isset($this->arrRowSpecificData[$i][$strKey])) - { + if (isset($this->arrRowSpecificData[$i][$strKey])) { $arrField = array_merge($arrField, $this->arrRowSpecificData[$i][$strKey]); } $objWidget = $this->initializeWidget($arrField, $i, $strKey, $this->varValue[$i][$strKey]); // load errors if there are any - if (!empty($this->arrWidgetErrors[$strKey][$i])) - { - foreach ($this->arrWidgetErrors[$strKey][$i] as $strErrorMsg) - { + if (!empty($this->arrWidgetErrors[$strKey][$i])) { + foreach ($this->arrWidgetErrors[$strKey][$i] as $strErrorMsg) { $objWidget->addError($strErrorMsg); } } - if ($objWidget === null) - { + if ($objWidget === null) { continue; - } - elseif (is_string($objWidget)) - { + } elseif (is_string($objWidget)) { $strWidget = $objWidget; - } - elseif ($arrField['inputType'] == 'hidden') - { + } elseif ($arrField['inputType'] == 'hidden') { $strHidden .= $objWidget->generate(); continue; - } - elseif ($arrField['eval']['hideBody'] == true || $arrField['eval']['hideHead'] == true) - { - if ($arrField['eval']['hideBody'] == true) - { + } elseif ($arrField['eval']['hideBody'] ?? false == true || ($arrField['eval']['hideHead'] ?? false) == true) { + if ($arrField['eval']['hideBody'] ?? false == true) { $blnHiddenBody = true; } $strWidget = $objWidget->parse(); - } - else - { + } else { $datepicker = ''; $colorpicker = ''; $tinyMce = ''; // Datepicker - if ($arrField['eval']['datepicker']) - { + if ($arrField['eval']['datepicker'] ?? false) { $rgxp = $arrField['eval']['rgxp']; $format = $this->getNumericDateFormat($rgxp); - switch ($rgxp) - { + switch ($rgxp) { case 'datim': $time = ",\n timePicker:true"; break; @@ -582,13 +521,12 @@ public function generate() '; */ } - // Color picker - if ($arrField['eval']['colorpicker']) - { - // Support single fields as well (see #5240) - //$strKey = $arrData['eval']['multiple'] ? $this->strField . '_0' : $this->strField; + // Color picker + if ($arrField['eval']['colorpicker'] ?? false) { + // Support single fields as well (see #5240) + //$strKey = $arrData['eval']['multiple'] ? $this->strField . '_0' : $this->strField; - $colorpicker = ' ' . \Image::getHtml('pickcolor.gif', $GLOBALS['TL_LANG']['MSC']['colorpicker'], 'style="vertical-align:top;cursor:pointer" title="'.specialchars($GLOBALS['TL_LANG']['MSC']['colorpicker']).'" id="moo_' . $objWidget->id . '"') . ' + $colorpicker = ' ' . \Image::getHtml('pickcolor.gif', $GLOBALS['TL_LANG']['MSC']['colorpicker'], 'style="vertical-align:top;cursor:pointer" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['colorpicker']) . '" id="moo_' . $objWidget->id . '"') . ' '; - } + } // Tiny MCE - if ($arrField['eval']['rte'] && strncmp($arrField['eval']['rte'], 'tiny', 4) === 0) - { + if ($arrField['eval']['rte'] ?? false && strncmp($arrField['eval']['rte'], 'tiny', 4) === 0) { $tinyMce = $this->getMcWTinyMCEString($objWidget->id, $arrField); $arrField['eval']['tl_class'] .= ' tinymce'; } // Add custom wizard - if ($arrField['wizard']) - { + if ($arrField['wizard'] ?? false) { $wizard = ''; $dataContainer = 'DC_' . $GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer']; @@ -624,16 +560,12 @@ public function generate() $dc->strInputName = $objWidget->id; $dc->value = $objWidget->value; - if (is_array($arrField['wizard'])) - { - foreach ($arrField['wizard'] as $callback) - { + if (is_array($arrField['wizard'])) { + foreach ($arrField['wizard'] as $callback) { $this->import($callback[0]); $wizard .= $this->{$callback[0]}->{$callback[1]}($dc, $objWidget); } - } - elseif (is_callable($arrField['wizard'])) - { + } elseif (is_callable($arrField['wizard'])) { $wizard .= $arrField['wizard']($dc, $objWidget); } @@ -644,20 +576,16 @@ public function generate() } // Build array of items - if ($arrField['eval']['columnPos'] != '') - { + if ($arrField['eval']['columnPos'] ?? false != '') { $arrItems[$i][$objWidget->columnPos]['entry'] .= $strWidget; $arrItems[$i][$objWidget->columnPos]['valign'] = $arrField['eval']['valign']; $arrItems[$i][$objWidget->columnPos]['tl_class'] = $arrField['eval']['tl_class']; $arrItems[$i][$objWidget->columnPos]['hide'] = $blnHiddenBody; - } - else - { - $arrItems[$i][$strKey] = array - ( + } else { + $arrItems[$i][$strKey] = array( 'entry' => $strWidget, - 'valign' => $arrField['eval']['valign'], - 'tl_class' => $arrField['eval']['tl_class'], + 'valign' => $arrField['eval']['valign'] ?? false, + 'tl_class' => $arrField['eval']['tl_class'] ?? false, 'hide' => $blnHiddenBody ); } @@ -666,18 +594,12 @@ public function generate() $strOutput = ''; - if ($this->blnTableless) - { + if ($this->blnTableless) { $strOutput = $this->generateDiv($arrUnique, $arrDatepicker, $arrColorpicker, $strHidden, $arrItems, $arrHiddenHeader); - } - else - { - if ($this->columnTemplate != '') - { + } else { + if ($this->columnTemplate != '') { $strOutput = $this->generateTemplateOutput($arrUnique, $arrDatepicker, $arrColorpicker, $strHidden, $arrItems, $arrHiddenHeader); - } - else - { + } else { $strOutput = $this->generateTable($arrUnique, $arrDatepicker, $arrColorpicker, $strHidden, $arrItems, $arrHiddenHeader); } } @@ -687,11 +609,10 @@ public function generate() protected function getMcWDatePickerString($strId, $strKey, $rgxp) { - if (version_compare(VERSION,'3.3','<')) { + if (version_compare(VERSION, '3.3', '<')) { $format = Date::formatToJs($this->getNumericDateFormat($rgxp)); - switch ($rgxp) - { + switch ($rgxp) { case 'datim': $time = ",\n timePicker:true"; break; @@ -720,14 +641,9 @@ protected function getMcWDatePickerString($strId, $strKey, $rgxp) }); }); '; - - } - - else - { + } else { $format = Date::formatToJs($this->getNumericDateFormat($rgxp)); - switch ($rgxp) - { + switch ($rgxp) { case 'datim': $time = ",\n timePicker:true"; break; @@ -761,26 +677,23 @@ protected function getMcWDatePickerString($strId, $strKey, $rgxp) protected function getMcWTinyMCEString($strId, $arrField) { - if (version_compare(VERSION, '3.3', '<')) - { + if (version_compare(VERSION, '3.3', '<')) { return ""; } - list ($file, $type) = explode('|', $arrField['eval']['rte'], 2); + list($file, $type) = explode('|', $arrField['eval']['rte'], 2); - if (!file_exists(TL_ROOT . '/system/config/' . $file . '.php')) - { + if (!file_exists(TL_ROOT . '/system/config/' . $file . '.php')) { throw new \Exception(sprintf('Cannot find editor configuration file "%s.php"', $file)); } // Backwards compatibility $language = substr($GLOBALS['TL_LANGUAGE'], 0, 2); - if (!file_exists(TL_ROOT . '/assets/tinymce/langs/' . $language . '.js')) - { + if (!file_exists(TL_ROOT . '/assets/tinymce/langs/' . $language . '.js')) { $language = 'en'; } @@ -818,24 +731,20 @@ protected function initializeWidget(&$arrField, $intRow, $strKey, $varValue) $arrField['activeRecord'] = $this->activeRecord; // Toggle line wrap (textarea) - if ($arrField['inputType'] == 'textarea' && $arrField['eval']['rte'] == '') - { + if ($arrField['inputType'] == 'textarea' && $arrField['eval']['rte'] == '') { $xlabel .= ' ' . $this->generateImage('wrap.gif', $GLOBALS['TL_LANG']['MSC']['wordWrap'], 'title="' . specialchars($GLOBALS['TL_LANG']['MSC']['wordWrap']) . '" class="toggleWrap" onclick="Backend.toggleWrap(\'ctrl_' . $this->strId . '_row' . $intRow . '_' . $strKey . '\');"'); } // Add the help wizard - if ($arrField['eval']['helpwizard']) - { + if ($arrField['eval']['helpwizard'] ?? false) { $xlabel .= ' ' . \Image::getHtml('about.gif', $GLOBALS['TL_LANG']['MSC']['helpWizard'], 'style="vertical-align:text-bottom"') . ''; } // Add the popup file manager - if ($arrField['inputType'] == 'fileTree' || $arrField['inputType'] == 'pageTree') - { + if ($arrField['inputType'] == 'fileTree' || $arrField['inputType'] == 'pageTree') { $path = ''; - if (isset($arrField['eval']['path'])) - { + if (isset($arrField['eval']['path'])) { $path = '?node=' . $arrField['eval']['path']; } @@ -848,23 +757,19 @@ protected function initializeWidget(&$arrField, $intRow, $strKey, $varValue) } // Add the table import wizard - elseif ($arrField['inputType'] == 'tableWizard') - { + elseif ($arrField['inputType'] == 'tableWizard') { $xlabel .= ' ' . $this->generateImage('tablewizard.gif', $GLOBALS['TL_LANG']['MSC']['tw_import'][0], 'style="vertical-align:text-bottom;"') . ''; $xlabel .= ' ' . $this->generateImage('demagnify.gif', '', 'title="' . specialchars($GLOBALS['TL_LANG']['MSC']['tw_shrink']) . '" style="vertical-align:text-bottom; cursor:pointer;" onclick="Backend.tableWizardResize(0.9);"') . $this->generateImage('magnify.gif', '', 'title="' . specialchars($GLOBALS['TL_LANG']['MSC']['tw_expand']) . '" style="vertical-align:text-bottom; cursor:pointer;" onclick="Backend.tableWizardResize(1.1);"'); } // Add the list import wizard - elseif ($arrField['inputType'] == 'listWizard') - { + elseif ($arrField['inputType'] == 'listWizard') { $xlabel .= ' ' . $this->generateImage('tablewizard.gif', $GLOBALS['TL_LANG']['MSC']['tw_import'][0], 'style="vertical-align:text-bottom;"') . ''; } // Input field callback - if (is_array($arrField['input_field_callback'])) - { - if (!is_object($this->{$arrField['input_field_callback'][0]})) - { + if (is_array($arrField['input_field_callback'] ?? false)) { + if (!is_object($this->{$arrField['input_field_callback'][0]})) { $this->import($arrField['input_field_callback'][0]); } @@ -873,70 +778,56 @@ protected function initializeWidget(&$arrField, $intRow, $strKey, $varValue) $strClass = $GLOBALS[(TL_MODE == 'BE' ? 'BE_FFL' : 'TL_FFL')][$arrField['inputType']]; - if ($strClass == '' || !$this->classFileExists($strClass)) - { + if ($strClass == '' || !$this->classFileExists($strClass)) { return null; } $arrField['eval']['required'] = false; // Use strlen() here (see #3277) - if ($arrField['eval']['mandatory']) - { - if (is_array($this->varValue[$intRow][$strKey])) - { - if (empty($this->varValue[$intRow][$strKey])) - { + if ($arrField['eval']['mandatory'] ?? false) { + if (is_array($this->varValue[$intRow][$strKey])) { + if (empty($this->varValue[$intRow][$strKey])) { $arrField['eval']['required'] = true; } - } - else - { - if (!strlen($this->varValue[$intRow][$strKey])) - { + } else { + if (!strlen($this->varValue[$intRow][$strKey])) { $arrField['eval']['required'] = true; } } } // Hide label except if multiple widgets are in one column - if ($arrField['eval']['columnPos'] == '') - { - $arrField['eval']['tl_class'] = trim($arrField['eval']['tl_class'] . ' hidelabel'); + if ($arrField['eval']['columnPos'] ?? false == '') { + $arrField['eval']['tl_class'] = trim($arrField['eval']['tl_class'] ?? false . ' hidelabel'); } // add class to enable easy updating of "name" attributes etc. $arrField['eval']['tl_class'] = trim($arrField['eval']['tl_class'] . ' mcwUpdateFields'); // if we have a row class, add that one aswell. - if (isset($arrField['eval']['rowClasses'][$intRow])) - { + if (isset($arrField['eval']['rowClasses'][$intRow])) { $arrField['eval']['tl_class'] = trim($arrField['eval']['tl_class'] . ' ' . $arrField['eval']['rowClasses'][$intRow]); } // load callback - if (is_array($arrField['load_callback'])) - { - foreach ($arrField['load_callback'] as $callback) - { + if (is_array($arrField['load_callback'] ?? false)) { + foreach ($arrField['load_callback'] as $callback) { $this->import($callback[0]); $varValue = $this->{$callback[0]}->{$callback[1]}($varValue, $this); } - } - elseif (is_callable($arrField['load_callback'])) - { + } elseif (is_callable($arrField['load_callback'] ?? false)) { $varValue = $arrField['load_callback']($varValue, $this); } // Convert date formats into timestamps (check the eval setting first -> #3063) - $rgxp = $arrField['eval']['rgxp']; - $dateFormatErrorMsg=""; - if (($rgxp == 'date' || $rgxp == 'time' || $rgxp == 'datim') && $varValue != '') - { - try{ + $rgxp = $arrField['eval']['rgxp'] ?? false; + $dateFormatErrorMsg = ""; + if (($rgxp == 'date' || $rgxp == 'time' || $rgxp == 'datim') && $varValue != '') { + try { $objDate = new Date($varValue, $this->getNumericDateFormat($rgxp)); - }catch(\Exception $e){ - $dateFormatErrorMsg=$e->getMessage(); + } catch (\Exception $e) { + $dateFormatErrorMsg = $e->getMessage(); } $varValue = $objDate->tstamp; @@ -945,7 +836,7 @@ protected function initializeWidget(&$arrField, $intRow, $strKey, $varValue) $arrField['activeRow'] = $intRow; $arrField['name'] = $this->strName . '[' . $intRow . '][' . $strKey . ']'; $arrField['id'] = $this->strId . '_row' . $intRow . '_' . $strKey; - $arrField['value'] = ($varValue !== '') ? $varValue : $arrField['default']; + $arrField['value'] = ($varValue !== '') ? $varValue : $arrField['default'] ?? false; $arrField['eval']['tableless'] = true; $arrData = $this->handleDcGeneral($arrField, $strKey); @@ -956,7 +847,7 @@ protected function initializeWidget(&$arrField, $intRow, $strKey, $varValue) $objWidget->storeValues = true; $objWidget->xlabel = $xlabel; $objWidget->currentRecord = $this->currentRecord; - if(!empty($dateFormatErrorMsg)){ + if (!empty($dateFormatErrorMsg)) { $objWidget->addError($e->getMessage()); } @@ -977,12 +868,11 @@ protected function initializeWidget(&$arrField, $intRow, $strKey, $varValue) private function buildWidget($strClass, array $arrData, array &$arrField) { // Check if the data container driver is an DC-General. - if (is_subclass_of($this->objDca, 'ContaoCommunityAlliance\DcGeneral\EnvironmentAwareInterface')) - { + if (is_subclass_of($this->objDca, 'ContaoCommunityAlliance\DcGeneral\EnvironmentAwareInterface')) { return $this->buildWidgetForDcGeneral($arrData, $arrField); } - return new $strClass(\MultiColumnWizard::getAttributesFromDca($arrData, $arrField['name'], $arrField['value'], $arrField['strField'], $this->strTable, $this)); + return new $strClass(\MultiColumnWizard::getAttributesFromDca($arrData, $arrField['name'], $arrField['value'], $arrField['strField'] ?? false, $this->strTable, $this)); } /** @@ -1065,18 +955,14 @@ private function buildWidgetForDcGeneral(array $arrData, array &$arrField) public function handleDcGeneral($arrData, $strName) { // DcGeneral 2.0 compatibility check. - if (is_subclass_of($this->objDca, 'ContaoCommunityAlliance\DcGeneral\EnvironmentAwareInterface')) - { + if (is_subclass_of($this->objDca, 'ContaoCommunityAlliance\DcGeneral\EnvironmentAwareInterface')) { // If options-callback registered, call that one first as otherwise \Widget::getAttributesFromDca will kill // our options. - if (is_array($arrData['options_callback'])) - { + if (is_array($arrData['options_callback'])) { $arrCallback = $arrData['options_callback']; $arrData['options'] = static::importStatic($arrCallback[0])->{$arrCallback[1]}($this); unset($arrData['options_callback']); - } - elseif (is_callable($arrData['options_callback'])) - { + } elseif (is_callable($arrData['options_callback'])) { $arrData['options'] = $arrData['options_callback']($this); unset($arrData['options_callback']); } @@ -1084,8 +970,7 @@ public function handleDcGeneral($arrData, $strName) /* @var \ContaoCommunityAlliance\DcGeneral\EnvironmentInterface $environment */ $environment = $this->objDca->getEnvironment(); // FIXME: begin of legacy code to be removed. - if (method_exists($environment, 'getEventPropagator')) - { + if (method_exists($environment, 'getEventPropagator')) { $event = new \ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent($environment, $this->objDca->getModel()); $event->setPropertyName($strName); $event->setOptions($arrData['options']); @@ -1099,8 +984,7 @@ public function handleDcGeneral($arrData, $strName) ) ); - if ($event->getOptions() !== $arrData['options']) - { + if ($event->getOptions() !== $arrData['options']) { $arrData['options'] = $event->getOptions(); } } @@ -1116,8 +1000,7 @@ public function handleDcGeneral($arrData, $strName) ); $environment->getEventDispatcher()->dispatch($event::NAME, $event); - if ($event->getOptions() !== $arrData['options']) - { + if ($event->getOptions() !== $arrData['options']) { $arrData['options'] = $event->getOptions(); } } @@ -1148,20 +1031,19 @@ protected function generateTable($arrUnique, $arrDatepicker, $arrColorpicker, $s { // generate header fields - foreach ($this->columnFields as $strKey => $arrField) - { + foreach ($this->columnFields as $strKey => $arrField) { - if ($arrField['eval']['columnPos']) - { + if ($arrField['eval']['columnPos'] ?? false) { $arrHeaderItems[$arrField['eval']['columnPos']] = '