You are here

function bynder_query_facet_link in Bynder 7

File

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

Code

function bynder_query_facet_link($facet, $facet_value, $selected_facets, $deactivate = false) {
  if (!$deactivate) {
    $selected_facets = array_merge_recursive(array(
      $facet => array(
        $facet_value,
      ),
    ), $selected_facets);
  }
  else {
    if (isset($selected_facets[$facet])) {
      $selected_facets[$facet] = array_diff(explode(',', $selected_facets[$facet][0]), array(
        $facet_value,
      ));
    }
  }
  $csv_facets = array();
  foreach (array_filter($selected_facets) as $selected_facet_key => $selected_facet) {
    $csv_facets[$selected_facet_key] = implode(',', $selected_facet);
  }
  $value = http_build_query($csv_facets);
  return $value;
}