function theme_glossary_overview_item in Glossary 7
Same name and namespace in other branches
- 5.2 glossary.module \theme_glossary_overview_item()
- 5 glossary.module \theme_glossary_overview_item()
- 6 glossary.module \theme_glossary_overview_item()
Theme a glossary overview item.
3 theme calls to theme_glossary_overview_item()
- glossary_overview in ./
glossary.module - Produce the Glossary overview.
- glossary_search_results in ./
glossary.module - Present the search results.
- glossary_term in ./
glossary.module - @todo Please document this function.
File
- ./
glossary.module, line 829 - Glossary terms will be automatically marked with links to their descriptions.
Code
function theme_glossary_overview_item($variables) {
$output = NULL;
$term = $variables['term'];
$show_desc = $variables['show_desc'];
$destination = isset($variables['dest']) ? $variables['dest'] : '';
global $base_url;
static $click_option, $link_related, $show_detailed, $one_way, $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_default_format());
}
if ($tax_img_avail && $show_desc) {
$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;
}
if (!isset($term->depth)) {
$term->depth = 0;
}
$output .= '<dt class="depth' . $term->depth . '">' . $img;
$output .= '<a id="term' . $term->tid . '"></a>';
if ($show_desc) {
$output .= str_repeat("—", $term->depth) . filter_xss_admin($term->name);
}
else {
$output .= l($term->name, 'glossary/term/' . $term->tid) . ' ';
}
if ($show_edit && $access_tax) {
$output .= ' ' . l(t('edit term'), "taxonomy/term/{$term->tid}/edit", array(
'attributes' => array(
'class' => 'glossary-edit-term',
'title' => t('edit this term and definition'),
),
'query' => $destination,
));
}
if ($show_search && $access_search) {
$output .= l(t('search for term'), 'search/node/"' . $term->name . '"', array(
'attributes' => array(
'class' => 'glossary-search-term',
'title' => t('search for content using this term'),
),
));
}
$output .= '</dt><dd class="depth' . $term->depth . '">';
if ($show_desc) {
if ($term->description) {
$output .= '<span class="glossary-term-description">' . check_markup($term->description, $format) . '</span>';
}
/*
if ($relations = glossary_get_related($term->tid, 'name', $one_way)) {
$output .= '<span class="glossary-related">' . t('See also') . ': ';
foreach ($relations as $related) {
$related->name = filter_xss($related->name);
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";
unset($items);
}
*/
// TODO Please convert this statement to the D7 database API syntax.
$detailed_exists = FALSE;
// $detailed_exists = db_query(db_rewrite_sql('SELECT COUNT(t.nid)
// FROM {taxonomy_term_node} t
// JOIN {node} n USING (nid)
// WHERE t.tid=%d AND n.status=1'), $term->tid)->fetchField();
if ($detailed_exists) {
// Do we want to show the teasers?
if ($show_detailed) {
$output .= '<div class="glossary-detailed">';
$text = NULL;
// TODO Please convert this statement to the D7 database API syntax.
/* There is not taxo_term_node any more. */
// $detailed = db_query(db_rewrite_sql('SELECT t.nid FROM
// {taxonomy_term_node} t JOIN {node} n USING (nid) WHERE t.tid=%d AND
// n.status=1'), $term->tid);
$detailed = db_query('taxonomy_index', 'ti')
->innerJoin('node', 'n', 'n.nid = ti.nid');
$detailed
->condition('t.tid', $term->tid)
->condition('n.status', 1)
->addTag('node_access')
->addTag('term_access')
->execute();
foreach ($detailed as $row) {
$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>\n";
}
else {
$uri = taxonomy_term_uri($term);
$output .= '<div class="glossary-detailed-link">' . l(t('Detailed definition of @term', array(
'@term' => $term->name,
)), $uri['path']) . '</div>';
}
}
}
return $output;
}