Index: modules/taxonomy/taxonomy.module =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v retrieving revision 1.330 diff -u -r1.330 taxonomy.module --- modules/taxonomy/taxonomy.module 11 Jan 2007 03:29:15 -0000 1.330 +++ modules/taxonomy/taxonomy.module 2 Feb 2007 15:58:21 -0000 @@ -118,12 +118,14 @@ else { if (arg(0) == 'admin' && arg(1) == 'content' && arg(2) == 'taxonomy' && is_numeric(arg(3))) { $vid = arg(3); - $items[] = array('path' => 'admin/content/taxonomy/'. $vid, + $items[] = array( + 'path' => 'admin/content/taxonomy/'. $vid, 'title' => t('List terms'), - 'callback' => 'taxonomy_overview_terms', - 'callback arguments' => array($vid), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('taxonomy_overview_terms', $vid), 'access' => user_access('administer taxonomy'), - 'type' => MENU_CALLBACK); + 'type' => MENU_CALLBACK + ); $items[] = array('path' => 'admin/content/taxonomy/'. $vid .'/list', 'title' => t('List'), @@ -170,46 +172,174 @@ } /** - * Display a tree of all the terms in a vocabulary, with options to edit - * each one. + * Manage vocabulary terms. + * + * @param $vid + * Vocabulary ID of the vocabulary whose terms are to be managed. + * @param $form_values + * $form_values for the multi-step form. This parameter is automatically added + * by the forms API. + * + * @return $form + * A multi-step form array. */ -function taxonomy_overview_terms($vid) { - $destination = drupal_get_destination(); +function taxonomy_overview_terms($vid, $form_values = NULL) { + $form = array(); - $header = array(t('Name'), t('Operations')); - $vocabulary = taxonomy_get_vocabulary($vid); - if (!$vocabulary) { - return drupal_not_found(); + if (!isset($form_values)) { + $step = 1; + } + else { + $step = $form_values['step'] + 1; + // Forward essential values from step 1 to subsequent steps. + $form['operation'] = array('#type' => 'value', '#value' => $form_values['operation']); + $form['terms'] = array('#type' => 'value', '#value' => $form_values['terms']); + $form['vid'] = array('#type' => 'value', '#value' => $vid); } - drupal_set_title(check_plain($vocabulary->name)); - $start_from = $_GET['page'] ? $_GET['page'] : 0; - $total_entries = 0; // total count for pager - $page_increment = 25; // number of tids per page - $displayed_count = 0; // number of tids shown + $form['step'] = array('#type' => 'hidden', '#value' => $step); - $tree = taxonomy_get_tree($vocabulary->vid); - foreach ($tree as $term) { - $total_entries++; // we're counting all-totals, not displayed - if (($start_from && ($start_from * $page_increment) >= $total_entries) || ($displayed_count == $page_increment)) { - continue; - } - $rows[] = array(str_repeat('--', $term->depth) . ' ' . l($term->name, "taxonomy/term/$term->tid"), l(t('edit'), "admin/content/taxonomy/edit/term/$term->tid", array(), $destination)); - $displayed_count++; // we're counting tids displayed + switch ($step) { + case 1: + $vocabulary = taxonomy_get_vocabulary($vid); + if (!$vocabulary) { + return drupal_not_found(); + } + + drupal_set_title(check_plain($vocabulary->name)); + + $start_from = $_GET['page'] ? $_GET['page'] : 0; + // Total count for pager. + $total_entries = 0; + // Number of tids per page. + $page_increment = 50; + // Number of tids shown. + $displayed_count = 0; + + $destination = drupal_get_destination(); + + $tree = taxonomy_get_tree($vocabulary->vid); + $terms = array(); + foreach ($tree as $term) { + // Count all tids. + $total_entries++; + if (($start_from && ($start_from * $page_increment) >= $total_entries) || ($displayed_count == $page_increment)) { + continue; + } + // Count the tids displayed. + $displayed_count++; + + $terms[$term->tid] = ''; + $form['name'][$term->tid] = array('#value' => l($term->name, "taxonomy/term/$term->tid")); + // Forward depth for use in the theme function. + // @see theme_taxonomy_overview_terms. + $form['depth'][$term->tid] = array('#type' => 'value', '#value' => $term->depth); + // Form element 'operations' not to be confused with element 'operation'. + $form['operations'][$term->tid] = array('#value' => l(t('edit'), "admin/content/taxonomy/edit/term/$term->tid", array(), $destination)); + } + $form['terms'] = array('#type' => 'checkboxes', '#options' => $terms); + + $GLOBALS['pager_page_array'][] = $start_from; // FIXME + $GLOBALS['pager_total'][] = intval($total_entries / $page_increment) + 1; // FIXME + + if ($total_entries >= $page_increment) { + $form['pager'] = array('#value' => theme('pager', NULL, $page_increment)); + } + + $form['perform'] = array( + '#type' => 'fieldset', + '#title' => t('Update options'), + '#prefix' => '