1 taxonomy.admin.inc taxonomy_overview_vocabularies($form)

Form builder to list and manage vocabularies.

See also

taxonomy_overview_vocabularies_submit()

theme_taxonomy_overview_vocabularies()

Related topics

File

core/modules/taxonomy/taxonomy.admin.inc, line 14
Administrative page callbacks for the taxonomy module.

Code

function taxonomy_overview_vocabularies($form) {
  $vocabularies = taxonomy_vocabulary_load_multiple(FALSE);
  $form['#tree'] = TRUE;
  $term_counts = db_query("SELECT vocabulary, count(tid) FROM {taxonomy_term_data} GROUP BY vocabulary")->fetchAllKeyed();
  foreach ($vocabularies as $vocabulary) {
    $terms_count = array_key_exists($vocabulary->machine_name, $term_counts) ? $term_counts[$vocabulary->machine_name] : 0;
    $form[$vocabulary->machine_name]['#vocabulary'] = $vocabulary;
    $form[$vocabulary->machine_name]['name'] = array('#markup' => check_plain($vocabulary->name));
    $form[$vocabulary->machine_name]['items'] = array('#markup' => $terms_count);
    $form[$vocabulary->machine_name]['weight'] = array(
      '#type' => 'weight',
      '#title' => t('Weight for @title', array('@title' => $vocabulary->name)),
      '#title_display' => 'invisible',
      '#delta' => 10,
      '#default_value' => $vocabulary->weight,
    );
    $links = array();
    $links['list'] = array(
      'title' => t('List terms'),
      'href' => "admin/structure/taxonomy/$vocabulary->machine_name",
    );
    $links['add'] = array(
      'title' => t('Add terms'),
      'href' => "admin/structure/taxonomy/$vocabulary->machine_name/add",
    );
    $links['configure'] = array(
      'title' => t('Configure'),
      'href' => "admin/structure/taxonomy/$vocabulary->machine_name/configure",
    );
    if (module_exists('field_ui') && user_access('administer fields')) {
      $links['fields'] = array(
        'title' => t('Manage fields'),
        'href' => "admin/structure/taxonomy/$vocabulary->machine_name/fields",
        'weight' => 5,
      );
      $links['display'] = array(
        'title' => t('Manage displays'),
        'href' => "admin/structure/taxonomy/$vocabulary->machine_name/display",
        'weight' => 10,
      );
    }
    if (user_access('synchronize configuration')) {
      $links['export'] = array(
        'title' => t('Export'),
        'href' => 'admin/config/development/configuration/single/export',
        'query' => array(
          'group' => 'Vocabularies',
          'name' => 'taxonomy.vocabulary.' . $vocabulary->machine_name,
        ),
      );
    }
    $links['delete'] = array(
      'title' => t('Delete'),
      'href' => "admin/structure/taxonomy/$vocabulary->machine_name/delete",
    );
    $form[$vocabulary->machine_name]['operations'] = array(
      '#type' => 'operations',
      '#links' => $links,
    );
  }

  // Only make this form include a submit button and weight if more than one
  // vocabulary exists.
  if (count($vocabularies) > 1) {
    $form['actions'] = array('#type' => 'actions');
    $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
  }
  elseif (isset($vocabulary)) {
    unset($form[$vocabulary->machine_name]['weight']);
  }
  return $form;
}