Browse Source

Tripal Bulk Loader adheres to Drupal coding standards

Pubudu Basnayaka 12 years ago
parent
commit
2b0d45ae11

+ 91 - 92
tripal_bulk_loader/tripal_bulk_loader.admin.inc

@@ -11,24 +11,24 @@
 function tripal_bulk_loader_admin_template() {
   $output = '';
 
-  $output .= '<br><h3>Quick Links:</h3>';
-  $output .= l('Create a new bulk loader template', 'admin/tripal/tripal_bulk_loader_template/create') . "<br>";
-  $output .= l('Edit a bulk loader template', 'admin/tripal/tripal_bulk_loader_template/edit') . "<br>";
-  $output .= l('Delete a bulk loader template', 'admin/tripal/tripal_bulk_loader_template/delete') . "<br>";
-  $output .= l('Export a bulk loader template', 'admin/tripal/tripal_bulk_loader_template/export') . "<br>";
-  $output .= l('Import a bulk loader template', 'admin/tripal/tripal_bulk_loader_template/import') . "<br>";
-  $output .= '<br>';
+  $output .= '<br /><h3>Quick Links:</h3>';
+  $output .= l(t('Create a new bulk loader template'), 'admin/tripal/tripal_bulk_loader_template/create') . "<br />";
+  $output .= l(t('Edit a bulk loader template'), 'admin/tripal/tripal_bulk_loader_template/edit') . "<br />";
+  $output .= l(t('Delete a bulk loader template'), 'admin/tripal/tripal_bulk_loader_template/delete') . "<br />";
+  $output .= l(t('Export a bulk loader template'), 'admin/tripal/tripal_bulk_loader_template/export') . "<br />";
+  $output .= l(t('Import a bulk loader template'), 'admin/tripal/tripal_bulk_loader_template/import') . "<br />";
+  $output .= '<br />';
 
   $output .= '<h3>Module Description:</h3>';
   $output .= '<p>This module provides the ability to create loading templates for any tab-delimited '
     . 'data file allowing it to be loaded into chado. The Loading Templates are a direct mapping '
     . 'between the columns in your file and the columns in chado tables. As such to use this tool '
     . 'you need to be very familar with the chado schema -See '
-    . l('Chado -Getting Started', 'http://gmod.org/wiki/Chado_-_Getting_Started')
+    . l(t('Chado -Getting Started'), 'http://gmod.org/wiki/Chado_-_Getting_Started')
     . '. The ability to add constants and specify foreign key contraints is also provided '
     . 'in order for the loader to fill chado columns which may be required but are not specified '
     . 'in your input file.</p>';
-  $output .= '<br>';
+  $output .= '<br />';
 
   $output .= '<h3>Setup Instructions</h3>';
   $output .= '<p>After intallation of the bulk loader module, the following tasks should be performed:</p>';
@@ -95,7 +95,7 @@ function tripal_bulk_loader_configuration_form($form_state = NULL) {
         fixing the error (manual intervention needed).</div>'),
       'none' => t('Do not use transactions<div class="description">This is not recommended.</div>')
     ),
-    '#default_value' => variable_get('tripal_bulk_loader_transactions','row')
+    '#default_value' => variable_get('tripal_bulk_loader_transactions',   'row')
   );
 
   $form['speed']['lock'] = array(
@@ -112,8 +112,7 @@ function tripal_bulk_loader_configuration_form($form_state = NULL) {
     '#default_value' => variable_get('tripal_bulk_loader_lock', 'ROW EXCLUSIVE'),
   );
 
-
- $form['submit1'] = array(
+  $form['submit1'] = array(
     '#type' => 'submit',
     '#value' => t('Save')
   );
@@ -129,7 +128,7 @@ function tripal_bulk_loader_configuration_form_submit($form, $form_state) {
   variable_set('tripal_bulk_loader_prepare', $form_state['values']['prepare']);
   variable_set('tripal_bulk_loader_disable_triggers', $form_state['values']['disable_triggers']);
   variable_set('tripal_bulk_loader_skip_validation', $form_state['values']['no_validate']);
-  variable_set('tripal_bulk_loader_transactions',$form_state['values']['transactions']);
+  variable_set('tripal_bulk_loader_transactions', $form_state['values']['transactions']);
   variable_set('tripal_bulk_loader_lock', $form_state['values']['lock']);
 
 }
@@ -146,7 +145,7 @@ function tripal_bulk_loader_modify_template_base_form($form_state = NULL, $mode)
   $form = array();
 
    // get template id from path and rebuild form
-   if ($_GET['template_id']) {
+  if ($_GET['template_id']) {
     if (preg_match('/^\d+$/', $_GET['template_id'])) {
       $form_state['storage']['template_id'] = $_GET['template_id'];
     }
@@ -159,7 +158,7 @@ function tripal_bulk_loader_modify_template_base_form($form_state = NULL, $mode)
     $form_state['storage']['record2priority'] = array();
     foreach ($form_state['storage']['template'] as $priority => $record_array) {
       if (!is_array($record_array)) {
-      continue; }
+        continue; }
       $form_state['storage']['record2priority'][$record_array['record_id']] = $priority;
     }
   }
@@ -171,15 +170,15 @@ function tripal_bulk_loader_modify_template_base_form($form_state = NULL, $mode)
 
   if ($form_state['storage']['template_id']) {
     $form['template_name'] = array(
-        '#type' => 'item',
-        '#title' => 'Template',
-        '#value' => $form_state['storage']['template_name'],
-        '#weight' => 1,
+      '#type' => 'item',
+      '#title' => 'Template',
+      '#value' => $form_state['storage']['template_name'],
+      '#weight' => 1,
     );
   }
   else {
     if (preg_match('/create/', $mode)) {
-     $form['new_template_name'] = array(
+      $form['new_template_name'] = array(
         '#type' => 'textfield',
         '#title' => 'Template Name',
         '#weight' => 1,
@@ -423,8 +422,8 @@ function tripal_bulk_loader_modify_template_base_form_submit($form, &$form_state
       $form_state['storage']['record2priority'] = array();
       foreach ($form_state['storage']['template'] as $priority => $record_array) {
         if (!is_array($record_array)) {
-         continue;
-         }
+          continue;
+        }
         $form_state['storage']['record2priority'][$record_array['record_id']] = $priority;
       }
     break;
@@ -444,11 +443,11 @@ function tripal_bulk_loader_modify_template_base_form_submit($form, &$form_state
     case 'Save Order':
       $new_template = $form_state['storage']['template'];
       // unset old elements
-       $form_state['storage']['record2priority'] = array();
+      $form_state['storage']['record2priority'] = array();
       foreach ($new_template as $priority => $record_array) {
         if (preg_match('/\d+/', $priority)) {
-           unset($new_template[$priority]);
-         }
+          unset($new_template[$priority]);
+        }
       }
       //set elements in new order
       foreach ($form_state['values']['records-data'] as $item) {
@@ -514,7 +513,7 @@ function tripal_bulk_loader_modify_template_base_form_submit($form, &$form_state
         unset($form_state['storage']['record2priority'][$form_state['storage']['template'][$priority]['record_id']]);
         unset($form_state['storage']['template'][$priority]);
       }
-      drupal_set_message('Deleted Field from Template.');
+      drupal_set_message(t('Deleted Field from Template.'));
     break;
   } //end of switch
 
@@ -524,7 +523,7 @@ function tripal_bulk_loader_modify_template_base_form_submit($form, &$form_state
     'template_array' => serialize($form_state['storage']['template'])
   );
   drupal_write_record('tripal_bulk_loader_template', $record, array('template_id'));
-  drupal_set_message('Template Saved.');
+  drupal_set_message(t('Template Saved.'));
 
 }
 
@@ -605,7 +604,7 @@ function tripal_bulk_loader_import_export_template_form($form_state = NULL, $mod
   );
 
   if (preg_match('/import/', $mode)) {
-   $form['new_template_name'] = array(
+    $form['new_template_name'] = array(
       '#type' => 'textfield',
       '#title' => 'Template Name',
       '#weight' => 1,
@@ -670,7 +669,7 @@ function tripal_bulk_loader_import_export_template_form_submit($form, &$form_sta
       );
       drupal_write_record('tripal_bulk_loader_template', $record);
       if ($record->template_id) {
-        drupal_set_message('Successfully imported Tripal Bulk Loader Template.');
+        drupal_set_message(t('Successfully imported Tripal Bulk Loader Template.'));
       }
     break;
   }
@@ -694,20 +693,20 @@ function tripal_bulk_loader_import_export_template_form_submit($form, &$form_sta
  *   A form array to be rendered by drupal_get_form
  */
 function tripal_bulk_loader_edit_template_record_form(&$form_state = NULL) {
-   $form['#cache'] = TRUE; // Make sure the form is cached.
+  $form['#cache'] = TRUE; // Make sure the form is cached.
 
    // get template id from path
-   $template_id = ($_GET['template_id'] !== NULL) ? $_GET['template_id'] : $form_state['values']['template_id'];
+  $template_id = ($_GET['template_id'] !== NULL) ? $_GET['template_id'] : $form_state['values']['template_id'];
 
-   // if there is no template supplied don't return rest of form
-   if (!$template_id) {
-     return $form;
-   }
+  // if there is no template supplied don't return rest of form
+  if (!$template_id) {
+    return $form;
+  }
 
   // Pre-process values/defaults ---------------------------
 
-   // If this is the first load of the form (no form state) we need to initialize some variables
-   if (!$form_state['storage']['template']) {
+  // If this is the first load of the form (no form state) we need to initialize some variables
+  if (!$form_state['storage']['template']) {
     $sql = "SELECT * FROM {tripal_bulk_loader_template} WHERE template_id=%d";
     $template = db_fetch_object(db_query($sql, $template_id));
     $form_state['storage']['template_array'] = unserialize($template->template_array);
@@ -716,8 +715,8 @@ function tripal_bulk_loader_edit_template_record_form(&$form_state = NULL) {
     $form_state['storage']['record2priority'] = array();
     foreach ($form_state['storage']['template_array'] as $priority => $record_array) {
       if (!is_array($record_array)) {
-         continue;
-       }
+        continue;
+      }
       $form_state['storage']['record2priority'][$record_array['record_id']] = $priority;
     }
 
@@ -727,10 +726,10 @@ function tripal_bulk_loader_edit_template_record_form(&$form_state = NULL) {
     $template = $form_state['storage']['template'];
   }
 
-   // get the record_id from the path
-   if ($_GET['record_id'] !== NULL) {
-     $form_state['values']['field_group'] = $_GET['record_id'];
-     $form_state['storage']['original_priority'] = $_GET['record_id'];
+  // get the record_id from the path
+  if ($_GET['record_id'] !== NULL) {
+    $form_state['values']['field_group'] = $_GET['record_id'];
+    $form_state['storage']['original_priority'] = $_GET['record_id'];
   }
 
 
@@ -855,8 +854,8 @@ function tripal_bulk_loader_edit_template_record_form_submit($form, &$form_state
       $success = drupal_write_record('tripal_bulk_loader_template', $form_state['storage']['template'], array('template_id'));
 
       if ($success) {
-        drupal_set_message('Successfully Updated Template Record');
-        drupal_set_message('Template Saved.');
+        drupal_set_message(t('Successfully Updated Template Record'));
+        drupal_set_message(t('Template Saved.'));
 
         $path = explode('?', $form_state['storage']['referring URL']);
         parse_str($path[1], $query);
@@ -864,7 +863,7 @@ function tripal_bulk_loader_edit_template_record_form_submit($form, &$form_state
         drupal_goto($path[0], $query);
       }
       else {
-        drupal_set_message('Unable to Save Template!', 'error');
+        drupal_set_message(t('Unable to Save Template!'), 'error');
         watchdog('T_bulk_loader',
           'Unable to save bulk loader template: %template',
           array('%template' => print_r($form_state['storage']['template'], TRUE)),
@@ -902,32 +901,32 @@ function tripal_bulk_loader_edit_template_record_form_submit($form, &$form_state
  */
 function tripal_bulk_loader_add_template_field_form(&$form_state = NULL) {
   $form = array();
-   $form['#cache'] = TRUE; // Make sure the form is cached.
+  $form['#cache'] = TRUE; // Make sure the form is cached.
 
-   // get template id from path
-   $template_id = ($_GET['template_id']) ? $_GET['template_id'] : $form_state['values']['template_id'];
+  // get template id from path
+  $template_id = ($_GET['template_id']) ? $_GET['template_id'] : $form_state['values']['template_id'];
 
-   // if there is no template supplied don't return rest of form
-   if (!$template_id) {
-     return $form;
-   }
+  // if there is no template supplied don't return rest of form
+  if (!$template_id) {
+    return $form;
+  }
 
   // Pre-set Variables needed for form proper------------------------------------------
 
    // If this is the first load of the form (no form state) we need to initialize some variables
-   if (!$form_state['storage']['template']) {
+  if (!$form_state['storage']['template']) {
     $sql = "SELECT * FROM {tripal_bulk_loader_template} WHERE template_id=%d";
     $template = db_fetch_object(db_query($sql, $template_id));
     $form_state['storage']['template_array'] = unserialize($template->template_array);
     $form_state['storage']['template'] = $template;
 
     $form_state['storage']['record2priority'] = array();
-    foreach ($form_state['storage']['template_array'] as $priority => $record_array) {
-      if (!is_array($record_array)) {
-        continue;
-      }
-      $form_state['storage']['record2priority'][$record_array['record_id']] = $priority;
+  foreach ($form_state['storage']['template_array'] as $priority => $record_array) {
+    if (!is_array($record_array)) {
+      continue;
     }
+    $form_state['storage']['record2priority'][$record_array['record_id']] = $priority;
+  }
 
     $form_state['storage']['referring URL'] = $_SERVER["HTTP_REFERER"];
   }
@@ -958,8 +957,8 @@ function tripal_bulk_loader_add_template_field_form(&$form_state = NULL) {
   }
 
    // get the record_id from the path
-   if ($_GET['record_id'] !== NULL) {
-     $form_state['values']['field_group'] = $_GET['record_id'];
+  if ($_GET['record_id'] !== NULL) {
+    $form_state['values']['field_group'] = $_GET['record_id'];
     if (preg_match('/\d+/', $_GET['record_id'])) {
       $priority = $form_state['values']['field_group'];
       $table = $form_state['storage']['template_array'][$priority]['table'];
@@ -1311,9 +1310,9 @@ function tripal_bulk_loader_add_template_field_form(&$form_state = NULL) {
     $form['add_fields']['additional']['regex_transform']['new_regex']['replace']['#description'] .= '<p>'
       .'The following references are also available for spreadsheet fields: <b><#column:<i>number</i>#></b>. '
       .'This allows you to substitute other spreadsheet values into the current field. For example, '
-      .'if you had the following line:<br>'
+      .'if you had the following line:<br />'
       . $tab . 'SNP' . $tab . '15-Jan-2011' . $tab . '1' . $tab . '54' . $tab . 'Contig34355'
-      .'<br> and your current field is for column #1 and you\'re inserting into the chado field '
+      .'<br /> and your current field is for column #1 and you\'re inserting into the chado field '
       .'feature.uniquename then you might want to add in the data to ensure your uniquename is '
       .'unique. The Match Pattern is (.*) to select all the first column and the Replacement '
       .'Pattern could be \1_<#column:2#> which would insert SNP_15-Jan-2011 into the database.</p>';
@@ -1441,8 +1440,8 @@ function tripal_bulk_loader_add_template_field_form_submit($form, &$form_state)
       $success = drupal_write_record('tripal_bulk_loader_template', $form_state['storage']['template'], array('template_id'));
 
       if ($success) {
-        drupal_set_message('Successfully Added Field to Template');
-        drupal_set_message('Template Saved.');
+        drupal_set_message(t('Successfully Added Field to Template'));
+        drupal_set_message(t('Template Saved.'));
 
         $path = explode('?', $form_state['storage']['referring URL']);
         parse_str($path[1], $query);
@@ -1450,7 +1449,7 @@ function tripal_bulk_loader_add_template_field_form_submit($form, &$form_state)
         drupal_goto($path[0], $query);
       }
       else {
-        drupal_set_message('Unable to Save Template!', 'error');
+        drupal_set_message(t('Unable to Save Template!'), 'error');
         watchdog('T_bulk_loader',
           'Unable to save bulk loader template: %template',
           array('%template' => print_r($form_state['storage']['template'], TRUE)),
@@ -1469,7 +1468,7 @@ function tripal_bulk_loader_add_template_field_form_submit($form, &$form_state)
       // Add transformation rule to original field
       $form_state['storage']['regex']['pattern'][] = '/' . $form_state['values']['pattern'] . '/';
       $form_state['storage']['regex']['replace'][] = $form_state['values']['replace'];
-      drupal_set_message('Successfully Added Transformation Rule');
+      drupal_set_message(t('Successfully Added Transformation Rule'));
 
     }
     elseif ($op == 'Save Transformation Rule Order') {
@@ -1526,20 +1525,20 @@ function tripal_bulk_loader_add_template_field_form_submit($form, &$form_state)
  */
 function tripal_bulk_loader_edit_template_field_form(&$form_state = NULL) {
   $form = array();
-   $form['#cache'] = TRUE; // Make sure the form is cached.
+  $form['#cache'] = TRUE; // Make sure the form is cached.
 
-   // get template id from path
-   $template_id = ($_GET['template_id']) ? $_GET['template_id'] : $form_state['values']['template_id'];
+  // get template id from path
+  $template_id = ($_GET['template_id']) ? $_GET['template_id'] : $form_state['values']['template_id'];
 
-   // if there is no template supplied don't return rest of form
-   if (!$template_id) {
-     return $form;
-   }
+  // if there is no template supplied don't return rest of form
+  if (!$template_id) {
+    return $form;
+  }
 
   // Pre-set Variables needed for form proper------------------------------------------
 
-   // If this is the first load of the form (no form state) we need to initialize some variables
-   if (!$form_state['storage']['template']) {
+  // If this is the first load of the form (no form state) we need to initialize some variables
+  if (!$form_state['storage']['template']) {
     $sql = "SELECT * FROM {tripal_bulk_loader_template} WHERE template_id=%d";
     $template = db_fetch_object(db_query($sql, $template_id));
     $form_state['storage']['template_array'] = unserialize($template->template_array);
@@ -1548,8 +1547,8 @@ function tripal_bulk_loader_edit_template_field_form(&$form_state = NULL) {
     $form_state['storage']['record2priority'] = array();
     foreach ($form_state['storage']['template_array'] as $priority => $record_array) {
       if (!is_array($record_array)) {
-         continue;
-       }
+        continue;
+      }
       $form_state['storage']['record2priority'][$record_array['record_id']] = $priority;
     }
 
@@ -1919,9 +1918,9 @@ function tripal_bulk_loader_edit_template_field_form(&$form_state = NULL) {
     $form['edit_fields']['additional']['regex_transform']['new_regex']['replace']['#description'] .= '<p>'
       .'The following references are also available for spreadsheet fields: <b><#column:<i>number</i>#></b>. '
       .'This allows you to substitute other spreadsheet values into the current field. For example, '
-      .'if you had the following line:<br>'
+      .'if you had the following line:<br />'
       . $tab . 'SNP' . $tab . '15-Jan-2011' . $tab . '1' . $tab . '54' . $tab . 'Contig34355'
-      .'<br> and your current field is for column #1 and you\'re inserting into the chado field '
+      .'<br /> and your current field is for column #1 and you\'re inserting into the chado field '
       .'feature.uniquename then you might want to add in the data to ensure your uniquename is '
       .'unique. The Match Pattern is (.*) to select all the first column and the Replacement '
       .'Pattern could be \1_<#column:2#> which would insert SNP_15-Jan-2011 into the database.</p>';
@@ -2062,8 +2061,8 @@ function tripal_bulk_loader_edit_template_field_form_submit($form, &$form_state)
       $success = drupal_write_record('tripal_bulk_loader_template', $form_state['storage']['template'], array('template_id'));
 
       if ($success) {
-        drupal_set_message('Successfully Updated Field');
-        drupal_set_message('Template Saved.');
+        drupal_set_message(t('Successfully Updated Field'));
+        drupal_set_message(t('Template Saved.'));
 
         $path = explode('?', $form_state['storage']['referring URL']);
         parse_str($path[1], $query);
@@ -2071,7 +2070,7 @@ function tripal_bulk_loader_edit_template_field_form_submit($form, &$form_state)
         drupal_goto($path[0], $query);
       }
       else {
-        drupal_set_message('Unable to Save Template!', 'error');
+        drupal_set_message(t('Unable to Save Template!'), 'error');
         watchdog('T_bulk_loader',
           'Unable to save bulk loader template: %template',
           array('%template' => print_r($form_state['storage']['template'], TRUE)),
@@ -2104,11 +2103,11 @@ function tripal_bulk_loader_edit_template_field_form_submit($form, &$form_state)
       $success = drupal_write_record('tripal_bulk_loader_template', $form_state['storage']['template'], array('template_id'));
 
       if ($success) {
-        drupal_set_message('Successfully Added Transformation Rule');
-        drupal_set_message('Template Saved.');
+        drupal_set_message(t('Successfully Added Transformation Rule'));
+        drupal_set_message(t('Template Saved.'));
       }
       else {
-        drupal_set_message('Unable to Save Template!', 'error');
+        drupal_set_message(t('Unable to Save Template!'), 'error');
         watchdog('T_bulk_loader',
           'Unable to save bulk loader template: %template',
           array('%template' => print_r($form_state['storage']['template'], TRUE)),
@@ -2141,11 +2140,11 @@ function tripal_bulk_loader_edit_template_field_form_submit($form, &$form_state)
       $success = drupal_write_record('tripal_bulk_loader_template', $form_state['storage']['template'], array('template_id'));
 
       if ($success) {
-        drupal_set_message('Successfully Reordered Transformation Rules');
-        drupal_set_message('Template Saved.');
+        drupal_set_message(t('Successfully Reordered Transformation Rules'));
+        drupal_set_message(t('Template Saved.'));
       }
       else {
-        drupal_set_message('Unable to Save Template!', 'error');
+        drupal_set_message(t('Unable to Save Template!'), 'error');
         watchdog('T_bulk_loader',
           'Unable to save bulk loader template: %template',
           array('%template' => print_r($form_state['storage']['template'], TRUE)),
@@ -2169,11 +2168,11 @@ function tripal_bulk_loader_edit_template_field_form_submit($form, &$form_state)
       $success = drupal_write_record('tripal_bulk_loader_template', $form_state['storage']['template'], array('template_id'));
 
       if ($success) {
-        drupal_set_message('Successfully Reordered Transformation Rules');
-        drupal_set_message('Template Saved.');
+        drupal_set_message(t('Successfully Reordered Transformation Rules'));
+        drupal_set_message(t('Template Saved.'));
       }
       else {
-        drupal_set_message('Unable to Save Template!', 'error');
+        drupal_set_message(t('Unable to Save Template!'), 'error');
         watchdog('T_bulk_loader',
           'Unable to save bulk loader template: %template',
           array('%template' => print_r($form_state['storage']['template'], TRUE)),

+ 2 - 2
tripal_bulk_loader/tripal_bulk_loader.constants.inc

@@ -509,7 +509,7 @@ function tripal_bulk_loader_edit_constant_set_form_submit($form, $form_state) {
         );
       }
     }
-    drupal_set_message('The constant set was successfully updated.');
+    drupal_set_message(t('The constant set was successfully updated.'));
 
   }
 
@@ -562,7 +562,7 @@ function tripal_bulk_loader_delete_constant_set_form_submit($form, $form_state)
   $nid = $form_state['values']['nid'];
   if ($nid && $form_state['values']['confirm']) {
     db_query("DELETE FROM {tripal_bulk_loader_constants} WHERE nid=%d AND group_id=%d", $nid, $group_id);
-    drupal_set_message('Constant set successfully deleted.');
+    drupal_set_message(t('Constant set successfully deleted.'));
   }
 
 }

+ 2 - 2
tripal_bulk_loader/tripal_bulk_loader.install

@@ -9,14 +9,14 @@
  * Implements hook_install
  */
 function tripal_bulk_loader_install() {
-   drupal_install_schema('tripal_bulk_loader');
+  drupal_install_schema('tripal_bulk_loader');
 }
 
 /**
  * Implements hook_uninstall
  */
 function tripal_bulk_loader_uninstall() {
-   drupal_uninstall_schema('tripal_bulk_loader');
+  drupal_uninstall_schema('tripal_bulk_loader');
 }
 
 /**

+ 13 - 13
tripal_bulk_loader/tripal_bulk_loader.loader.inc

@@ -144,7 +144,7 @@ function tripal_bulk_loader_load_data($nid) {
 
     // Add tables being inserted into to a list to be treated differently
     // this is used to acquire locks on these tables
-    if (preg_match('/insert/',$record_array['mode'])) {
+    if (preg_match('/insert/', $record_array['mode'])) {
       $tables[$record_array['table']] = $record_array['table'];
     }
 
@@ -257,7 +257,7 @@ function tripal_bulk_loader_load_data($nid) {
     }
 
     // Start Transaction
-    switch (variable_get('tripal_bulk_loader_transactions','row')) {
+    switch (variable_get('tripal_bulk_loader_transactions', 'row')) {
       case "none":
         break;
       case "all":
@@ -431,9 +431,9 @@ function process_data_array_for_line($priority, &$data, &$default_data, $field2c
       // a field is considered missing if it cannot be null and there is no default
       // value for it or it is of type 'serial'
       if ($def['not null'] == 1 and !array_key_exists($field, $insert_values) and !isset($def['default']) and strcmp($def['type'], serial)!=0) {
-         $msg = 'Line ' . $line_num . ' ' . $table_data['record_id'] . ' (' . $table_data['mode'] . ') Missing Database Required Value: ' . $table . '.' . $field;
-         watchdog('T_bulk_loader', $msg, array(), WATCHDOG_NOTICE);
-         $data[$priority]['error'] = TRUE;
+        $msg = 'Line ' . $line_num . ' ' . $table_data['record_id'] . ' (' . $table_data['mode'] . ') Missing Database Required Value: ' . $table . '.' . $field;
+        watchdog('T_bulk_loader', $msg, array(), WATCHDOG_NOTICE);
+        $data[$priority]['error'] = TRUE;
       }
     }
   } //end of if optional record
@@ -485,8 +485,8 @@ function process_data_array_for_line($priority, &$data, &$default_data, $field2c
 
   if (!preg_match('/select/', $table_data['mode'])) {
     // Use prepared statement?
-    if (variable_get('tripal_bulk_loader_prepare',TRUE)) {
-      $options = array('statement_name' => 'record_'.$priority);
+    if (variable_get('tripal_bulk_loader_prepare', TRUE)) {
+      $options = array('statement_name' => 'record_' . $priority);
       if ($line_num == 1 && $group_index == 1) {
         $options['prepare'] = TRUE;
       }
@@ -635,8 +635,8 @@ function tripal_bulk_loader_regex_tranform_values($values, $table_data, $line) {
 
   foreach ($table_data['regex_transform'] as $field => $regex_array) {
     if (!is_array($regex_array['replace'])) {
-       continue;
-     }
+      continue;
+    }
 
     //print 'Match:'.print_r($regex_array['pattern'],TRUE)."\n";
     //print 'Replace:'.print_r($regex_array['replace'],TRUE)."\n";
@@ -680,8 +680,8 @@ function tripal_bulk_loader_flatten_array($values) {
     if (is_array($v)) {
       $vstr = array();
       foreach ($v as $vk => $vv) {
-        if (strlen($vv) > 20) {
-          $vstr[] = $vk . '=>' . substr($vv, 0, 20) . '...';
+        if (drupal_strlen($vv) > 20) {
+          $vstr[] = $vk . '=>' . drupal_substr($vv, 0, 20) . '...';
         }
         else {
           $vstr[] = $vk . '=>' . $vv;
@@ -689,8 +689,8 @@ function tripal_bulk_loader_flatten_array($values) {
       }
       $v = '{' . implode(',', $vstr) . '}';
     }
-    elseif (strlen($v) > 20) {
-      $v = substr($v, 0, 20) . '...';
+    elseif (drupal_strlen($v) > 20) {
+      $v = drupal_substr($v, 0, 20) . '...';
     }
     $flattened_values[] = $k . '=>' . $v;
   }

+ 106 - 106
tripal_bulk_loader/tripal_bulk_loader.module

@@ -18,140 +18,140 @@ function tripal_bulk_loader_init() {
  */
 function tripal_bulk_loader_menu() {
   $items = array();
-   // Show all loaders
-   $items['tripal_bulk_loaders'] = array(
-     'title' => 'Tripal Bulk Loaders',
-     'description' => 'Tripal bulk loaders for loading tab-delimited file into chado database',
-     'page callback' => 'tripal_bulk_loader_list',
-     'access arguments' => array('access tripal_bulk_loader'),
-     'type' => MENU_NORMAL_ITEM,
-   );
-   // Bulk Loading Job Node
-   $items['node/%node/constants/%/edit'] = array(
-      'title' => 'Edit Constant Set',
-      'description' => 'Edit a group of constants associated with the current bulk loader',
-      'page callback' => 'drupal_get_form',
-      'page arguments' => array('tripal_bulk_loader_edit_constant_set_form', 1, 3),
-      'access arguments' => array('administer site configuration'),
-      'type' => MENU_CALLBACK,
-      'file' => 'tripal_bulk_loader.constants.inc',
-   );
-   $items['node/%node/constants/%/delete'] = array(
-      'title' => 'Delete Constant Set',
-      'description' => 'Delete a group of constants associated with the current bulk loader',
-      'page callback' => 'drupal_get_form',
-      'page arguments' => array('tripal_bulk_loader_delete_constant_set_form', 1, 3),
-      'access arguments' => array('administer site configuration'),
-      'type' => MENU_CALLBACK,
-      'file' => 'tripal_bulk_loader.constants.inc',
-   );
-
-   // Admin page to create the template
-   $items['admin/tripal/tripal_bulk_loader_template'] = array(
-      'title' => 'Bulk Loader Template',
-      'description' => 'Templates for loading tab-delimited data',
-      'page callback' => 'tripal_bulk_loader_admin_template',
-      'access arguments' => array('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM,
-      'file' => 'tripal_bulk_loader.admin.inc',
+  // Show all loaders
+  $items['tripal_bulk_loaders'] = array(
+    'title' => 'Tripal Bulk Loaders',
+    'description' => 'Tripal bulk loaders for loading tab-delimited file into chado database',
+    'page callback' => 'tripal_bulk_loader_list',
+    'access arguments' => array('access tripal_bulk_loader'),
+    'type' => MENU_NORMAL_ITEM,
   );
-   $items['admin/tripal/tripal_bulk_loader_template/configure'] = array(
-      'title' => 'Configure',
-      'description' => 'Configuration of global options related to bulk loading jobs',
-      'page callback' => 'drupal_get_form',
-      'page arguments' => array('tripal_bulk_loader_configuration_form'),
-      'access arguments' => array('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM,
-      'file' => 'tripal_bulk_loader.admin.inc',
+  // Bulk Loading Job Node
+  $items['node/%node/constants/%/edit'] = array(
+    'title' => 'Edit Constant Set',
+    'description' => 'Edit a group of constants associated with the current bulk loader',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_bulk_loader_edit_constant_set_form', 1, 3),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_CALLBACK,
+    'file' => 'tripal_bulk_loader.constants.inc',
+  );
+  $items['node/%node/constants/%/delete'] = array(
+    'title' => 'Delete Constant Set',
+    'description' => 'Delete a group of constants associated with the current bulk loader',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_bulk_loader_delete_constant_set_form', 1, 3),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_CALLBACK,
+    'file' => 'tripal_bulk_loader.constants.inc',
+  );
+
+  // Admin page to create the template
+  $items['admin/tripal/tripal_bulk_loader_template'] = array(
+    'title' => 'Bulk Loader Template',
+    'description' => 'Templates for loading tab-delimited data',
+    'page callback' => 'tripal_bulk_loader_admin_template',
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_NORMAL_ITEM,
+    'file' => 'tripal_bulk_loader.admin.inc',
+  );
+  $items['admin/tripal/tripal_bulk_loader_template/configure'] = array(
+    'title' => 'Configure',
+    'description' => 'Configuration of global options related to bulk loading jobs',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_bulk_loader_configuration_form'),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_NORMAL_ITEM,
+    'file' => 'tripal_bulk_loader.admin.inc',
   );
 
   // Create/Edit Template -------
   $items['admin/tripal/tripal_bulk_loader_template/create'] = array(
-      'title' => 'Create Template',
-      'description' => 'Create loader template for loading tab-delimited data',
-      'page callback' => 'drupal_get_form',
-      'page arguments' => array('tripal_bulk_loader_modify_template_base_form', 'create'),
-      'access arguments' => array('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM,
+    'title' => 'Create Template',
+    'description' => 'Create loader template for loading tab-delimited data',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_bulk_loader_modify_template_base_form', 'create'),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_NORMAL_ITEM,
     'file' => 'tripal_bulk_loader.admin.inc',
   );
   $items['admin/tripal/tripal_bulk_loader_template/edit'] = array(
-      'title' => 'Edit Template',
-      'description' => 'Edit loader template for loading tab-delimited data',
-      'page callback' => 'drupal_get_form',
-      'page arguments' => array('tripal_bulk_loader_modify_template_base_form', 'edit'),
-      'access arguments' => array('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM,
-      'file' => 'tripal_bulk_loader.admin.inc',
+    'title' => 'Edit Template',
+    'description' => 'Edit loader template for loading tab-delimited data',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_bulk_loader_modify_template_base_form', 'edit'),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_NORMAL_ITEM,
+    'file' => 'tripal_bulk_loader.admin.inc',
   );
   $items['admin/tripal/tripal_bulk_loader_template/edit_record'] = array(
-      'title' => 'Edit Template Record',
-      'description' => 'Edit a record in an existing tripal bulk loader template.',
-      'page callback' => 'drupal_get_form',
-      'page arguments' => array('tripal_bulk_loader_edit_template_record_form'),
-      'access arguments' => array('administer site configuration'),
-      'type' => MENU_CALLBACK,
+    'title' => 'Edit Template Record',
+    'description' => 'Edit a record in an existing tripal bulk loader template.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_bulk_loader_edit_template_record_form'),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_CALLBACK,
     'file' => 'tripal_bulk_loader.admin.inc',
   );
   $items['admin/tripal/tripal_bulk_loader_template/add_field'] = array(
-      'title' => 'Add Template Field',
-      'description' => 'Add a template field to an existing tripal bulk loader template.',
-      'page callback' => 'drupal_get_form',
-      'page arguments' => array('tripal_bulk_loader_add_template_field_form'),
-      'access arguments' => array('administer site configuration'),
-      'type' => MENU_CALLBACK,
+    'title' => 'Add Template Field',
+    'description' => 'Add a template field to an existing tripal bulk loader template.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_bulk_loader_add_template_field_form'),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_CALLBACK,
     'file' => 'tripal_bulk_loader.admin.inc',
   );
   $items['admin/tripal/tripal_bulk_loader_template/edit_field'] = array(
-      'title' => 'Edit Template Field',
-      'description' => 'Edit an existing field from a tripal bulk loader template.',
-      'page callback' => 'drupal_get_form',
-      'page arguments' => array('tripal_bulk_loader_edit_template_field_form'),
-      'access arguments' => array('administer site configuration'),
-      'type' => MENU_CALLBACK,
+    'title' => 'Edit Template Field',
+    'description' => 'Edit an existing field from a tripal bulk loader template.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_bulk_loader_edit_template_field_form'),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_CALLBACK,
     'file' => 'tripal_bulk_loader.admin.inc',
   );
   // Delete Template -----
   $items['admin/tripal/tripal_bulk_loader_template/delete'] = array(
-      'title' => 'Delete Template',
-      'description' => 'Delete bulk loader template',
-      'page callback' => 'drupal_get_form',
-      'page arguments' => array('tripal_bulk_loader_delete_template_base_form'),
-      'access arguments' => array('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM,
+    'title' => 'Delete Template',
+    'description' => 'Delete bulk loader template',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_bulk_loader_delete_template_base_form'),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_NORMAL_ITEM,
     'file' => 'tripal_bulk_loader.admin.inc',
   );
   // Import/Export ---------
   $items['admin/tripal/tripal_bulk_loader_template/import'] = array(
-      'title' => 'Import Template',
-      'description' => 'Import Loaders',
-      'page callback' => 'drupal_get_form',
-      'page arguments' => array('tripal_bulk_loader_import_export_template_form', 'import'),
-      'access arguments' => array('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM,
-      'file' => 'tripal_bulk_loader.admin.inc',
+    'title' => 'Import Template',
+    'description' => 'Import Loaders',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_bulk_loader_import_export_template_form', 'import'),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_NORMAL_ITEM,
+    'file' => 'tripal_bulk_loader.admin.inc',
   );
   $items['admin/tripal/tripal_bulk_loader_template/export'] = array(
-      'title' => 'Export Template',
-      'description' => 'Export Loaders',
-      'page callback' => 'drupal_get_form',
-      'page arguments' => array('tripal_bulk_loader_import_export_template_form', 'export'),
-      'access arguments' => array('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM,
-      'file' => 'tripal_bulk_loader.admin.inc',
+    'title' => 'Export Template',
+    'description' => 'Export Loaders',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_bulk_loader_import_export_template_form', 'export'),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_NORMAL_ITEM,
+    'file' => 'tripal_bulk_loader.admin.inc',
   );
   // AHAH ---------
   $items['admin/tripal/tripal_bulk_loader_template/add_field_ahah'] = array(
-      'page callback' => 'tripal_bulk_loader_add_field_ahah',
-      'access arguments' => array('administer site configuration'),
-      'type' => MENU_CALLBACK,
-      'file' => 'tripal_bulk_loader.admin.inc',
+    'page callback' => 'tripal_bulk_loader_add_field_ahah',
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_CALLBACK,
+    'file' => 'tripal_bulk_loader.admin.inc',
   );
   $items['admin/tripal/tripal_bulk_loader_template/edit_field_ahah'] = array(
-      'page callback' => 'tripal_bulk_loader_edit_field_ahah',
-      'access arguments' => array('administer site configuration'),
-      'type' => MENU_CALLBACK,
-      'file' => 'tripal_bulk_loader.admin.inc',
+    'page callback' => 'tripal_bulk_loader_edit_field_ahah',
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_CALLBACK,
+    'file' => 'tripal_bulk_loader.admin.inc',
   );
 
   return $items;
@@ -191,8 +191,8 @@ function tripal_bulk_loader_theme() {
 function tripal_bulk_loader_access($op, $node, $account) {
   if ($op == 'create') {
     if (!user_access('create tripal_bulk_loader', $account)) {
-         return FALSE;
-      }
+      return FALSE;
+    }
   }
   if ($op == 'update') {
     if (!user_access('edit tripal_bulk_loader', $account)) {
@@ -426,7 +426,7 @@ function tripal_bulk_loader_insert($node) {
   drupal_write_record('node', $node, 'nid');
   drupal_write_record('node_revision', $node, 'nid');
 
-  drupal_set_message('After reviewing the details, please Submit this Job (by clicking the "Submit Job" button below). No data will be loaded until the submitted job is reached in the queue.');
+  drupal_set_message(t('After reviewing the details, please Submit this Job (by clicking the "Submit Job" button below). No data will be loaded until the submitted job is reached in the queue.'));
 
 }