You are here

function _lexicon_get_synonyms in Lexicon 7

Same name and namespace in other branches
  1. 6 lexicon.module \_lexicon_get_synonyms()

Get all synonyms for all lexicon terms in a specific vocabulary.

File

./lexicon.module, line 1219
The Lexicon module is used to create lists of terms and definitions to use on a website and optionally mark those terms in the content of the website.

Code

function _lexicon_get_synonyms($vid) {
  $synonyms = array();
  if (module_exists('i18n_taxonomy')) {
    global $language;
    $tree = i18n_taxonomy_get_tree($vid, $language->language, 0, NULL, TRUE);
  }
  else {
    $tax_tree = taxonomy_get_tree($vid, 0, NULL, TRUE);
  }
  $synonyms_field = variable_get('lexicon_synonyms_field_' . $vid, '');
  if ($synonyms_field != '') {
    foreach ($tax_tree as $term) {
      $synonyms_field_items = field_get_items('taxonomy_term', $term, $synonyms_field);
      if (!empty($synonyms_field_items)) {
        foreach ($synonyms_field_items as $item) {
          $synonyms[$term->tid][] = $item['safe_value'];
        }
      }
    }
  }
  return $synonyms;
}