function lexicon_overview in Lexicon 6
1 call to lexicon_overview()
File
- ./
lexicon.module, line 813 - 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 lexicon_overview($vocab, $letter = NULL) {
$dest = drupal_get_destination();
$module_path = drupal_get_path('module', 'lexicon');
drupal_add_js($module_path . '/js/jquery.scrollTo-min.js');
drupal_add_js($module_path . '/js/jquery.localscroll-min.js');
if (variable_get('lexicon_local_links_scroll', 0) == 1) {
drupal_add_js($module_path . '/js/lexicon.js');
}
$output = '<div id="' . drupal_strtolower(_lexicon_create_valid_id($vocab->name)) . '">';
if ($vocab->description) {
$output .= '<p class="lexicon-description">' . filter_xss_admin($vocab->description) . '</p>';
}
$vid = $vocab->vid;
$path = variable_get('lexicon_path_' . $vid, 'lexicon/' . $vid);
if ($letter) {
drupal_set_title(t('!title beginning with !let', array(
'!title' => check_plain(variable_get('lexicon_title_' . $vid, 'lexicon/' . $vid)),
'!let' => drupal_strtoupper($letter),
)));
}
$current_let = '';
$no_overview = variable_get('lexicon_click_option', 0) == 0 && variable_get('lexicon_page_per_letter', FALSE) == TRUE;
$show_desc = variable_get('lexicon_show_description', FALSE);
$separate = variable_get('lexicon_separate_letters', FALSE);
$tree = taxonomy_get_tree($vid);
$synonyms = _lexicon_get_synonyms($vid);
$output .= _lexicon_alphabar($vid, $tree);
$output .= '<div class="lexicon-list">' . "\n";
if ($tree) {
$notfirst = FALSE;
foreach ($tree as $term) {
$term->synonyms = $synonyms[$term->tid];
// If we're looking for a single letter, see if this is it.
if (!$no_overview && !$letter || $term->let == $letter) {
// See if it's a new section.
if ($term->let != $current_let) {
//If this is not the first new section and we are not viewing a single letter then close the previous <dl>
if ($notfirst == TRUE && $letter == NULL) {
$output .= '</dl>';
if ($separate && variable_get('lexicon_go_to_top_link', FALSE) == TRUE) {
$output .= '<p><a href="#' . variable_get('lexicon_go_to_top_link_fragment', 'top') . '" title="' . t('Go to top') . '" class="lexicon_to_top_link">' . t('Go to top') . '</a></p>';
}
}
$output .= "\n" . '<a id="letter_' . $term->let . '"></a>';
if ($separate) {
$output .= '<h2 class="lexicon-letter">' . drupal_strtoupper($term->let) . '</h2>';
}
$output .= '<dl>';
$current_let = $term->let;
}
$output .= theme('lexicon_overview_item', $vid, $term, $show_desc, $dest);
}
$notfirst = TRUE;
}
//Close the last <dl>
$output .= '</dl>';
if ($separate && variable_get('lexicon_go_to_top_link', FALSE) == TRUE) {
$output .= '<p><a href="#' . variable_get('lexicon_go_to_top_link_fragment', 'top') . '" title="' . t('Go to top') . '" class="lexicon_to_top_link">' . t('Go to top') . '</a></p>';
}
}
$output .= '</div></div>';
return lexicon_admin_links($vocab, $dest) . $output;
}