';
- if($diff['rows'] != '') {
+ if($diff['rows'] !== '') {
$content .= '
diff --git a/plugins/manager/lib/yform_history_helper.php b/plugins/manager/lib/yform_history_helper.php
index 52f78a4d..8d20d565 100644
--- a/plugins/manager/lib/yform_history_helper.php
+++ b/plugins/manager/lib/yform_history_helper.php
@@ -9,7 +9,7 @@
*/
class rex_yform_history_helper
{
- const FIELD_TYPE_ICONS = [
+ const array FIELD_TYPE_ICONS = [
'question' => 'question',
'checkbox' => 'square-check',
@@ -40,7 +40,7 @@ class rex_yform_history_helper
'email' => 'at'
];
- const FIELD_TYPE_ICON_WEIGHT_CLASS = 'far';
+ const string FIELD_TYPE_ICON_WEIGHT_CLASS = 'far';
/**
* detect diffs in 2 strings
@@ -51,13 +51,13 @@ class rex_yform_history_helper
* @created 17.04.2024
* @copyright https://github.com/paulgb/simplediff | Paul Butler (paulgb)
*/
- public static function diffStrings($old, $new):array
+ public static function diffStrings($old, $new): array
{
$matrix = array();
- $maxlen = 0;
+ $maxlen = $omax = $nmax = 0;
foreach ($old as $oindex => $ovalue) {
- $nkeys = array_keys($new, $ovalue);
+ $nkeys = array_keys($new, $ovalue, true);
foreach ($nkeys as $nindex) {
$matrix[$oindex][$nindex] =
@@ -74,14 +74,14 @@ public static function diffStrings($old, $new):array
}
}
- if ($maxlen == 0) {
+ if ($maxlen === 0) {
return array(array('d' => $old, 'i' => $new));
}
return array_merge(
- self::diffStrings(array_slice($old, 0, $omax), array_slice($new, 0, $nmax)),
+ rex_yform_history_helper::diffStrings(array_slice($old, 0, $omax), array_slice($new, 0, $nmax)),
array_slice($new, $nmax, $maxlen),
- self::diffStrings(array_slice($old, $omax + $maxlen), array_slice($new, $nmax + $maxlen))
+ rex_yform_history_helper::diffStrings(array_slice($old, $omax + $maxlen), array_slice($new, $nmax + $maxlen))
);
}
@@ -94,20 +94,16 @@ public static function diffStrings($old, $new):array
* @created 17.04.2024
* @copyright https://github.com/paulgb/simplediff | Paul Butler (paulgb)
*/
- public static function diffStringsToHtml($old, $new)
+ public static function diffStringsToHtml($old, $new): string
{
$ret = '';
- $diff = self::diffStrings(preg_split("/[\s]+/", $old), preg_split("/[\s]+/", $new));
+ $diff = rex_yform_history_helper::diffStrings(preg_split("/[\s]+/", $old), preg_split("/[\s]+/", $new));
foreach ($diff as $k) {
- if (is_array($k)) {
- $ret .=
- (!empty($k['d']) ? "" . implode(' ', $k['d']) . " " : '').
- (!empty($k['i']) ? "" . implode(' ', $k['i']) . " " : '')
- ;
- } else {
- $ret .= $k . ' ';
- }
+ $ret .=
+ (isset($k['d']) ? "" . implode(' ', $k['d']) . " " : '').
+ (isset($k['i']) ? "" . implode(' ', $k['i']) . " " : '')
+ ;
}
return $ret;
@@ -126,8 +122,8 @@ public static function diffStringsToHtml($old, $new)
*/
public static function getFieldTypeIcon(rex_yform_manager_field $field, bool $addPrefix = true, bool $outputHtml = true, bool $addTooltip = true, string $tooltipPlacement = 'top'):string
{
- $icon = self::FIELD_TYPE_ICONS[$field->getTypeName()] ?? 'default';
- $tag = isset(self::FIELD_TYPE_ICONS[$field->getTypeName()]) ? 'i' : 'span';
+ $icon = rex_yform_history_helper::FIELD_TYPE_ICONS[$field->getTypeName()] ?? 'default';
+ $tag = isset(rex_yform_history_helper::FIELD_TYPE_ICONS[$field->getTypeName()]) ? 'i' : 'span';
switch($field->getTypeName()) {
case 'choice':
@@ -135,9 +131,9 @@ public static function getFieldTypeIcon(rex_yform_manager_field $field, bool $ad
$multiple = (bool)(int)$field->getElement('multiple');
if($expanded && $multiple) {
- $icon = self::FIELD_TYPE_ICONS['choice_checkbox'];
+ $icon = rex_yform_history_helper::FIELD_TYPE_ICONS['choice_checkbox'];
} elseif($expanded) {
- $icon = self::FIELD_TYPE_ICONS['choice_radio'];
+ $icon = rex_yform_history_helper::FIELD_TYPE_ICONS['choice_radio'];
}
break;
}
@@ -147,7 +143,7 @@ public static function getFieldTypeIcon(rex_yform_manager_field $field, bool $ad
($addTooltip ? ' data-toggle="tooltip" data-placement="' . $tooltipPlacement . '" title="' . rex_i18n::msg('yform_manager_type_name') . ': ' . $field->getTypeName() . '"' : '') .
' class="' : ''
).
- ($icon !== 'default' ? self::FIELD_TYPE_ICON_WEIGHT_CLASS . ' ' : '').($addPrefix ? 'rex-icon ' : '') . 'fa-' . $icon .
+ ($icon !== 'default' ? rex_yform_history_helper::FIELD_TYPE_ICON_WEIGHT_CLASS . ' ' : '').($addPrefix ? 'rex-icon ' : '') . 'fa-' . $icon .
($outputHtml ? '">' . $tag . '>' : '');
}
@@ -164,8 +160,8 @@ public static function getFieldValue(rex_yform_manager_field $field, rex_yform_m
$class = 'rex_yform_value_' . $field->getTypeName();
$currentValue = ($dataset->hasValue($field->getName()) ? $dataset->getValue($field->getName()) : '-');
- if (is_callable($class, 'getListValue') && !in_array($field->getTypeName(), ['text','textarea'])) {
- /** @var $class rex_yform_value_abstract */
+ if (is_callable([$class, 'getListValue']) && !in_array($field->getTypeName(), ['text','textarea'], true)) {
+ /** @var rex_yform_value_abstract $class */
// get (formatted) value for current entry
if($dataset->hasValue($field->getName())) {
diff --git a/plugins/manager/pages/data_history.php b/plugins/manager/pages/data_history.php
index 0b15e435..75d940c8 100644
--- a/plugins/manager/pages/data_history.php
+++ b/plugins/manager/pages/data_history.php
@@ -214,7 +214,7 @@
$list->setColumnFormat(
$revision,
'custom',
- static function($a) use (&$rev, &$historyDatasets, &$table, &$sql, &$dataset) {
+ static function($a) use (&$rev, &$historyDatasets, &$table, &$sql) {
// early column ... store all values for current revision
$rev = rex::getProperty('YFORM_HISTORY_REVISION', 0);
@@ -287,7 +287,7 @@ static function($a) use (&$rev, &$historyDatasets, &$table, &$sql, &$dataset) {
$list->setColumnFormat(
$changesCurrent,
'custom',
- static function($a) use (&$dataset, $table, $sql, &$historyDatasets, $actionsCell, $normalCell, $changesCurrent) {
+ static function($a) use (&$dataset, $table, &$historyDatasets, $actionsCell, $normalCell, $changesCurrent) {
$rev = rex::getProperty('YFORM_HISTORY_REVISION', 0) - 1;
$changes = 0;