getAllColumnValues($this->result); // column dropdowns foreach ($colValues as $num => $colData) { /** @var Column $column */ $column = $colData['column']; $this->renderer->doc .= '
'; $this->renderer->doc .= '' . hsc($colData['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'] = $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 $pairs = array_combine((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 } }