tripal_bulk_loader_fields.tpl.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 = [];
  12. $constants = [];
  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 = [
  38. 'Record Name',
  39. 'Field Name',
  40. 'Value',
  41. 'Chado Table',
  42. 'Chado Field',
  43. ];
  44. $rows = [];
  45. // iterate through the fields and add rows to the table
  46. foreach ($constants as $field) {
  47. $rows[] = [
  48. $field['record'],
  49. $field['title'],
  50. $field['constant value'],
  51. $field['table'],
  52. $field['field'],
  53. ];
  54. }
  55. // theme the table
  56. $table = [
  57. 'header' => $headers,
  58. 'rows' => $rows,
  59. 'attributes' => [
  60. 'id' => 'tripal_bulk_loader-table-constants',
  61. 'class' => 'tripal-data-table',
  62. ],
  63. 'sticky' => FALSE,
  64. 'caption' => '',
  65. 'colgroups' => [],
  66. 'empty' => '',
  67. ];
  68. print theme_table($table);
  69. }
  70. ?>
  71. <br><p><b>Data Columns</b></p> <?php
  72. // add a table specifying the data file columns
  73. if (sizeof($fields)) {
  74. $headers = [
  75. 'Record Name',
  76. 'Field Name',
  77. 'Data File Column',
  78. 'Chado Table',
  79. 'Chado Field',
  80. ];
  81. $rows = [];
  82. // iterate through the fields and add rows to the table
  83. foreach ($fields as $column) {
  84. foreach ($column as $field) {
  85. $rows[] = [
  86. $field['record'],
  87. $field['title'],
  88. $field['spreadsheet column'],
  89. $field['table'],
  90. $field['field'],
  91. ];
  92. }
  93. }
  94. // theme the table
  95. $table = [
  96. 'header' => $headers,
  97. 'rows' => $rows,
  98. 'attributes' => [
  99. 'id' => 'tripal_bulk_loader-table-columns',
  100. 'class' => 'tripal-data-table',
  101. ],
  102. 'sticky' => FALSE,
  103. 'caption' => '',
  104. 'colgroups' => [],
  105. 'empty' => '',
  106. ];
  107. print theme_table($table);
  108. }