You are here

public function CurrentSearchItemText::execute in Facet API 7

Same name and namespace in other branches
  1. 6.3 contrib/current_search/plugins/current_search/item_text.inc \CurrentSearchItemText::execute()
  2. 7.2 contrib/current_search/plugins/current_search/item_text.inc \CurrentSearchItemText::execute()

Implements CurrentSearchItem::execute().

Overrides CurrentSearchItem::execute

File

contrib/current_search/plugins/current_search/item_text.inc, line 21
The text current search item plugin class.

Class

CurrentSearchItemText
Current search item plugin that displays text configured by the user.

Code

public function execute(FacetapiAdapter $adapter) {
  $data = array(
    'facetapi_results' => array(
      'facetapi_adapter' => $adapter,
    ),
  );

  // Determines plurality of string.
  if ($this->settings['plural']) {
    $condition = '[' . $this->settings['plural_condition'] . ']';
    $count = (int) token_replace($condition, $data);
    if ($count != 1) {
      $raw_text = $this->settings['text_plural'];
      $translation_key = 'text_plural';
    }
    else {
      $raw_text = $this->settings['text'];
      $translation_key = 'text';
    }
  }
  else {
    $raw_text = $this->settings['text'];
    $translation_key = 'text';
  }

  // Translates text, returns themed output.
  $translated_text = $this
    ->translate($translation_key, $raw_text);
  $variables = array(
    'text' => filter_xss_admin(token_replace($translated_text, $data)),
    'wrapper' => $this->settings['wrapper'],
    'element' => $this->settings['element'],
    'css' => $this->settings['css'],
    'class' => current_search_get_classes($this->settings['classes'], $data),
    'options' => array(
      'html' => TRUE,
    ),
  );
  return array(
    '#markup' => theme('current_search_text', $variables),
  );
}