tripal_bulk_loader_fields.tpl.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. $node = $variables['node'];
  3. // Retrieve Template
  4. $template = db_select('tripal_bulk_loader_template', 't')
  5. ->fields('t')
  6. ->condition('template_id', $node->template->template_id, '=')
  7. ->execute()
  8. ->fetchObject();
  9. $template->template_array = unserialize($template->template_array);
  10. // Summarize Template
  11. $fields = array();
  12. $constants = array();
  13. foreach ($template->template_array as $priority => $table_array) {
  14. if (!is_array($table_array)) {
  15. continue;
  16. }
  17. $table = $table_array['table'];
  18. $record = $table_array['record_id'];
  19. foreach ($table_array['fields'] as $field) {
  20. if (preg_match('/table field/', $field['type'])) {
  21. $field['table'] = $table;
  22. $field['record'] = $record;
  23. $sheet = 0;//$field['spreadsheet sheet'];
  24. $column = $field['spreadsheet column'];
  25. $fields[$sheet.'-'.$column][] = $field;
  26. }
  27. elseif ($field['type'] == 'constant') {
  28. $field['table'] = $table;
  29. $field['record'] = $record;
  30. $constants[] = $field;
  31. }
  32. }
  33. } ?>
  34. <p><b>Constants</b></p> <?php
  35. // add a table describing the constants specified in the file
  36. if (sizeof($constants)) {
  37. $headers = array('Record Name', 'Field Name', 'Value', 'Chado Table', 'Chado Field');
  38. $rows = array();
  39. // iterate through the fields and add rows to the table
  40. foreach ($constants as $field) {
  41. $rows[] = array($field['record'], $field['title'], $field['constant value'], $field['table'], $field['field']);
  42. }
  43. // theme the table
  44. $table = array(
  45. 'header' => $headers,
  46. 'rows' => $rows,
  47. 'attributes' => array(
  48. 'id' => 'tripal_bulk_loader-table-constants',
  49. 'class' => 'tripal-data-table'
  50. ),
  51. 'sticky' => FALSE,
  52. 'caption' => '',
  53. 'colgroups' => array(),
  54. 'empty' => '',
  55. );
  56. print theme_table($table);
  57. }
  58. ?>
  59. <br><p><b>Data Columns</b></p> <?php
  60. // add a table specifying the data file columns
  61. if (sizeof($fields)) {
  62. $headers = array('Record Name', 'Field Name', 'Data File Column', 'Chado Table', 'Chado Field');
  63. $rows = array();
  64. // iterate through the fields and add rows to the table
  65. foreach ($fields as $column) {
  66. foreach ($column as $field) {
  67. $rows[] = array(
  68. $field['record'],
  69. $field['title'],
  70. $field['spreadsheet column'],
  71. $field['table'],
  72. $field['field']
  73. );
  74. }
  75. }
  76. // theme the table
  77. $table = array(
  78. 'header' => $headers,
  79. 'rows' => $rows,
  80. 'attributes' => array(
  81. 'id' => 'tripal_bulk_loader-table-columns',
  82. 'class' => 'tripal-data-table'
  83. ),
  84. 'sticky' => FALSE,
  85. 'caption' => '',
  86. 'colgroups' => array(),
  87. 'empty' => '',
  88. );
  89. print theme_table($table);
  90. }