You are here

function theme_glossary_block_term in Glossary 7

Same name and namespace in other branches
  1. 5.2 glossary.module \theme_glossary_block_term()
  2. 6 glossary.module \theme_glossary_block_term()

@todo Please document this function.

See also

http://drupal.org/node/1354

1 theme call to theme_glossary_block_term()
glossary_block_view in ./glossary.module
Implements hook_block_view().

File

./glossary.module, line 974
Glossary terms will be automatically marked with links to their descriptions.

Code

function theme_glossary_block_term($variables) {
  $term = $variables['0'];
  $link = $variables['1'];
  global $base_url;
  static $click_option, $link_related, $one_way, $tax_img_avail;
  $output = '';
  if (!isset($click_option)) {
    $click_option = variable_get('glossary_click_option', 0);
    $link_related = variable_get('glossary_link_related', TRUE);
    $one_way = variable_get('glossary_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="glossary-block-term-name">';
  $output .= $link ? l($term->name, 'glossary/term/' . $term->tid) : check_plain($term->name);
  $output .= "</div>\n";
  $output .= '<div class="glossary-block-term-description">';
  $output .= $term->description ? check_markup($term->description) : NULL;
  $output .= "</div>\n";
  if ($relations = glossary_get_related($term->tid, 'name', $one_way)) {
    $output .= '<span class="glossary-related">' . t('See also') . ': ';
    $items = array();
    foreach ($relations as $related) {
      if ($link_related) {
        if ($click_option == 1) {
          $items[] .= l($related->name, 'glossary/' . $term->vid, array(
            'fragment' => 'term' . $related->tid,
          ));
        }
        else {
          $items[] .= l($related->name, 'glossary/term/' . $related->tid);
        }
      }
      else {
        $items[] .= check_plain($related->name);
      }
    }
    $output .= implode(', ', $items) . "</span>\n";
  }
  return $output;
}