Skip to content

Commit

Permalink
UHF-11076 (#1601)
Browse files Browse the repository at this point in the history
* UHF-11076: fix encoded ampersands on form fields after loading data from atv

* UHF-11076: fix the encoded ampersand problem on grantpremsesservice. decode also all string string fields as well

* UHF-11076: reorder the first section by weight

* UHF-11076: sort all sections inside a page
  • Loading branch information
rpnykanen authored Dec 10, 2024
1 parent 6d5fdbc commit 6d6f508
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ public function __invoke(string $submission_id): array {
}
}

// Sort the fields based on weight.
// Sort the sections inside a page based on section weight.
foreach ($newPages as $pageKey => $page) {
usort($newPages[$pageKey]['sections'], fn($a, $b) => $a['weight'] > $b['weight']);
}

// Sort the fields inside the sections based on weight.
foreach ($newPages as $pageKey => $page) {
foreach ($page['sections'] as $sectionKey => $section) {
usort($newPages[$pageKey]['sections'][$sectionKey]['fields'], function ($fieldA, $fieldB) {
Expand Down
14 changes: 8 additions & 6 deletions public/modules/custom/grants_metadata/src/AtvSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,14 @@ private static function extractValuesRecursively(array $items, array $keys, arra
if (in_array($key, $keys) && !in_array($key, $values)) {
$values[$key] = $item;
}
if (is_numeric($key) &&
!AtvSchema::numericKeys($item) &&
isset($item['ID']) &&
in_array($item['ID'], $keys) &&
!in_array($item['ID'], $values)) {
$values[$item['ID']] = $item['value'];
if (
is_numeric($key) &&
!AtvSchema::numericKeys($item) &&
isset($item['ID']) &&
in_array($item['ID'], $keys) &&
!in_array($item['ID'], $values)
) {
$values[$item['ID']] = htmlspecialchars_decode($item['value']);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,12 @@ protected static function getArrayElementItemValue(
$itemValue = self::processNestedArrayItem($v, $itemPropertyDefinitions);
if (array_key_exists('value', $v)) {
$meta = isset($v['meta']) ? json_decode($v['meta'], TRUE) : NULL;
$retval[$key][$v['ID']] = InputmaskHandler::convertPossibleInputmaskValue(
$itemValue ?? $v['value'],
$meta ?? []
$value = InputmaskHandler::convertPossibleInputmaskValue(
$itemValue ?? $v['value'],
$meta ?? []
);

$retval[$key][$v['ID']] = htmlspecialchars_decode($value);
}
else {
$retval[$key][$key2] = $itemValue ?? $v;
Expand Down Expand Up @@ -210,7 +212,7 @@ protected static function extractItemValue(
if ($valueExtractorConfig) {
$valueExtractorService = self::getDynamicService($valueExtractorConfig['service']);
$method = $valueExtractorConfig['method'];
return $valueExtractorService->$method($item);
return htmlspecialchars_decode($valueExtractorService->$method($item));
}
return NULL;
}
Expand Down Expand Up @@ -239,7 +241,7 @@ protected static function extractSimpleItemValue(
if ($valueExtractorConfig) {
$valueExtractorService = self::getDynamicService($valueExtractorConfig['service']);
$method = $valueExtractorConfig['method'];
return $valueExtractorService->$method($item);
return htmlspecialchars_decode($valueExtractorService->$method($item));
}
}
return NULL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function extractToWebformData(DataDefinitionInterface $definition, array
$value2value = 0;
}
}
$temp[$value2['ID']] = $value2value;
$temp[$value2['ID']] = htmlspecialchars_decode($value2value);
}
$returnValueArray[$key] = $temp;
}
Expand Down

0 comments on commit 6d6f508

Please sign in to comment.