diff -Naurx .svn taxonomy_multi_edit/taxonomy_multi_edit.info taxonomy_multi_edit_new/taxonomy_multi_edit.info --- taxonomy_multi_edit/taxonomy_multi_edit.info 2007-03-20 05:45:03.000000000 -0400 +++ taxonomy_multi_edit_new/taxonomy_multi_edit.info 2008-05-25 03:45:14.000000000 -0400 @@ -3,6 +3,7 @@ description = A mass category editor. package = "Content management" ; Information added by drupal.org packaging script on 2007-03-20 -version = "5.x-1.0" +version = "6.x-1.0" +core = "6.x" project = "taxonomy_multi_edit" diff -Naurx .svn taxonomy_multi_edit/taxonomy_multi_edit.module taxonomy_multi_edit_new/taxonomy_multi_edit.module --- taxonomy_multi_edit/taxonomy_multi_edit.module 2007-03-20 05:35:51.000000000 -0400 +++ taxonomy_multi_edit_new/taxonomy_multi_edit.module 2008-05-25 03:49:56.000000000 -0400 @@ -1,6 +1,8 @@ 'admin/content/node/taxonomy_multi_edit', 'title' => t('assign categories'), - 'callback' => 'taxonomy_multi_edit_overview_page', - 'access' => user_access('administer nodes'), +function taxonomy_multi_edit_menu() { + $items['admin/content/node/taxonomy_multi_edit'] = array( + 'title' => t('assign categories'), + 'page callback' => 'taxonomy_multi_edit_overview_page', + 'access arguments' => user_access('administer nodes'), 'weight' => 5, 'type' => MENU_LOCAL_TASK); - return $items; - } + return $items; } function taxonomy_multi_edit_overview_page() { @@ -37,13 +38,13 @@ $sql = "SELECT n.nid, title, type FROM {node} n ORDER BY changed DESC"; $result = pager_query(db_rewrite_sql($sql), variable_get('default_nodes_main', 10)); while ($node = db_fetch_object($result)) { - - // $form_taxonomy = taxonomy_node_form($node); - $fakeform = array('type' => array( + $node=node_load($node->nid); + // $form_taxonomy = taxonomy_node_form($node); + $fakeform = array('type' => array( '#value' => $node->type), '#node' => $node, - ); - + ); + if (is_array($fakeform['#node']->taxonomy)) { foreach ($fakeform['#node']->taxonomy as $id => $term) { if (is_array($term)) { @@ -54,36 +55,48 @@ } } } - taxonomy_form_alter($node->type. '_node_form', $fakeform); + taxonomy_form_alter($fakeform,array(),$node->type. '_node_form'); + //drupal_set_message("
".print_r($fakeform['taxonomy'],1));
     unset($fakeform['type'], $fakeform['taxonomy']['#type']); // kill the fieldset and type field
     // kill description fields
     foreach ((array)$fakeform['taxonomy'] as $key => $arr) {
       if (is_numeric($key)) {
-        unset($fakeform['taxonomy'][$key]['#description']); 
+        unset($fakeform['taxonomy'][$key]['#description']);
+        unset($fakeform['taxonomy'][$key]['#theme']);
       }
     }
     // dprint_r($fakeform);
     // $form['myform'][$node->nid] = $fakeform;
-		// TODO: manipulate $form_taxonomy elements so that many nodes can be manipulated on same page.
-		// $form['title'][$node->nid] = array('#value' => l($node->title, "node/$node->nid", array()));
-		// $form['nid'][$node->nid] = array('#value' => $node->nid);
-		$form['nodes'][$node->nid] = $fakeform;
+    // TODO: manipulate $form_taxonomy elements so that many nodes can be manipulated on same page.
+    // $form['title'][$node->nid] = array('#value' => l($node->title, "node/$node->nid", array()));
+    // $form['nid'][$node->nid] = array('#value' => $node->nid);
+    
+    // Ulhume: It seems that if the name of the subform is still 'taxonomy', some hook
+    // somewhere mess up the form. 
+    $form['nodes'][$node->nid] = array('#node_title'=>$node->title, 'taxonomy'=>$fakeform['taxonomy']);
     unset($fakeform);
   }
   $form['submit'] = array('#type' => 'submit', '#value' => t('Save categories'));
   $form['pager'] = array('#value' => theme('pager', NULL, variable_get('default_nodes_main', 10), 0));
-
+  //$form['#submit'][]='taxonomy_multi_edit_overview_submit';
   return $form;
 }
 
+function taxonomy_multi_edit_theme() {
+  return array(
+    'taxonomy_multi_edit_overview' => array(
+      'arguments' => array('form' => NULL)
+    )
+  );
+}
 /**
  * lay the from out into an admin table
  */
 function theme_taxonomy_multi_edit_overview(&$form) {
 
-	foreach (element_children($form['nodes']) as $nid) {
+  foreach (element_children($form['nodes']) as $nid) {
     $row = array();
-    $row[] = l(truncate_utf8($form['nodes'][$nid]['#node']->title, 20), "node/$nid");
+    $row[] = l(truncate_utf8($form['nodes'][$nid]['#node_title'], 20), "node/$nid");
     foreach (element_children($form['nodes'][$nid]['taxonomy']) as $vid) {
       // disperse into rows. May give odd layout results with mixed node types
       $row[] = array('data' => drupal_render($form['nodes'][$nid]['taxonomy'][$vid]));
@@ -92,8 +105,8 @@
   }
 
   $header = array(
-    array("data" => t('title'), ),
-    array("data" => t('vocabularies'))
+  array("data" => t('title'), ),
+  array("data" => t('vocabularies'))
   );
 
   $output = theme('table', $header, $rows);
@@ -105,19 +118,21 @@
  * Forms API form callback hook
  */
 function taxonomy_multi_edit_overview_submit($form_id, $form_values) {
-  drupal_set_message(print_r($form_values,1));
-   foreach ($form_values['nodes'] as $nid => $terms) {
-     if (!$tax = $terms['taxonomy']) {
-       $tax = $terms['tags'];
-     }
-     taxonomy_node_save($nid, $tax);
-   }
-   drupal_set_message(t('categories updated.'));
+  foreach ($form_values['values']['nodes'] as $nid => $terms) {
+    if (!$tax = $terms['taxonomy']) { 
+      $tax = $terms['tags'];
+    }
+    $node=node_load($nid);
+    unset($node->taxonomy);
+//    drupal_set_message("
".print_r($tax,1)."
"); + taxonomy_node_save($node, $tax); + } + drupal_set_message(t('categories updated.')); } /** * Below here is the alternate interface - * + * * - integrated with the normal Drupal content management page. */ @@ -151,13 +166,13 @@ '#size' => 10, '#theme' => 'taxonomy_term_select', '#description' => t("

Warning, using this form may override some of the normal vocabulary restrictions.

"), - ), + ), ); // used the extra fieldset because renderer was failing to honour doing the same via #prefix - $form['#submit']['taxonomy_multi_edit_content_form_submit']=array(); + $form['#submit']['taxonomy_multi_edit_content_form_submit']=array(); - drupal_add_js(taxonomy_multi_edit_content_form_javascript(),'inline'); + drupal_add_js(taxonomy_multi_edit_content_form_javascript(),'inline'); -} +} /** * Capture additional operations on the content managemment page @@ -168,10 +183,10 @@ $terms = $edit['terms']; foreach ($edit['nodes'] as $nid => $value) { if($value){ - // I could have done this direct to database, + // I could have done this direct to database, // but we'll do it safer via the published methods instead. // Means we can safely merge instead of overwrite - + $existing = taxonomy_node_get_terms($nid); foreach($terms as $t){ // cannot array_merge as it messes the indexes $existing[$t] = $t;