You are here

function _glossary_list in Glossary 6

Same name and namespace in other branches
  1. 5.2 glossary.module \_glossary_list()
  2. 5 glossary.module \_glossary_list()
  3. 7 glossary.module \_glossary_list()
1 call to _glossary_list()
glossary_page in ./glossary.module

File

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

Code

function _glossary_list() {
  $output = "";
  $destination = drupal_get_destination();
  $vids = _glossary_get_filter_vids();
  $vocs = array();
  foreach ($vids as $vid) {
    $voc = taxonomy_vocabulary_load($vid);
    $vocs[$voc->name] = $voc;
  }
  uksort($vocs, _glossary_cmp_strcase);
  $eo = array(
    'even',
    'odd',
  );
  $i = 0;
  $output .= '<table><tr><th>' . t("Glossary name") . '</th><th>' . t('Operations') . '</th></tr>';
  foreach ($vocs as $voc) {
    $links = array();
    $class = $eo[++$i & 1];
    if (user_access('administer taxonomy')) {
      $links['glossary_edit'] = array(
        'title' => t('Edit'),
        'href' => 'admin/content/taxonomy/edit/vocabulary/' . $voc->vid,
        'query' => $destination,
      );
    }
    $links['glossary_view'] = array(
      'title' => t('List'),
      'href' => 'glossary/' . $voc->vid,
    );
    if ($voc->description) {
      $output .= '<tr class="' . $class . ' merge-down"><th>' . filter_xss($voc->name) . '</th><td>' . theme('links', $links) . '</td></tr>';
      $output .= '<tr class="' . $class . ' merge-up"><td colspan="2" class="glossary-list-description">' . filter_xss($voc->description) . '</td></tr>';
    }
    else {
      $output .= '<tr class="' . $class . '">';
      $output .= '<th>' . filter_xss($voc->name) . '</th><td>' . theme('links', $links) . '</td></tr>';
    }
  }

  // Were there any rows produced?
  if ($i == 0) {
    $output .= '<tr><td colspan="5">' . t('No applicable vocabularies were found, please check your settings.') . '</td></tr>';
  }
  $output .= '</table>';
  return $output;
}