1 taxonomy.admin.inc taxonomy_overview_vocabularies()

Page callback at admin/structure/taxonomy to list all available vocabularies.

File

core/modules/taxonomy/taxonomy.admin.inc, line 10
Admin page callbacks for the Taxonomy module.

Code

function taxonomy_overview_vocabularies() {
  $vocabularies = taxonomy_vocabulary_load_multiple(FALSE);

  $header = array(
    array('data' => t('Vocabulary name'), 'class' => array('vocabulary-name')),
    array('data' => t('Description'), 'class' => array('vocabulary-description', 'priority-low')),
    array('data' => t('Number of terms'), 'class' => array('vocabulary-term-count', 'priority-medium')),
    array('data' => t('Operations'), 'class' => array('vocabulary-operations')),
  );

  $rows = array();

  foreach ($vocabularies as $vocabulary) {
    $term_count = db_query("SELECT count(tid) FROM {taxonomy_term_data} WHERE vocabulary = :vocab", array(':vocab' => $vocabulary->machine_name))->fetchField();
    if (taxonomy_vocabulary_access(FALSE, $vocabulary)) {
      $row = array();
      $row[] = array(
        'data' => theme('label_machine_name__vocabulary', array(
          'label' => $vocabulary->name,
          'machine_name' => $vocabulary->machine_name,
        )),
        'class' => array('vocabulary-name'),
        'data-label' => t('Vocabulary name'),
      );
      $row[] = array(
        'data' => theme('taxonomy_vocabulary_description', array('vocabulary' => $vocabulary)),
        'class' => array('vocabulary-description'),
        'data-label' => t('Description'),
      );
      $row[] = array(
        'data' => $term_count,
        'class' => array('vocabulary-term-count'),
        'data-label' => t('Number of terms'),
      );
      $row[] = array(
        'data' => array(
          '#type' => 'operations',
          '#links' => _vocabulary_get_operations($vocabulary),
        ),
        'class' => array('vocabulary-operations'),
        'data-label' => t('Operations'),
      );

      $rows[] = $row;
    }
  }

  backdrop_add_css(backdrop_get_path('module', 'taxonomy') . '/css/taxonomy.css');

  $table = array(
    'header' => $header,
    'rows' => $rows,
    'empty' => t('No vocabularies available. <a href="@link">Add vocabulary</a>.', array('@link' => url('admin/structure/taxonomy/add'))),
    'attributes' => array(
      'id' => 'vocabulary-list',
      'class' => array('vocabulary-list'),
    ),
  );

  return theme('table', $table);
}