Skip to content

Commit

Permalink
feat(bazar): in bazarliste dynamic components, format wikitext for de…
Browse files Browse the repository at this point in the history
…scription
  • Loading branch information
mrflos committed Jul 28, 2024
1 parent cf8c7d9 commit c476419
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tools/bazar/controllers/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,24 +306,26 @@ public function getBazarListData()
return $entry['id_typeannonce'];
}, $entries);
$formIds = array_unique($formIds);
$usedForms = array_filter($forms, function ($form) use ($formIds) {
return in_array($form['bn_id_nature'], $formIds);
});
$usedForms = array_map(function ($f) {
return $f['prepared'];
}, $usedForms);

// Reduce the size of the data sent by transforming entries object into array
// we use the $fieldMapping to transform back the data when receiving data in the front end
$entries = array_map(function ($entry) use ($fieldList) {
$result = [];
foreach ($fieldList as $field) {
if (!empty($entry[$field]) && !empty($_GET['displayfields']['subtitle']) && $_GET['displayfields']['subtitle'] == $field) {
$entry[$field] = $this->wiki->Format($entry[$field]);
}
$result[] = $entry[$field] ?? null;
}

return $result;
}, $entries);

$usedForms = array_filter($forms, function ($form) use ($formIds) {
return in_array($form['bn_id_nature'], $formIds);
});
$usedForms = array_map(function ($f) {
return $f['prepared'];
}, $usedForms);

return new ApiResponse(
[
Expand Down

0 comments on commit c476419

Please sign in to comment.