You are here

function taxonomy_overview_vocabularies in Drupal 7

Same name and namespace in other branches
  1. 4 modules/taxonomy.module \taxonomy_overview_vocabularies()
  2. 5 modules/taxonomy/taxonomy.module \taxonomy_overview_vocabularies()
  3. 6 modules/taxonomy/taxonomy.admin.inc \taxonomy_overview_vocabularies()

Form builder to list and manage vocabularies.

See also

taxonomy_overview_vocabularies_submit()

theme_taxonomy_overview_vocabularies()

Related topics

1 string reference to 'taxonomy_overview_vocabularies'
taxonomy_menu in modules/taxonomy/taxonomy.module
Implements hook_menu().

File

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

Code

function taxonomy_overview_vocabularies($form) {
  $vocabularies = taxonomy_get_vocabularies();
  $form['#tree'] = TRUE;
  foreach ($vocabularies as $vocabulary) {
    $form[$vocabulary->vid]['#vocabulary'] = $vocabulary;
    $form[$vocabulary->vid]['name'] = array(
      '#markup' => check_plain($vocabulary->name),
    );
    $form[$vocabulary->vid]['weight'] = array(
      '#type' => 'weight',
      '#title' => t('Weight for @title', array(
        '@title' => $vocabulary->name,
      )),
      '#title_display' => 'invisible',
      '#delta' => 10,
      '#default_value' => $vocabulary->weight,
    );
    $form[$vocabulary->vid]['edit'] = array(
      '#type' => 'link',
      '#title' => t('edit vocabulary'),
      '#href' => "admin/structure/taxonomy/{$vocabulary->machine_name}/edit",
    );
    $form[$vocabulary->vid]['list'] = array(
      '#type' => 'link',
      '#title' => t('list terms'),
      '#href' => "admin/structure/taxonomy/{$vocabulary->machine_name}",
    );
    $form[$vocabulary->vid]['add'] = array(
      '#type' => 'link',
      '#title' => t('add terms'),
      '#href' => "admin/structure/taxonomy/{$vocabulary->machine_name}/add",
    );
  }

  // 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->vid]['weight']);
  }
  return $form;
}