getAllColumnValues($this->searchConfig->getResult()->getRows()); // column dropdowns foreach ($colValues as $num => $colData) { /** @var Column $column */ $column = $colData['column']; $label = $this->data['headers'][$num] ?? $colData['label']; $this->renderer->doc .= '
'; $this->renderer->doc .= '' . hsc($label) . ''; $this->renderer->doc .= ''; $this->renderer->doc .= '
'; } } /** * Get all values from given search result grouped by column * * @return array */ protected function getAllColumnValues($result) { $colValues = []; foreach ($result as $row) { foreach ($row as $value) { /** @var Value $value */ $colName = $value->getColumn()->getFullQualifiedLabel(); $colValues[$colName]['column'] = $value->getColumn(); $colValues[$colName]['label'] = $value->getColumn()->getTranslatedLabel(); $colValues[$colName]['values'] ??= []; if (empty($value->getDisplayValue())) continue; // create an array with [value => displayValue] pairs // the cast to array will handle single and multi-value fields the same // using the full value as key will make sure we don't have duplicates // // because a value might be interpreted as integer in the array key, we pad // each key with a space at the end to enforce string keys. The space will // be ignored when parsing JSON values and trimmed for all other types. // This is a work around for #665 $pairs = array_combine( array_map( static fn($v) => "$v ", (array)$value->getValue() ), (array)$value->getDisplayValue() ); $colValues[$colName]['values'] = array_merge($colValues[$colName]['values'], $pairs); } } // sort by display value array_walk($colValues, function (&$col) { Sort::asort($col['values']); }); return array_values($colValues); // reindex } }