function facetapi_get_facet_info in Facet API 6.3
Same name and namespace in other branches
- 7.2 facetapi.module \facetapi_get_facet_info()
- 7 facetapi.module \facetapi_get_facet_info()
Returns all defined facet definitions available to the searcher.
Parameters
$searcher: A string containing the machine readable name of the searcher.
Return value
array An array of facet definitions. Each definition is an array keyed by the machine readable name of the facet. See the return value of the facetapi_facet_load() function for the structure of the definitions.
3 calls to facetapi_get_facet_info()
- facetapi_facet_load in ./
facetapi.module - Returns a facet definition.
- facetapi_get_enabled_facets in ./
facetapi.module - Returns all enabled facet definitions available to the searcher.
- facetapi_realm_settings_form in ./
facetapi.admin.inc - Form constructor for the realm settings form.
File
- ./
facetapi.module, line 612 - An abstracted facet API that can be used by various search backends.
Code
function facetapi_get_facet_info($searcher) {
$facet_info =& ctools_static(__FUNCTION__, array());
// Gets facet info if we haven't gotten it already.
if (!isset($facet_info[$searcher])) {
$searcher_info = facetapi_get_searcher_info();
$facet_info[$searcher] = array();
// Invokes hook_facetapi_facet_info(), normalizes facets.
foreach (module_implements('facetapi_facet_info') as $module) {
$facets = call_user_func($module . '_facetapi_facet_info', $searcher_info[$searcher]);
if (!$facets || !is_array($facets)) {
$facets = array();
}
// Iterates over facet definitions, merges defaults.
foreach ($facets as $facet_name => $info) {
// @see http://drupal.org/node/1161434
// Converts "query type" to an array and stores in "query types".
// @todo Remove in later versions.
if (isset($info['query type']) && !isset($info['query types'])) {
$info['query types'] = array(
$info['query type'],
);
}
$facet_info[$searcher][$facet_name] = $info;
$facet_info[$searcher][$facet_name] += array(
'name' => $facet_name,
'label' => $facet_name,
'description' => '',
'field' => $facet_name,
'field alias' => isset($info['field']) ? $info['field'] : $facet_name,
'field api name' => FALSE,
'field api bundles' => array(),
'query types' => array(
'term',
),
'alter callbacks' => array(),
'dependency plugins' => array(),
'default widget' => FALSE,
'allowed operators' => array(
FACETAPI_OPERATOR_AND => TRUE,
FACETAPI_OPERATOR_OR => TRUE,
),
'facet missing allowed' => FALSE,
'facet mincount allowed' => FALSE,
'weight' => 0,
'map callback' => FALSE,
'map options' => array(),
'hierarchy callback' => FALSE,
'values callback' => FALSE,
'min callback' => FALSE,
'max callback' => FALSE,
'default sorts' => array(
array(
'active',
SORT_DESC,
),
array(
'count',
SORT_DESC,
),
array(
'display',
SORT_ASC,
),
),
);
// @see http://drupal.org/node/1161434
// Makes sure old style "query type" is present.
// @todo Remove in later versions.
if (!isset($facet_info[$searcher][$facet_name]['query type'])) {
$type = key($facet_info[$searcher][$facet_name]['query types']);
$facet_info[$searcher][$facet_name]['type'] = $type;
}
}
}
// Invokes alter hook, sorts and returns.
drupal_alter('facetapi_facet_info', $facet_info[$searcher], $searcher_info[$searcher]);
array_walk($facet_info[$searcher], 'facetapi_map_assoc', 'field api bundles');
uasort($facet_info[$searcher], 'facetapi_sort_weight');
}
return $facet_info[$searcher];
}