function fonts_com_get_all_filter_choices in @font-your-face 7.2
Gets choices for all filter given current values.
1 call to fonts_com_get_all_filter_choices()
- fonts_com_filter_choices in modules/
fonts_com/ fonts_com.module - Returns filter choices, refreshed periodically.
File
- modules/
fonts_com/ api.inc, line 701 - API functions.
Code
function fonts_com_get_all_filter_choices($current_filters) {
$path = '/rest/json/AllFilterValues/?' . drupal_http_build_query($current_filters);
$response = drupal_http_request(FONTS_COM_API_BASE_URL . $path, array(
'headers' => fonts_com_api_headers($path),
));
if ($response->code == 200) {
$data = json_decode($response->data);
if (isset($data->FilterValues) && isset($data->FilterValues->FilterValue)) {
$choices = fonts_com_unknown_to_array($data->FilterValues->FilterValue);
$choices_by_filter = array();
foreach ($choices as $choice) {
if (!isset($choices_by_filter[$choice->FilterType])) {
$choices_by_filter[$choice->FilterType] = array();
}
// if
$choices_by_filter[$choice->FilterType][] = $choice;
}
// foreach
return $choices_by_filter;
}
else {
drupal_set_message(t('There was an error getting filter choices from Fonts.com. Check !configuration.', array(
'!configuration' => l(t('configuration'), 'admin/config/user-interface/fontyourface/fonts_com'),
)), 'error');
fontyourface_log('Invalid drupal_http_request response: @response', array(
'@response' => print_r($response, TRUE),
));
}
// else
}
else {
drupal_set_message(t('There was an error getting filter choices from Fonts.com. Check !configuration.', array(
'!configuration' => l(t('configuration'), 'admin/config/user-interface/fontyourface/fonts_com'),
)), 'error');
fontyourface_log('Invalid drupal_http_request response: @response', array(
'@response' => print_r($response, TRUE),
));
}
// else
return array();
}