? feedapi_mapper_5t6.2.patch
Index: feedapi_mapper.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/feedapi_mapper/feedapi_mapper.info,v
retrieving revision 1.1
diff -u -r1.1 feedapi_mapper.info
--- feedapi_mapper.info	18 Jan 2008 21:59:58 -0000	1.1
+++ feedapi_mapper.info	30 Jun 2008 23:27:31 -0000
@@ -1,4 +1,6 @@
 name = FeedAPI Mapper
 description = "Maps feed item elements to node fields."
-dependencies = feedapi feedapi_node
-package = FeedAPI Add On
\ No newline at end of file
+dependencies[] = feedapi_node
+dependencies[] = feedapi
+package = FeedAPI Add On
+core = 6.x
\ No newline at end of file
Index: feedapi_mapper.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/feedapi_mapper/feedapi_mapper.install,v
retrieving revision 1.1
diff -u -r1.1 feedapi_mapper.install
--- feedapi_mapper.install	18 Jan 2008 21:59:58 -0000	1.1
+++ feedapi_mapper.install	30 Jun 2008 23:27:31 -0000
@@ -2,33 +2,36 @@
 // $Id: feedapi_mapper.install,v 1.1 2008/01/18 21:59:58 alexb Exp $
 
 /**
+ * Implementaton of hook_schema().
+ */
+function feedapi_mapper_schema() {
+  $schema['feedapi_mapper'] = array(
+    'description' => t('Store date for the feedapi mapper'),
+    'fields' => array(
+      'nid' => array(
+        'description' => t('The primary identifier for the feed.'),
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE),
+      'mapping' => array(
+        'type' => 'text',
+        'size' => 'big',
+        'not null' => TRUE),
+      ),
+    'primary key' => array('nid'),
+    );
+  return $schema;
+}
+/**
  * Implementaton of hook_install().
  */
 function feedapi_mapper_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysqli':
-    case 'mysql':
-      db_query("CREATE TABLE {feedapi_mapper} (
-        `nid` INT( 10 ) UNSIGNED NOT NULL ,
-        `mapping` LONGTEXT NOT NULL ,
-        PRIMARY KEY ( `nid` )
-        )"); 
-      break;
-    case 'pgsql':
-      // Todo.
-      break;
-  }
+  drupal_install_schema('feedapi_mapper');
 }
 
 /**
  * Implementaton of hook_uninstall().
  */
 function feedapi_mapper_uninstall() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysqli':
-    case 'mysql':
-    case 'pgsql':
-      db_query("DROP TABLE {feedapi_mapper}");
-      break;
-  }
+  drupal_uninstall_schema('feedapi_mapper');
 }
\ No newline at end of file
Index: feedapi_mapper.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/feedapi_mapper/feedapi_mapper.module,v
retrieving revision 1.1.2.7
diff -u -r1.1.2.7 feedapi_mapper.module
--- feedapi_mapper.module	17 Mar 2008 16:24:16 -0000	1.1.2.7
+++ feedapi_mapper.module	30 Jun 2008 23:27:31 -0000
@@ -4,8 +4,8 @@
 /**
  * Implementation of hook_help().
  */
-function feedapi_mapper_help($section) {
-  switch ($section) {
+function feedapi_mapper_help($path, $arg) {
+  switch ($path) {
     case 'admin/help#feedapi_mapper':
       return t('FeedAPI Mapper - maps feed item elements to node fields');
     case 'feedapi_mapper/full_name':
@@ -16,58 +16,57 @@
 /**
  * Implementation of hook_menu().
  */
-function feedapi_mapper_menu($may_cache) {
+function feedapi_mapper_menu() {
   $items = array();
-  if (!$may_cache) {
-    if (arg(0) == 'node' && is_numeric(arg(1))) {
-      $node = node_load(arg(1));
-      if (feedapi_enabled($node->type)) {
-        global $user;
-        $items[] = array('path' => 'node/'. $node->nid .'/map',
-          'title' => t('Map'),
-          'callback' => 'feedapi_mapper_page',
-          'callback arguments' => array($node),
-          'type' => MENU_LOCAL_TASK,
-          'access' => (user_access('administer feedapi')),
-          );
-      }
-    }
-    else if (arg(0) == 'admin' && arg(1) == 'content' && arg(2) == 'types') {
-      $node_type = arg(3) ? str_replace('-', '_', arg(3)) : NULL;
-      if ($node_type && feedapi_enabled($node_type)) {
-        $items[] = array(
-            'path' => 'admin/content/types/'. str_replace('_', '-', $node_type) .'/edit',
-            'title' => t('Edit'),
-            'callback' => 'drupal_get_form',
-            'callback arguments' => array('node_type_form', $node_type),
-            'type' => MENU_DEFAULT_LOCAL_TASK,
-          );
-        // @todo: this should finally live in a sub tab of "Feed".
-        $node = new stdClass();
-        $node->type = $node_type;
-        $items[] = array('path' => 'admin/content/types/'. str_replace('_', '-', $node_type) .'/map',
-          'title' => t('Map'),
-          'callback' => 'feedapi_mapper_page',
-          'callback arguments' => array($node),
-          'type' => MENU_LOCAL_TASK,
-          'access' => user_access('administer feedapi'),
-          );
-      }
-    }
-  }
+  $items['node/%node/map'] = array(
+    'title' => 'Map',
+    'page callback' => 'feedapi_mapper_page',
+    'page arguments' => array(1),
+    'type' => MENU_LOCAL_TASK,
+    'access callback' => 'user_access',
+    'access arguments' => array('administer feedapi'),
+    );
+   $items['admin/content/node-type/%feedapi_mapper_node_type/edit'] = array(
+      'title' => t('Edit'),
+      'page callback' => 'drupal_get_form',
+      'page arguments' => array('node_type_form', 3),
+      'type' => MENU_DEFAULT_LOCAL_TASK,
+      'access callback' => 'user_access',
+      'access arguments' => array('administer node types'),
+    );
+  $items['admin/content/node-type/%feedapi_mapper_node_type/map'] = array(
+    'title' => t('Map'),
+    'page callback' => 'feedapi_mapper_page',
+    'callback arguments' => array(3),
+    'type' => MENU_LOCAL_TASK,
+    'page callback' => 'user_access',
+    'access arguments' => array('administer feedapi'),
+    );
   return $items;
 }
 
 /**
+ * Implementation of hook_load().
+ */
+function feedapi_mapper_node_type_load($node_type) {
+  if (feedapi_enabled($node_type)) {
+    $node = new stdClass();
+    $node->type = $node_type;
+    return $node;
+  }
+  return FALSE;
+}
+
+/**
  * Implementation of hook_nodeapi().
  */
 function feedapi_mapper_nodeapi(&$node, $op, $teaser, $page) {
   switch ($op) {
   case 'prepare':
-   if ($node->feedapi->feed_item) {
-     _feedapi_mapper_map($node);
-   }
-   break;
+    if ($node->feedapi->feed_item) {
+      _feedapi_mapper_map($node);
+    }
+    break;
   }
 }
 
@@ -125,7 +124,7 @@
 /**
  * Mapping form.
  */
-function feedapi_mapper_form($node) {
+function feedapi_mapper_form($form_state, $node) {
   // Get fields of node type with available feed element mappers.
   if ($node->feed->settings['processors']['feedapi_node']['content_type']) {
     $settings = $node->feed->settings;
@@ -177,11 +176,11 @@
       '#collapsible' => TRUE,
       '#collapsed' => FALSE,
       '#tree' => TRUE,
-      );  
+      );
     $form['descriptions']['descriptions'] = array(
       '#type' => 'markup',
       '#value' => $descriptions,
-      );  
+      );
   }
   // Create mapping form.
   $form['mapping'] = array(
@@ -210,8 +209,8 @@
 /**
  * Submit hook.
  */
-function feedapi_mapper_form_submit($form_id, $form_values) {
-  _feedapi_mapper_store_mapping($form_values['nid'], $form_values['mapping'], $form_values['elements']);
+function feedapi_mapper_form_submit($form, &$form_state) {
+  _feedapi_mapper_store_mapping($form_state['nid'], $form_state['mapping'], $form_state['elements']);
 }
 
 /**
@@ -225,8 +224,8 @@
  */
 function _feedapi_mapper_store_mapping($param, $mapping, $elements) {
   // Wrap the mapping array (element_name => node_field)
-  // and the elements array (element_name => element_path) 
-  // arrays into one: 
+  // and the elements array (element_name => element_path)
+  // arrays into one:
   // We store a mapping as element_path => node_field.
   // - element_path and node_field are both a serialized array.
   $stored_mapping = array();
@@ -250,7 +249,7 @@
 
 /**
  * Retrieve mapping from db.
- * @param $param 
+ * @param $param
  * node id or node type
  * @return Associative array in the format
  * array(
@@ -282,9 +281,9 @@
   static $loaded = FALSE;
   if (!$loaded) {
     // Load all feedapi mapper implementations from ./mappers
-    $path = drupal_get_path('module', 'feedapi_mapper') . '/mappers';
+    $path = drupal_get_path('module', 'feedapi_mapper') .'/mappers';
     $files = drupal_system_listing('.*\.inc$', $path, 'name', 0);
-    foreach($files as $file) {
+    foreach ($files as $file) {
       require_once("./$file->filename");
     }
     // Rebuild cache.
@@ -371,7 +370,7 @@
 /**
  * Traverse an associative array and look for path to first leaf.
  * If found, unset leaf and return path to it.
- * @return 
+ * @return
  * A path to a leaf element in the format
  * array(path, to, leaf, element);
  */
@@ -408,7 +407,7 @@
 }
 
 /**
- * Converts a multidemensional associative array with interdispersed objects into 
+ * Converts a multidemensional associative array with interdispersed objects into
  * an associative array only.
  */
 function _feedapi_mapper_obj2array($items) {
@@ -440,7 +439,7 @@
 }
 
 /**
- * Like array_merge_recursive. Only difference: does NOT merge 
+ * Like array_merge_recursive. Only difference: does NOT merge
  * two different keys into an array, but merges key on key.
  * Argument 1 always has to be an array.
  */
@@ -467,11 +466,11 @@
 }
 
 /**
- * Get field mappers for a given node type. Returns an array of all 
+ * Get field mappers for a given node type. Returns an array of all
  * feed mappers that are applicable to this node type.
  * @param $node_type
  *   Valid node type.
- * @return 
+ * @return
  *   Array of fields that are mappable for this content type.
  */
 function _feedapi_mapper_get_field_mappers($node_type) {
@@ -502,10 +501,10 @@
 
 /**
  * Returns descriptions for all mappable fields of given node type.
- * @return 
- *   Array in the format 
- *   array('field_name_a' => 
- *          array('module_name_a' => 'Descriptive text'), 
+ * @return
+ *   Array in the format
+ *   array('field_name_a' =>
+ *          array('module_name_a' => 'Descriptive text'),
  *                'module_name_b' => ...),
  *         'field_name_b' =>  array(...),
  *         );
@@ -536,19 +535,23 @@
   // being listed. We set a special flag to inform them this form is special.
   $node->cck_dummy_node_form = TRUE;
   
-  $form = call_user_func_array('drupal_retrieve_form', array($form_id, $node));
-  drupal_process_form($form_id, $form);
+  // Include node.pages.inc which contains the node_form definitions.
+  include_once(drupal_get_path('module', 'node') .'/node.pages.inc');
+  $form_state = array('storage' => NULL, 'submitted' => FALSE);
+  $form_state['values']['name'] = $name;
+  $form = drupal_retrieve_form($form_id, $form_state, $node);
+  drupal_process_form($form_id, $form, $form_state);
   // return drupal_render_form($args[0], $form);
   return $form;
 }
 
 /**
  * Retrieve all field names on a given node type.
- * 
+ *
  * @todo:
  * This is still somewhat of a cooking recipe and e. g. does not expose teaser nor body filter,
  * as they are not present as such neither on the form nor in the node of the initial form.
- * 
+ *
  * If there are suggestions on how to improve this routine, I'd be happy to know them.
  *
  * @param string $node_type
@@ -557,6 +560,7 @@
   static $field_names;
   if (!is_array($field_names[$node_type])) {
     $form = _feedapi_mapper_get_node_form($node_type);
+    drupal_set_message('<pre>'. print_r($form, true) .'</pre>');
     $node = (array)$form['#node'];
     $fields = array_merge($form, $node);
     $i = 0;
@@ -573,7 +577,7 @@
  * Theming function for outputting result of _feedapi_mapper_get_field_mappers_descriptions().
  * @param $descriptions
  *   Result of _feedapi_mapper_get_field_mappers_descriptions().
- * @return 
+ * @return
  *   HTML output.
  */
 function theme_feedapi_mapper_descriptions($descriptions) {
@@ -586,4 +590,18 @@
   }
   $output .= '</dl>';
   return $output;
+}
+
+/**
+ * Implementation of hook_theme
+ *
+ */
+function feedapi_mapper_theme() {
+  return array(
+    'feedapi_mapper_descriptions' => array(
+        'arguments' => array('descriptions'),
+        ),
+    
+    );
+  
 }
\ No newline at end of file
Index: mappers/feedapi_mapper_taxonomy.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/feedapi_mapper/mappers/feedapi_mapper_taxonomy.inc,v
retrieving revision 1.1
diff -u -r1.1 feedapi_mapper_taxonomy.inc
--- mappers/feedapi_mapper_taxonomy.inc	18 Jan 2008 21:59:58 -0000	1.1
+++ mappers/feedapi_mapper_taxonomy.inc	30 Jun 2008 23:27:31 -0000
@@ -35,6 +35,7 @@
       return t('Maps a string or an array of strings to taxonomy terms. Chose a vocabulary from sub options.');
     }
     else if ($op == 'list') {
+      drupal_set_message('print '. print_r($node));
       if ($vocabularies = taxonomy_get_vocabularies($node->type)) {
         foreach ($vocabularies as $v) {
           $sub_fields[$v->vid] = $v->name;
