function theme_glossary_overview_item in Glossary 5.2
Same name and namespace in other branches
- 5 glossary.module \theme_glossary_overview_item()
- 6 glossary.module \theme_glossary_overview_item()
- 7 glossary.module \theme_glossary_overview_item()
3 theme calls to theme_glossary_overview_item()
File
- ./
glossary.module, line 868 - Glossary terms will be automatically marked with links to their descriptions.
Code
function theme_glossary_overview_item($term, $show_desc = TRUE, $destination = NULL) {
global $base_url;
static $click_option, $link_related, $one_way, $show_detailed, $tax_img_avail, $access_tax, $access_search, $show_edit, $show_search, $format;
if (!isset($click_option)) {
$click_option = variable_get('glossary_click_option', 0);
$link_related = variable_get('glossary_link_related', TRUE);
$show_detailed = variable_get('glossary_show_detailed', FALSE);
$show_edit = variable_get('glossary_show_edit', TRUE);
$show_search = variable_get('glossary_show_search', TRUE);
$one_way = variable_get('glossary_link_related_how', FALSE);
$tax_img_avail = module_exists('taxonomy_image');
$access_tax = user_access('administer taxonomy');
$access_search = user_access('search content');
$format = variable_get('glossary_default_filter', FILTER_FORMAT_DEFAULT);
}
if ($tax_img_avail && $show_desc) {
// Use of the wrapper is against the XHTML standards.
$img = taxonomy_image_display($term->tid, NULL, NULL, array(
'wrapper' => FALSE,
));
if ($img) {
$obj = taxonomy_image_get_object($term->tid);
$img = '<a href="' . $obj->url . '">' . $img . '</a>';
}
}
else {
$img = NULL;
}
$output .= '<dt class="depth' . $term->depth . '">' . $img;
$output .= '<a id="term' . $term->tid . '"></a>';
if ($show_desc) {
$output .= str_repeat('--', $term->depth) . check_plain($term->name);
}
else {
$output .= l($term->name, 'glossary/term/' . $term->tid);
}
if ($show_edit && $access_tax) {
$output .= ' ' . l(t('edit term'), 'admin/content/taxonomy/edit/term/' . $term->tid, array(
'title' => t('Edit this term and definition'),
'class' => 'glossary-edit-term',
), $destination);
}
if ($show_search && $access_search) {
$output .= l(t('search for term'), 'search/node/"' . $term->name . '"', array(
'title' => t('Search for content using this term'),
'class' => 'glossary-search-term',
));
}
$output .= '</dt><dd class="depth' . $term->depth . '">';
if ($show_desc) {
if ($term->description) {
$output .= htmlspecialchars(check_markup($term->description, $format));
}
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(), NULL, 'term' . $related->tid);
}
else {
$items[] .= l($related->name, 'glossary/term/' . $related->tid);
}
}
else {
$items[] .= check_plain($related->name);
}
}
$output .= implode(', ', $items) . "</span>\n";
}
if ($term->synonyms) {
$output .= '<span class="glossary-synonyms"><strong>' . t('Synonyms') . '</strong>: ';
$output .= implode(', ', $term->synonyms) . "</span>\n";
}
$output .= "</dd>\n";
$detailed_exists = db_result(db_query(db_rewrite_sql('SELECT COUNT(t.nid) FROM {term_node} t JOIN {node} n USING (nid) WHERE t.tid=%d AND n.status=1'), $term->tid));
if ($detailed_exists) {
// Do we want to show the teasers?
if ($show_detailed) {
// If we just throw the teasers out, we won't validate XHTML strict.
$output .= '</dl>';
$output .= '<div class="glossary-detailed">';
$text = NULL;
$detailed = db_query(db_rewrite_sql('SELECT t.nid FROM {term_node} t JOIN {node} n USING (nid) WHERE t.tid=%d AND n.status=1'), $term->tid);
while ($row = db_fetch_array($detailed)) {
$node = node_load($row['nid']);
// Format as teaser view with links.
$text .= node_view($node, TRUE, FALSE, TRUE);
}
if ($text) {
$fieldset = array(
'#title' => t('Detailed definition of @term', array(
'@term' => $term->name,
)),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#value' => $text,
);
$output .= theme('fieldset', $fieldset);
}
$output .= "</div><dl>\n";
}
else {
$output .= '<div class="glossary-detailed-link">' . l(t('Detailed definition of @term', array(
'@term' => $term->name,
)), taxonomy_term_path($term)) . '</div>';
}
}
}
return decode_entities($output);
}