summaryrefslogtreecommitdiff
path: root/modules/taxonomy/taxonomy.admin.inc
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-07-31 13:01:50 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-07-31 13:01:50 +0000
commit4037fa86db033e758a52642f602323cdd3e85015 (patch)
treea3bcc8bd3af5dea73c3fc8f4f2e035737412a7d3 /modules/taxonomy/taxonomy.admin.inc
parent9588a5b38b2e607c8c3253a56585eedc80481d2b (diff)
downloadbrdo-4037fa86db033e758a52642f602323cdd3e85015.tar.gz
brdo-4037fa86db033e758a52642f602323cdd3e85015.tar.bz2
#846524 by aaronbauman, mgifford: Fixed Terms cannot be manually reordered by weight.
Diffstat (limited to 'modules/taxonomy/taxonomy.admin.inc')
-rw-r--r--modules/taxonomy/taxonomy.admin.inc19
1 files changed, 15 insertions, 4 deletions
diff --git a/modules/taxonomy/taxonomy.admin.inc b/modules/taxonomy/taxonomy.admin.inc
index 1080e3818..9063b217c 100644
--- a/modules/taxonomy/taxonomy.admin.inc
+++ b/modules/taxonomy/taxonomy.admin.inc
@@ -284,6 +284,7 @@ function taxonomy_overview_terms($form, &$form_state, $vocabulary) {
// An array of the terms to be displayed on this page.
$current_page = array();
+ $delta = 0;
$term_deltas = array();
$tree = taxonomy_get_tree($vocabulary->vid);
$term = current($tree);
@@ -292,6 +293,7 @@ function taxonomy_overview_terms($form, &$form_state, $vocabulary) {
if (empty($term)) {
break;
}
+ $delta++;
// Count entries before the current page.
if ($page && ($page * $page_increment) > $before_entries && !isset($back_step)) {
$before_entries++;
@@ -392,6 +394,13 @@ function taxonomy_overview_terms($form, &$form_state, $vocabulary) {
// Same as above, the depth is modified by javascript, so it's a default_value.
'#default_value' => $term->depth,
);
+ $form[$key]['weight'] = array(
+ '#type' => 'weight',
+ '#delta' => $delta,
+ '#title_display' => 'invisible',
+ '#title' => t('Weight for added term'),
+ '#default_value' => $term->weight,
+ );
}
$form[$key]['edit'] = array('#type' => 'link', '#title' => t('edit'), '#href' => 'taxonomy/term/' . $term->tid . '/edit', '#options' => array('query' => drupal_get_destination()));
}
@@ -446,8 +455,8 @@ function taxonomy_overview_terms_submit($form, &$form_state) {
return;
}
- $order = array_flip(array_keys($form_state['input'])); // Get the $_POST order.
- $form_state['values'] = array_merge($order, $form_state['values']); // Update our original form with the new order.
+ // Sort term order based on weight.
+ uasort($form_state['values'], 'drupal_sort_weight');
$vocabulary = $form['#vocabulary'];
$hierarchy = 0; // Update the current hierarchy type as we go.
@@ -562,6 +571,7 @@ function theme_taxonomy_overview_terms($variables) {
drupal_add_js(array('taxonomy' => array('backStep' => $back_step, 'forwardStep' => $forward_step)), 'setting');
drupal_add_css(drupal_get_path('module', 'taxonomy') . '/taxonomy.css');
}
+ drupal_add_tabledrag('taxonomy', 'order', 'sibling', 'term-weight');
$errors = form_get_errors() != FALSE ? form_get_errors() : array();
$rows = array();
@@ -577,8 +587,9 @@ function theme_taxonomy_overview_terms($variables) {
$term['depth']['#attributes']['class'] = array('term-depth');
$row[0] .= drupal_render($term['parent']) . drupal_render($term['tid']) . drupal_render($term['depth']);
}
+ $term['weight']['#attributes']['class'] = array('term-weight');
+ $row[] = drupal_render($term['weight']);
$row[] = drupal_render($term['edit']);
-
$row = array('data' => $row);
$rows[$key] = $row;
}
@@ -619,7 +630,7 @@ function theme_taxonomy_overview_terms($variables) {
$rows[] = array(array('data' => $form['#empty_text'], 'colspan' => '2'));
}
- $header = array(t('Name'), t('Operations'));
+ $header = array(t('Name'), t('Weight'), t('Operations'));
$output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'taxonomy')));
$output .= drupal_render_children($form);
$output .= theme('pager', array('tags' => NULL));