浏览代码

Bulk Loader: Fixed PHPv5.5 bug relating to &, added unserialize/serialize to export/import template forms to mimic Tripalv1.0

Lacey Sanderson 11 年之前
父节点
当前提交
ca61418ca6
共有 1 个文件被更改,包括 18 次插入8 次删除
  1. 18 8
      tripal_bulk_loader/includes/tripal_bulk_loader.admin.templates.inc

+ 18 - 8
tripal_bulk_loader/includes/tripal_bulk_loader.admin.templates.inc

@@ -17,7 +17,7 @@
  *
  * @ingroup tripal_bulk_loader
  */
-function tripal_bulk_loader_modify_template_base_form($form, $form_state = NULL, $mode) {
+function tripal_bulk_loader_modify_template_base_form($form, &$form_state = NULL, $mode) {
 
   // set the breadcrumb
   $breadcrumb = array();
@@ -690,9 +690,13 @@ function tripal_bulk_loader_import_template_form($form, $form_state) {
  */
 function tripal_bulk_loader_import_template_form_submit($form, &$form_state) {
 
+  // get the template array, and convert from text into an array.
+  $t = array();
+  eval("\$t = " . $form_state['values']['template_array'] . ";");
+
   $record = array(
     'name' => $form_state['values']['new_template_name'],
-    'template_array' => $form_state['values']['template_array'],
+    'template_array' => serialize($t),
     'created' => time(),
     'changed' => time()
   );
@@ -722,7 +726,7 @@ function tripal_bulk_loader_import_template_form_submit($form, &$form_state) {
  *
  * @ingroup tripal_bulk_loader
  */
-function tripal_bulk_loader_export_template_form($form, $form_state) {
+function tripal_bulk_loader_export_template_form($form, &$form_state) {
 
   // set the breadcrumb
   $breadcrumb = array();
@@ -742,7 +746,13 @@ function tripal_bulk_loader_export_template_form($form, $form_state) {
       ->condition('t.template_id',$template_id)
       ->execute();
     $template = $result->fetchObject();
-    $form_state['storage']['template_array'] = $template->template_array;
+
+    $t = var_export(unserialize($template->template_array), TRUE);
+    $t = preg_replace("/\n\s+array/", "array", $t); // move array( to previous line
+    $t = preg_replace("/true/", "TRUE", $t); // upper case true
+    $t = preg_replace("/false/", "FALSE", $t); // upper case false
+    $t = preg_replace("/array\(/", "array (", $t); // put a space between array and paren
+    $form_state['storage']['template_array'] = $t;
   }
 
   $form['name'] = array(
@@ -786,7 +796,7 @@ function tripal_bulk_loader_export_template_form($form, $form_state) {
  *
  * @ingroup tripal_bulk_loader
  */
-function tripal_bulk_loader_edit_template_record_form($form, $form_state) {
+function tripal_bulk_loader_edit_template_record_form($form, &$form_state) {
   $form['#cache'] = TRUE; // Make sure the form is cached.
 
   // get args from path
@@ -1152,7 +1162,7 @@ function tripal_bulk_loader_edit_template_record_form_submit($form, &$form_state
  *
  * @ingroup tripal_bulk_loader
  */
-function tripal_bulk_loader_delete_template_record_form($form, $form_state) {
+function tripal_bulk_loader_delete_template_record_form($form, &$form_state) {
   $form['#cache'] = TRUE; // Make sure the form is cached.
 
   // get args from path
@@ -1706,7 +1716,7 @@ function tripal_bulk_loader_template_field_form_default_values($mode, &$form_sta
  *
  * @ingroup tripal_bulk_loader
  */
-function tripal_bulk_loader_template_field_form($form, $form_state = NULL) {
+function tripal_bulk_loader_template_field_form($form, &$form_state = NULL) {
   $form['#cache'] = TRUE; // Make sure the form is cached.
 
   // if there is no template supplied don't return rest of form
@@ -2270,7 +2280,7 @@ function tripal_bulk_loader_template_field_form_submit($form, &$form_state) {
  *
  * @ingroup tripal_bulk_loader
  */
-function tripal_bulk_loader_delete_template_field_form($form, $form_state) {
+function tripal_bulk_loader_delete_template_field_form($form, &$form_state) {
   $form['#cache'] = TRUE; // Make sure the form is cached.
 
   // get args from path