You are here

function facetapi_sorts_get in Facet API 6

Invokes hook_facetapi_sort_info(), returns all defined sorts.

Parameters

$reset: A boolean flagging whether the static should be reset.

Return value

An associative array of sort definitions keyed by sort name.

3 calls to facetapi_sorts_get()
facetapi_facet_settings_form in ./facetapi.admin.inc
Returns settings for an individual facet that apply to a realm.
facetapi_facet_sorts_get in ./facetapi.module
Returns sorts enabled for a facet in a realm. Sort definitions are returned in the order specified in the configurations settings.
theme_facetapi_facet_settings_form in ./facetapi.admin.inc
Themes the facet sort form into a draggable table.

File

./facetapi.module, line 617
An abstracted facet API that can be used by various search backens.

Code

function facetapi_sorts_get($reset = FALSE) {
  static $sorts;
  if (NULL === $sorts || $reset) {

    // Gets realm info from hooks, merges with defaults.
    $sorts = array();
    foreach (module_invoke_all('facetapi_sort_info') as $sort_name => $sort) {
      $defaults = array(
        'name' => $sort_name,
        'title' => $sort_name,
        'callback' => '',
        'description' => '',
        'weight' => 0,
      );
      $sorts[$sort_name] = array_merge($defaults, $sort);
    }

    // Invokes alter hook.
    drupal_alter('facetapi_sort_info', $sorts);
  }
  return $sorts;
}