You are here

function bynder_generate_facets_link in Bynder 7

Generate links for facets.

1 call to bynder_generate_facets_link()
bynder_generate_facets in includes/bynder.browser.inc
Generate facets.

File

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

Code

function bynder_generate_facets_link($facet_category, $facet_category_name, $selected_facets) {
  global $filter_labels;
  $facet_links = array();
  foreach ($facet_category as $facet_id => $facet_count) {
    $facet_name = $facet_id;
    if (!isset($filter_labels[$facet_name])) {
      $filter_labels[$facet_name] = $facet_name;
    }
    $filter_key = $facet_category_name;
    $filter_value = $facet_id;
    $active = bynder_facet_active($selected_facets, array(
      $facet_category_name => array(
        $facet_id,
      ),
    ));
    $active_class = $active ? "active" : "";
    $link = "";
    $link .= '<a class="filter-url ' . filter_xss($active_class) . '" href="#" data-filter-key="' . filter_xss($filter_key) . '" data-filter-value="' . filter_xss($filter_value) . '">' . filter_xss($filter_labels[$facet_name]) . '</a>';
    $link .= '<span class="count">(' . filter_xss($facet_count) . ')</span>';
    $facet_links[] = $link;
  }
  return $facet_links;
}