From 3c795c554f9ada0df9518b5bdad3de02e25b2a61 Mon Sep 17 00:00:00 2001 From: Gerhard Killesreiter Date: Sun, 26 Mar 2006 16:59:17 +0000 Subject: [PATCH] #28625, further form API conversion of taxonomy.module and small bugfix in forms API, patch by profix898 and chx --- modules/taxonomy.module | 32 ++++++++++++++++++++++++++++---- modules/taxonomy/taxonomy.module | 32 ++++++++++++++++++++++++++++---- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/modules/taxonomy.module b/modules/taxonomy.module index 647ef3f5601..b14ca95f72e 100644 --- a/modules/taxonomy.module +++ b/modules/taxonomy.module @@ -121,21 +121,45 @@ function taxonomy_menu($may_cache) { * List and manage vocabularies. */ function taxonomy_overview_vocabularies() { - $header = array(t('Name'), t('Type'), array('data' => t('Operations'), 'colspan' => '2')); - $vocabularies = taxonomy_get_vocabularies(); + $vocabularies = taxonomy_get_vocabularies(); foreach ($vocabularies as $vocabulary) { $types = array(); foreach ($vocabulary->nodes as $type) { $node_type = node_get_name($type); $types[] = $node_type ? $node_type : $type; } - $rows[] = array(check_plain($vocabulary->name), implode(', ', $types), l(t('edit vocabulary'), "admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t('list terms'), "admin/taxonomy/$vocabulary->vid")); + $form[$vocabulary->vid]['name'] = array('#value' => check_plain($vocabulary->name)); + $form[$vocabulary->vid]['type'] = array('#value' => implode(', ', $types)); + $form[$vocabulary->vid]['edit'] = array('#value' => l(t('edit vocabulary'), "admin/taxonomy/edit/vocabulary/$vocabulary->vid")); + $form[$vocabulary->vid]['list'] = array('#value' => l(t('list terms'), "admin/taxonomy/$vocabulary->vid")); } + + return drupal_get_form('taxonomy_overview_vocabularies', $form); +} +/** + * Theme overview vocabularies. + */ +function theme_taxonomy_overview_vocabularies($form) { + $rows = array(); + foreach (element_children($form) as $key) { + if (isset($form[$key]['name'])) { + $row = array(); + $row[] = form_render($form[$key]['name']); + $row[] = form_render($form[$key]['type']); + $row[] = form_render($form[$key]['edit']); + $row[] = form_render($form[$key]['list']); + $rows[] = $row; + } + } if (!$rows) { $rows[] = array(array('data' => t('No categories available.'), 'colspan' => '4', 'class' => 'message')); } - return theme('table', $header, $rows, array('id' => 'taxonomy')); + $header = array(t('Name'), t('Type'), array('data' => t('Operations'), 'colspan' => '2')); + + $output = theme('table', $header, $rows, array('id' => 'taxonomy')); + $output .= form_render($form); + return $output; } /** diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 647ef3f5601..b14ca95f72e 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -121,21 +121,45 @@ function taxonomy_menu($may_cache) { * List and manage vocabularies. */ function taxonomy_overview_vocabularies() { - $header = array(t('Name'), t('Type'), array('data' => t('Operations'), 'colspan' => '2')); - $vocabularies = taxonomy_get_vocabularies(); + $vocabularies = taxonomy_get_vocabularies(); foreach ($vocabularies as $vocabulary) { $types = array(); foreach ($vocabulary->nodes as $type) { $node_type = node_get_name($type); $types[] = $node_type ? $node_type : $type; } - $rows[] = array(check_plain($vocabulary->name), implode(', ', $types), l(t('edit vocabulary'), "admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t('list terms'), "admin/taxonomy/$vocabulary->vid")); + $form[$vocabulary->vid]['name'] = array('#value' => check_plain($vocabulary->name)); + $form[$vocabulary->vid]['type'] = array('#value' => implode(', ', $types)); + $form[$vocabulary->vid]['edit'] = array('#value' => l(t('edit vocabulary'), "admin/taxonomy/edit/vocabulary/$vocabulary->vid")); + $form[$vocabulary->vid]['list'] = array('#value' => l(t('list terms'), "admin/taxonomy/$vocabulary->vid")); } + + return drupal_get_form('taxonomy_overview_vocabularies', $form); +} +/** + * Theme overview vocabularies. + */ +function theme_taxonomy_overview_vocabularies($form) { + $rows = array(); + foreach (element_children($form) as $key) { + if (isset($form[$key]['name'])) { + $row = array(); + $row[] = form_render($form[$key]['name']); + $row[] = form_render($form[$key]['type']); + $row[] = form_render($form[$key]['edit']); + $row[] = form_render($form[$key]['list']); + $rows[] = $row; + } + } if (!$rows) { $rows[] = array(array('data' => t('No categories available.'), 'colspan' => '4', 'class' => 'message')); } - return theme('table', $header, $rows, array('id' => 'taxonomy')); + $header = array(t('Name'), t('Type'), array('data' => t('Operations'), 'colspan' => '2')); + + $output = theme('table', $header, $rows, array('id' => 'taxonomy')); + $output .= form_render($form); + return $output; } /**