You are here

function _glossify_taxonomy_process in Glossify 7.4

Taxonomy filter process callback for the glossify filter.

1 string reference to '_glossify_taxonomy_process'
glossify_filter_info in ./glossify.module
Implements hook_filter_info().

File

./glossify.module, line 199
Glossify module.

Code

function _glossify_taxonomy_process($text, $filter, $format, $langcode, $cache, $cache_id) {

  //get vocabularies
  $vocabs = array_filter($filter->settings['glossify_taxonomy_vocabs']);
  if (!$vocabs) {
    return $text;
  }

  //get terms
  $result = db_query("SELECT tid AS id, name, LOWER(name) AS name_norm, description AS tip, format FROM {taxonomy_term_data} WHERE vid IN (:vids) ORDER by CHAR_LENGTH(name) DESC", array(
    ':vids' => $vocabs,
  ));
  $terms = $result
    ->fetchAllAssoc('name_norm');

  //process text
  if (count($terms) > 0) {
    return _glossify_to_links($text, $terms, 'taxonomy', $filter->settings['glossify_taxonomy_case_sensitivity'], $filter->settings['glossify_taxonomy_first_only'], $filter->settings['glossify_taxonomy_tooltips']);
  }
  else {
    return $text;
  }
}