From e6a88be5d127f41837137a0d00980c8d8115ab1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= Date: Mon, 26 Nov 2007 19:46:52 +0000 Subject: #193333 by quicksketch et al: taxonomy drag and drop support --- modules/forum/forum.admin.inc | 35 +++++++++++++++++++++-------------- modules/forum/forum.module | 3 ++- 2 files changed, 23 insertions(+), 15 deletions(-) (limited to 'modules/forum') diff --git a/modules/forum/forum.admin.inc b/modules/forum/forum.admin.inc index 099dae094..6b0bcb8f8 100644 --- a/modules/forum/forum.admin.inc +++ b/modules/forum/forum.admin.inc @@ -214,26 +214,33 @@ function forum_admin_settings() { /** * Returns an overview list of existing forums and containers */ -function forum_overview() { - $header = array(t('Name'), t('Operations')); +function forum_overview(&$form_state) { + include_once(drupal_get_path('module', 'taxonomy') .'/taxonomy.admin.inc'); $vid = variable_get('forum_nav_vocabulary', ''); - $tree = taxonomy_get_tree($vid); - if ($tree) { - foreach ($tree as $term) { - if (in_array($term->tid, variable_get('forum_containers', array()))) { - $rows[] = array(str_repeat(' -- ', $term->depth) .' '. l($term->name, 'forum/'. $term->tid), l(t('edit container'), 'admin/content/forum/edit/container/'. $term->tid)); + $vocabulary = taxonomy_vocabulary_load($vid); + $form = taxonomy_overview_terms($form_state, $vocabulary); + drupal_set_title('Forums'); + + foreach (element_children($form) as $key) { + if (isset($form[$key]['#term'])) { + $term = $form[$key]['#term']; + $form[$key]['view']['#value'] = l($term['name'], 'forum/'. $term['tid']); + if (in_array($form[$key]['#term']['tid'], variable_get('forum_containers', array()))) { + $form[$key]['edit']['#value'] = l(t('edit container'), 'admin/content/forum/edit/container/'. $term['tid']); } else { - $rows[] = array(str_repeat(' -- ', $term->depth) .' '. l($term->name, 'forum/'. $term->tid), l(t('edit forum'), 'admin/content/forum/edit/forum/'. $term->tid)); - } - + $form[$key]['edit']['#value'] = l(t('edit forum'), 'admin/content/forum/edit/forum/'. $term['tid']); + } } } - else { - $rows[] = array(array('data' => ''. t('There are no existing containers or forums. You may add some on the add container or add forum pages.', array('@container' => url('admin/content/forum/add/container'), '@forum' => url('admin/content/forum/add/forum'))) .'', 'colspan' => 2)); - } - return theme('table', $header, $rows); + + // The form needs to have submit and validate handlers set explicitly. + $form['#theme'] = 'taxonomy_overview_terms'; + $form['#submit'] = array('taxonomy_overview_terms_submit'); // Use the existing taxonomy overview submit handler. + $form['#validate'] = array('taxonomy_overview_terms_validate'); + $form['#empty_text'] = ''. t('There are no existing containers or forums. You may add some on the add container or add forum pages.', array('@container' => url('admin/content/forum/add/container'), '@forum' => url('admin/content/forum/add/forum'))) .''; + return $form; } /** diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 6647daff6..46f0a9615 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -92,7 +92,8 @@ function forum_menu() { $items['admin/content/forum'] = array( 'title' => 'Forums', 'description' => 'Control forums and their hierarchy and change forum settings.', - 'page callback' => 'forum_overview', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('forum_overview'), 'access arguments' => array('administer forums'), 'file' => 'forum.admin.inc', ); -- cgit v1.2.3