You are here

function _lexicon_list in Lexicon 6

1 call to _lexicon_list()
lexicon_page in ./lexicon.module

File

./lexicon.module, line 1096
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_list() {
  $output = "";
  $destination = drupal_get_destination();
  $vids = variable_get('lexicon_vids', array());
  $vocs = array();
  foreach ($vids as $vid) {
    $voc = taxonomy_vocabulary_load($vid);
    $vocs[$voc->name] = $voc;
  }
  uksort($vocs, _lexicon_cmp_strcase);
  $eo = array(
    'even',
    'odd',
  );
  $i = 0;
  $output .= '<table><tr><th>' . t("Lexicon name") . '</th><th>' . t('Operations') . '</th></tr>';
  foreach ($vocs as $voc) {
    $links = array();
    $class = $eo[++$i & 1];
    if (user_access('administer taxonomy')) {
      $links['lexicon_edit'] = array(
        'title' => t('Edit @name', array(
          '@name' => drupal_strto($vocabulary->name),
        )),
        'href' => 'admin/content/taxonomy/edit/vocabulary/' . $voc->vid,
        'query' => $destination,
      );
    }
    $links['lexicon_view'] = array(
      'title' => t('List'),
      //'href' => 'lexicon/'. $voc->vid,
      'href' => variable_get('lexicon_path_' . $voc->vid, 'lexicon/' . $voc->vid),
    );
    if ($voc->description) {
      $output .= '<tr class="' . $class . ' merge-down"><th>' . $voc->name . '</th><td>' . theme('links', $links) . '</td></tr>';
      $output .= '<tr class="' . $class . ' merge-up"><td colspan="2" class="lexicon-list-description">' . $voc->description . '</td></tr>';
    }
    else {
      $output .= '<tr class="' . $class . '">';
      $output .= '<th>' . $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;
}