PHRAS-1326_intl-labels-in-facets_MASTER

add "labels" array to facets
This commit is contained in:
Jean-Yves Gaulier
2018-11-27 19:33:36 +01:00
parent e2f5afc07b
commit 61058a3658
2 changed files with 27 additions and 7 deletions

View File

@@ -327,6 +327,10 @@ class QueryController extends Controller
foreach(ElasticsearchOptions::getAggregableTechnicalFields() as $k => $f) {
$fieldsInfosByName[$k] = $f;
$fieldsInfosByName[$k]['trans_label'] = $this->app->trans($f['label']);
$fieldsInfosByName[$k]['labels'] = [];
foreach($this->app->getAvailableLanguages() as $locale => $lng) {
$fieldsInfosByName[$k]['labels'][$locale] = $this->app->trans($f['label'], [], "messages", $locale);
}
}
// add databox fields
@@ -338,17 +342,22 @@ class QueryController extends Controller
foreach ($databox->get_meta_structure() as $field) {
$name = $field->get_name();
$fieldsInfos[$sbasId][$name] = [
'label' => $field->get_label($this->app['locale']),
'type' => $field->get_type(),
'label' => $field->get_label($this->app['locale']),
'labels' => $field->get_labels(),
'type' => $field->get_type(),
'business' => $field->isBusiness(),
'multi' => $field->is_multi(),
'multi' => $field->is_multi(),
];
// infos on the "same" field (by name) on multiple databoxes !!!
// label(s) can be inconsistants : the first databox wins
if (!isset($fieldsInfosByName[$name])) {
$fieldsInfosByName[$name] = [
'label' => $field->get_label($this->app['locale']),
'type' => $field->get_type(),
'field' => $field->get_name(),
'query' => "field." . $field->get_name() . ":%s",
'label' => $field->get_label($this->app['locale']),
'labels' => $field->get_labels(),
'type' => $field->get_type(),
'field' => $field->get_name(),
'query' => "field." . $field->get_name() . ":%s",
'trans_label' => $field->get_label($this->app['locale']),
];
$field->get_label($this->app['locale']);
@@ -399,6 +408,7 @@ class QueryController extends Controller
$f = $fieldsInfosByName[$facetName];
$facet['label'] = $f['trans_label'];
$facet['labels'] = $f['labels'];
$facet['type'] = strtoupper($f['type']) . "-AGGREGATE";
$facets[] = $facet;