From cc87239ddd1623140b1a703bc87fb5610dde2cee Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Fri, 11 Nov 2011 10:31:37 +0000
Subject: [PATCH 01/13] Applied Coder upgrade coding standards conversion.

---
 data.install                                       |    4 +-
 data.module                                        |    8 ++--
 data.views.inc                                     |    8 ++--
 data_node/data_node.admin.inc                      |    2 +-
 data_node/data_node.install                        |    2 +-
 data_node/data_node.module                         |   21 +++-----
 data_node/data_node.theme.inc                      |    2 +-
 data_node/views/data_node.views.inc                |    4 +-
 .../data_node_views_handler_field_add_remove.inc   |    4 +-
 .../data_node_views_handler_field_item_count.inc   |    4 +-
 .../data_node_views_handler_field_node_list.inc    |    8 ++-
 data_search/data_search.install                    |    2 +-
 data_search/data_search.module                     |    2 +-
 data_taxonomy/data_taxonomy.admin.inc              |    2 +-
 data_taxonomy/data_taxonomy.module                 |   25 +++++-----
 data_taxonomy/views/data_taxonomy.views.inc        |    6 +-
 .../data_taxonomy_views_handler_field_form.inc     |    2 +-
 ...ata_taxonomy_views_handler_field_item_count.inc |    7 ++-
 data_ui/data_ui.admin.inc                          |   52 ++++++++++----------
 data_ui/data_ui.module                             |   10 ++--
 data_ui/data_ui.views_default.inc                  |    2 +-
 includes/DataHandler.inc                           |   12 ++--
 tests/data.test.inc                                |    6 +-
 23 files changed, 101 insertions(+), 94 deletions(-)

diff --git a/data.install b/data.install
index 3b3af63..5a68b73 100644
--- a/data.install
+++ b/data.install
@@ -13,10 +13,10 @@ function data_schema() {
     'export' => array(
       'key' => 'name',
       'identifier' => 'data_table',
-      'default hook' => 'data_default',  // Function hook name.
+      'default hook' => 'data_default', // Function hook name.
       'api' => array(
         'owner' => 'data',
-        'api' => 'data_default',  // Base name for api include files.
+        'api' => 'data_default', // Base name for api include files.
         'minimum_version' => 1,
         'current_version' => 1,
       ),
diff --git a/data.module b/data.module
index 6aca77f..2be42dd 100644
--- a/data.module
+++ b/data.module
@@ -252,7 +252,7 @@ function data_get_index_definition($field_name, $spec) {
  * @todo: make overridable.
  */
 function data_name($table) {
-  return 'data_table_'. $table;
+  return 'data_table_' . $table;
 }
 
 /**
@@ -280,7 +280,7 @@ function data_safe_name($name) {
   if (is_numeric($simple)) {
     // We need to escape numerics because Drupal's drupal_write_record()
     // does not properly escape token MYSQL names.
-    $simple = '__num_'. $simple;
+    $simple = '__num_' . $simple;
   }
   return db_escape_table($simple);
 }
@@ -454,7 +454,7 @@ function _data_override($name) {
 function data_include($class) {
   static $included;
   if (!isset($included[$class])) {
-    include drupal_get_path('module', 'data') .'/includes/'. $class .'.inc';
+    include drupal_get_path('module', 'data') . '/includes/' . $class . '.inc';
     $included[$class] = TRUE;
   }
 }
@@ -462,4 +462,4 @@ function data_include($class) {
 /**
  * Base class for any exceptions thrown in Data.
  */
-class DataException extends Exception {}
+class DataException extends Exception { }
diff --git a/data.views.inc b/data.views.inc
index e6fdc13..1f012a5 100644
--- a/data.views.inc
+++ b/data.views.inc
@@ -6,7 +6,7 @@
 
 /**
  * Implementation of hook_views_data().
- * 
+ *
  * Dynamically create views integration for any table Data manages.
  */
 function data_views_data() {
@@ -26,7 +26,7 @@ function data_views_data() {
     $table_data = array();
     $table_data['table'] = array(
       'group' => $table->get('title'),
-      );
+    );
     foreach ($schema['fields'] as $field_name => $field) {
       // If there is no label, generate one from field name.
       $title = empty($meta['fields'][$field_name]['label']) ? data_natural_name($field_name) : $meta['fields'][$field_name]['label'];
@@ -61,7 +61,7 @@ function data_views_data() {
         'field' => current($schema['primary key']),
         'title' => $table->get('title'),
         'help' => t('Data table'),
-        'weight' => 10, 
+        'weight' => 10,
       );
     }
 
@@ -220,7 +220,7 @@ function data_get_views_handler($type, $table, $field_name, $default = FALSE) {
         case 'datetime':
           return 'views_handler_argument_date';
         case 'varchar':
-        return 'views_handler_argument_string';
+          return 'views_handler_argument_string';
       }
       return 'views_handler_argument';
 
diff --git a/data_node/data_node.admin.inc b/data_node/data_node.admin.inc
index 0280468..91c4751 100644
--- a/data_node/data_node.admin.inc
+++ b/data_node/data_node.admin.inc
@@ -47,4 +47,4 @@ function data_node_settings_form_submit($form, &$form_state) {
   $meta['data_node']['id'] = $form_state['values']['id'];
   $form['#table']->update(array('meta' => $meta));
   drupal_set_message(t('Settings saved.'));
-}
\ No newline at end of file
+}
diff --git a/data_node/data_node.install b/data_node/data_node.install
index 8b9b6c7..4020c4e 100644
--- a/data_node/data_node.install
+++ b/data_node/data_node.install
@@ -63,4 +63,4 @@ function data_node_update_6001() {
   $ret = array();
   db_add_index($ret, 'data_table_node', 'name_id', array('data_table_name', 'id'));
   return $ret;
-}
\ No newline at end of file
+}
diff --git a/data_node/data_node.module b/data_node/data_node.module
index b303acf..02a9232 100644
--- a/data_node/data_node.module
+++ b/data_node/data_node.module
@@ -10,7 +10,7 @@
 function data_node_views_api() {
   return array(
     'api' => '2.0',
-    'path' => drupal_get_path('module', 'data_node') .'/views',
+    'path' => drupal_get_path('module', 'data_node') . '/views',
   );
 }
 
@@ -55,7 +55,7 @@ function data_node_block($op = 'list', $delta = 0) {
         return array(
           'subject' => t('Active !type', array('!type' => $type_name)),
           'content' => drupal_get_form('data_node_active_form', $table),
-         );
+        );
       }
   }
 }
@@ -71,21 +71,21 @@ function data_node_menu() {
     'access callback' => 'user_access',
     'access arguments' => array('manage data relations'),
     'type' => MENU_CALLBACK,
-    );
+  );
   $items['data-node/remove/%data_ui_table/%/%/%'] = array(
     'page callback' => 'data_node_remove_page',
     'page arguments' => array(2, 3, 4, 5),
     'access callback' => 'user_access',
     'access arguments' => array('manage data relations'),
     'type' => MENU_CALLBACK,
-    );
+  );
   $items['data-node/active/%data_ui_table/%'] = array(
     'page callback' => 'data_node_active_page',
     'page arguments' => array(2, 3),
     'access callback' => 'user_access',
     'access arguments' => array('manage data relations'),
     'type' => MENU_CALLBACK,
-    );
+  );
   $items['admin/build/data/edit/%data_ui_table/node'] = array(
     'title' => 'Relate to nodes',
     'description' => 'Administer data tables.',
@@ -113,7 +113,6 @@ function data_node_active_form(&$form_state, $table) {
     '#attributes' => array('class' => 'data-node-active-form'),
     '#table' => $table,
     '#theme' => 'data_node_active_form',
-
     // These three are here to keep JS from doing reconstructive URL surgery.
     'ajax_url' => array(
       '#type' => 'hidden',
@@ -132,7 +131,7 @@ function data_node_active_form(&$form_state, $table) {
     ),
   );
 
-  $nodes = array(0 => '--'. t('Select') .'--');
+  $nodes = array(0 => '--' . t('Select') . '--');
   $nodes += data_node_get_nodes($table);
 
   // Grab the node type name and provide a creation option
@@ -140,7 +139,7 @@ function data_node_active_form(&$form_state, $table) {
   $names = node_get_types('names');
   $type_name = check_plain($names[$meta['data_node']['content_type']]);
   if (node_access('create', $meta['data_node']['content_type'])) {
-    $nodes['new'] = '< '. t('New !type', array('!type' => $type_name)) .' >';
+    $nodes['new'] = '< ' . t('New !type', array('!type' => $type_name)) . ' >';
   }
 
   $form['nid'] = array(
@@ -203,7 +202,7 @@ function data_node_active_form_create_submit($form, &$form_state) {
     $node->title = $title;
     $node->type = $form_state['values']['type'];
     $node->body = '';
-    foreach (variable_get('node_options_'. $node->type, array('status')) as $key) {
+    foreach (variable_get('node_options_' . $node->type, array('status')) as $key) {
       $node->{$key} = 1;
     }
     node_save($node);
@@ -239,7 +238,6 @@ function data_node_add_page($table, $id, $nid, $token) {
       'id' => $id,
       'nid' => $nid,
       'labels' => data_node_render_labels($table, $id),
-
       'add_link' => data_node_render_remove_link($table, $id, $nid),
       'remove_link' => data_node_render_add_link($table, $id, $nid),
     );
@@ -292,7 +290,6 @@ function data_node_remove_page($table, $id, $nid, $token) {
       'id' => $id,
       'nid' => $nid,
       'labels' => data_node_render_labels($table, $id),
-
       'add_link' => data_node_render_remove_link($table, $id, $nid),
       'remove_link' => data_node_render_add_link($table, $id, $nid),
     );
@@ -404,7 +401,7 @@ function data_node_add_path($table, $id, $nid) {
 function data_node_render_labels($table, $id) {
   $nids = data_node_get_nids($table, $id);
   foreach ($nids as $nid) {
-    $title = _data_node_get_title($nid);;
+    $title = _data_node_get_title($nid);
     $output .= theme('data_node_label', $table, $id, $nid, $title);
   }
   $table_name = $table->get('name');
diff --git a/data_node/data_node.theme.inc b/data_node/data_node.theme.inc
index 589d242..21f99de 100644
--- a/data_node/data_node.theme.inc
+++ b/data_node/data_node.theme.inc
@@ -28,7 +28,7 @@ function theme_data_node_active_form($form) {
 
   $output = '';
   $output .= drupal_render($form['nid']);
-  $output .= "<div class='new-node clear-block'>". drupal_render($form['new']) ."</div>";
+  $output .= "<div class='new-node clear-block'>" . drupal_render($form['new']) . "</div>";
   $output .= drupal_render($form);
   return $output;
 }
diff --git a/data_node/views/data_node.views.inc b/data_node/views/data_node.views.inc
index 58d493f..5604871 100644
--- a/data_node/views/data_node.views.inc
+++ b/data_node/views/data_node.views.inc
@@ -79,7 +79,7 @@ function data_node_views_data() {
 function data_node_views_handlers() {
   return array(
     'info' => array(
-      'path' => drupal_get_path('module', 'data_node') .'/views',
+      'path' => drupal_get_path('module', 'data_node') . '/views',
     ),
     'handlers' => array(
       // field handlers
@@ -94,4 +94,4 @@ function data_node_views_handlers() {
       ),
     ),
   );
-}
\ No newline at end of file
+}
diff --git a/data_node/views/data_node_views_handler_field_add_remove.inc b/data_node/views/data_node_views_handler_field_add_remove.inc
index b4e92d9..33b9767 100644
--- a/data_node/views/data_node_views_handler_field_add_remove.inc
+++ b/data_node/views/data_node_views_handler_field_add_remove.inc
@@ -7,7 +7,9 @@
 class data_node_views_handler_field_add_remove extends views_handler_field {
   protected $table_name, $id;
 
-  function allow_advanced_render() { return FALSE; }
+  function allow_advanced_render() {
+    return FALSE;
+  }
 
   function query() {
     $this->ensure_my_table();
diff --git a/data_node/views/data_node_views_handler_field_item_count.inc b/data_node/views/data_node_views_handler_field_item_count.inc
index cd3bcda..db14d59 100644
--- a/data_node/views/data_node_views_handler_field_item_count.inc
+++ b/data_node/views/data_node_views_handler_field_item_count.inc
@@ -5,7 +5,9 @@
  */
 
 class data_node_views_handler_field_item_count extends views_handler_field {
-  function query() { return; }
+  function query() {
+    return;
+  }
 
   function pre_render($result) {
     $this->items = array();
diff --git a/data_node/views/data_node_views_handler_field_node_list.inc b/data_node/views/data_node_views_handler_field_node_list.inc
index 412d30f..0533d76 100644
--- a/data_node/views/data_node_views_handler_field_node_list.inc
+++ b/data_node/views/data_node_views_handler_field_node_list.inc
@@ -5,9 +5,13 @@
  */
 
 class data_node_views_handler_field_node_list extends views_handler_field {
-  function allow_advanced_render() { return FALSE; }
+  function allow_advanced_render() {
+    return FALSE;
+  }
 
-  function query() { return; }
+  function query() {
+    return;
+  }
 
   function render($values) {
     if (user_access('manage data relations')) {
diff --git a/data_search/data_search.install b/data_search/data_search.install
index f5bbceb..4c56706 100644
--- a/data_search/data_search.install
+++ b/data_search/data_search.install
@@ -2,7 +2,7 @@
 
 /**
  * Implementation of hook_install().
- * 
+ *
  * @todo: Should use db_change_field()
  * @todo: What happens if data_search and search are installed at the same time?
  */
diff --git a/data_search/data_search.module b/data_search/data_search.module
index 52aeb49..fd5ae2c 100644
--- a/data_search/data_search.module
+++ b/data_search/data_search.module
@@ -73,7 +73,7 @@ function data_search_views_data_alter(&$data) {
  * Implementation of hook_update_index().
  */
 function data_search_update_index() {
-  $limit = (int)variable_get('search_cron_limit', 100);
+  $limit = (int) variable_get('search_cron_limit', 100);
 
   $tables = data_search_get_tables();
   foreach ($tables as $table) {
diff --git a/data_taxonomy/data_taxonomy.admin.inc b/data_taxonomy/data_taxonomy.admin.inc
index 139b6b7..84ea1df 100644
--- a/data_taxonomy/data_taxonomy.admin.inc
+++ b/data_taxonomy/data_taxonomy.admin.inc
@@ -53,4 +53,4 @@ function data_taxonomy_settings_form_submit($form, &$form_state) {
   $meta['data_taxonomy']['id'] = $form_state['values']['id'];
   $form['#table']->update(array('meta' => $meta));
   drupal_set_message(t('Settings saved.'));
-}
\ No newline at end of file
+}
diff --git a/data_taxonomy/data_taxonomy.module b/data_taxonomy/data_taxonomy.module
index e64ec45..c3b21a0 100644
--- a/data_taxonomy/data_taxonomy.module
+++ b/data_taxonomy/data_taxonomy.module
@@ -11,7 +11,7 @@
 function data_taxonomy_views_api() {
   return array(
     'api' => '2.0',
-    'path' => drupal_get_path('module', 'data_taxonomy') .'/views',
+    'path' => drupal_get_path('module', 'data_taxonomy') . '/views',
   );
 }
 
@@ -65,7 +65,7 @@ function data_taxonomy_feeds_data_processor_targets_alter(&$fields, $table_name)
   if ($info = data_taxonomy_get_info($table_name)) {
     foreach ($info['vocabularies'] as $vid) {
       $vocabulary = data_taxonomy_get_vocabulary($vid);
-      $fields['data_taxonomy:'. $vid] = array(
+      $fields['data_taxonomy:' . $vid] = array(
         'name' => t('Taxonomy: @vocabulary', array("@vocabulary" => $vocabulary->name)),
         'description' => t('Map to taxonomy terms of @vocabulary vocabulary.', array("@vocabulary" => $vocabulary->name)),
       );
@@ -80,8 +80,8 @@ function data_taxonomy_data_insert($record, $table_name) {
   if ($info = data_taxonomy_get_info($table_name)) {
     $id = $record[$info['id']];
     foreach ($info['vocabularies'] as $vid) {
-      if (isset($record['data_taxonomy:'. $vid])) {
-        _data_taxonomy_insert_terms($table_name, $id, $record['data_taxonomy:'. $vid], data_taxonomy_get_vocabulary($vid));
+      if (isset($record['data_taxonomy:' . $vid])) {
+        _data_taxonomy_insert_terms($table_name, $id, $record['data_taxonomy:' . $vid], data_taxonomy_get_vocabulary($vid));
       }
     }
   }
@@ -94,10 +94,10 @@ function data_taxonomy_data_update($record, $table_name) {
   if ($info = data_taxonomy_get_info($table_name)) {
     $id = $record[$info['id']];
     foreach ($info['vocabularies'] as $vid) {
-      if (isset($record['data_taxonomy:'. $vid])) {
+      if (isset($record['data_taxonomy:' . $vid])) {
         $vocabulary = data_taxonomy_get_vocabulary($vid);
         db_query("DELETE dt FROM {data_taxonomy} dt JOIN {term_data} td ON dt.tid = td.tid WHERE td.vid = %d", $vocabulary->vid);
-        _data_taxonomy_insert_terms($table_name, $id, $record['data_taxonomy:'. $vid], $vocabulary);
+        _data_taxonomy_insert_terms($table_name, $id, $record['data_taxonomy:' . $vid], $vocabulary);
       }
     }
   }
@@ -107,7 +107,7 @@ function data_taxonomy_data_update($record, $table_name) {
  * Implementation of hook_taxonomy().
  */
 function data_taxonomy_taxonomy($op = NULL, $type = NULL, $term = NULL) {
-  if ($type =='term' && $term['tid'] && $op == 'delete') {
+  if ($type == 'term' && $term['tid'] && $op == 'delete') {
     db_query("DELETE FROM {data_taxonomy} WHERE tid = %d", $term['tid']);
   }
 }
@@ -140,7 +140,7 @@ function _data_taxonomy_insert_terms($table_name, $id, $terms, $vocabulary) {
     }
     else {
       if (is_object($term)) {
-        $term = (array)$term;
+        $term = (array) $term;
       }
       if (is_array($term)) {
         $term['name'] = data_taxonomy_sanitize($term['name'], $vocabulary->vid);
@@ -223,7 +223,7 @@ function data_taxonomy_tagging_form(&$form_state, $vid, $id, $table_name, $path,
   $form['tags'] = array(
     '#type' => 'textfield',
     '#default_value' => implode(', ', $tags),
-    '#autocomplete_path' => 'taxonomy/autocomplete/'. $vid,
+    '#autocomplete_path' => 'taxonomy/autocomplete/' . $vid,
     '#id' => "edit-tags-data-taxonomy-{$vid}-{$id}",
     '#access' => $access,
   );
@@ -240,7 +240,6 @@ function data_taxonomy_tagging_form(&$form_state, $vid, $id, $table_name, $path,
     '#type' => 'submit',
     '#value' => t('Save'),
     '#access' => $access,
-
     // AHAH stack: We need to assign our submit button its own ID as auto
     // assignment will quickly lead to a situation where our AJAX form button
     // has a different ID from the original.
@@ -360,7 +359,7 @@ function data_taxonomy_lookup_term($name, $vid) {
   if (!isset($terms[$vid][$name])) {
     foreach (data_taxonomy_get_term_by_name_vid($name, $vid) as $term) {
       if ($term->vid == $vid) {
-        $terms[$vid][$name] = (array)$term;
+        $terms[$vid][$name] = (array) $term;
       }
     }
   }
@@ -486,8 +485,8 @@ function _data_taxonomy_replace_tokens($path, $args) {
  * Preprocessor for theme('data_taxonomy_tagging_form').
  */
 function template_preprocess_data_taxonomy_tagging_form(&$vars) {
-  drupal_add_js(drupal_get_path('module', 'data_taxonomy') .'/theme/data_taxonomy.js');
-  drupal_add_css(drupal_get_path('module', 'data_taxonomy') .'/theme/data_taxonomy.css');
+  drupal_add_js(drupal_get_path('module', 'data_taxonomy') . '/theme/data_taxonomy.js');
+  drupal_add_css(drupal_get_path('module', 'data_taxonomy') . '/theme/data_taxonomy.css');
   $vars['label'] = $vars['form']['#vocab']->name;
   if ($vars['form']['#edit']) {
     $vars['edit'] = $vars['form']['#edit'];
diff --git a/data_taxonomy/views/data_taxonomy.views.inc b/data_taxonomy/views/data_taxonomy.views.inc
index 7d090e5..26c8173 100644
--- a/data_taxonomy/views/data_taxonomy.views.inc
+++ b/data_taxonomy/views/data_taxonomy.views.inc
@@ -65,7 +65,7 @@ function data_taxonomy_views_data() {
         'field' => 'tid',
       );
       // don't want to overwrite any other relationships this might have...
-      $data[$table->get('name')]['data_taxonomy_'. $meta['data_taxonomy']['id']]['relationship'] = array(
+      $data[$table->get('name')]['data_taxonomy_' . $meta['data_taxonomy']['id']]['relationship'] = array(
         'title' => t('Term tid.'),
         'help' => t('Relate a data record to a term tid.'),
         'label' => t('Relate a data record to a term tid.'),
@@ -105,7 +105,7 @@ function data_taxonomy_views_data_alter(&$data) {
 function data_taxonomy_views_handlers() {
   return array(
     'info' => array(
-      'path' => drupal_get_path('module', 'data_taxonomy') .'/views',
+      'path' => drupal_get_path('module', 'data_taxonomy') . '/views',
     ),
     'handlers' => array(
       'data_taxonomy_views_handler_field_form' => array(
@@ -116,4 +116,4 @@ function data_taxonomy_views_handlers() {
       ),
     ),
   );
-}
\ No newline at end of file
+}
diff --git a/data_taxonomy/views/data_taxonomy_views_handler_field_form.inc b/data_taxonomy/views/data_taxonomy_views_handler_field_form.inc
index 4d1a9aa..dfae1d5 100644
--- a/data_taxonomy/views/data_taxonomy_views_handler_field_form.inc
+++ b/data_taxonomy/views/data_taxonomy_views_handler_field_form.inc
@@ -85,4 +85,4 @@ class data_taxonomy_views_handler_field_form extends views_handler_field {
   function label() {
     return '';
   }
-}
\ No newline at end of file
+}
diff --git a/data_taxonomy/views/data_taxonomy_views_handler_field_item_count.inc b/data_taxonomy/views/data_taxonomy_views_handler_field_item_count.inc
index 31af56c..ad4b84a 100644
--- a/data_taxonomy/views/data_taxonomy_views_handler_field_item_count.inc
+++ b/data_taxonomy/views/data_taxonomy_views_handler_field_item_count.inc
@@ -5,7 +5,9 @@
  */
 
 class data_taxonomy_views_handler_field_item_count extends views_handler_field {
-  function query() { return; }
+  function query() {
+    return;
+  }
 
   function pre_render($result) {
     $this->items = array();
@@ -14,7 +16,8 @@ class data_taxonomy_views_handler_field_item_count extends views_handler_field {
         $tid = $row->{$this->view->base_field};
         if ($this->view->base_table == 'node') {
           $this->items[$tid] = db_result(db_query("SELECT COUNT(DISTINCT dt.id) AS count FROM {node} n LEFT JOIN {term_node} tn ON tn.nid = n.nid LEFT JOIN {data_taxonomy} dt ON dt.tid = tn.tid WHERE n.nid = %d", $tid));
-        } else {
+        }
+        else {
           $this->items[$tid] = db_result(db_query("SELECT COUNT(id) AS count FROM {data_taxonomy} WHERE tid = %d", $tid));
         }
       }
diff --git a/data_ui/data_ui.admin.inc b/data_ui/data_ui.admin.inc
index aed075d..bb9cc03 100644
--- a/data_ui/data_ui.admin.inc
+++ b/data_ui/data_ui.admin.inc
@@ -14,7 +14,7 @@ function data_ui_view() {
     $row = array(
       $table->get('title'),
       $table->get('name'),
-      db_result(db_query('SELECT COUNT(*) FROM {'. db_escape_table($table->get('name')) .'}')),
+      db_result(db_query('SELECT COUNT(*) FROM {' . db_escape_table($table->get('name')) . '}')),
     );
     if (module_exists('views')) {
       $row[] = l(t('View'), data_ui_get_default_path($table->get('name')));
@@ -39,20 +39,20 @@ function data_ui_manage() {
     $operations = array();
     if ($table->get('export_type') == EXPORT_IN_CODE) {
       $status = t('Default');
-      $operations[] = l(t('Override'), 'admin/build/data/edit/'. $table->get('name'));
+      $operations[] = l(t('Override'), 'admin/build/data/edit/' . $table->get('name'));
     }
     else if ($table->get('export_type') == (EXPORT_IN_CODE | EXPORT_IN_DATABASE)) {
       $status = t('Overridden');
-      $operations[] = l(t('Edit'), 'admin/build/data/edit/'. $table->get('name'));
-      $operations[] = l(t('Revert'), 'admin/build/data/revert/'. $table->get('name'));
+      $operations[] = l(t('Edit'), 'admin/build/data/edit/' . $table->get('name'));
+      $operations[] = l(t('Revert'), 'admin/build/data/revert/' . $table->get('name'));
     }
     else {
       $status = t('Normal');
-      $operations[] = l(t('Edit'), 'admin/build/data/edit/'. $table->get('name'));
-      $operations[] = l(t('Drop'), 'admin/build/data/drop/'. $table->get('name'));
+      $operations[] = l(t('Edit'), 'admin/build/data/edit/' . $table->get('name'));
+      $operations[] = l(t('Drop'), 'admin/build/data/drop/' . $table->get('name'));
     }
     if (module_exists('ctools')) {
-      $operations[] = l(t('Export'), 'admin/build/data/export/'. $table->get('name'));
+      $operations[] = l(t('Export'), 'admin/build/data/export/' . $table->get('name'));
     }
 
     $row = array();
@@ -85,7 +85,7 @@ function data_ui_compare() {
     $row[] = $table->get('name');
     $status = $comp['status'];
     if ($status != 'same') {
-      $status .= ' - '. l(t('adjust'), 'admin/build/data/compare/'. $table->get('name'));
+      $status .= ' - ' . l(t('adjust'), 'admin/build/data/compare/' . $table->get('name'));
     }
     $row[] = $status;
     $row[] = empty($comp['warning']) ? '-' : $comp['warning'];
@@ -121,7 +121,7 @@ function data_ui_adjust_form(&$form_state, $table) {
     $form['update_schema'] = array(
       '#type' => 'fieldset',
       '#title' => t('Option 1: Update schema information'),
-      );
+    );
     $form['update_schema']['description'] = array(
       '#value' => t('<p>This option will update the schema information about this table.</p>'),
     );
@@ -133,7 +133,7 @@ function data_ui_adjust_form(&$form_state, $table) {
     $form['alter_table'] = array(
       '#type' => 'fieldset',
       '#title' => t('Option 2: Alter table'),
-      );
+    );
     $form['alter_table']['description'] = array(
       '#value' => t('<p>Review the changes above carefully!
         This option will alter the database table and can very
@@ -149,7 +149,7 @@ function data_ui_adjust_form(&$form_state, $table) {
     $form['alter_table'] = array(
       '#type' => 'fieldset',
       '#title' => t('Create table'),
-      );
+    );
     $form['alter_table']['description'] = array(
       '#value' => t('<p>Create a new table from schema information.</p>'),
     );
@@ -162,7 +162,7 @@ function data_ui_adjust_form(&$form_state, $table) {
   $form['cancel'] = array(
     '#type' => 'fieldset',
     '#title' => t('Don\'t change anything'),
-    );
+  );
   $form['cancel']['cancel'] = array(
     '#type' => 'submit',
     '#value' => t('Cancel'),
@@ -315,7 +315,7 @@ function data_ui_create_form(&$form_state) {
       '#tree' => TRUE,
     );
     for ($i = 0; $i < $form_state['storage']['field_num']; $i++) {
-      $form['fields']['field_'. $i] = _data_ui_field_form(TRUE);
+      $form['fields']['field_' . $i] = _data_ui_field_form(TRUE);
     }
     $form['submit'] = array(
       '#type' => 'submit',
@@ -502,12 +502,12 @@ function data_ui_edit_form(&$form_state, $table) {
         '#default_value' => isset($schema['primary key']) ? in_array($field_name, $schema['primary key']) : FALSE,
       );
       if (isset($meta['join']) && $join = _data_ui_get_join($meta['join'], $field_name)) {
-        $join = $join['left_table'] .'.'. $join['left_field'];
+        $join = $join['left_table'] . '.' . $join['left_field'];
       }
       else {
         $join = t('<none>');
       }
-      $join = l($join, 'admin/build/data/edit/'. $table->get('name') .'/join/'.$field_name);
+      $join = l($join, 'admin/build/data/edit/' . $table->get('name') . '/join/' . $field_name);
       $form['fields'][$field_name]['join']['#value'] = $join;
     }
   }
@@ -517,11 +517,11 @@ function data_ui_edit_form(&$form_state, $table) {
   $form['new']['primary'] = array(
     '#type' => 'markup',
     '#value' => '&nbsp;',
-    );
+  );
   $form['new']['join'] = array(
     '#type' => 'markup',
     '#value' => '&nbsp;',
-    );
+  );
   $form['new']['add'] = array(
     '#type' => 'submit',
     '#value' => t('Add new'),
@@ -742,7 +742,7 @@ function data_ui_join_form(&$form_state, $table, $field_name) {
   // Validate input.
   if (!isset($field_name) || !isset($schema['fields'][$field_name])) {
     drupal_set_message(t('Invalid field.'), 'error');
-    drupal_goto('admin/build/data/edit/'. $table->get('name'));
+    drupal_goto('admin/build/data/edit/' . $table->get('name'));
   }
 
   // List all tables that schema API knows about as optoins.
@@ -753,7 +753,7 @@ function data_ui_join_form(&$form_state, $table, $field_name) {
   foreach ($table_schemas as $table_name => $schema) {
     if ($table->get('name') != $table_name) {
       foreach ($schema['fields'] as $name => $info) {
-        $options[$table_name][$table_name .'.'. $name] = $table_name .'.'. $name;
+        $options[$table_name][$table_name . '.' . $name] = $table_name . '.' . $name;
       }
     }
   }
@@ -762,14 +762,14 @@ function data_ui_join_form(&$form_state, $table, $field_name) {
   $form = array();
   $form['#table'] = $table;
   $form['#field_name'] = $field_name;
-  $form['#redirect'] = 'admin/build/data/edit/'. $table->get('name');
+  $form['#redirect'] = 'admin/build/data/edit/' . $table->get('name');
   $join = _data_ui_get_join($meta['join'], $field_name);
   $form['#original_join'] = $join;
   $form['left'] = array(
     '#type' => 'select',
-    '#title' => t('Join !table_field to', array('!table_field' => $table->get('name') .'.'. $field_name)),
+    '#title' => t('Join !table_field to', array('!table_field' => $table->get('name') . '.' . $field_name)),
     '#options' => $options,
-    '#default_value' => $join['left_table'] .'.'. $join['left_field'],
+    '#default_value' => $join['left_table'] . '.' . $join['left_field'],
   );
   $form['inner_join'] = array(
     '#type' => 'radios',
@@ -781,7 +781,7 @@ function data_ui_join_form(&$form_state, $table, $field_name) {
   // Use confirm form for its formatting.
   $form = confirm_form($form,
     t('Join field'),
-    'admin/build/data/edit/'. $table->get('name'),
+    'admin/build/data/edit/' . $table->get('name'),
     '',
     t('Save'), t('Cancel')
   );
@@ -833,10 +833,10 @@ function data_ui_export_form(&$form_state, $table) {
  */
 function data_ui_view_schema($table) {
   drupal_set_title($table->get('title'));
-  $output = '<H3>'. t('Schema') .'</H3>';
+  $output = '<H3>' . t('Schema') . '</H3>';
   $output .= kprint_r($table->get('table_schema'), TRUE);
   if ($meta = $table->get('meta')) {
-    $output .= '<H3>'. t('Meta info') .'</H3>';
+    $output .= '<H3>' . t('Meta info') . '</H3>';
     $output .= kprint_r($table->get('meta'), TRUE);
   }
   return $output;
@@ -930,7 +930,7 @@ function theme_data_ui_schema_compare_table($comparison) {
     if (!empty($v)) {
       if (is_string($k)) {
         $output .= '<dl>';
-        $output .= '<dt>'. ucfirst($k) .':</dt>';
+        $output .= '<dt>' . ucfirst($k) . ':</dt>';
         $output .= '<dd>';
         if (is_string($v)) {
           $output .= $v;
diff --git a/data_ui/data_ui.module b/data_ui/data_ui.module
index 42fcefe..0d74b77 100644
--- a/data_ui/data_ui.module
+++ b/data_ui/data_ui.module
@@ -10,17 +10,17 @@
 function data_ui_help($path, $arg) {
   switch ($path) {
     case 'admin/content/data':
-      $output = '<p>'. t('View content in data tables. If you would like to edit these tables, visit the !data_manage_page.', array('!data_manage_page' => l(t('Data table management page'), 'admin/build/data'))) .'</p>';
+      $output = '<p>' . t('View content in data tables. If you would like to edit these tables, visit the !data_manage_page.', array('!data_manage_page' => l(t('Data table management page'), 'admin/build/data'))) . '</p>';
       return $output;
     case 'admin/build/data/adopt':
       $output = '<p>' . t('Manage database tables that aren\'t claimed by other modules. Adopting tables listed here will add them to Data\'s list of tables.') . '</p>';
       return $output;
     case 'admin/build/data':
       if (module_exists('views')) {
-        $output = '<p>'. t('Manage data tables. If you would like to view the content of these tables, visit the !data_view_page.', array('!data_view_page' => l(t('Data table content page'), 'admin/content/data'))) .'</p>';
+        $output = '<p>' . t('Manage data tables. If you would like to view the content of these tables, visit the !data_view_page.', array('!data_view_page' => l(t('Data table content page'), 'admin/content/data'))) . '</p>';
       }
       else {
-        $output = '<p>'. t('Manage data tables.') .'</p>';
+        $output = '<p>' . t('Manage data tables.') . '</p>';
       }
       return $output;
   }
@@ -239,10 +239,10 @@ function data_ui_get_default_path($name) {
     if (isset($meta['join']) && is_array($meta['join'])) {
       $left_table_name = key($meta['join']);
       if ($left_table = data_get_table($left_table_name)) {
-        $path .= $left_table_name .'/';
+        $path .= $left_table_name . '/';
       }
     }
-    return 'admin/content/data/view/'. $path . $name;
+    return 'admin/content/data/view/' . $path . $name;
   }
   return '';
 }
diff --git a/data_ui/data_ui.views_default.inc b/data_ui/data_ui.views_default.inc
index cecbcc9..be37d70 100644
--- a/data_ui/data_ui.views_default.inc
+++ b/data_ui/data_ui.views_default.inc
@@ -68,7 +68,7 @@ function data_ui_views_default_views() {
         'style_options' => array(),
         'wildcard' => 'all',
         'wildcard_substitution' => 'All',
-        'title' => $table->get('title') .' %1',
+        'title' => $table->get('title') . ' %1',
         'id' => $first,
         'table' => $table->get('name'),
         'field' => $first,
diff --git a/includes/DataHandler.inc b/includes/DataHandler.inc
index ec3c3c0..73b0d46 100644
--- a/includes/DataHandler.inc
+++ b/includes/DataHandler.inc
@@ -53,12 +53,12 @@ class DataHandler {
       if (!isset($fields[$key]['type'])) {
         return FALSE;
       }
-      $where[] = db_escape_string($key) ." = ". db_type_placeholder($fields[$key]['type']);
+      $where[] = db_escape_string($key) . " = " . db_type_placeholder($fields[$key]['type']);
       $values[] = $value;
     }
 
     if (!empty($where)) {
-      $result = db_query('SELECT * FROM {'. db_escape_table($this->table) .'} WHERE '. implode(' AND ', $where), $values);
+      $result = db_query('SELECT * FROM {' . db_escape_table($this->table) . '} WHERE ' . implode(' AND ', $where), $values);
       $results = array();
       while ($row = db_fetch_array($result)) {
         $results[] = $row;
@@ -159,7 +159,7 @@ class DataHandler {
         $operator = array_shift($value);
         $value = array_shift($value);
       }
-      $query->addWhere(db_escape_table($this->table) .'.'. db_escape_string($key) ." ". $operator ." ". db_type_placeholder($fields[$key]['type']), $value);
+      $query->addWhere(db_escape_table($this->table) . '.' . db_escape_string($key) . " " . $operator . " " . db_type_placeholder($fields[$key]['type']), $value);
     }
     drupal_alter('data_delete_query', $query, $this->table);
     if (!empty($query->where)) {
@@ -172,7 +172,7 @@ class DataHandler {
    * Empty data table.
    */
   public function truncate() {
-    db_query('TRUNCATE TABLE {'. db_escape_table($this->table) .'}');
+    db_query('TRUNCATE TABLE {' . db_escape_table($this->table) . '}');
   }
 }
 
@@ -238,7 +238,7 @@ class DataQuery {
    */
   public function execute() {
     $table = db_escape_table($this->table);
-    $query = "DELETE ". implode(', ', $this->subject);
+    $query = "DELETE " . implode(', ', $this->subject);
     $query .= " FROM {{$table}} {$table}";
     if (!empty($this->join)) {
       foreach ($this->join as $table => $join) {
@@ -256,7 +256,7 @@ class DataQuery {
       }
     }
     if (!empty($where)) {
-      $query .= " WHERE ". implode(' AND ', $where);
+      $query .= " WHERE " . implode(' AND ', $where);
     }
     return db_query($query, $values);
   }
diff --git a/tests/data.test.inc b/tests/data.test.inc
index 9489b3b..23951aa 100644
--- a/tests/data.test.inc
+++ b/tests/data.test.inc
@@ -8,7 +8,7 @@
  * Base class for Data module test cases.
  */
 class DataTestCase extends DrupalWebTestCase {
-  
+
   /**
    * Return a test schema.
    */
@@ -35,7 +35,7 @@ class DataTestCase extends DrupalWebTestCase {
       ),
       'indexes' => array(
         'id' => array('id'),
-       ),
+      ),
     );
   }
 
@@ -56,4 +56,4 @@ class DataTestCase extends DrupalWebTestCase {
       ),
     );
   }
-}
\ No newline at end of file
+}
-- 
1.7.0.3


From fb5547d7de83a35d7ca731b5e3315eb40be4ff04 Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Fri, 11 Nov 2011 10:38:59 +0000
Subject: [PATCH 02/13] Applied Coder upgrade Core API conversion.

---
 data.info                                          |    2 +-
 data.install                                       |   30 ++++--
 data.module                                        |    8 +-
 data.views.inc                                     |    4 +-
 data_node/data_node.admin.inc                      |    4 +-
 data_node/data_node.info                           |    2 +-
 data_node/data_node.install                        |   19 ++--
 data_node/data_node.module                         |  112 ++++++++++++--------
 data_node/data_node.theme.inc                      |   11 ++-
 data_node/views/data_node.views.inc                |    4 +-
 .../data_node_views_handler_field_item_count.inc   |    2 +-
 data_search/data_search.admin.inc                  |    9 +-
 data_search/data_search.info                       |    2 +-
 data_search/data_search.install                    |    8 ++-
 data_search/data_search.module                     |   38 +++++--
 data_taxonomy/data_taxonomy.admin.inc              |    2 +-
 data_taxonomy/data_taxonomy.info                   |    3 +-
 data_taxonomy/data_taxonomy.install                |   12 ++-
 data_taxonomy/data_taxonomy.module                 |   74 +++++++++-----
 data_taxonomy/views/data_taxonomy.views.inc        |   20 ++--
 ...ata_taxonomy_views_handler_field_item_count.inc |    4 +-
 data_ui/data_ui.admin.inc                          |  103 ++++++++++---------
 data_ui/data_ui.info                               |    2 +-
 data_ui/data_ui.module                             |   63 ++++++-----
 data_ui/data_ui.views_default.inc                  |    2 +-
 data_ui/tests/data_ui_test.info                    |    4 +-
 data_ui/tests/data_ui_test.install                 |   13 ++-
 data_ui/tests/data_ui_test.module                  |    4 +-
 includes/DataHandler.inc                           |    3 +
 includes/DataTable.inc                             |   34 ++++---
 views/views_handler_field_data_markup.inc          |    2 +-
 31 files changed, 357 insertions(+), 243 deletions(-)

diff --git a/data.info b/data.info
index dfc063a..9987d66 100644
--- a/data.info
+++ b/data.info
@@ -2,4 +2,4 @@ name = Data
 description = Provides two dimensional storage space for arbitrary data sets.
 package = Data
 dependencies[] = ctools
-core = 6.x
\ No newline at end of file
+core = 7.x
diff --git a/data.install b/data.install
index 5a68b73..6e29a25 100644
--- a/data.install
+++ b/data.install
@@ -5,7 +5,7 @@
  */
 
 /**
- * Implementation of hook_schema().
+ * Implements hook_schema().
  */
 function data_schema() {
   $schema['data_tables'] = array(
@@ -55,19 +55,21 @@ function data_schema() {
 }
 
 /**
- * Implementation of hook_install().
+ * Implements hook_install().
  */
 function data_install() {
   // Create tables.
-  drupal_install_schema('data');
+  // TODO The drupal_(un)install_schema functions are called automatically in D7.
+  // drupal_install_schema('data')
 }
 
 /**
- * Implementation of hook_uninstall().
+ * Implements hook_uninstall().
  */
 function data_uninstall() {
   // Remove tables.
-  drupal_uninstall_schema('data');
+  // TODO The drupal_(un)install_schema functions are called automatically in D7.
+  // drupal_uninstall_schema('data')
 }
 
 /**
@@ -81,8 +83,11 @@ function data_update_6001() {
       $table->link($row->left_table, $row->left_field, $row->right_field, $row->inner_join ? TRUE : FALSE);
     }
   }
-  db_drop_table($ret, 'data_join');
-  return $ret;
+  db_drop_table('data_join');
+  // hook_update_N() no longer returns a $ret array. Instead, return
+  // nothing or a translated string indicating the update ran successfully.
+  // See http://drupal.org/node/224333#update_sql.
+  return t('TODO Add a descriptive string here to show in the UI.') /* $ret */;
 }
 
 /**
@@ -90,7 +95,7 @@ function data_update_6001() {
  */
 function data_update_6002() {
   $ret = array();
-  db_drop_index($ret, 'data_tables', 'name');
+  db_drop_index('data_tables', 'name');
   $spec = array(
     'type' => 'varchar',
     'length' => '128',
@@ -98,13 +103,16 @@ function data_update_6002() {
     'default' => '',
     'description' => 'Table name.',
   );
-  db_change_field($ret, 'data_tables', 'name', 'name', $spec);
-  db_add_primary_key($ret, 'data_tables', array('name'));
+  db_change_field('data_tables', 'name', 'name', $spec);
+  db_add_primary_key('data_tables', array('name'));
   // reset cTools static cache of this table; otherwise it throws an error about
   // lacking a primary key, which just adds insult to injury as we're trying to fix that!
   drupal_get_schema('data_tables', TRUE);
   if (function_exists('ctools_static_reset')) {
     ctools_static_reset('ctools_export_get_schema');
   }
-  return $ret;
+  // hook_update_N() no longer returns a $ret array. Instead, return
+  // nothing or a translated string indicating the update ran successfully.
+  // See http://drupal.org/node/224333#update_sql.
+  return t('TODO Add a descriptive string here to show in the UI.') /* $ret */;
 }
diff --git a/data.module b/data.module
index 2be42dd..ab44279 100644
--- a/data.module
+++ b/data.module
@@ -5,7 +5,7 @@
  */
 
 /**
- * Implementation of hook_views_api().
+ * Implements hook_views_api().
  */
 function data_views_api() {
   return array(
@@ -15,7 +15,7 @@ function data_views_api() {
 }
 
 /**
- * Implementation of hook_schema_alter().
+ * Implements hook_schema_alter().
  *
  * This is a central piece of data module:
  * Here we tack schema information that has been defined through the API in data_tables
@@ -441,7 +441,7 @@ function data_alter_table($table, $field_reason) {
  * data_tables.
  */
 function _data_override($name) {
-  if (!db_result(db_query("SELECT name FROM {data_tables} WHERE name = '%s'", $name))) {
+  if (!db_query("SELECT name FROM {data_tables} WHERE name = :name", array(':name' => $name))->fetchField()) {
     if ($table = _data_load_table($name)) {
       drupal_write_record('data_tables', $table);
     }
@@ -454,7 +454,7 @@ function _data_override($name) {
 function data_include($class) {
   static $included;
   if (!isset($included[$class])) {
-    include drupal_get_path('module', 'data') . '/includes/' . $class . '.inc';
+    include DRUPAL_ROOT . '/' . drupal_get_path('module', 'data') . '/includes/' . $class . '.inc';
     $included[$class] = TRUE;
   }
 }
diff --git a/data.views.inc b/data.views.inc
index 1f012a5..80a9e4a 100644
--- a/data.views.inc
+++ b/data.views.inc
@@ -5,7 +5,7 @@
  */
 
 /**
- * Implementation of hook_views_data().
+ * Implements hook_views_data().
  *
  * Dynamically create views integration for any table Data manages.
  */
@@ -92,7 +92,7 @@ function data_views_data() {
 }
 
 /**
- * Implementation of hook_views_handlers().
+ * Implements hook_views_handlers().
  */
 function data_views_handlers() {
   return array(
diff --git a/data_node/data_node.admin.inc b/data_node/data_node.admin.inc
index 91c4751..6a79143 100644
--- a/data_node/data_node.admin.inc
+++ b/data_node/data_node.admin.inc
@@ -7,12 +7,12 @@
 /**
  * Form callback for relating a data table to a node.
  */
-function data_node_settings_form(&$form_state, $table) {
+function data_node_settings_form($form, &$form_state, $table) {
   drupal_set_title($table->get('title'));
 
   $form = array();
   $content_types = array('' => t('None'));
-  $content_types += node_get_types('names');
+  $content_types += node_type_get_names();
   $meta = $table->get('meta');
   $form['#table'] = $table;
   $form['content_type'] = array(
diff --git a/data_node/data_node.info b/data_node/data_node.info
index 6a0b530..4820734 100644
--- a/data_node/data_node.info
+++ b/data_node/data_node.info
@@ -3,4 +3,4 @@ description = Relate data tables to nodes.
 package = Data
 dependencies[] = data
 dependencies[] = data_ui
-core = 6.x
\ No newline at end of file
+core = 7.x
diff --git a/data_node/data_node.install b/data_node/data_node.install
index 4020c4e..d61e201 100644
--- a/data_node/data_node.install
+++ b/data_node/data_node.install
@@ -5,7 +5,7 @@
  */
 
 /**
- * Implementation of hook_schema().
+ * Implements hook_schema().
  */
 function data_node_schema() {
   $schema = array();
@@ -43,17 +43,19 @@ function data_node_schema() {
 }
 
 /**
- * Implementation of hook_install().
+ * Implements hook_install().
  */
 function data_node_install() {
-  drupal_install_schema('data_node');
+  // TODO The drupal_(un)install_schema functions are called automatically in D7.
+  // drupal_install_schema('data_node')
 }
 
 /**
- * Implementation of hook_uninstall().
+ * Implements hook_uninstall().
  */
 function data_node_uninstall() {
-  drupal_uninstall_schema('data_node');
+  // TODO The drupal_(un)install_schema functions are called automatically in D7.
+  // drupal_uninstall_schema('data_node')
 }
 
 /**
@@ -61,6 +63,9 @@ function data_node_uninstall() {
  */
 function data_node_update_6001() {
   $ret = array();
-  db_add_index($ret, 'data_table_node', 'name_id', array('data_table_name', 'id'));
-  return $ret;
+  db_add_index('data_table_node', 'name_id', array('data_table_name', 'id'));
+  // hook_update_N() no longer returns a $ret array. Instead, return
+  // nothing or a translated string indicating the update ran successfully.
+  // See http://drupal.org/node/224333#update_sql.
+  return t('TODO Add a descriptive string here to show in the UI.') /* $ret */;
 }
diff --git a/data_node/data_node.module b/data_node/data_node.module
index 02a9232..ac1fe1a 100644
--- a/data_node/data_node.module
+++ b/data_node/data_node.module
@@ -5,7 +5,7 @@
  */
 
 /**
- * Implementation of hook_views_api().
+ * Implements hook_views_api().
  */
 function data_node_views_api() {
   return array(
@@ -15,53 +15,60 @@ function data_node_views_api() {
 }
 
 /**
- * Implementation of hook_theme().
+ * Implements hook_theme().
  */
 function data_node_theme() {
   return array(
     'data_node_label' => array(
-      'arguments' => array('table' => NULL, 'id' => NULL, 'nid' => NULL, 'title' => NULL),
+      'variables' => array('table' => NULL, 'id' => NULL, 'nid' => NULL, 'title' => NULL),
       'file' => 'data_node.theme.inc',
     ),
     'data_node_active_form' => array(
-      'arguments' => array('form' => array()),
+      'render element' => 'form',
       'file' => 'data_node.theme.inc',
     ),
   );
 }
 
 /**
- * Implementation of hook_block().
+ * Implements hook_block_info().
  */
-function data_node_block($op = 'list', $delta = 0) {
-  switch ($op) {
-    case 'list':
-      $blocks = array();
-      $tables = data_get_all_tables();
-      foreach ($tables as $table) {
-        $meta = $table->get('meta');
-        if (!empty($meta['data_node']['content_type'])) {
-          $blocks[$table->get('name')]['info'] = t('Data node: Active node form for !table', array('!table' => $table->get('title')));
-        }
-      }
-      return $blocks;
-    case 'view':
-      if (user_access('manage data relations') && $table = data_get_table($delta)) {
-        // Grab the node type name
-        $meta = $table->get('meta');
-        $names = node_get_types('names');
-        $type_name = check_plain($names[$meta['data_node']['content_type']]);
-
-        return array(
-          'subject' => t('Active !type', array('!type' => $type_name)),
-          'content' => drupal_get_form('data_node_active_form', $table),
-        );
-      }
+function data_node_block_info() {
+  $blocks = array();
+  $tables = data_get_all_tables();
+  foreach ($tables as $table) {
+    $meta = $table->get('meta');
+    if (!empty($meta['data_node']['content_type'])) {
+      $blocks[$table->get('name')]['info'] = t('Data node: Active node form for !table', array('!table' => $table->get('title')));
+    }
+  }
+  return $blocks;
+}
+
+/**
+ * Implements hook_block_view().
+ */
+function data_node_block_view($delta) {
+  if (user_access('manage data relations') && $table = data_get_table($delta)) {
+    // Grab the node type name
+    $meta = $table->get('meta');
+    $names = node_type_get_names();
+    $type_name = check_plain($names[$meta['data_node']['content_type']]);
+
+    return array(
+      'subject' => t('Active !type', array('!type' => $type_name)),
+      'content' => drupal_get_form('data_node_active_form', $table),
+    );
   }
 }
 
 /**
- * Implementation of hook_menu().
+ * Implements hook_block().
+ */
+function data_node_block_OLD($op = 'list', $delta = 0) { }
+
+/**
+ * Implements hook_menu().
  */
 function data_node_menu() {
   $items = array();
@@ -86,7 +93,7 @@ function data_node_menu() {
     'access arguments' => array('manage data relations'),
     'type' => MENU_CALLBACK,
   );
-  $items['admin/build/data/edit/%data_ui_table/node'] = array(
+  $items['admin/structure/data/edit/%data_ui_table/node'] = array(
     'title' => 'Relate to nodes',
     'description' => 'Administer data tables.',
     'page callback' => 'drupal_get_form',
@@ -99,16 +106,21 @@ function data_node_menu() {
 }
 
 /**
- * Implementation of hook_perm().
+ * Implements hook_permission().
  */
-function data_node_perm() {
-  return array('edit data node relations');
+function data_node_permission() {
+  return array(
+    'edit data node relations' => array(
+      'title' => t('edit data node relations'),
+      'description' => t('TODO Add a description for \'edit data node relations\''),
+    ),
+  );
 }
 
 /**
  * Form callback for setting the active node.
  */
-function data_node_active_form(&$form_state, $table) {
+function data_node_active_form($form, &$form_state, $table) {
   $form = array(
     '#attributes' => array('class' => 'data-node-active-form'),
     '#table' => $table,
@@ -136,7 +148,7 @@ function data_node_active_form(&$form_state, $table) {
 
   // Grab the node type name and provide a creation option
   $meta = $table->get('meta');
-  $names = node_get_types('names');
+  $names = node_type_get_names();
   $type_name = check_plain($names[$meta['data_node']['content_type']]);
   if (node_access('create', $meta['data_node']['content_type'])) {
     $nodes['new'] = '< ' . t('New !type', array('!type' => $type_name)) . ' >';
@@ -187,7 +199,8 @@ function data_node_active_form_submit($form, &$form_state) {
       $query[] = "$k=$v";
     }
   }
-  drupal_goto($_GET['q'], implode('&', $query));
+  // TODO implode('&', $query) needs to be an array of keys and values instead of a string.
+  drupal_goto($_GET['q'], array('query' => implode('&', $query)));
 }
 
 /**
@@ -217,7 +230,8 @@ function data_node_active_form_create_submit($form, &$form_state) {
       $query[] = "$k=$v";
     }
   }
-  drupal_goto($_GET['q'], implode('&', $query));
+  // TODO implode('&', $query) needs to be an array of keys and values instead of a string.
+  drupal_goto($_GET['q'], array('query' => implode('&', $query)));
 }
 
 /**
@@ -241,7 +255,7 @@ function data_node_add_page($table, $id, $nid, $token) {
       'add_link' => data_node_render_remove_link($table, $id, $nid),
       'remove_link' => data_node_render_add_link($table, $id, $nid),
     );
-    drupal_json($response);
+    drupal_json_output($response);
     exit;
   }
   drupal_goto($_GET['q']);
@@ -267,7 +281,7 @@ function data_node_active_page($table, $nid) {
       'nid' => $nid,
       'refresh' => $refresh,
     );
-    drupal_json($response);
+    drupal_json_output($response);
     exit;
   }
   drupal_goto($_GET['q']);
@@ -293,7 +307,7 @@ function data_node_remove_page($table, $id, $nid, $token) {
       'add_link' => data_node_render_remove_link($table, $id, $nid),
       'remove_link' => data_node_render_add_link($table, $id, $nid),
     );
-    drupal_json($response);
+    drupal_json_output($response);
     exit;
   }
   drupal_goto($_GET['q']);
@@ -316,7 +330,7 @@ function data_node_add($table, $id, $nid) {
  */
 function data_node_get_nids($table, $id) {
   $list = array();
-  $result = db_query("SELECT nid FROM {data_table_node} WHERE data_table_name = '%s' AND id = %d", $table->get('name'), $id);
+  $result = db_query("SELECT nid FROM {data_table_node} WHERE data_table_name = :data_table_name AND id = :id", array(':data_table_name' => $table->get('name'), ':id' => $id));
   while ($row = db_fetch_object($result)) {
     $list[] = $row->nid;
   }
@@ -327,7 +341,13 @@ function data_node_get_nids($table, $id) {
  * Remove a relationship between a data table and a node.
  */
 function data_node_remove($table, $id, $nid) {
-  db_query("DELETE FROM {data_table_node} WHERE data_table_name = '%s' AND id = %d AND nid = %d", $table->get('name'), $id, $nid);
+  // TODO Please review the conversion of this statement to the D7 database API syntax.
+  /* db_query("DELETE FROM {data_table_node} WHERE data_table_name = '%s' AND id = %d AND nid = %d", $table->get('name'), $id, $nid) */
+  db_delete('data_table_node')
+  ->condition('data_table_name', $table->get('name'))
+  ->condition('id', $id)
+  ->condition('nid', $nid)
+  ->execute();
 }
 
 /**
@@ -337,7 +357,7 @@ function data_node_get_nodes($table) {
   $nodes = array();
   $meta = $table->get('meta');
   if ($meta['data_node']['content_type']) {
-    $result = db_query("SELECT nid, title FROM {node} WHERE type = '%s' ORDER BY title ASC", $meta['data_node']['content_type']);
+    $result = db_query("SELECT nid, title FROM {node} WHERE type = :type ORDER BY title ASC", array(':type' => $meta['data_node']['content_type']));
     while ($node = db_fetch_object($result)) {
       $nodes[$node->nid] = $node->title;
     }
@@ -372,7 +392,7 @@ function _data_node_hash($table, $id, $nid) {
 function _data_node_get_title($nid) {
   static $nodes = array();
   if (!isset($nodes[$nid])) {
-    $nodes[$nid] = check_plain(db_result(db_query("SELECT title FROM {node} WHERE nid = %d", $nid)));
+    $nodes[$nid] = check_plain(db_query("SELECT title FROM {node} WHERE nid = :nid", array(':nid' => $nid))->fetchField());
   }
   return isset($nodes[$nid]) ? $nodes[$nid] : NULL;
 }
@@ -402,7 +422,7 @@ function data_node_render_labels($table, $id) {
   $nids = data_node_get_nids($table, $id);
   foreach ($nids as $nid) {
     $title = _data_node_get_title($nid);
-    $output .= theme('data_node_label', $table, $id, $nid, $title);
+    $output .= theme('data_node_label', array('table' => $table, 'id' => $id, 'nid' => $nid, 'title' => $title));
   }
   $table_name = $table->get('name');
   $class = "data_node_labels-{$table_name}-{$id}";
diff --git a/data_node/data_node.theme.inc b/data_node/data_node.theme.inc
index 21f99de..b6f57a2 100644
--- a/data_node/data_node.theme.inc
+++ b/data_node/data_node.theme.inc
@@ -7,7 +7,11 @@
 /**
  * Theme a label for an existing item-node relationship.
  */
-function theme_data_node_label($table, $id, $nid, $title) {
+function theme_data_node_label($variables) {
+  $table = $variables['table'];
+  $id = $variables['id'];
+  $nid = $variables['nid'];
+  $title = $variables['title'];
   drupal_add_css(drupal_get_path('module', 'data_node') . '/data_node.css');
   drupal_add_js(drupal_get_path('module', 'data_node') . '/data_node.js');
 
@@ -22,13 +26,14 @@ function theme_data_node_label($table, $id, $nid, $title) {
 /**
  * Theme for data_node_active_form.
  */
-function theme_data_node_active_form($form) {
+function theme_data_node_active_form($variables) {
+  $form = $variables['form'];
   drupal_add_css(drupal_get_path('module', 'data_node') . '/data_node.css');
   drupal_add_js(drupal_get_path('module', 'data_node') . '/data_node.js');
 
   $output = '';
   $output .= drupal_render($form['nid']);
   $output .= "<div class='new-node clear-block'>" . drupal_render($form['new']) . "</div>";
-  $output .= drupal_render($form);
+  $output .= drupal_render_children($form);
   return $output;
 }
diff --git a/data_node/views/data_node.views.inc b/data_node/views/data_node.views.inc
index 5604871..39b21f9 100644
--- a/data_node/views/data_node.views.inc
+++ b/data_node/views/data_node.views.inc
@@ -5,7 +5,7 @@
  */
 
 /**
- * Implementation of hook_views_data().
+ * Implements hook_views_data().
  */
 function data_node_views_data() {
   $data = array();
@@ -74,7 +74,7 @@ function data_node_views_data() {
 }
 
 /**
- * Implementation of hook_views_handlers().
+ * Implements hook_views_handlers().
  */
 function data_node_views_handlers() {
   return array(
diff --git a/data_node/views/data_node_views_handler_field_item_count.inc b/data_node/views/data_node_views_handler_field_item_count.inc
index db14d59..802a520 100644
--- a/data_node/views/data_node_views_handler_field_item_count.inc
+++ b/data_node/views/data_node_views_handler_field_item_count.inc
@@ -14,7 +14,7 @@ class data_node_views_handler_field_item_count extends views_handler_field {
     foreach ($result as $row) {
       if (!empty($row->{$this->view->base_field})) {
         $nid = $row->{$this->view->base_field};
-        $this->items[$nid] = db_result(db_query("SELECT COUNT(id) AS count FROM {data_table_node} WHERE nid = %d", $nid));
+        $this->items[$nid] = db_query("SELECT COUNT(id) AS count FROM {data_table_node} WHERE nid = :nid", array(':nid' => $nid))->fetchField();
       }
     }
   }
diff --git a/data_search/data_search.admin.inc b/data_search/data_search.admin.inc
index 67f829c..9e40a4f 100644
--- a/data_search/data_search.admin.inc
+++ b/data_search/data_search.admin.inc
@@ -3,7 +3,7 @@
 /**
  * Views handler configuration form.
  */
-function data_search_admin_form(&$form_state, $table) {
+function data_search_admin_form($form, &$form_state, $table) {
   drupal_set_title($table->get('title'));
 
   $schema = $table->get('table_schema');
@@ -59,7 +59,8 @@ function data_search_admin_form_submit(&$form, &$form_state) {
 /**
  * Theme data_search_admin_form.
  */
-function theme_data_search_admin_form($form) {
+function theme_data_search_admin_form($variables) {
+  $form = $variables['form'];
 
   // Format existing fields.
   $rows = array();
@@ -72,7 +73,7 @@ function theme_data_search_admin_form($form) {
   }
 
   $header = array(t('Name'), t('Search index'));
-  $output = theme('table', $header, $rows);
-  $output .= drupal_render($form);
+  $output = theme('table', array('header' => $header, 'rows' => $rows));
+  $output .= drupal_render_children($form);
   return $output;
 }
diff --git a/data_search/data_search.info b/data_search/data_search.info
index 9dac7a0..bb58b08 100644
--- a/data_search/data_search.info
+++ b/data_search/data_search.info
@@ -3,4 +3,4 @@ description = "Provides search and views search integration for Data tables."
 package = Data
 dependencies[] = data
 dependencies[] = search
-core = 6.x
\ No newline at end of file
+core = 7.x
diff --git a/data_search/data_search.install b/data_search/data_search.install
index 4c56706..426ccaf 100644
--- a/data_search/data_search.install
+++ b/data_search/data_search.install
@@ -1,7 +1,13 @@
 <?php
+/**
+ * @file
+ * Install, update and uninstall functions for the data_search module.
+ *
+ */
+
 
 /**
- * Implementation of hook_install().
+ * Implements hook_install().
  *
  * @todo: Should use db_change_field()
  * @todo: What happens if data_search and search are installed at the same time?
diff --git a/data_search/data_search.module b/data_search/data_search.module
index fd5ae2c..9fce879 100644
--- a/data_search/data_search.module
+++ b/data_search/data_search.module
@@ -1,11 +1,11 @@
 <?php
 
 /**
- * Implementation of hook_menu()
+ * Implements hook_menu().
  */
 function data_search_menu() {
   $items = array();
-  $items['admin/build/data/edit/%data_ui_table/search'] = array(
+  $items['admin/structure/data/edit/%data_ui_table/search'] = array(
     'title' => 'Configure search',
     'description' => 'Administer data tables.',
     'page callback' => 'drupal_get_form',
@@ -18,18 +18,18 @@ function data_search_menu() {
 }
 
 /**
- * Implementation of hook_theme()
+ * Implements hook_theme().
  */
 function data_search_theme() {
   return array(
     'data_search_admin_form' => array(
-      'arguments' => array('form' => array()),
+      'render element' => 'form',
     ),
   );
 }
 
 /**
- * Implementation of hook_cron().
+ * Implements hook_cron().
  *
  * Wipe all orphaned search records.
  *
@@ -45,7 +45,7 @@ function data_search_cron() {
 }
 
 /**
- * Implementation of hook_views_data_alter().
+ * Implements hook_views_data_alter().
  */
 function data_search_views_data_alter(&$data) {
   $tables = data_search_get_tables();
@@ -70,7 +70,7 @@ function data_search_views_data_alter(&$data) {
 }
 
 /**
- * Implementation of hook_update_index().
+ * Implements hook_update_index().
  */
 function data_search_update_index() {
   $limit = (int) variable_get('search_cron_limit', 100);
@@ -84,9 +84,11 @@ function data_search_update_index() {
     $fields = implode(', ', $fields);
     $base_field = current($schema['primary key']);
 
-    $result = db_query_range("SELECT dt.{$base_field} id FROM {{$name}} dt LEFT JOIN {search_dataset} d ON d.type = '{$name}' AND d.sid = dt.{$base_field} WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, dt.{$base_field} ASC", 0, $limit);
+    // TODO Please convert this statement to the D7 database API syntax.
+    $result = db_query_range("SELECT dt.{$base_field} id FROM {{$name}} dt LEFT JOIN {search_dataset} d ON d.type = '{$name}' AND d.sid = dt.{$base_field} WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, dt.{$base_field} ASC");
 
     while ($row = db_fetch_object($result)) {
+      // TODO Please convert this statement to the D7 database API syntax.
       $values = db_fetch_array(db_query("SELECT {$fields} FROM {{$name}} WHERE {$base_field} = '%s'", $row->id));
       $fulltext = '';
       foreach ($values as $field => $value) {
@@ -95,12 +97,13 @@ function data_search_update_index() {
       search_index($row->id, $name, $fulltext);
     }
     // Delete orphaned data search records, no nodeapi to take care of this as it occurs.
+    // TODO Please convert this statement to the D7 database API syntax.
     db_query("DELETE sd, si, snl FROM {search_dataset} sd LEFT JOIN {{$name}} dt ON sd.type = '{$name}' AND sd.sid = dt.{$base_field} LEFT JOIN {search_index} si ON sd.sid = si.sid AND sd.type = si.type LEFT JOIN {search_node_links} snl ON sd.sid = snl.sid AND sd.type = snl.type WHERE dt.{$base_field} IS NULL");
   }
 }
 
 /**
- * Implementation of hook_search().
+ * Implements hook_search().
  */
 function data_search_search($op = 'search', $keys = NULL) {
   switch ($op) {
@@ -111,7 +114,14 @@ function data_search_search($op = 'search', $keys = NULL) {
       $tables = data_search_get_tables();
       foreach ($tables as $table) {
         $name = $table->get('name');
-        db_query("UPDATE {search_dataset} SET reindex = %d WHERE type = '%s'", time(), $name);
+        // TODO Please review the conversion of this statement to the D7 database API syntax.
+        /* db_query("UPDATE {search_dataset} SET reindex = %d WHERE type = '%s'", REQUEST_TIME, $name) */
+        db_update('search_dataset')
+  ->fields(array(
+    'reindex' => REQUEST_TIME,
+  ))
+  ->condition('type', $name)
+  ->execute();
       }
       return;
 
@@ -123,8 +133,10 @@ function data_search_search($op = 'search', $keys = NULL) {
         $schema = $table->get('table_schema');
         $base_field = current($schema['primary key']);
 
-        $total = $total + db_result(db_query("SELECT COUNT(*) FROM {{$name}}"));
-        $remaining = $remaining + db_result(db_query("SELECT COUNT(*) FROM {{$name}} dt LEFT JOIN {search_dataset} d ON d.type = '{$name}' AND d.sid = dt.{$base_field} WHERE (d.sid IS NULL OR d.reindex <> 0)"));
+        // TODO Please convert this statement to the D7 database API syntax.
+        $total = $total + db_query("SELECT COUNT(*) FROM {{$name}}")->fetchField();
+        // TODO Please convert this statement to the D7 database API syntax.
+        $remaining = $remaining + db_query("SELECT COUNT(*) FROM {{$name}} dt LEFT JOIN {search_dataset} d ON d.type = '{$name}' AND d.sid = dt.{$base_field} WHERE (d.sid IS NULL OR d.reindex <> 0)")->fetchField();
       }
       return array('remaining' => $remaining, 'total' => $total);
   }
@@ -146,7 +158,9 @@ function data_search_wipe($table) {
   $name = db_escape_table($table->get('name'));
   $field = db_escape_string(current($schema['primary key']));
 
+  // TODO Please convert this statement to the D7 database API syntax.
   db_query("DELETE s FROM {search_dataset} s LEFT JOIN {{$name}} t ON s.sid = t.$field WHERE s.type = '%s' AND t.$field IS NULL", $table->get('name'));
+  // TODO Please convert this statement to the D7 database API syntax.
   db_query("DELETE s FROM {search_index} s LEFT JOIN {{$name}} t ON s.sid = t.$field WHERE s.type = '%s' AND t.$field IS NULL", $table->get('name'));
 }
 
diff --git a/data_taxonomy/data_taxonomy.admin.inc b/data_taxonomy/data_taxonomy.admin.inc
index 84ea1df..16dfa5b 100644
--- a/data_taxonomy/data_taxonomy.admin.inc
+++ b/data_taxonomy/data_taxonomy.admin.inc
@@ -7,7 +7,7 @@
 /**
  * Form callback for relating a data table to a node.
  */
-function data_taxonomy_settings_form(&$form_state, $table) {
+function data_taxonomy_settings_form($form, &$form_state, $table) {
   drupal_set_title($table->get('title'));
 
   $form = $vocabularies = array();
diff --git a/data_taxonomy/data_taxonomy.info b/data_taxonomy/data_taxonomy.info
index 8f7d101..cd9a6fc 100644
--- a/data_taxonomy/data_taxonomy.info
+++ b/data_taxonomy/data_taxonomy.info
@@ -4,4 +4,5 @@ package = Data
 dependencies[] = data
 dependencies[] = data_ui
 dependencies[] = taxonomy
-core = 6.x
+core = 7.x
+
diff --git a/data_taxonomy/data_taxonomy.install b/data_taxonomy/data_taxonomy.install
index 9495d36..edab597 100644
--- a/data_taxonomy/data_taxonomy.install
+++ b/data_taxonomy/data_taxonomy.install
@@ -5,7 +5,7 @@
  */
 
 /**
- * Implementation of hook_schema().
+ * Implements hook_schema().
  */
 function data_taxonomy_schema() {
   $schema = array();
@@ -43,15 +43,17 @@ function data_taxonomy_schema() {
 }
 
 /**
- * Implementation of hook_install().
+ * Implements hook_install().
  */
 function data_taxonomy_install() {
-  drupal_install_schema('data_taxonomy');
+  // TODO The drupal_(un)install_schema functions are called automatically in D7.
+  // drupal_install_schema('data_taxonomy')
 }
 
 /**
- * Implementation of hook_uninstall().
+ * Implements hook_uninstall().
  */
 function data_taxonomy_uninstall() {
-  drupal_uninstall_schema('data_taxonomy');
+  // TODO The drupal_(un)install_schema functions are called automatically in D7.
+  // drupal_uninstall_schema('data_taxonomy')
 }
diff --git a/data_taxonomy/data_taxonomy.module b/data_taxonomy/data_taxonomy.module
index c3b21a0..18706cf 100644
--- a/data_taxonomy/data_taxonomy.module
+++ b/data_taxonomy/data_taxonomy.module
@@ -6,7 +6,7 @@
  */
 
 /**
- * Implementation of hook_views_api().
+ * Implements hook_views_api().
  */
 function data_taxonomy_views_api() {
   return array(
@@ -16,7 +16,7 @@ function data_taxonomy_views_api() {
 }
 
 /**
- * Implementation of hook_menu().
+ * Implements hook_menu().
  */
 function data_taxonomy_menu() {
   $items = array();
@@ -26,7 +26,7 @@ function data_taxonomy_menu() {
     'access arguments' => array('edit data taxonomy relations'),
     'type' => MENU_CALLBACK,
   );
-  $items['admin/build/data/edit/%data_ui_table/taxonomy'] = array(
+  $items['admin/structure/data/edit/%data_ui_table/taxonomy'] = array(
     'title' => 'Relate to taxonomy',
     'description' => 'Administer data tables.',
     'page callback' => 'drupal_get_form',
@@ -39,12 +39,12 @@ function data_taxonomy_menu() {
 }
 
 /**
- * Implementation of hook_theme().
+ * Implements hook_theme().
  */
 function data_taxonomy_theme() {
   return array(
     'data_taxonomy_tagging_form' => array(
-      'arguments' => array('form' => array()),
+      'render element' => 'form',
       'path' => drupal_get_path('module', 'data_taxonomy') . '/theme',
       'template' => 'data-taxonomy-tagging-form',
     ),
@@ -52,14 +52,19 @@ function data_taxonomy_theme() {
 }
 
 /**
- * Implementation of hook_perm().
+ * Implements hook_permission().
  */
-function data_taxonomy_perm() {
-  return array('edit data taxonomy relations');
+function data_taxonomy_permission() {
+  return array(
+    'edit data taxonomy relations' => array(
+      'title' => t('edit data taxonomy relations'),
+      'description' => t('TODO Add a description for \'edit data taxonomy relations\''),
+    ),
+  );
 }
 
 /**
- * Implementation of hook_feeds_data_processor_targets_alter().
+ * Implements hook_feeds_data_processor_targets_alter().
  */
 function data_taxonomy_feeds_data_processor_targets_alter(&$fields, $table_name) {
   if ($info = data_taxonomy_get_info($table_name)) {
@@ -74,7 +79,7 @@ function data_taxonomy_feeds_data_processor_targets_alter(&$fields, $table_name)
 }
 
 /**
- * Implementation of hook_data_insert().
+ * Implements hook_data_insert().
  */
 function data_taxonomy_data_insert($record, $table_name) {
   if ($info = data_taxonomy_get_info($table_name)) {
@@ -88,7 +93,7 @@ function data_taxonomy_data_insert($record, $table_name) {
 }
 
 /**
- * Implementation of hook_data_update().
+ * Implements hook_data_update().
  */
 function data_taxonomy_data_update($record, $table_name) {
   if ($info = data_taxonomy_get_info($table_name)) {
@@ -96,7 +101,9 @@ function data_taxonomy_data_update($record, $table_name) {
     foreach ($info['vocabularies'] as $vid) {
       if (isset($record['data_taxonomy:' . $vid])) {
         $vocabulary = data_taxonomy_get_vocabulary($vid);
-        db_query("DELETE dt FROM {data_taxonomy} dt JOIN {term_data} td ON dt.tid = td.tid WHERE td.vid = %d", $vocabulary->vid);
+        // TODO Please convert this statement to the D7 database API syntax.
+        /* db_query("DELETE dt FROM {data_taxonomy} dt JOIN {taxonomy_term_data} td ON dt.tid = td.tid WHERE td.vid = %d", $vocabulary->vid) */
+        NULL;
         _data_taxonomy_insert_terms($table_name, $id, $record['data_taxonomy:' . $vid], $vocabulary);
       }
     }
@@ -104,11 +111,15 @@ function data_taxonomy_data_update($record, $table_name) {
 }
 
 /**
- * Implementation of hook_taxonomy().
+ * Implements hook_taxonomy().
  */
 function data_taxonomy_taxonomy($op = NULL, $type = NULL, $term = NULL) {
   if ($type == 'term' && $term['tid'] && $op == 'delete') {
-    db_query("DELETE FROM {data_taxonomy} WHERE tid = %d", $term['tid']);
+    // TODO Please review the conversion of this statement to the D7 database API syntax.
+    /* db_query("DELETE FROM {data_taxonomy} WHERE tid = %d", $term['tid']) */
+    db_delete('data_taxonomy')
+  ->condition('tid', $term['tid'])
+  ->execute();
   }
 }
 
@@ -152,13 +163,15 @@ function _data_taxonomy_insert_terms($table_name, $id, $terms, $vocabulary) {
     }
     if (is_numeric($term) && !isset($tids[$term])) {
       $tids[$term] = $term;
-      db_query("INSERT INTO {data_taxonomy}(id, data_table_name, tid) VALUES(%d, '%s', %d)", $id, $table_name, $term);
+      // TODO Please convert this statement to the D7 database API syntax.
+      /* db_query("INSERT INTO {data_taxonomy}(id, data_table_name, tid) VALUES(%d, '%s', %d)", $id, $table_name, $term) */
+      NULL;
     }
   }
 }
 
 /**
- * Implementation of hook_data_delete_query_alter().
+ * Implements hook_data_delete_query_alter().
  */
 function data_taxonomy_data_delete_query_alter($query, $table_name) {
   if ($info = data_taxonomy_get_info($table_name)) {
@@ -214,7 +227,7 @@ function data_taxonomy_tagging_form(&$form_state, $vid, $id, $table_name, $path,
     '#value' => implode('&', $args),
     '#access' => $access,
   );
-  $result = db_query('SELECT td.tid, td.name, td.vid FROM {term_data} td JOIN {data_taxonomy} dt ON td.tid = dt.tid WHERE dt.data_table_name = "%s" AND dt.id = %d AND td.vid = %d', $table_name, $id, $vid);
+  $result = db_query('SELECT td.tid, td.name, td.vid FROM {taxonomy_term_data} td JOIN {data_taxonomy} dt ON td.tid = dt.tid WHERE dt.data_table_name = :dt.data_table_name AND dt.id = :dt.id AND td.vid = :td.vid', array(':dt.data_table_name' => $table_name, ':dt.id' => $id, ':td.vid' => $vid));
   $tags = $terms = array();
   while ($term = db_fetch_object($result)) {
     $tags[$term->tid] = $term->name;
@@ -278,9 +291,19 @@ function data_taxonomy_tagging_form_submit($form, &$form_state) {
  * Save term_data - data table relationships in data_taxonomy table.
  */
 function data_taxonomy_save_relations($vid, $id, $table_name, $tids) {
-  db_query("DELETE dt FROM {data_taxonomy} dt JOIN {term_data} td ON dt.tid = td.tid WHERE dt.id = %d AND dt.data_table_name = '%s' AND td.vid = %d", $id, $table_name, $vid);
+  // TODO Please convert this statement to the D7 database API syntax.
+  /* db_query("DELETE dt FROM {data_taxonomy} dt JOIN {taxonomy_term_data} td ON dt.tid = td.tid WHERE dt.id = %d AND dt.data_table_name = '%s' AND td.vid = %d", $id, $table_name, $vid) */
+  NULL;
   foreach ($tids as $tid) {
-    db_query('INSERT INTO {data_taxonomy} (id, data_table_name, tid) VALUES (%d, "%s", %d)', $id, $table_name, $tid);
+    // TODO Please review the conversion of this statement to the D7 database API syntax.
+    /* db_query('INSERT INTO {data_taxonomy} (id, data_table_name, tid) VALUES (%d, "%s", %d)', $id, $table_name, $tid) */
+    $id = db_insert('data_taxonomy')
+  ->fields(array(
+    'id' => $id,
+    'data_table_name' => $table_name,
+    'tid' => $tid,
+  ))
+  ->execute();
   }
 }
 
@@ -303,7 +326,7 @@ function data_taxonomy_save_term_name($name, $vid) {
     'vid' => $vid,
     'name' => $name,
   );
-  taxonomy_save_term($term);
+  taxonomy_term_save($term /* TODO Term object replaces array $term */);
   return $term;
 }
 
@@ -327,7 +350,7 @@ function data_taxonomy_save_term_array($term, $vid) {
       $term = $term + $lookup;
     }
   }
-  taxonomy_save_term($term);
+  taxonomy_term_save($term /* TODO Term object replaces array $term */);
   return $term;
 }
 
@@ -372,7 +395,8 @@ function data_taxonomy_lookup_term($name, $vid) {
  * @see taxonomy_get_term_by_name().
  */
 function data_taxonomy_get_term_by_name_vid($name, $vid) {
-  $db_result = db_query(db_rewrite_sql("SELECT t.tid, t.* FROM {term_data} t WHERE t.vid = %d AND LOWER(t.name) = LOWER('%s')", 't', 'tid'), $vid, trim($name));
+  // TODO Please convert this statement to the D7 database API syntax.
+  $db_result = db_query(db_rewrite_sql("SELECT t.tid, t.* FROM {taxonomy_term_data} t WHERE t.vid = %d AND LOWER(t.name) = LOWER('%s')", 't', 'tid'), $vid, trim($name));
   $result = array();
   while ($term = db_fetch_object($db_result)) {
     $result[] = $term;
@@ -425,10 +449,10 @@ function data_taxonomy_ajax_save() {
     $values = $form_state['values'];
     $terms = data_taxonomy_save_tags($values['tags'], $values['vid']);
     data_taxonomy_save_relations($values['vid'], $values['id'], $values['table_name'], array_keys($terms));
-    drupal_json(array('status' => 1, 'data' => theme('links', data_taxonomy_tag_links($terms, $_POST['path'], explode('&', $_POST['args'])), array('class' => 'links data-taxonomy-tags'))));
+    drupal_json_output(array('status' => 1, 'data' => theme('links', array('links' => data_taxonomy_tag_links($terms, $_POST['path'], explode('&', $_POST['args'])), 'attributes' => array('class' => 'links data-taxonomy-tags')))));
     exit;
   }
-  drupal_json(array('status' => 1, 'data' => 'Error submitting form'));
+  drupal_json_output(array('status' => 1, 'data' => 'Error submitting form'));
   exit;
 }
 
@@ -491,7 +515,7 @@ function template_preprocess_data_taxonomy_tagging_form(&$vars) {
   if ($vars['form']['#edit']) {
     $vars['edit'] = $vars['form']['#edit'];
   }
-  $vars['tags'] = theme('links', data_taxonomy_tag_links($vars['form']['#terms'], $vars['form']['#path'], $vars['form']['#args']), array('class' => 'links data-taxonomy-tags'));
+  $vars['tags'] = theme('links', array('links' => data_taxonomy_tag_links($vars['form']['#terms'], $vars['form']['#path'], $vars['form']['#args']), 'attributes' => array('class' => 'links data-taxonomy-tags')));
 }
 
 /**
diff --git a/data_taxonomy/views/data_taxonomy.views.inc b/data_taxonomy/views/data_taxonomy.views.inc
index 26c8173..7a30681 100644
--- a/data_taxonomy/views/data_taxonomy.views.inc
+++ b/data_taxonomy/views/data_taxonomy.views.inc
@@ -5,7 +5,7 @@
  */
 
 /**
- * Implementation of hook_views_data().
+ * Implements hook_views_data().
  */
 function data_taxonomy_views_data() {
   $data = array();
@@ -13,12 +13,12 @@ function data_taxonomy_views_data() {
   $data['data_taxonomy']['table']['group']  = t('Data taxonomy');
   $data['data_taxonomy']['table']['title']  = t('Taxonomy');
   $data['data_taxonomy']['table']['join'] = array(
-    'term_data' => array(
+    'taxonomy_term_data' => array(
       'left_field' => 'tid',
       'field' => 'tid',
     ),
     'node' => array(
-      'left_table' => 'term_node',
+      'left_table' => 'taxonomy_term_node',
       'left_field' => 'tid',
       'field' => 'tid',
     ),
@@ -27,7 +27,7 @@ function data_taxonomy_views_data() {
     'title' => t('Term data.'),
     'help' => t('Relate data_taxonomy to a term data.'),
     'label' => t('Relate data_taxonomy to a term data.'),
-    'base' => 'term_data',
+    'base' => 'taxonomy_term_data',
     'base field' => 'tid',
   );
   $data['data_taxonomy']['tid_2'] = array(
@@ -36,7 +36,7 @@ function data_taxonomy_views_data() {
       'title' => t('Nodes with term.'),
       'help' => t('Relate data taxonomy to all nodes with same term.'),
       'label' => t('Relate data taxonomy to nodes with term.'),
-      'base' => 'term_node',
+      'base' => 'taxonomy_term_node',
       'base field' => 'tid',
       'relationship field' => 'tid',
     ),
@@ -59,7 +59,7 @@ function data_taxonomy_views_data() {
         'field' => 'id',
       );
       // allow term data to join directly to affected data tables
-      $data['term_data']['table']['join'][$table->get('name')] = array(
+      $data['taxonomy_term_data']['table']['join'][$table->get('name')] = array(
         'left_table' => 'data_taxonomy',
         'left_field' => 'tid',
         'field' => 'tid',
@@ -86,21 +86,21 @@ function data_taxonomy_views_data() {
 }
 
 /**
- * Implementation of hook_views_data_alter().
+ * Implements hook_views_data_alter().
  *
  * Expose node table fields/filters for terms as base table.
  * @todo This really doesn't belong here.
  */
 function data_taxonomy_views_data_alter(&$data) {
-  $data['node']['table']['join']['term_node'] = array(
-    'left_table' => 'term_node',
+  $data['node']['table']['join']['taxonomy_term_node'] = array(
+    'left_table' => 'taxonomy_term_node',
     'left_field' => 'nid',
     'field' => 'nid',
   );
 }
 
 /**
- * Implementation of hook_views_handlers().
+ * Implements hook_views_handlers().
  */
 function data_taxonomy_views_handlers() {
   return array(
diff --git a/data_taxonomy/views/data_taxonomy_views_handler_field_item_count.inc b/data_taxonomy/views/data_taxonomy_views_handler_field_item_count.inc
index ad4b84a..4b79951 100644
--- a/data_taxonomy/views/data_taxonomy_views_handler_field_item_count.inc
+++ b/data_taxonomy/views/data_taxonomy_views_handler_field_item_count.inc
@@ -15,10 +15,10 @@ class data_taxonomy_views_handler_field_item_count extends views_handler_field {
       if (!empty($row->{$this->view->base_field})) {
         $tid = $row->{$this->view->base_field};
         if ($this->view->base_table == 'node') {
-          $this->items[$tid] = db_result(db_query("SELECT COUNT(DISTINCT dt.id) AS count FROM {node} n LEFT JOIN {term_node} tn ON tn.nid = n.nid LEFT JOIN {data_taxonomy} dt ON dt.tid = tn.tid WHERE n.nid = %d", $tid));
+          $this->items[$tid] = db_query("SELECT COUNT(DISTINCT dt.id) AS count FROM {node} n LEFT JOIN {taxonomy_term_node} tn ON tn.nid = n.nid LEFT JOIN {data_taxonomy} dt ON dt.tid = tn.tid WHERE n.nid = :n.nid", array(':n.nid' => $tid))->fetchField();
         }
         else {
-          $this->items[$tid] = db_result(db_query("SELECT COUNT(id) AS count FROM {data_taxonomy} WHERE tid = %d", $tid));
+          $this->items[$tid] = db_query("SELECT COUNT(id) AS count FROM {data_taxonomy} WHERE tid = :tid", array(':tid' => $tid))->fetchField();
         }
       }
     }
diff --git a/data_ui/data_ui.admin.inc b/data_ui/data_ui.admin.inc
index bb9cc03..666f365 100644
--- a/data_ui/data_ui.admin.inc
+++ b/data_ui/data_ui.admin.inc
@@ -11,10 +11,11 @@ function data_ui_view() {
   $tables = data_get_all_tables();
   $rows = array();
   foreach ($tables as $table) {
+    // TODO Please convert this statement to the D7 database API syntax.
     $row = array(
       $table->get('title'),
       $table->get('name'),
-      db_result(db_query('SELECT COUNT(*) FROM {' . db_escape_table($table->get('name')) . '}')),
+      db_query('SELECT COUNT(*) FROM {' . db_escape_table($table->get('name')) . '}')->fetchField(),
     );
     if (module_exists('views')) {
       $row[] = l(t('View'), data_ui_get_default_path($table->get('name')));
@@ -25,7 +26,7 @@ function data_ui_view() {
   if (module_exists('views')) {
     $header[] = '&nbsp;';
   }
-  return theme('table', $header, $rows);
+  return theme('table', array('header' => $header, 'rows' => $rows));
 }
 
 /**
@@ -39,20 +40,20 @@ function data_ui_manage() {
     $operations = array();
     if ($table->get('export_type') == EXPORT_IN_CODE) {
       $status = t('Default');
-      $operations[] = l(t('Override'), 'admin/build/data/edit/' . $table->get('name'));
+      $operations[] = l(t('Override'), 'admin/structure/data/edit/' . $table->get('name'));
     }
     else if ($table->get('export_type') == (EXPORT_IN_CODE | EXPORT_IN_DATABASE)) {
       $status = t('Overridden');
-      $operations[] = l(t('Edit'), 'admin/build/data/edit/' . $table->get('name'));
-      $operations[] = l(t('Revert'), 'admin/build/data/revert/' . $table->get('name'));
+      $operations[] = l(t('Edit'), 'admin/structure/data/edit/' . $table->get('name'));
+      $operations[] = l(t('Revert'), 'admin/structure/data/revert/' . $table->get('name'));
     }
     else {
       $status = t('Normal');
-      $operations[] = l(t('Edit'), 'admin/build/data/edit/' . $table->get('name'));
-      $operations[] = l(t('Drop'), 'admin/build/data/drop/' . $table->get('name'));
+      $operations[] = l(t('Edit'), 'admin/structure/data/edit/' . $table->get('name'));
+      $operations[] = l(t('Drop'), 'admin/structure/data/drop/' . $table->get('name'));
     }
     if (module_exists('ctools')) {
-      $operations[] = l(t('Export'), 'admin/build/data/export/' . $table->get('name'));
+      $operations[] = l(t('Export'), 'admin/structure/data/export/' . $table->get('name'));
     }
 
     $row = array();
@@ -64,13 +65,13 @@ function data_ui_manage() {
     $rows[] = $row;
   }
   $rows[] = array(
-    l(t('Create new table'), 'admin/build/data/create'),
+    l(t('Create new table'), 'admin/structure/data/create'),
     '&nbsp;',
     '&nbsp;',
     '&nbsp;',
   );
   $header = array(t('Title'), t('Name'), t('Status'), t('Operations'));
-  return theme('table', $header, $rows);
+  return theme('table', array('header' => $header, 'rows' => $rows));
 }
 
 /**
@@ -85,14 +86,14 @@ function data_ui_compare() {
     $row[] = $table->get('name');
     $status = $comp['status'];
     if ($status != 'same') {
-      $status .= ' - ' . l(t('adjust'), 'admin/build/data/compare/' . $table->get('name'));
+      $status .= ' - ' . l(t('adjust'), 'admin/structure/data/compare/' . $table->get('name'));
     }
     $row[] = $status;
     $row[] = empty($comp['warning']) ? '-' : $comp['warning'];
     $rows[] = $row;
   }
   $header = array(t('Name'), t('Status'), t('Warnings'));
-  return theme('table', $header, $rows);
+  return theme('table', array('header' => $header, 'rows' => $rows));
 }
 
 /**
@@ -103,19 +104,19 @@ function data_ui_compare() {
  * - adjust database or
  * - leave it.
  */
-function data_ui_adjust_form(&$form_state, $table) {
+function data_ui_adjust_form($form, &$form_state, $table) {
   drupal_set_title(t('Adjust !table', array('!table' => $table->get('name'))));
   $comparison = $table->compareSchema();
 
   $form = array();
-  $form['#redirect'] = 'admin/build/data/compare';
+  $form_state['#redirect'] = 'admin/structure/data/compare';
   $form['#table'] = $table;
   $form['#comparison'] = $comparison;
   $form['comparison'] = array(
     '#type' => 'fieldset',
     '#title' => t('Comparison'),
   );
-  $form['comparison']['comparison']['#value'] = theme('data_ui_schema_compare_table', $comparison);
+  $form['comparison']['comparison']['#value'] = theme('data_ui_schema_compare_table', array('comparison' => $comparison));
 
   if ($comparison['status'] == 'different') {
     $form['update_schema'] = array(
@@ -202,10 +203,10 @@ function data_ui_adjust_form_submit_alter_table($form, &$form_state) {
     }
   }
   if (count($resolved)) {
-    drupal_set_message(t('Resolved') . theme('item_list', $resolved));
+    drupal_set_message(t('Resolved') . theme('item_list', array('items' => $resolved)));
   }
   if (count($unresolved)) {
-    drupal_set_message(t('Could not resolve') . theme('item_list', $unresolved), 'error');
+    drupal_set_message(t('Could not resolve') . theme('item_list', array('items' => $unresolved)), 'error');
   }
 }
 
@@ -215,7 +216,7 @@ function data_ui_adjust_form_submit_alter_table($form, &$form_state) {
 function data_ui_adjust_form_submit_create_table($form, &$form_state) {
   $table = $form['#table'];
   $ret = array();
-  db_create_table($ret, $table->get('name'), $table->get('table_schema'));
+  db_create_table($table->get('name'), $table->get('table_schema'));
   drupal_get_schema($table->get('name'), TRUE);
   if ($ret[0]['success']) {
     drupal_set_message(t('Created table !table', array('!table' => $table->get('name'))));
@@ -231,7 +232,7 @@ function data_ui_adjust_form_submit_create_table($form, &$form_state) {
  * 'Orphaned' tables are database tables that don't have an active schema
  * definition.
  */
-function data_ui_adopt_form($form_state) {
+function data_ui_adopt_form($form, $form_state) {
   $form = array();
 
   // Compile a list of orphaned tables.
@@ -276,13 +277,13 @@ function data_ui_adopt_form_submit($form, &$form_state) {
 
   DataTable::clearCaches();
 
-  $form_state['redirect'] = 'admin/build/data';
+  $form_state['redirect'] = 'admin/structure/data';
 }
 
 /**
  * Form callback for create table form.
  */
-function data_ui_create_form(&$form_state) {
+function data_ui_create_form($form, &$form_state) {
   $form = array();
   if (!$form_state['storage']['field_num']) {
     $form['name'] = array(
@@ -397,21 +398,21 @@ function data_ui_create_form_submit($form, &$form_state) {
 
     // Unset storage to enable redirect.
     unset($form_state['storage']);
-    $form_state['redirect'] = 'admin/build/data';
+    $form_state['redirect'] = 'admin/structure/data';
   }
 }
 
 /**
  * Form callback for revert table form.
  */
-function data_ui_revert_form(&$form_state, $table) {
+function data_ui_revert_form($form, &$form_state, $table) {
   $form = array();
-  $form['#redirect'] = 'admin/build/data';
+  $form_state['#redirect'] = 'admin/structure/data';
   $form['#table'] = $table;
 
   return confirm_form($form,
     t('Revert this table?'),
-    'admin/build/data',
+    'admin/structure/data',
     t('Are you sure you would like to revert table !table? This will reset all information about this table its definition in code. This action cannot be undone.', array('!table' => $table->get('name'))),
     t('Revert'), t('Cancel')
   );
@@ -428,14 +429,14 @@ function data_ui_revert_form_submit($form, &$form_state) {
 /**
  * Form callback for drop table form.
  */
-function data_ui_drop_form(&$form_state, $table) {
+function data_ui_drop_form($form, &$form_state, $table) {
   $form = array();
-  $form['#redirect'] = 'admin/build/data';
+  $form_state['#redirect'] = 'admin/structure/data';
   $form['#table'] = $table;
 
   return confirm_form($form,
     t('Drop this table?'),
-    'admin/build/data',
+    'admin/structure/data',
     t('Are you sure you would like to drop table !table? This action cannot be undone.', array('!table' => $table->get('name'))),
     t('Drop'), t('Cancel')
   );
@@ -452,7 +453,7 @@ function data_ui_drop_form_submit($form, &$form_state) {
 /**
  * Form callback for editing a table.
  */
-function data_ui_edit_form(&$form_state, $table) {
+function data_ui_edit_form($form, &$form_state, $table) {
   drupal_set_title($table->get('title'));
 
   $schema = $table->get('table_schema');
@@ -507,7 +508,7 @@ function data_ui_edit_form(&$form_state, $table) {
       else {
         $join = t('<none>');
       }
-      $join = l($join, 'admin/build/data/edit/' . $table->get('name') . '/join/' . $field_name);
+      $join = l($join, 'admin/structure/data/edit/' . $table->get('name') . '/join/' . $field_name);
       $form['fields'][$field_name]['join']['#value'] = $join;
     }
   }
@@ -554,7 +555,7 @@ function data_ui_edit_form_submit($form, &$form_state) {
   if (!db_table_exists($table->get('name'))) {
     drupal_set_message(t('Table does not exist in database.'), 'error');
     if (module_exists('schema')) {
-      drupal_set_message(t('Go to !compare to resolve conflicts.', array('!compare' => l(t('Compare schemas'), 'admin/build/data/compare'))), 'error');
+      drupal_set_message(t('Go to !compare to resolve conflicts.', array('!compare' => l(t('Compare schemas'), 'admin/structure/data/compare'))), 'error');
     }
     return;
   }
@@ -636,7 +637,7 @@ function data_ui_edit_form_submit($form, &$form_state) {
 /**
  * Edit title form.
  */
-function data_ui_edit_title_form(&$form_state, $table) {
+function data_ui_edit_title_form($form, &$form_state, $table) {
   drupal_set_title($table->get('title'));
 
   $form = array();
@@ -665,7 +666,7 @@ function data_ui_edit_title_form_submit($form, &$form_state) {
 /**
  * Views handler configuration form.
  */
-function data_ui_views_form(&$form_state, $table) {
+function data_ui_views_form($form, &$form_state, $table) {
   drupal_set_title($table->get('title'));
 
   module_load_include('inc', 'data', 'data.views');
@@ -733,7 +734,7 @@ function data_ui_views_form_submit($form, &$form_state) {
 /**
  * Join form.
  */
-function data_ui_join_form(&$form_state, $table, $field_name) {
+function data_ui_join_form($form, &$form_state, $table, $field_name) {
   // drupal_set_title(t('Join field'));
 
   $schema = $table->get('table_schema');
@@ -742,7 +743,7 @@ function data_ui_join_form(&$form_state, $table, $field_name) {
   // Validate input.
   if (!isset($field_name) || !isset($schema['fields'][$field_name])) {
     drupal_set_message(t('Invalid field.'), 'error');
-    drupal_goto('admin/build/data/edit/' . $table->get('name'));
+    drupal_goto('admin/structure/data/edit/' . $table->get('name'));
   }
 
   // List all tables that schema API knows about as optoins.
@@ -762,7 +763,7 @@ function data_ui_join_form(&$form_state, $table, $field_name) {
   $form = array();
   $form['#table'] = $table;
   $form['#field_name'] = $field_name;
-  $form['#redirect'] = 'admin/build/data/edit/' . $table->get('name');
+  $form_state['#redirect'] = 'admin/structure/data/edit/' . $table->get('name');
   $join = _data_ui_get_join($meta['join'], $field_name);
   $form['#original_join'] = $join;
   $form['left'] = array(
@@ -781,7 +782,7 @@ function data_ui_join_form(&$form_state, $table, $field_name) {
   // Use confirm form for its formatting.
   $form = confirm_form($form,
     t('Join field'),
-    'admin/build/data/edit/' . $table->get('name'),
+    'admin/structure/data/edit/' . $table->get('name'),
     '',
     t('Save'), t('Cancel')
   );
@@ -816,7 +817,7 @@ function data_ui_join_form_submit_delete($form, &$form_state) {
 /**
  * Export form.
  */
-function data_ui_export_form(&$form_state, $table) {
+function data_ui_export_form($form, &$form_state, $table) {
   $code = data_export($table->get('name'));
 
   $form['export'] = array(
@@ -845,7 +846,8 @@ function data_ui_view_schema($table) {
 /**
  * Theme data_ui_create_form.
  */
-function theme_data_ui_create_form($form) {
+function theme_data_ui_create_form($variables) {
+  $form = $variables['form'];
 
   // Render field definition form elements in a table.
   if (isset($form['fields'])) {
@@ -860,18 +862,19 @@ function theme_data_ui_create_form($form) {
       $rows[] = $row;
     }
     $header = array(t('Name *'), t('Label'), t('Type'), t('Size'), t('Unsigned'), t('Index'), t('Primary key'));
-    $output .= theme('table', $header, $rows);
+    $output .= theme('table', array('header' => $header, 'rows' => $rows));
 
     $output .= drupal_render($form);
     return $output;
   }
-  return drupal_render($form);
+  return drupal_render_children($form);
 }
 
 /**
  * Theme data_ui_edit_form.
  */
-function theme_data_ui_edit_form($form) {
+function theme_data_ui_edit_form($variables) {
+  $form = $variables['form'];
 
   // Format existing fields.
   $rows = array();
@@ -892,15 +895,16 @@ function theme_data_ui_edit_form($form) {
   $rows[] = $row;
 
   $header = array(t('Select'), t('Name'), t('Label'), t('Type'), t('Size'), t('Unsigned'), t('Index'), t('Primary key'), t('Joins'));
-  $output = theme('table', $header, $rows);
-  $output .= drupal_render($form);
+  $output = theme('table', array('header' => $header, 'rows' => $rows));
+  $output .= drupal_render_children($form);
   return $output;
 }
 
 /**
  * Theme data_ui_views_form.
  */
-function theme_data_ui_views_form($form) {
+function theme_data_ui_views_form($variables) {
+  $form = $variables['form'];
 
   // Format existing fields.
   $rows = array();
@@ -914,8 +918,8 @@ function theme_data_ui_views_form($form) {
   }
 
   $header = array(t('Name'), t('Field handler'), t('Filter handler'), t('Argument handler'), t('Sort handler'));
-  $output = theme('table', $header, $rows);
-  $output .= drupal_render($form);
+  $output = theme('table', array('header' => $header, 'rows' => $rows));
+  $output .= drupal_render_children($form);
   return $output;
 }
 
@@ -924,7 +928,8 @@ function theme_data_ui_views_form($form) {
  *
  * @todo: move to schema module - write a patch.
  */
-function theme_data_ui_schema_compare_table($comparison) {
+function theme_data_ui_schema_compare_table($variables) {
+  $comparison = $variables['comparison'];
   $output = '';
   foreach ($comparison as $k => $v) {
     if (!empty($v)) {
@@ -936,7 +941,7 @@ function theme_data_ui_schema_compare_table($comparison) {
           $output .= $v;
         }
         elseif (is_array($v)) {
-          $output .= theme('item_list', $v);
+          $output .= theme('item_list', array('items' => $v));
         }
         $output .= '</dd>';
         $output .= '</dl>';
diff --git a/data_ui/data_ui.info b/data_ui/data_ui.info
index ec4de52..b0938d9 100644
--- a/data_ui/data_ui.info
+++ b/data_ui/data_ui.info
@@ -3,4 +3,4 @@ description = Admin UI for Data Module
 package = Data
 dependencies[] = data
 dependencies[] = schema
-core = 6.x
\ No newline at end of file
+core = 7.x
diff --git a/data_ui/data_ui.module b/data_ui/data_ui.module
index 0d74b77..8aeae37 100644
--- a/data_ui/data_ui.module
+++ b/data_ui/data_ui.module
@@ -5,17 +5,17 @@
  */
 
 /**
- * Implementation of hook_help().
+ * Implements hook_help().
  */
 function data_ui_help($path, $arg) {
   switch ($path) {
     case 'admin/content/data':
-      $output = '<p>' . t('View content in data tables. If you would like to edit these tables, visit the !data_manage_page.', array('!data_manage_page' => l(t('Data table management page'), 'admin/build/data'))) . '</p>';
+      $output = '<p>' . t('View content in data tables. If you would like to edit these tables, visit the !data_manage_page.', array('!data_manage_page' => l(t('Data table management page'), 'admin/structure/data'))) . '</p>';
       return $output;
-    case 'admin/build/data/adopt':
+    case 'admin/structure/data/adopt':
       $output = '<p>' . t('Manage database tables that aren\'t claimed by other modules. Adopting tables listed here will add them to Data\'s list of tables.') . '</p>';
       return $output;
-    case 'admin/build/data':
+    case 'admin/structure/data':
       if (module_exists('views')) {
         $output = '<p>' . t('Manage data tables. If you would like to view the content of these tables, visit the !data_view_page.', array('!data_view_page' => l(t('Data table content page'), 'admin/content/data'))) . '</p>';
       }
@@ -27,7 +27,7 @@ function data_ui_help($path, $arg) {
 }
 
 /**
- * Implementation of hook_menu()
+ * Implements hook_menu().
  */
 function data_ui_menu() {
   $items = array();
@@ -40,21 +40,21 @@ function data_ui_menu() {
       'access arguments' => array('administer data tables'),
     );
   }
-  $items['admin/build/data'] = array(
+  $items['admin/structure/data'] = array(
     'title' => 'Data tables',
     'description' => 'Create, modify and delete data tables.',
     'page callback' => 'data_ui_manage',
     'file' => 'data_ui.admin.inc',
     'access arguments' => array('administer data tables'),
   );
-  $items['admin/build/data/overview'] = array(
+  $items['admin/structure/data/overview'] = array(
     'title' => 'Overview',
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'weight' => -10,
   );
   // Only offer these options if schema module exists.
   if (module_exists('schema')) {
-    $items['admin/build/data/compare'] = array(
+    $items['admin/structure/data/compare'] = array(
       'title' => 'Compare schemas',
       'description' => 'Administer data tables.',
       'page callback' => 'data_ui_compare',
@@ -62,7 +62,7 @@ function data_ui_menu() {
       'access arguments' => array('administer data tables'),
       'type' => MENU_LOCAL_TASK,
     );
-    $items['admin/build/data/compare/%data_ui_table'] = array(
+    $items['admin/structure/data/compare/%data_ui_table'] = array(
       'title' => 'Adjust schema',
       'description' => 'Administer data tables.',
       'page callback' => 'drupal_get_form',
@@ -71,7 +71,7 @@ function data_ui_menu() {
       'access arguments' => array('administer data tables'),
       'type' => MENU_LOCAL_TASK,
     );
-    $items['admin/build/data/adopt'] = array(
+    $items['admin/structure/data/adopt'] = array(
       'title' => 'Adopt tables',
       'description' => 'Adopt data tables that aren\'t claimed by any module.',
       'page callback' => 'drupal_get_form',
@@ -82,7 +82,7 @@ function data_ui_menu() {
       'weight' => 10,
     );
   }
-  $items['admin/build/data/create'] = array(
+  $items['admin/structure/data/create'] = array(
     'title' => 'Create a table',
     'description' => 'Create a data table.',
     'page callback' => 'drupal_get_form',
@@ -91,7 +91,7 @@ function data_ui_menu() {
     'access arguments' => array('administer data tables'),
     'type' => MENU_CALLBACK,
   );
-  $items['admin/build/data/drop/%data_ui_table'] = array(
+  $items['admin/structure/data/drop/%data_ui_table'] = array(
     'title' => 'Drop table',
     'description' => 'Drop a data table.',
     'page callback' => 'drupal_get_form',
@@ -100,7 +100,7 @@ function data_ui_menu() {
     'access arguments' => array('administer data tables'),
     'type' => MENU_CALLBACK,
   );
-  $items['admin/build/data/edit/%data_ui_table'] = array(
+  $items['admin/structure/data/edit/%data_ui_table'] = array(
     'title' => 'Data table',
     'description' => 'Administer data tables.',
     'page callback' => 'drupal_get_form',
@@ -109,12 +109,12 @@ function data_ui_menu() {
     'access arguments' => array('administer data tables'),
     'type' => MENU_CALLBACK,
   );
-  $items['admin/build/data/edit/%data_ui_table/edit'] = array(
+  $items['admin/structure/data/edit/%data_ui_table/edit'] = array(
     'title' => 'Edit schema',
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'weight' => -10,
   );
-  $items['admin/build/data/edit/%data_ui_table/title'] = array(
+  $items['admin/structure/data/edit/%data_ui_table/title'] = array(
     'title' => 'Edit title',
     'description' => 'Edit the title of the table.',
     'page callback' => 'drupal_get_form',
@@ -125,7 +125,7 @@ function data_ui_menu() {
     'weight' => -9,
   );
   if (module_exists('views')) {
-    $items['admin/build/data/edit/%data_ui_table/views'] = array(
+    $items['admin/structure/data/edit/%data_ui_table/views'] = array(
       'title' => 'Configure views',
       'description' => 'Administer data tables.',
       'page callback' => 'drupal_get_form',
@@ -136,7 +136,7 @@ function data_ui_menu() {
     );
   }
   if (module_exists('devel')) {
-    $items['admin/build/data/edit/%data_ui_table/view-schema'] = array(
+    $items['admin/structure/data/edit/%data_ui_table/view-schema'] = array(
       'title' => 'Devel load',
       'description' => 'Administer data tables.',
       'page callback' => 'data_ui_view_schema',
@@ -147,7 +147,7 @@ function data_ui_menu() {
       'weight' => 10,
     );
   }
-  $items['admin/build/data/edit/%data_ui_table/join'] = array(
+  $items['admin/structure/data/edit/%data_ui_table/join'] = array(
     'title' => 'Join tables',
     'description' => 'Administer data tables.',
     'page callback' => 'drupal_get_form',
@@ -156,7 +156,7 @@ function data_ui_menu() {
     'access arguments' => array('administer data tables'),
     'type' => MENU_CALLBACK,
   );
-  $items['admin/build/data/revert/%data_ui_table'] = array(
+  $items['admin/structure/data/revert/%data_ui_table'] = array(
     'title' => 'Revert data table',
     'description' => 'Administer data tables.',
     'page callback' => 'drupal_get_form',
@@ -165,7 +165,7 @@ function data_ui_menu() {
     'access arguments' => array('administer data tables'),
     'type' => MENU_CALLBACK,
   );
-  $items['admin/build/data/export/%data_ui_table'] = array(
+  $items['admin/structure/data/export/%data_ui_table'] = array(
     'title' => 'Data table',
     'description' => 'Export data table.',
     'page callback' => 'drupal_get_form',
@@ -192,7 +192,7 @@ function data_ui_title($title) {
 }
 
 /**
- * Implementation of hook_views_api().
+ * Implements hook_views_api().
  */
 function data_ui_views_api() {
   return array(
@@ -201,30 +201,35 @@ function data_ui_views_api() {
 }
 
 /**
- * Implementation of hook_theme()
+ * Implements hook_theme().
  */
 function data_ui_theme() {
   return array(
     'data_ui_edit_form' => array(
-      'arguments' => array('form' => array()),
+      'render element' => 'form',
     ),
     'data_ui_views_form' => array(
-      'arguments' => array('form' => array()),
+      'render element' => 'form',
     ),
     'data_ui_create_form' => array(
-      'arguments' => array('form' => array()),
+      'render element' => 'form',
     ),
     'data_ui_schema_compare_table' => array(
-      'arguments' => array('comparison' => array()),
+      'variables' => array('comparison' => array()),
     ),
   );
 }
 
 /**
- * Implementation of hook_perm().
+ * Implements hook_permission().
  */
-function data_ui_perm() {
-  return array('administer data tables');
+function data_ui_permission() {
+  return array(
+    'administer data tables' => array(
+      'title' => t('administer data tables'),
+      'description' => t('TODO Add a description for \'administer data tables\''),
+    ),
+  );
 }
 
 /**
diff --git a/data_ui/data_ui.views_default.inc b/data_ui/data_ui.views_default.inc
index be37d70..4e95f3c 100644
--- a/data_ui/data_ui.views_default.inc
+++ b/data_ui/data_ui.views_default.inc
@@ -5,7 +5,7 @@
  */
 
 /**
- * Implementation of hook_views_default_views().
+ * Implements hook_views_default_views().
  */
 function data_ui_views_default_views() {
   $views = array();
diff --git a/data_ui/tests/data_ui_test.info b/data_ui/tests/data_ui_test.info
index 3779e6e..021d460 100644
--- a/data_ui/tests/data_ui_test.info
+++ b/data_ui/tests/data_ui_test.info
@@ -2,5 +2,5 @@ name = "Data UI module tests"
 description = "Test module for Data UI testing."
 package = Testing
 version = VERSION
-core = 6.x
-hidden = TRUE
\ No newline at end of file
+core = 7.x
+hidden = TRUE
diff --git a/data_ui/tests/data_ui_test.install b/data_ui/tests/data_ui_test.install
index 17db751..bcc7d15 100644
--- a/data_ui/tests/data_ui_test.install
+++ b/data_ui/tests/data_ui_test.install
@@ -1,14 +1,21 @@
 <?php
+/**
+ * @file
+ * Install, update and uninstall functions for the data_ui_test module.
+ *
+ */
+
 
 /**
- * Implementation of hook_install().
+ * Implements hook_install().
  */
 function data_ui_test_install() {
-  drupal_install_schema('data_ui_test');
+  // TODO The drupal_(un)install_schema functions are called automatically in D7.
+  // drupal_install_schema('data_ui_test')
 }
 
 /**
- * Implementation of hook_schema().
+ * Implements hook_schema().
  */
 function data_ui_test_schema() {
   // Pull defaults and expose schema to Drupal.
diff --git a/data_ui/tests/data_ui_test.module b/data_ui/tests/data_ui_test.module
index 715e1e4..fcfb7ec 100644
--- a/data_ui/tests/data_ui_test.module
+++ b/data_ui/tests/data_ui_test.module
@@ -5,7 +5,7 @@
  */
 
 /**
- * Implementation of hook_ctools_plugin_api().
+ * Implements hook_ctools_plugin_api().
  */
 function data_ui_test_ctools_plugin_api($module, $api) {
   if ($module == 'data' && $api == 'data_default') {
@@ -16,7 +16,7 @@ function data_ui_test_ctools_plugin_api($module, $api) {
 }
 
 /**
- * Implementation of hook_data_default().
+ * Implements hook_data_default().
  */
 function data_ui_test_data_default() {
   $data_table = new stdClass;
diff --git a/includes/DataHandler.inc b/includes/DataHandler.inc
index 73b0d46..df1ee4a 100644
--- a/includes/DataHandler.inc
+++ b/includes/DataHandler.inc
@@ -58,6 +58,7 @@ class DataHandler {
     }
 
     if (!empty($where)) {
+      // TODO Please convert this statement to the D7 database API syntax.
       $result = db_query('SELECT * FROM {' . db_escape_table($this->table) . '} WHERE ' . implode(' AND ', $where), $values);
       $results = array();
       while ($row = db_fetch_array($result)) {
@@ -172,6 +173,7 @@ class DataHandler {
    * Empty data table.
    */
   public function truncate() {
+    // TODO Please convert this statement to the D7 database API syntax.
     db_query('TRUNCATE TABLE {' . db_escape_table($this->table) . '}');
   }
 }
@@ -258,6 +260,7 @@ class DataQuery {
     if (!empty($where)) {
       $query .= " WHERE " . implode(' AND ', $where);
     }
+    // TODO Please convert this statement to the D7 database API syntax.
     return db_query($query, $values);
   }
 }
diff --git a/includes/DataTable.inc b/includes/DataTable.inc
index 16a4bea..3de8f4b 100644
--- a/includes/DataTable.inc
+++ b/includes/DataTable.inc
@@ -80,7 +80,7 @@ class DataTable {
     if (!_data_load_table($this->name, TRUE) && !db_table_exists($this->name)) {
 
       // Create table.
-      db_create_table($ret, $this->name, $table_schema);
+      db_create_table($this->name, $table_schema);
       if ($ret[0]['success'] != 1) {
         drupal_set_message(t('Error creating table.'), 'error');
         return FALSE;
@@ -231,7 +231,7 @@ class DataTable {
   public function addField($field, $spec) {
 
     $ret = array();
-    db_add_field($ret, $this->name, $field, $spec);
+    db_add_field($this->name, $field, $spec);
 
     if ($ret[0]['success']) {
       $schema = $this->table_schema;
@@ -258,7 +258,7 @@ class DataTable {
     $schema = $this->table_schema;
     if ($schema['fields'][$field]) {
       $index = data_get_index_definition($field, $schema['fields'][$field]);
-      db_add_index($ret, $this->name, $field, $index);
+      db_add_index($this->name, $field, $index);
       if ($ret[0]['success']) {
         $schema['indexes'][$field] = $index;
         $this->update(array('table_schema' => $schema));
@@ -276,7 +276,7 @@ class DataTable {
    */
   public function dropIndex($field) {
     $ret = array();
-    db_drop_index($ret, $this->name, $field);
+    db_drop_index($this->name, $field);
     if ($ret[0]['success']) {
       $schema = $this->table_schema;
       unset($schema['indexes'][$field]);
@@ -297,7 +297,7 @@ class DataTable {
     if ($schema['fields'][$field]) {
       $ret = array();
       $index = data_get_index_definition($field, $schema['fields'][$field]);
-      db_add_unique_key($ret, $this->name, $field, $index);
+      db_add_unique_key($this->name, $field, $index);
       if ($ret[0]['success']) {
         $schema['unique keys'][$field] = array($field);
         $this->update(array('table_schema' => $schema));
@@ -315,7 +315,7 @@ class DataTable {
    */
   public function dropUniqueKey($field) {
     $ret = array();
-    db_drop_unique_key($ret, $this->name, $field);
+    db_drop_unique_key($this->name, $field);
     if ($ret[0]['success']) {
       $schema = $this->table_schema;
       unset($schema['unique keys'][$field]);
@@ -362,7 +362,7 @@ class DataTable {
         throw new DataException(t('A text field cannot be made a primary key.'));
       }
     }
-    db_add_primary_key($ret, $this->name, $fields);
+    db_add_primary_key($this->name, $fields);
     if ($ret[0]['success']) {
       $schema['primary key'] = $fields;
       $this->update(array('table_schema' => $schema));
@@ -379,7 +379,7 @@ class DataTable {
    */
   public function dropPrimaryKey() {
     $ret = array();
-    db_drop_primary_key($ret, $this->name);
+    db_drop_primary_key($this->name);
     if ($ret[0]['success']) {
       $schema = $this->table_schema;
       $schema['primary key'] = array();
@@ -428,7 +428,7 @@ class DataTable {
         }
       }
     }
-    db_change_field($ret, $this->name, $field, $field, $spec);
+    db_change_field($this->name, $field, $field, $spec);
     if ($ret[0]['success']) {
       $schema = $this->table_schema;
       $schema['fields'][$field] = $spec;
@@ -446,7 +446,7 @@ class DataTable {
    */
   public function dropField($field) {
     $ret = array();
-    db_drop_field($ret, $this->name, $field);
+    db_drop_field($this->name, $field);
 
     if ($ret[0]['success']) {
       $schema = $this->table_schema;
@@ -469,12 +469,16 @@ class DataTable {
   public function drop() {
     if ($this->export_type == EXPORT_IN_DATABASE) {
       if (db_table_exists($this->name)) {
-        db_drop_table($ret, $this->name);
+        db_drop_table($this->name);
       }
       $this->update(array('table_schema' => array()));
       drupal_get_schema($this->name, TRUE);
 
-      db_query('DELETE FROM {data_tables} WHERE name = "%s"', $this->name);
+      // TODO Please review the conversion of this statement to the D7 database API syntax.
+      /* db_query('DELETE FROM {data_tables} WHERE name = "%s"', $this->name) */
+      db_delete('data_tables')
+  ->condition('name', $this->name)
+  ->execute();
       $this->title = '';
       $this->table_schema = $this->meta = array();
       return TRUE;
@@ -492,7 +496,11 @@ class DataTable {
    */
   public function revert() {
     if ($this->export_type & EXPORT_IN_CODE) {
-      db_query('DELETE FROM {data_tables} WHERE name = "%s"', $this->name);
+      // TODO Please review the conversion of this statement to the D7 database API syntax.
+      /* db_query('DELETE FROM {data_tables} WHERE name = "%s"', $this->name) */
+      db_delete('data_tables')
+  ->condition('name', $this->name)
+  ->execute();
       return TRUE;
     }
     return FALSE;
diff --git a/views/views_handler_field_data_markup.inc b/views/views_handler_field_data_markup.inc
index 85b4b27..eb6799a 100644
--- a/views/views_handler_field_data_markup.inc
+++ b/views/views_handler_field_data_markup.inc
@@ -31,7 +31,7 @@ class views_handler_field_data_markup extends views_handler_field {
     $value = $values->{$this->field_alias};
     if ($value) {
       $format = is_numeric($this->options['format']) ? $this->options['format'] : variable_get('filter_default_format', 1);
-      return check_markup($value, $format, FALSE);
+      return check_markup($value, $format, $langcode = '' /* TODO Set this variable. */, FALSE);
     }
   }
 }
-- 
1.7.0.3


From b75046f2ee137d7ff9fdb5ccb561ecaa702f84ce Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Fri, 11 Nov 2011 10:43:00 +0000
Subject: [PATCH 03/13] Upgraded for changes to CTools.

---
 data.install |    4 ++--
 data.module  |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/data.install b/data.install
index 6e29a25..ebb1c63 100644
--- a/data.install
+++ b/data.install
@@ -108,8 +108,8 @@ function data_update_6002() {
   // reset cTools static cache of this table; otherwise it throws an error about
   // lacking a primary key, which just adds insult to injury as we're trying to fix that!
   drupal_get_schema('data_tables', TRUE);
-  if (function_exists('ctools_static_reset')) {
-    ctools_static_reset('ctools_export_get_schema');
+  if (function_exists('drupal_static_reset')) {
+    drupal_static_reset('ctools_export_get_schema');
   }
   // hook_update_N() no longer returns a $ret array. Instead, return
   // nothing or a translated string indicating the update ran successfully.
diff --git a/data.module b/data.module
index ab44279..d0910c3 100644
--- a/data.module
+++ b/data.module
@@ -373,8 +373,8 @@ function data_export($name, $indent = '') {
 function _data_load_table($name = NULL, $reset = FALSE) {
   ctools_include('export');
   if ($reset) {
-    ctools_static_reset('ctools_export_load_object');
-    ctools_static_reset('ctools_export_load_object_all');
+    drupal_static_reset('ctools_export_load_object');
+    drupal_static_reset('ctools_export_load_object_all');
   }
   if ($name === NULL) {
     return ctools_export_load_object('data_tables', 'all', array());
-- 
1.7.0.3


From 34ca3f99afefd2c18db39fe422086c7ff4c8d7b9 Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Fri, 11 Nov 2011 10:52:16 +0000
Subject: [PATCH 04/13] Fixed incorrect menu path.

---
 data_ui/data_ui.module |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/data_ui/data_ui.module b/data_ui/data_ui.module
index 8aeae37..372b497 100644
--- a/data_ui/data_ui.module
+++ b/data_ui/data_ui.module
@@ -32,7 +32,7 @@ function data_ui_help($path, $arg) {
 function data_ui_menu() {
   $items = array();
   if (module_exists('views')) {
-    $items['admin/content/data'] = array(
+    $items['admin/structure/data'] = array(
       'title' => 'Data tables',
       'description' => 'View data tables.',
       'page callback' => 'data_ui_view',
-- 
1.7.0.3


From 899e019186b2ad61082106ecd0a757eced0c646c Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Fri, 11 Nov 2011 11:09:04 +0000
Subject: [PATCH 05/13] Replaced obsolete schema_invoke() for upgraded Schema module.

---
 data_ui/data_ui.admin.inc  |    4 ++--
 data_ui/tests/data_ui.test |    2 ++
 includes/DataTable.inc     |    4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/data_ui/data_ui.admin.inc b/data_ui/data_ui.admin.inc
index 666f365..8c47298 100644
--- a/data_ui/data_ui.admin.inc
+++ b/data_ui/data_ui.admin.inc
@@ -176,7 +176,7 @@ function data_ui_adjust_form($form, &$form_state, $table) {
  */
 function data_ui_adjust_form_submit_update_schema($form, &$form_state) {
   $table = $form['#table'];
-  $schema = schema_invoke('inspect');
+  $schema = schema_dbobject()->inspect();
   if (isset($schema[$table->get('name')])) {
     $table->update(array('table_schema' => $schema[$table->get('name')]));
     drupal_set_message(t('Updated schema for !table', array('!table' => $table->get('name'))));
@@ -237,7 +237,7 @@ function data_ui_adopt_form($form, $form_state) {
 
   // Compile a list of orphaned tables.
   $drupal_schema = drupal_get_schema(NULL, TRUE);
-  $db_schema = schema_invoke('inspect');
+  $db_schema = schema_dbobject()->inspect();
   $orphaned_tables = array();
   foreach ($db_schema as $name => $table) {
     if (!isset($drupal_schema[$name])) {
diff --git a/data_ui/tests/data_ui.test b/data_ui/tests/data_ui.test
index 5f90e45..2657aed 100644
--- a/data_ui/tests/data_ui.test
+++ b/data_ui/tests/data_ui.test
@@ -86,6 +86,8 @@ class DataTestCaseUI extends DataTestCase {
     $this->drupalPost('admin/build/data/compare/data_table_kittens', array(), t('Create table'));
     $this->assertText('Created table data_table_kittens');
     $this->assertTrue(db_table_exists('data_table_kittens'), 'Table data_table_kittens exists in DB.');
+    // TODO upgrade: schema_invoke is deprecated; see commit
+    // 900fda77a8ed95a64afb6bf01448917bf6be77a6 in its repository.
     $schema = schema_invoke('inspect', db_prefix_tables('{data_table_kittens}'));
     $this->assertTrue(isset($schema['data_table_kittens']), 'Schema API inspector detects table.');
     $this->assertTrue(!empty($table), 'Table loaded');
diff --git a/includes/DataTable.inc b/includes/DataTable.inc
index 3de8f4b..ba6f584 100644
--- a/includes/DataTable.inc
+++ b/includes/DataTable.inc
@@ -91,7 +91,7 @@ class DataTable {
       // @todo: this is slow, maybe we need to make this an explicit method
       // on DataTable.
       if (module_exists('schema')) {
-        $schema = schema_invoke('inspect');
+        $schema = schema_dbobject()->inspect();
         if (isset($schema[$this->name])) {
           $table_schema = $schema[$this->name];
         }
@@ -145,7 +145,7 @@ class DataTable {
       return FALSE;
     }
 
-    $schema = schema_invoke('inspect', $this->name);
+    $schema = schema_dbobject()->inspect(variable_get('schema_database_connection', 'default'), $this->name);
     if (isset($schema[$this->name])) {
       $table = array(
         'name' => $this->name,
-- 
1.7.0.3


From af776f8359263425e3c13dd15f304e7d74cc361f Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Fri, 11 Nov 2011 11:20:05 +0000
Subject: [PATCH 06/13] Added file list to info file; removed obsolete data_include().

---
 data.info                 |    7 +++++++
 data.module               |   14 --------------
 data_ui/data_ui.admin.inc |    1 -
 3 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/data.info b/data.info
index 9987d66..1427723 100644
--- a/data.info
+++ b/data.info
@@ -3,3 +3,10 @@ description = Provides two dimensional storage space for arbitrary data sets.
 package = Data
 dependencies[] = ctools
 core = 7.x
+
+files[] = data.module
+files[] = includes/DataHandler.inc
+files[] = includes/DataTable.inc
+files[] = tests/data.test
+files[] = tests/data.test.inc
+files[] = views/views_handler_field_data_markup.inc
diff --git a/data.module b/data.module
index d0910c3..0da8ce6 100644
--- a/data.module
+++ b/data.module
@@ -56,7 +56,6 @@ function data_schema_alter(&$schema) {
  *   A DataTable object if one could be created, FALSE otherwise.
  */
 function data_create_table($name, $schema, $title = NULL) {
-  data_include('DataTable');
   $table = DataTable::instance($name);
   if ($table->create($schema)) {
     if (!empty($title)) {
@@ -83,7 +82,6 @@ function data_create_table($name, $schema, $title = NULL) {
  * DataTable object.
  */
 function data_get_table($name) {
-  data_include('DataTable');
   $table = DataTable::instance($name);
   if ($table->defined()) {
     return $table;
@@ -128,7 +126,6 @@ function data_get_all_tables($reset = FALSE) {
  *   DataHandler object that provides access to a table's data.
  */
 function data_get_handler($table_name) {
-  data_include('DataHandler');
   return DataHandler::instance($table_name);
 }
 
@@ -449,17 +446,6 @@ function _data_override($name) {
 }
 
 /**
- * Include class file.
- */
-function data_include($class) {
-  static $included;
-  if (!isset($included[$class])) {
-    include DRUPAL_ROOT . '/' . drupal_get_path('module', 'data') . '/includes/' . $class . '.inc';
-    $included[$class] = TRUE;
-  }
-}
-
-/**
  * Base class for any exceptions thrown in Data.
  */
 class DataException extends Exception { }
diff --git a/data_ui/data_ui.admin.inc b/data_ui/data_ui.admin.inc
index 8c47298..0ad4ccc 100644
--- a/data_ui/data_ui.admin.inc
+++ b/data_ui/data_ui.admin.inc
@@ -267,7 +267,6 @@ function data_ui_adopt_form($form, $form_state) {
  * Submit handler for adopt table form.
  */
 function data_ui_adopt_form_submit($form, &$form_state) {
-  data_include('DataTable');
   $tables = array_keys(array_filter($form_state['values']['orphaned_tables']));
   foreach ($tables as $table_name) {
     $table = DataTable::instance($table_name);
-- 
1.7.0.3


From 5d9f63df34477a934cc6187c8d0bd413469eff63 Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Fri, 11 Nov 2011 12:08:04 +0000
Subject: [PATCH 07/13] Upgraded for FormAPI #markup elements.

---
 data_ui/data_ui.admin.inc |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/data_ui/data_ui.admin.inc b/data_ui/data_ui.admin.inc
index 0ad4ccc..6b84011 100644
--- a/data_ui/data_ui.admin.inc
+++ b/data_ui/data_ui.admin.inc
@@ -124,7 +124,7 @@ function data_ui_adjust_form($form, &$form_state, $table) {
       '#title' => t('Option 1: Update schema information'),
     );
     $form['update_schema']['description'] = array(
-      '#value' => t('<p>This option will update the schema information about this table.</p>'),
+      '#markup' => t('<p>This option will update the schema information about this table.</p>'),
     );
     $form['update_schema']['submit'] = array(
       '#type' => 'submit',
@@ -136,7 +136,7 @@ function data_ui_adjust_form($form, &$form_state, $table) {
       '#title' => t('Option 2: Alter table'),
     );
     $form['alter_table']['description'] = array(
-      '#value' => t('<p>Review the changes above carefully!
+      '#markup' => t('<p>Review the changes above carefully!
         This option will alter the database table and can very
         easily cause data loss.</p>'),
     );
@@ -152,7 +152,7 @@ function data_ui_adjust_form($form, &$form_state, $table) {
       '#title' => t('Create table'),
     );
     $form['alter_table']['description'] = array(
-      '#value' => t('<p>Create a new table from schema information.</p>'),
+      '#markup' => t('<p>Create a new table from schema information.</p>'),
     );
     $form['alter_table']['submit'] = array(
       '#type' => 'submit',
@@ -310,7 +310,7 @@ function data_ui_create_form($form, &$form_state) {
     );
   }
   else {
-    $form['help']['#value'] = t('Define the fields of the new table.');
+    $form['help']['#markup'] = t('Define the fields of the new table.');
     $form['fields'] = array(
       '#tree' => TRUE,
     );
@@ -473,7 +473,7 @@ function data_ui_edit_form($form, &$form_state, $table) {
       $form['fields'][$field_name]['selected'] = array(
         '#type' => 'checkbox',
       );
-      $form['fields'][$field_name]['name'] = array('#value' => $field_name);
+      $form['fields'][$field_name]['name'] = array('#markup' => $field_name);
       $form['fields'][$field_name]['label'] = array(
         '#type' => 'textfield',
         '#size' => 20,
@@ -508,7 +508,7 @@ function data_ui_edit_form($form, &$form_state, $table) {
         $join = t('<none>');
       }
       $join = l($join, 'admin/structure/data/edit/' . $table->get('name') . '/join/' . $field_name);
-      $form['fields'][$field_name]['join']['#value'] = $join;
+      $form['fields'][$field_name]['join']['#markup'] = $join;
     }
   }
 
@@ -682,7 +682,7 @@ function data_ui_views_form($form, &$form_state, $table) {
   if (isset($schema['fields'])) {
     foreach ($schema['fields'] as $field_name => $field) {
       $form['fields'][$field_name] = array();
-      $form['fields'][$field_name]['name'] = array('#value' => $field_name);
+      $form['fields'][$field_name]['name'] = array('#markup' => $field_name);
       $form['fields'][$field_name]['views_field_handler'] = array(
         '#type' => 'select',
         '#options' => data_get_views_handler_options('field'),
-- 
1.7.0.3


From 2debfc401aae30c4d8cd8a1784a429961b90a50d Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Fri, 11 Nov 2011 12:13:34 +0000
Subject: [PATCH 08/13] Commented out hook_schema_alter() for the time being.

---
 data.module |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/data.module b/data.module
index 0da8ce6..789e6a9 100644
--- a/data.module
+++ b/data.module
@@ -26,7 +26,8 @@ function data_views_api() {
  * we are actually rebuilding it - follow path through
  * data_get_all_tables() ... _data_load_table() ... ctools_export_load_object().
  */
-function data_schema_alter(&$schema) {
+// TODO upgrade: this produces spectacular crashes! 
+function Xdata_schema_alter(&$schema) {
   $tables = data_get_all_tables(TRUE);
   foreach ($tables as $table) {
     // Only add table if not yet present or the table at hand is defined in DB.
-- 
1.7.0.3


From a3d2e7b954e2392018a64086a95e5c531e4eb97f Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Fri, 11 Nov 2011 13:37:15 +0000
Subject: [PATCH 09/13] Fixed adding a field to a table.

---
 includes/DataTable.inc |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/includes/DataTable.inc b/includes/DataTable.inc
index ba6f584..ed021c5 100644
--- a/includes/DataTable.inc
+++ b/includes/DataTable.inc
@@ -229,11 +229,9 @@ class DataTable {
    * @todo: Check wether field name is available, otherwise change.
    */
   public function addField($field, $spec) {
+    try {
+      db_add_field($this->name, $field, $spec);
 
-    $ret = array();
-    db_add_field($this->name, $field, $spec);
-
-    if ($ret[0]['success']) {
       $schema = $this->table_schema;
       $schema['fields'][$field] = $spec;
       $this->update(array('table_schema' => $schema));
@@ -246,6 +244,10 @@ class DataTable {
       }
       return $field;
     }
+    catch (DatabaseSchemaObjectExistsException $e) {
+      throw new DataException(t('Error adding field.'));
+    }
+
     throw new DataException(t('Error adding field.'));
   }
 
-- 
1.7.0.3


From 96aa7e7ec679291a9d116f3827f7919c8f59de6a Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Fri, 11 Nov 2011 13:37:25 +0000
Subject: [PATCH 10/13] Fixed warning on empty field labels.

---
 data_ui/data_ui.admin.inc |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/data_ui/data_ui.admin.inc b/data_ui/data_ui.admin.inc
index 6b84011..bd4ac6d 100644
--- a/data_ui/data_ui.admin.inc
+++ b/data_ui/data_ui.admin.inc
@@ -477,7 +477,7 @@ function data_ui_edit_form($form, &$form_state, $table) {
       $form['fields'][$field_name]['label'] = array(
         '#type' => 'textfield',
         '#size' => 20,
-        '#default_value' => $meta['fields'][$field_name]['label'],
+        '#default_value' => isset($meta['fields'][$field_name]['label']) ? $meta['fields'][$field_name]['label'] : '',
       );
       $form['fields'][$field_name]['type'] = array(
         '#type' => 'select',
-- 
1.7.0.3


From 06c5481a188acca2b6ddee25d86e829f1897a32c Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Fri, 11 Nov 2011 13:57:07 +0000
Subject: [PATCH 11/13] Fixed for changes to Database API functions.

---
 includes/DataTable.inc |  102 +++++++++++++++++++++++++-----------------------
 1 files changed, 53 insertions(+), 49 deletions(-)

diff --git a/includes/DataTable.inc b/includes/DataTable.inc
index ed021c5..19e4683 100644
--- a/includes/DataTable.inc
+++ b/includes/DataTable.inc
@@ -39,7 +39,7 @@ class DataTable {
   // @todo: change $table_schema to $schema.
   // @todo: change $name to $id.
   // Unfortunately drupal_write_record does not escape field names. $table_schema instead of $schema it is.
-  protected $name, $title, $table_schema, $meta, $export_type;
+  public $name, $title, $table_schema, $meta, $export_type;
 
   /**
    * Instiate a DataTable object. Use this function instead of new DataTable.
@@ -80,8 +80,10 @@ class DataTable {
     if (!_data_load_table($this->name, TRUE) && !db_table_exists($this->name)) {
 
       // Create table.
-      db_create_table($this->name, $table_schema);
-      if ($ret[0]['success'] != 1) {
+      try {
+        db_create_table($this->name, $table_schema);
+      }
+      catch (DatabaseSchemaObjectExistsException $e) {
         drupal_set_message(t('Error creating table.'), 'error');
         return FALSE;
       }
@@ -260,15 +262,17 @@ class DataTable {
     $schema = $this->table_schema;
     if ($schema['fields'][$field]) {
       $index = data_get_index_definition($field, $schema['fields'][$field]);
-      db_add_index($this->name, $field, $index);
-      if ($ret[0]['success']) {
-        $schema['indexes'][$field] = $index;
-        $this->update(array('table_schema' => $schema));
-        drupal_get_schema($this->name, TRUE);
-        return;
+      try {
+        db_add_index($this->name, $field, $index);
+      }
+      catch (DatabaseSchemaObjectExistsException $e) {
+        throw new DataException(t('Error adding index.'));
       }
+
+      $schema['indexes'][$field] = $index;
+      $this->update(array('table_schema' => $schema));
+      drupal_get_schema($this->name, TRUE);
     }
-    throw new DataException(t('Error adding index.'));
   }
 
   /**
@@ -277,9 +281,8 @@ class DataTable {
    * @throws DataException
    */
   public function dropIndex($field) {
-    $ret = array();
-    db_drop_index($this->name, $field);
-    if ($ret[0]['success']) {
+    $success = db_drop_index($this->name, $field);
+    if ($success) {
       $schema = $this->table_schema;
       unset($schema['indexes'][$field]);
       $this->update(array('table_schema' => $schema));
@@ -297,17 +300,20 @@ class DataTable {
   public function addUniqueKey($field) {
     $schema = $this->table_schema;
     if ($schema['fields'][$field]) {
-      $ret = array();
       $index = data_get_index_definition($field, $schema['fields'][$field]);
-      db_add_unique_key($this->name, $field, $index);
-      if ($ret[0]['success']) {
+      try {
+        $success = db_add_unique_key($this->name, $field, $index);
+      }
+      catch (DatabaseSchemaObjectExistsException $e) {
+        throw new DataException(t('Error adding unique key.'));
+      }
+      if ($success) {
         $schema['unique keys'][$field] = array($field);
         $this->update(array('table_schema' => $schema));
         drupal_get_schema($this->name, TRUE);
         return;
       }
     }
-    throw new DataException(t('Error adding unique key.'));
   }
 
   /**
@@ -316,9 +322,8 @@ class DataTable {
    * @throws DataException
    */
   public function dropUniqueKey($field) {
-    $ret = array();
-    db_drop_unique_key($this->name, $field);
-    if ($ret[0]['success']) {
+    $success = db_drop_unique_key($this->name, $field);
+    if ($success) {
       $schema = $this->table_schema;
       unset($schema['unique keys'][$field]);
       $this->update(array('table_schema' => $schema));
@@ -357,21 +362,23 @@ class DataTable {
    * @throws DataException
    */
   public function addPrimaryKey($fields) {
-    $ret = array();
     $schema = $this->table_schema;
     foreach ($fields as $field) {
       if ($schema['fields'][$field]['type'] == 'text') {
         throw new DataException(t('A text field cannot be made a primary key.'));
       }
     }
-    db_add_primary_key($this->name, $fields);
-    if ($ret[0]['success']) {
-      $schema['primary key'] = $fields;
-      $this->update(array('table_schema' => $schema));
-      drupal_get_schema($this->name, TRUE);
-      return;
+
+    try {
+      db_add_primary_key($this->name, $fields);
+    }
+    catch (DatabaseSchemaObjectExistsException $e) {
+      throw new DataException(t('Error creating primary key.'));
     }
-    throw new DataException(t('Error creating primary key.'));
+
+    $schema['primary key'] = $fields;
+    $this->update(array('table_schema' => $schema));
+    drupal_get_schema($this->name, TRUE);
   }
 
   /**
@@ -380,16 +387,13 @@ class DataTable {
    * @throws DataException
    */
   public function dropPrimaryKey() {
-    $ret = array();
     db_drop_primary_key($this->name);
-    if ($ret[0]['success']) {
-      $schema = $this->table_schema;
-      $schema['primary key'] = array();
-      $this->update(array('table_schema' => $schema));
-      drupal_get_schema($this->name, TRUE);
-      return;
-    }
-    throw new DataException(t('Error dropping primary key.'));
+
+    $schema = $this->table_schema;
+    $schema['primary key'] = array();
+    $this->update(array('table_schema' => $schema));
+    drupal_get_schema($this->name, TRUE);
+    return;
   }
 
   /**
@@ -413,7 +417,6 @@ class DataTable {
    * @throws DataException
    */
   public function changeField($field, $spec) {
-    $ret = array();
     // If new type is text, check for PK and index restrictions.
     if ($spec['type'] == 'text') {
       if (in_array($field, $this->table_schema['primary key'])) {
@@ -430,15 +433,17 @@ class DataTable {
         }
       }
     }
-    db_change_field($this->name, $field, $field, $spec);
-    if ($ret[0]['success']) {
-      $schema = $this->table_schema;
-      $schema['fields'][$field] = $spec;
-      $this->update(array('table_schema' => $schema));
-      drupal_get_schema($this->name, TRUE);
-      return;
+    try {
+      db_change_field($this->name, $field, $field, $spec);
+    }
+    catch (DatabaseSchemaObjectDoesNotExistException $e) {
+      throw new DataException(t('Cannot change field.'));
     }
-    throw new DataException(t('Cannot change field.'));
+
+    $schema = $this->table_schema;
+    $schema['fields'][$field] = $spec;
+    $this->update(array('table_schema' => $schema));
+    drupal_get_schema($this->name, TRUE);
   }
 
   /**
@@ -447,10 +452,9 @@ class DataTable {
    * @throws DataException
    */
   public function dropField($field) {
-    $ret = array();
-    db_drop_field($this->name, $field);
+    $success = db_drop_field($this->name, $field);
 
-    if ($ret[0]['success']) {
+    if ($success) {
       $schema = $this->table_schema;
       unset($schema['fields'][$field]);
       $meta = $this->meta;
-- 
1.7.0.3


From 88edda88df1807326a2d17145577c68ae9fcc5e9 Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Tue, 15 Nov 2011 13:48:59 +0000
Subject: [PATCH 12/13] Uncomment hook_schema_alter(); seems to work ok.

---
 data.module |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/data.module b/data.module
index 789e6a9..1fea7e2 100644
--- a/data.module
+++ b/data.module
@@ -26,8 +26,8 @@ function data_views_api() {
  * we are actually rebuilding it - follow path through
  * data_get_all_tables() ... _data_load_table() ... ctools_export_load_object().
  */
-// TODO upgrade: this produces spectacular crashes! 
-function Xdata_schema_alter(&$schema) {
+// TODO: this has produced some spectacular crashes on module enable and that sort of thing!
+function data_schema_alter(&$schema) {
   $tables = data_get_all_tables(TRUE);
   foreach ($tables as $table) {
     // Only add table if not yet present or the table at hand is defined in DB.
-- 
1.7.0.3


From 62c32b1c72c7d4ce6a9fc8ca7db65400a04fb69a Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Tue, 15 Nov 2011 13:49:07 +0000
Subject: [PATCH 13/13] Fixed warning message in UI.

---
 data_ui/data_ui.admin.inc |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/data_ui/data_ui.admin.inc b/data_ui/data_ui.admin.inc
index bd4ac6d..3e69171 100644
--- a/data_ui/data_ui.admin.inc
+++ b/data_ui/data_ui.admin.inc
@@ -968,6 +968,9 @@ function _data_ui_changed($new, $field) {
     $field['type'] = $new['type'];
     $changed = TRUE;
   }
+  if (!isset($field['unsigned'])) {
+    $field['unsigned'] = FALSE;
+  }
   if ($field['unsigned'] != $new['unsigned']) {
     $field['unsigned'] = $new['unsigned'];
     $changed = TRUE;
-- 
1.7.0.3

