You are here

function theme_lexicon_block_term in Lexicon 6

1 theme call to theme_lexicon_block_term()
lexicon_block in ./lexicon.module
Implementation of hook_block().

File

./lexicon.module, line 999
Lexicon is used to create lists of terms and definitions to use on a website and optionally mark them in the content with an indicator.

Code

function theme_lexicon_block_term($vid, $term, $link = TRUE) {
  $path = variable_get('lexicon_path_' . $vid, 'lexicon/' . $vid);
  global $base_url;
  static $click_option, $link_related, $one_way, $tax_img_avail;
  if (!isset($click_option)) {
    $click_option = variable_get('lexicon_click_option', 0);
    $link_related = variable_get('lexicon_link_related', TRUE);
    $one_way = variable_get('lexicon_link_related_how', FALSE);
    $tax_img_avail = module_exists('taxonomy_image');
  }
  if ($tax_img_avail) {
    $img = taxonomy_image_display($term->tid);
    if ($img) {
      $obj = taxonomy_image_get_object($term->tid);
      $img = '<a href="' . $obj->url . '">' . $img . '</a>';
    }
  }
  else {
    $img = NULL;
  }
  $output .= '<div class="lexicon-block-term-name">';
  if ($link) {
    if (variable_get('lexicon_page_per_letter', FALSE)) {
      $output .= l($term->name, $path . '/letter_' . drupal_strtolower(drupal_substr($term->name, 0, 1)), array(
        'fragment' => _lexicon_create_valid_id($term->name),
      ));
    }
    else {
      $output .= l($term->name, $path, array(
        'fragment' => _lexicon_create_valid_id($term->name),
      ));
    }
  }
  else {
    $output .= check_plain($term->name);
  }
  $output .= "</div>\n";
  $output .= '<div class="lexicon-block-term-description">';
  $output .= $term->description ? check_markup($term->description) : NULL;
  $output .= "</div>\n";
  if ($relations = lexicon_get_related($term->tid, 'name', $one_way)) {
    $output .= '<span class="lexicon-related">' . t('See also') . ': ';
    $items = array();
    foreach ($relations as $related) {
      if ($link_related) {
        if ($click_option == 1) {
          $items[] .= l($related->name, $path . '/' . $term->vid, array(
            'fragment' => 'term' . $related->tid,
          ));
        }
        else {
          $items[] .= l($related->name, $path . '/term/' . $related->tid);
        }
      }
      else {
        $items[] .= check_plain($related->name);
      }
    }
    $output .= implode(', ', $items) . "</span>\n";
  }
  if ($term->synonyms) {
    $output .= '<span class="lexicon-synonyms"><strong>' . t('Synonyms') . '</strong>: ';
    $output .= implode(', ', $term->synonyms) . "</span>\n";
  }
  return decode_entities($output);
}