You are here

function facetapi_get_widgets in Facet API 6.3

Same name and namespace in other branches
  1. 7.2 facetapi.admin.inc \facetapi_get_widgets()
  2. 7 facetapi.admin.inc \facetapi_get_widgets()

Returns the widget plugin definitions available to the facet.

All widget plugins are checked against their requirmenets. Only widgets that pall all requirements are returned by this function.

Parameters

array $realm: The realm definition.

array $facet: The facet definition.

Return value

array An array of available widget plugins.

1 call to facetapi_get_widgets()
facetapi_facet_display_form in ./facetapi.admin.inc
Form constructor for the facet display settings form.

File

./facetapi.admin.inc, line 319
Admin page callbacks for the Facet API module.

Code

function facetapi_get_widgets(array $realm, array $facet) {
  $plugins = array();

  // Iterates over all defined plugins, initializes requirements.
  foreach (ctools_get_plugins('facetapi', 'widgets') as $id => $plugin) {

    //Exclude abstract classes
    if (!isset($plugin['handler']['abstract']) || !$plugin['handler']['abstract']) {
      $plugin['handler'] += array(
        'requirements' => array(
          'facetapi_requirement_realm_property' => array(
            'element type' => 'links',
          ),
        ),
        'requirements operator' => 'AND',
      );

      // Checks requirements, only saves widgets that pass all requirements.
      if (facetapi_check_requirements($plugin['handler']['requirements'], $realm, $facet, $plugin['handler']['requirements operator'])) {
        $plugins[$id] = $plugin;
      }
    }
  }
  return $plugins;
}