function facetapi_get_enabled_facets in Facet API 6.3
Same name and namespace in other branches
- 7.2 facetapi.module \facetapi_get_enabled_facets()
- 7 facetapi.module \facetapi_get_enabled_facets()
Returns all enabled facet definitions available to the searcher.
If a realm is passed, this function returns all facets enabled in the realm. If no realm is passed, this function returns all facets that are enabled in at least one realm.
Parameters
$searcher: The machine readable name of the searcher.
$realm_name: The machine readable name of the realm, pass NULL to return all facets that are enabled in at least one realm.
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.
4 calls to facetapi_get_enabled_facets()
- FacetapiAdapter::getEnabledFacets in plugins/
facetapi/ adapter.inc - Returns the enabled facets associated with the instance of the adapter.
- facetapi_facet_enabled in ./
facetapi.module - Tests whether a single facet is enabled in a given realm.
- facetapi_get_delta_map_queue in ./
facetapi.block.inc - Returns facets that are enabled or whose delta mapping is forced.
- facetapi_set_facet_status in ./
facetapi.module - Enables or disables a facet for this page load only.
3 string references to 'facetapi_get_enabled_facets'
- FacetapiTestCase::enableFacet in tests/
facetapi.test - Enables a facet in the block realm, adds it to the "sidebar_first" region.
- facetapi_save_facet_status in ./
facetapi.module - Sets the facet status in a given realm, stores settings in the database.
- facetapi_set_facet_status in ./
facetapi.module - Enables or disables a facet for this page load only.
File
- ./
facetapi.module, line 813 - An abstracted facet API that can be used by various search backends.
Code
function facetapi_get_enabled_facets($searcher, $realm_name = NULL) {
$enabled_facets =& ctools_static(__FUNCTION__, array());
$cid = $searcher . ':' . (string) $realm_name;
if (!isset($enabled_facets[$cid])) {
$facets = array();
// Gets cached settings, finds enabled facets.
$cached = facetapi_get_searcher_settings($searcher);
foreach ($cached as $name => $settings) {
$test_enabled = NULL === $realm_name || $realm_name == $settings->realm;
if ($test_enabled && $settings->enabled) {
$facets[$settings->facet] = $settings->facet;
}
}
// Gets facet definitions for all enabled facets.
$facet_info = facetapi_get_facet_info($searcher);
$enabled_facets[$cid] = array_intersect_key($facet_info, $facets);
}
return $enabled_facets[$cid];
}