You are here

function _lexicon_alphabar in Lexicon 6

Same name and namespace in other branches
  1. 7 includes/lexicon.pages.inc \_lexicon_alphabar()
2 calls to _lexicon_alphabar()
lexicon_overview in ./lexicon.module
lexicon_term in ./lexicon.module

File

./lexicon.module, line 781
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_alphabar($vid, &$tree) {
  $path = variable_get('lexicon_path_' . $vid, 'lexicon/' . $vid);
  $page_per_letter = variable_get('lexicon_page_per_letter', FALSE);
  if (variable_get('lexicon_suppress_unused', FALSE)) {

    // Just make it empty; it will be filled in below.
    $letters = array();
  }
  else {
    $lets = array_merge(variable_get('lexicon_alphabet', range('a', 'z')), variable_get('lexicon_digits', range('0', '9')));
    $letters = drupal_map_assoc($lets);
  }
  foreach ($tree as $key => $term) {
    $term->let = drupal_strtolower(drupal_substr($term->name, 0, 1));
    if ($page_per_letter) {
      $letters[$term->let] = l($term->let, $path . '/letter_' . $term->let, array(
        'attributes' => array(
          'class' => 'lexicon-item',
        ),
      ));
    }
    else {
      $letters[$term->let] = l($term->let, $path, array(
        'fragment' => 'letter_' . $term->let,
        'attributes' => array(
          'class' => 'lexicon-item',
        ),
      ));
    }
  }
  $sep = ' ' . variable_get('lexicon_alphabar_separator', '|') . ' ';
  $output = '<div class="lexicon-links">' . implode($sep, $letters);
  $output .= '<div class="lexicon-alphabar-instructions">';
  $output .= variable_get('lexicon_alphabar_instruction', _alphabar_instruction_default());
  $output .= "</div></div>\n";
  return $output;
}