You are here

function bynder_generate_selected_facets in Bynder 7

1 call to bynder_generate_selected_facets()
bynder_generate_search in includes/bynder.browser.inc
Generate search page.

File

includes/bynder.browser.inc, line 461
Manages the Bynder media browser functionality

Code

function bynder_generate_selected_facets($selected_facets) {
  global $filter_labels;
  if (empty($selected_facets)) {
    return array();
  }
  $facets_list = array(
    '#theme' => 'item_list',
    '#type' => 'ul',
    '#title' => t('Selected Filters'),
    '#attributes' => array(
      'class' => 'selected_facet_list facet_list',
    ),
  );
  foreach ($selected_facets as $selected_facet) {
    $selected_facet_key = $selected_facet->key;
    $selected_facet_value = $selected_facet->value;
    $facet_name = $selected_facet_value;
    if (!isset($filter_labels[$selected_facet_key])) {
      $filter_labels[$selected_facet_key] = t($selected_facet_key);
    }
    $facet_category = array(
      'data' => "<span>" . filter_xss($facet_name) . "<span class='expand'><i class='fa fa-times'></i></span></span>",
      'class' => array(
        'facet_title',
      ),
      'data-filter-key' => filter_xss($selected_facet->key),
    );
    $facets_list['#items'][] = $facet_category;
  }
  $facet_remove_all = array(
    'data' => "<span id='clear-all'>Clear filters<span class='expand'></span></span>",
    'class' => array(
      'facet_title',
    ),
    'data-filter-key' => 'bynder_remove_all_facets_filter_key',
  );
  $facets_list['#items'][] = $facet_remove_all;
  return $facets_list;
}