You are here

abstract class FacetapiAdapter in Facet API 6.3

Same name and namespace in other branches
  1. 6 facetapi.adapter.inc \FacetapiAdapter
  2. 7.2 plugins/facetapi/adapter.inc \FacetapiAdapter
  3. 7 plugins/facetapi/adapter.inc \FacetapiAdapter

Abstract class extended by search backends that retrieves facet information from the database.

Hierarchy

Expanded class hierarchy of FacetapiAdapter

1 string reference to 'FacetapiAdapter'
facetapi_facetapi_adapters in ./facetapi.facetapi.inc
Implements hook_facetapi_widgets().

File

plugins/facetapi/adapter.inc, line 12
Adapter plugin and adapter related calsses.

View source
abstract class FacetapiAdapter {

  /**
   * Searcher information retrieved by the hook.
   *
   * @var array
   */
  protected $info = array();

  /**
   * The search keys passed by the user.
   *
   * @var string
   */
  protected $keys;

  /**
   * An array of FacetapiFacet objects.
   *
   * @var array
   */
  protected $facets = array();

  /**
   * An array of FacetapiFacetProcessor objects.
   *
   * @var array
   */
  protected $processors = array();

  /**
   * An array of executed query type plugins keyed by field name.
   *
   * @var array
   */
  protected $queryTypes = array();

  /**
   * The URL processor associated with this adapter.
   *
   * @var FacetapiUrlProcessor
   */
  protected $urlProcessor;

  /**
   * An array of active filters.
   *
   * @var array
   */
  protected $activeItems;

  /**
   * A boolean flagging whether the facets have been processed.
   *
   * @var boolean
   */
  protected $processed = FALSE;

  /**
   * Stores the search path so we only need to calculate it once.
   *
   * @var string
   */
  protected $searchPath;

  /**
   * Stores whether each facet passed dependencies.
   *
   * @var array
   */
  protected $dependenciesPassed = array();

  /**
   * Stores settings with defaults.
   *
   * @var array
   */
  protected $settings = array();

  /**
   * Constructor, sets searcher and type of content being indexed.
   *
   * @param array $searcher_info
   *   The searcher definition.
   */
  public function __construct(array $searcher_info) {
    $this->info = $searcher_info;

    // Registers the query type plugins classes associated with this adapter.
    $registered_types = array();
    foreach (ctools_get_plugins('facetapi', 'query_types') as $plugin) {
      if (isset($searcher_info['adapter']) && isset($plugin['handler']['adapter']) && $searcher_info['adapter'] == $plugin['handler']['adapter']) {
        $class = ctools_plugin_get_class($plugin, 'handler');
        $type = call_user_func(array(
          $class,
          'getType',
        ));
        $registered_types[$type] = $class;
      }
    }

    // Iterates over facets and registers query type plugins.
    foreach ($this
      ->getEnabledFacets() as $facet) {

      // Gets widget type from setting if there are more than one available.
      if (1 == count($facet['query types'])) {
        $query_type = $facet['query types'][0];
      }
      else {
        $settings = $this
          ->getFacetSettingsGlobal($facet)->settings;
        $query_type = !empty($settings['query_type']) ? $settings['query_type'] : FALSE;
      }

      // If we found a query type, register the query type plugin.
      if ($query_type && isset($registered_types[$query_type])) {
        $plugin = new $registered_types[$query_type]($this, $facet);
        $this->queryTypes[$facet['name']] = $plugin;
      }
      else {
        $this->queryTypes[$facet['name']] = FALSE;
      }
    }

    // Instantiates URL processor plugin.
    $id = $searcher_info['url processor'];
    $class = ctools_plugin_load_class('facetapi', 'url_processors', $id, 'handler');
    if (!$class) {
      $class = ctools_plugin_load_class('facetapi', 'url_processors', 'standard', 'handler');
    }
    $this->urlProcessor = new $class($this);

    // Fetches, normalizes, and sets filter params.
    $filter_key = $this->urlProcessor
      ->getFilterKey();
    $params = $this->urlProcessor
      ->fetchParams();
    $this
      ->setParams($params, $filter_key);
  }

  /**
   * Returns a boolean flagging whether $this->info['searcher'] executed a search.
   *
   * @return
   *   A boolean flagging whether $this->info['searcher'] executed a search.
   *
   * @todo Generic search API should provide consistent functionality.
   */
  public abstract function searchExecuted();

  /**
   * Returns a boolean flagging whether facets in a realm shoud be displayed.
   *
   * Useful, for example, for suppressing sidebar blocks in some cases.
   *
   * @return
   *   A boolean flagging whether to display a given realm.
   *
   * @todo Generic search API should provide consistent functionality.
   */
  public abstract function suppressOutput($realm_name);

  /**
   * Processes a raw array of active filters.
   *
   * @param array $params
   *   An array of keyed params, such as $_GET.
   * @param string $filter_key
   *   The array key in $params corresponding to filters.
   *
   * @return FacetapiAdapter
   *   An instance of this class.
   */
  public function setParams(array $params = array(), $filter_key = 'f') {
    $this->facets = array();
    $normalized = $this->urlProcessor
      ->normalizeParams($params, $filter_key);
    $this->urlProcessor
      ->setParams($normalized, $filter_key);
    $this
      ->processActiveItems();
    return $this;
  }

  /**
   * Processes active items.
   *
   * @see FacetapiAdapter::setParams()
   */
  public function processActiveItems() {
    $this->activeItems = array(
      'facet' => array(),
      'filter' => array(),
    );

    // Groups enabled facets by facet alias.
    $enabled_aliases = array();
    foreach ($this
      ->getEnabledFacets() as $facet) {
      $enabled_aliases[$facet['field alias']][] = $facet['name'];
      $this->activeItems['facet'][$facet['name']] = array();
    }

    // Extracts valid filters from query string.
    $filter_key = $this->urlProcessor
      ->getFilterKey();
    $params = $this->urlProcessor
      ->getParams();
    foreach ($params[$filter_key] as $pos => $filter) {

      // Bails if an object or array.
      if (!is_scalar($filter)) {
        continue;
      }

      // Performs basic parsing of the filter.
      $parts = explode(':', $filter, 2);
      $field_alias = rawurldecode($parts[0]);
      if (isset($parts[1]) && isset($enabled_aliases[$field_alias])) {

        // Stores the base item.
        $item = array(
          'field alias' => $field_alias,
          'value' => $parts[1],
          'pos' => $pos,
        );

        // Stores active items in the global active item array.
        $this->activeItems['filter'][$filter] = $item;
        $this->activeItems['filter'][$filter]['facets'] = array();

        // Stores active items per facet.
        foreach ($enabled_aliases[$field_alias] as $facet_name) {
          $item += $this->queryTypes[$facet_name]
            ->extract($item);
          $this->activeItems['filter'][$filter]['facets'][] = $facet_name;
          $this->activeItems['facet'][$facet_name][$parts[1]] = $item;
        }
      }
    }
  }

  /**
   * Returns the URL Processor.
   *
   * @return FacetapiUrlProcessor
   *   The URL Processor plugin.
   */
  public function getUrlProcessor() {
    return $this->urlProcessor;
  }

  /**
   * Returns all active filters.
   *
   * @return array
   *   An array of active filters.
   */
  public function getAllActiveItems() {
    return $this->activeItems['filter'];
  }

  /**
   * Returns a facet's active items.
   *
   * @param array|string $facet
   *   The facet definition or facet name,
   *
   * @return array
   *   The facet's active items.
   */
  public function getActiveItems(array $facet) {
    return $this->activeItems['facet'][$facet['name']];
  }

  /**
   * Tests whether a facet item is active by passing it's value.
   *
   * @param string $facet_name
   *   The facet name.
   * @param string $value
   *   The facet item's value.
   *
   * @return
   *   Returns 1 if the item is active, 0 if it is inactive.
   */
  public function itemActive($facet_name, $value) {
    return (int) isset($this->activeItems['facet'][$facet_name][$value]);
  }

  /**
   * Returns the id of the adapter plugin.
   *
   * @return string
   *   The machine readable if of the adapter plugin.
   */
  public function getId() {
    return $this->info['adapter'];
  }

  /**
   * Returns the machine readable name of the searcher.
   *
   * @return string
   *   The machine readable name of the searcher.
   */
  public function getSearcher() {
    return $this->info['name'];
  }

  /**
   * Returns the type of content indexed by $this->info['searcher'].
   *
   * @return
   *   The type of content indexed by $this->info['searcher'].
   */
  public function getTypes() {
    return $this->info['types'];
  }

  /**
   * Returns the path to the admin settings for a given realm.
   *
   * @param $realm_name
   *   The name of the realm.
   *
   * @return
   *   The path to the admin settings.
   */
  public function getPath($realm_name) {
    return $this->info['path'] . '/facets/' . $realm_name;
  }

  /**
   * Returns the search path.
   *
   * @return string
   *   A string containing the search path.
   *
   * @todo D8 should provide an API function for this.
   */
  public function getSearchPath() {
    if (NULL === $this->searchPath) {

      // Backwards compatibility with apachesolr <= beta8.
      // @see http://drupal.org/node/1305748#comment-5102352
      foreach (array(
        $this->info['module'],
        $this->info['module'] . '_search',
      ) as $module) {
        if ($path = module_invoke($module, 'search_info')) {
          $this->searchPath = 'search/' . $path['path'];
          if (!isset($_GET['keys']) && ($keys = $this
            ->getSearchKeys())) {
            $this->searchPath .= '/' . $keys;
          }
          break;
        }
      }
    }
    return $this->searchPath;
  }

  /**
   * Sets the search keys.
   *
   * @param string $keys
   *   The search keys entered by the user.
   *
   * @return FacetapiAdapter
   *   An instance of this class.
   */
  public function setSearchKeys($keys) {
    $this->keys = $keys;
    return $this;
  }

  /**
   * Gets the search keys.
   *
   * @return string
   *   The search keys entered by the user.
   */
  public function getSearchKeys() {
    return $this->keys;
  }

  /**
   * Returns the number of results returned by the search query.
   *
   * @return int
   *   An integer containing the number of results.
   */
  public function getResultCount() {
    global $pager_total;
    return isset($pager_total[0]) ? $pager_total[0] : 0;
  }

  /**
   * Returns the number of results per page.
   *
   * @return int
   *   The number of results per page, or the limit.
   */
  public function getPageLimit() {
    global $pager_limits;
    return isset($pager_limits[0]) ? $pager_limits[0] : 10;
  }

  /**
   * Returns the page number of the search result set.
   *
   * @return int
   *   The current page of the result set.
   */
  public function getPageNumber() {
    return (isset($_GET['page']) ? $_GET['page'] : 0) + 1;
  }

  /**
   * Returns the total number of pages in the result set.
   *
   * @return int
   *   The total number of pages.
   */
  public function getPageTotal() {
    global $pager_total;
    return isset($pager_total[0]) ? $pager_total[0] : 0;
  }

  /**
   * Allows for backend specific overrides to the settings form.
   */
  public function settingsForm(&$form_state) {

    // Nothing to do...
  }

  /**
   * Provides default values for the backend specific settings.
   *
   * @return array
   *   The defaults keyed by setting name to value.
   */
  public function getDefaultSettings() {
    return array();
  }

  /**
   * Returns TRUE if the back-end supports "missing" facets.
   *
   * @return bool
   *   TRUE or FALSE.
   */
  public function supportsFacetMissing() {
    return $this->info['supports facet missing'];
  }

  /**
   * Returns TRUE if the back-end supports "minimum facet counts".
   *
   * @return bool
   *   TRUE or FALSE.
   */
  public function supportsFacetMincount() {
    return $this->info['supports facet mincount'];
  }

  /**
   * Adds facet query type plugins to the queue and invokes the execute() hook
   * to allow for the backend to add filters to its native query object.
   *
   * @param mixed $query
   *   The backend's native object.
   */
  function addActiveFilters($query) {
    module_load_include('inc', 'facetapi', 'facetapi.callbacks');
    facetapi_add_active_searcher($this->info['name']);

    // Runs initActiveFilters hook, finds active facets.
    $this
      ->initActiveFilters($query);
    foreach ($this
      ->getEnabledFacets() as $facet) {
      $settings = $this
        ->getFacet($facet)
        ->getSettings();

      // Invoke the dependency plugins.
      $display = TRUE;
      foreach ($facet['dependency plugins'] as $id) {
        $class = ctools_plugin_load_class('facetapi', 'dependencies', $id, 'handler');
        $plugin = new $class($id, $this, $facet, $settings, $this->activeItems['facet']);
        if (NULL !== ($return = $plugin
          ->execute())) {
          $display = $return;
        }
      }

      // Stores whether this facet passed its dependencies.
      $this->dependenciesPassed[$facet['name']] = $display;

      // Add query type plugin if dependencies were met, otherwise remove the
      // facet's active items so they don't display in the current search block
      // or appear as active in the breadcrumb trail.
      if ($display && $this->queryTypes[$facet['name']]) {
        $this->queryTypes[$facet['name']]
          ->execute($query);
      }
      else {
        foreach ($this->activeItems['facet'][$facet['name']] as $item) {
          $this->urlProcessor
            ->removeParam($item['pos']);
          $filter = $item['field alias'] . ':' . $item['value'];
          unset($this->activeItems['filter'][$filter]);
        }
        $this->activeItems['facet'][$facet['name']] = array();
      }
    }
  }

  /**
   * Allows the backend to initialize its query object before adding the facet
   * filters.
   *
   * @param mixed $query
   *   The backend's native object.
   */
  public function initActiveFilters($query) {

    // Nothing to do ...
  }

  /**
   * Initializes a new settings object.
   *
   * @param $name
   *   A string containing the unique name of the configuration.
   * @param array $facet_name
   *   A string containing the machine readable name of the facet.
   * @param $realm_name
   *   A string containing the machine readable name of the realm, NULL if we
   *   are initializing global settings.
   *
   * @return stdClass
   *   An object containing the initialized settings.
   */
  public function initSettingsObject($name, $facet_name, $realm_name = NULL) {
    $cached_settings = facetapi_get_searcher_settings($this->info['name']);
    if (!isset($cached_settings[$name])) {
      $settings = ctools_export_crud_new('facetapi');
      $settings->name = $name;
      $settings->searcher = $this->info['name'];
      $settings->realm = (string) $realm_name;
      $settings->facet = $facet_name;
      $settings->enabled = 0;
      $settings->settings = array();
    }
    else {
      $settings = $cached_settings[$name];
    }
    return $settings;
  }

  /**
   * Returns realm specific settings for a facet.
   *
   * @param array $facet
   *   An array containing the facet definition.
   * @param array $realm
   *   An array containing the realm definition.
   *
   * @return stdClass
   *   An object containing the settings.
   *
   * @see ctools_export_crud_load()
   */
  public function getFacetSettings(array $facet, array $realm) {

    // Builds the unique name of the configuration settings and loads.
    $name = $this->info['name'] . ':' . $realm['name'] . ':' . $facet['name'];
    if (!isset($this->settings[$name])) {
      $this->settings[$name] = $this
        ->initSettingsObject($name, $facet['name'], $realm['name']);
      $is_new = empty($this->settings[$name]->settings);

      // Use realm's default widget if facet doesn't define one.
      if (!empty($facet['default widget'])) {
        $widget = $facet['default widget'];
      }
      else {
        $widget = $realm['default widget'];
      }

      // Apply default settings.
      $this->settings[$name]->settings += array(
        'weight' => 0,
        'widget' => $widget,
        'filters' => array(),
        'active_sorts' => array(),
        'sort_weight' => array(),
        'sort_order' => array(),
        'empty_behavior' => 'none',
      );

      // Apply default sort info if necessary.
      if ($is_new) {
        $weight = -50;
        foreach ($facet['default sorts'] as $sort => $default) {
          $this->settings[$name]->settings['active_sorts'][$default[0]] = $default[0];
          $this->settings[$name]->settings['sort_weight'][$default[0]] = $weight++;
          $this->settings[$name]->settings['sort_order'][$default[0]] = $default[1];
        }
      }

      // Apply the widget plugin's default settings.
      $id = $this->settings[$name]->settings['widget'];
      $class = ctools_plugin_load_class('facetapi', 'widgets', $id, 'handler');

      // If we have an invalid widget, fall back to the realm's default.
      if (!$class) {
        $id = $this->settings[$name]->settings['widget'] = $realm['default widget'];
        $class = ctools_plugin_load_class('facetapi', 'widgets', $id, 'handler');
      }
      $plugin = new $class($id, $realm, $this
        ->getFacet($facet), $this->settings[$name]);
      $this->settings[$name]->settings += $plugin
        ->getDefaultSettings();

      // @todo Save for performance?
    }
    return $this->settings[$name];
  }

  /**
   * Returns realm specific settings for a facet.
   *
   * @param array $facet
   *   An array containing the facet definition.
   *
   * @return
   *   An object containing the settings.
   *
   * @see ctools_export_crud_load()
   */
  public function getFacetSettingsGlobal(array $facet) {
    $name = $this->info['name'] . '::' . $facet['name'];
    if (!isset($this->settings[$name])) {
      $this->settings[$name] = $this
        ->initSettingsObject($name, $facet['name']);
      $is_new = empty($this->settings[$name]->settings);

      // Ensure the default operator and query type are valid.
      // @see http://drupal.org/node/1443340
      $default_query_type = reset($facet['query types']);
      $allowed_operators = array_filter($facet['allowed operators']);
      $default_operator = key($allowed_operators);

      // Apply defaults common across all configs.
      $this->settings[$name]->settings += array(
        'operator' => $default_operator,
        'hard_limit' => 50,
        'dependencies' => array(),
        'facet_mincount' => 1,
        'facet_missing' => 0,
        'flatten' => 0,
        'query_type' => $default_query_type,
      );

      // Apply the adapter's default settings.
      $this->settings[$name]->settings += $this
        ->getDefaultSettings();

      // Applies each dependency plugin's default settings.
      foreach ($facet['dependency plugins'] as $id) {
        if ($is_new) {
          $this->settings[$name]->settings['dependencies'] = array();
        }
        $class = ctools_plugin_load_class('facetapi', 'dependencies', $id, 'handler');
        $plugin = new $class($id, $this, $facet, $this->settings[$name], array());
        $this->settings[$name]->settings['dependencies'] += $plugin
          ->getDefaultSettings();
      }

      // @todo Save for performance?
    }
    return $this->settings[$name];
  }

  /**
   * Returns the enabled facets associated with the instance of the adapter.
   *
   * @param string $realm_name
   *   The machine readable name of the realm, pass NULL to get the enabled
   *   facets in all realms.
   *
   * @return array
   *   An array of enabled facets.
   */
  public function getEnabledFacets($realm_name = NULL) {
    return facetapi_get_enabled_facets($this->info['name'], $realm_name);
  }

  /**
   * Returns a FacetapiFacet instance for the facet being rendered.
   *
   * @param array $facet
   *   The facet definition.
   *
   * @return FacetapiFacet
   *   The facet rendering object object.
   */
  public function getFacet(array $facet) {
    if (!isset($this->facets[$facet['name']])) {
      $this->facets[$facet['name']] = new FacetapiFacet($this, $facet);
    }
    return $this->facets[$facet['name']];
  }

  /**
   * Returns a registered facet query
   *
   * @param array|string $facet
   *   The facet definition or facet name.
   *
   * @return FacetapiQueryTypeInterface
   *   The instantiated query type plugin.
   */
  public function getFacetQuery($facet) {
    $facet_name = is_array($facet) ? $facet['name'] : $facet;
    if (isset($this->queryTypes[$facet_name])) {
      return $this->queryTypes[$facet_name];
    }
  }

  /**
   * Returns the human readable value associated with a facet's raw value.
   *
   * @param string $facet_name
   *   The machine readable name of the facet.
   * @param string $value
   *   The raw value passed through the query string.
   *
   * @return string
   *   The mapped value.
   */
  public function getMappedValue($facet_name, $value) {
    if (isset($this->processors[$facet_name])) {
      return $this->processors[$facet_name]
        ->getMappedValue($value);
    }
    else {
      return array(
        '#value' => $value,
      );
    }
  }

  /**
   * Returns the processor associates with the facet.
   *
   * @param string $facet_name
   *   The machine readable name of the facet.
   *
   * @return FacetapiFacetProcessor
   */
  public function getProcessor($facet_name) {
    if (isset($this->processors[$facet_name])) {
      return $this->processors[$facet_name];
    }
    else {
      return FALSE;
    }
  }

  /**
   * Helper function that returns the query string variables for a facet item.
   *
   * @param array $facet
   *   The facet definition.
   * @param array $values
   *   An array containing the item's values being added to or removed from the
   *   query string dependent on whether or not the item is active.
   * @param int $active
   *   An integer flagging whether the item is active or not.
   *
   * @return array
   *   The query string vriables.
   */
  public function getQueryString(array $facet, array $values, $active) {
    return $this->urlProcessor
      ->getQueryString($facet, $values, $active);
  }

  /**
   * Helper function that returns the facet path for a facet item.
   *
   * @param array $facet
   *   The facet definition.
   * @param array $values
   *   An array containing the item's values being added to or removed from the
   *   query string dependent on whether or not the item is active.
   * @param int $active
   *   An integer flagging whether the item is active or not.
   *
   * @return string
   *   The facet path.
   */
  public function getFacetPath(array $facet, array $values, $active) {
    return $this->urlProcessor
      ->getFacetPath($facet, $values, $active);
  }

  /**
   * Initializes facet builds, adds breadcrumb trail.
   */
  public function processFacets() {
    if (!$this->processed) {
      $this->processed = TRUE;

      // Initializes each facet's render array.
      foreach ($this
        ->getEnabledFacets() as $facet) {
        $processor = new FacetapiFacetProcessor($this
          ->getFacet($facet));
        $this->processors[$facet['name']] = $processor;
        $this->processors[$facet['name']]
          ->process();
      }

      // Sets the breadcrumb trail if a search was executed.
      if ($this
        ->searchExecuted()) {
        $this->urlProcessor
          ->setBreadcrumb();
      }
    }
  }

  /**
   * Builds the render array for facets in a realm.
   *
   * @param string $realm_name
   *   The machine readable name of the realm.
   *
   * @return array
   *   The render array.
   */
  public function buildRealm($realm_name) {

    // Bails if realm isn't valid.
    // @todo Call watchdog()?
    if (!($realm = facetapi_realm_load($realm_name))) {
      return array();
    }

    // Makes sure facet builds are initialized.
    $this
      ->processFacets();

    // Adds JavaScript, initializes render array.
    drupal_add_js(drupal_get_path('module', 'facetapi') . '/facetapi.js');
    $build = array(
      '#adapter' => $this,
      '#realm' => $realm,
    );

    // Builds each facet in the realm, merges into realm's render array.
    foreach ($this
      ->getEnabledFacets($realm['name']) as $facet) {

      // Continue to the next facet if this one failed its dependencies.
      if (!$this->dependenciesPassed[$facet['name']]) {
        continue;
      }

      // Gets the initialized build.
      $field_alias = $facet['field alias'];
      $processor = $this->processors[$facet['name']];
      $facet_build = $this
        ->getFacet($facet)
        ->build($realm, $processor);

      // Tries to be smart when merging the render arrays. Crazy things happen
      // when merging facets with the same field alias such as taxonomy terms in
      // the fieldset realm. We want to merge only the values.
      foreach (element_children($facet_build) as $child) {

        // Bails if there is nothing to render.
        if (!element_children($facet_build[$child])) {
          continue;
        }

        // Attempts to merge gracefully.
        if (!isset($build[$child])) {
          $build = array_merge_recursive($build, $facet_build);
        }
        else {
          if (isset($build[$child][$field_alias]) && isset($facet_build[$child][$field_alias])) {
            $build[$child][$field_alias] = array_merge_recursive($build[$child][$field_alias], $facet_build[$child][$field_alias]);
          }
          elseif (isset($build[$child]['#options']) && isset($facet_build[$child]['#options'])) {
            $build[$child]['#options'] = array_merge_recursive($build[$child]['#options'], $facet_build[$child]['#options']);
          }
          else {
            $build = array_merge_recursive($build, $facet_build);
          }
        }
      }
    }
    return $build;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FacetapiAdapter::$activeItems protected property An array of active filters.
FacetapiAdapter::$dependenciesPassed protected property Stores whether each facet passed dependencies.
FacetapiAdapter::$facets protected property An array of FacetapiFacet objects.
FacetapiAdapter::$info protected property Searcher information retrieved by the hook.
FacetapiAdapter::$keys protected property The search keys passed by the user.
FacetapiAdapter::$processed protected property A boolean flagging whether the facets have been processed.
FacetapiAdapter::$processors protected property An array of FacetapiFacetProcessor objects.
FacetapiAdapter::$queryTypes protected property An array of executed query type plugins keyed by field name.
FacetapiAdapter::$searchPath protected property Stores the search path so we only need to calculate it once.
FacetapiAdapter::$settings protected property Stores settings with defaults.
FacetapiAdapter::$urlProcessor protected property The URL processor associated with this adapter.
FacetapiAdapter::addActiveFilters function Adds facet query type plugins to the queue and invokes the execute() hook to allow for the backend to add filters to its native query object.
FacetapiAdapter::buildRealm public function Builds the render array for facets in a realm.
FacetapiAdapter::getActiveItems public function Returns a facet's active items.
FacetapiAdapter::getAllActiveItems public function Returns all active filters.
FacetapiAdapter::getDefaultSettings public function Provides default values for the backend specific settings.
FacetapiAdapter::getEnabledFacets public function Returns the enabled facets associated with the instance of the adapter.
FacetapiAdapter::getFacet public function Returns a FacetapiFacet instance for the facet being rendered.
FacetapiAdapter::getFacetPath public function Helper function that returns the facet path for a facet item.
FacetapiAdapter::getFacetQuery public function Returns a registered facet query
FacetapiAdapter::getFacetSettings public function Returns realm specific settings for a facet.
FacetapiAdapter::getFacetSettingsGlobal public function Returns realm specific settings for a facet.
FacetapiAdapter::getId public function Returns the id of the adapter plugin.
FacetapiAdapter::getMappedValue public function Returns the human readable value associated with a facet's raw value.
FacetapiAdapter::getPageLimit public function Returns the number of results per page.
FacetapiAdapter::getPageNumber public function Returns the page number of the search result set.
FacetapiAdapter::getPageTotal public function Returns the total number of pages in the result set.
FacetapiAdapter::getPath public function Returns the path to the admin settings for a given realm.
FacetapiAdapter::getProcessor public function Returns the processor associates with the facet.
FacetapiAdapter::getQueryString public function Helper function that returns the query string variables for a facet item.
FacetapiAdapter::getResultCount public function Returns the number of results returned by the search query. 1
FacetapiAdapter::getSearcher public function Returns the machine readable name of the searcher.
FacetapiAdapter::getSearchKeys public function Gets the search keys.
FacetapiAdapter::getSearchPath public function Returns the search path.
FacetapiAdapter::getTypes public function Returns the type of content indexed by $this->info['searcher'].
FacetapiAdapter::getUrlProcessor public function Returns the URL Processor.
FacetapiAdapter::initActiveFilters public function Allows the backend to initialize its query object before adding the facet filters.
FacetapiAdapter::initSettingsObject public function Initializes a new settings object.
FacetapiAdapter::itemActive public function Tests whether a facet item is active by passing it's value.
FacetapiAdapter::processActiveItems public function Processes active items.
FacetapiAdapter::processFacets public function Initializes facet builds, adds breadcrumb trail.
FacetapiAdapter::searchExecuted abstract public function Returns a boolean flagging whether $this->info['searcher'] executed a search. 1
FacetapiAdapter::setParams public function Processes a raw array of active filters.
FacetapiAdapter::setSearchKeys public function Sets the search keys.
FacetapiAdapter::settingsForm public function Allows for backend specific overrides to the settings form.
FacetapiAdapter::supportsFacetMincount public function Returns TRUE if the back-end supports "minimum facet counts".
FacetapiAdapter::supportsFacetMissing public function Returns TRUE if the back-end supports "missing" facets.
FacetapiAdapter::suppressOutput abstract public function Returns a boolean flagging whether facets in a realm shoud be displayed. 1
FacetapiAdapter::__construct public function Constructor, sets searcher and type of content being indexed.