tripal_fields_layout_generic.tpl.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. drupal_add_js('misc/form.js');
  3. drupal_add_js('misc/collapse.js');
  4. $panels = $variables['element']['#panels'];
  5. $fields = $variables['element']['#fields'];
  6. // TODO, the horz_table variable needs to be set in a variable and checked here.
  7. $horz_table = TRUE;
  8. // Group fields into panels
  9. $content = '';
  10. $toc = '';
  11. foreach ($panels AS $panel_id => $panel) {
  12. $panel_settings = unserialize($panel->settings);
  13. $hz_table_group = key_exists('hz_table', $panel_settings) ? $panel_settings['hz_table'] : array();
  14. $vt_table_group = key_exists('vt_table', $panel_settings) ? $panel_settings['vt_table'] : array();
  15. $panel_fields = $fields[$panel_id];
  16. // Rearrange fields into groups for each panel
  17. $hz_table = array();
  18. $vt_table = array();
  19. $no_group = array();
  20. // Order by field's '#weight' which is never the same
  21. foreach ($panel_fields AS $field) {
  22. if (in_array($field['#field_name'], $hz_table_group)) {
  23. $hz_table [$field['#weight']] = $field;
  24. }
  25. else if (in_array($field['#field_name'], $vt_table_group)) {
  26. $vt_table [$field['#weight']] = $field;
  27. }
  28. else {
  29. $no_group [$field['#weight']] = $field;
  30. }
  31. }
  32. // Render horizontal table
  33. $horz_table = '';
  34. if (count($hz_table) != 0) {
  35. ksort($hz_table);
  36. $rows = array();
  37. foreach ($hz_table as $field) {
  38. $rows[] = array(
  39. array(
  40. 'data' => $field['#title'],
  41. 'header' => TRUE,
  42. 'width' => '20%',
  43. 'nowrap' => 'nowrap'
  44. ),
  45. $field[0]['#markup']
  46. );
  47. }
  48. $horz_table = theme_table(array(
  49. 'header' => array(),
  50. 'rows' => $rows,
  51. 'attributes' => array(
  52. 'id' => '', // TODO: need to add an ID
  53. 'class' => 'tripal-data-horz-table'
  54. ),
  55. 'sticky' => FALSE,
  56. 'caption' => '',
  57. 'colgroups' => array(),
  58. 'empty' => '',
  59. ));
  60. }
  61. // Render horizontal table
  62. $vert_table = '';
  63. if (count($vt_table) != 0) {
  64. ksort($vt_table);
  65. $value = array();
  66. $headers = array();
  67. foreach ($vt_table as $field) {
  68. $headers [] = $field['#title'];
  69. array_push($value, $field[0]['#markup']);
  70. }
  71. $vert_table = theme_table(array(
  72. 'header' => $headers,
  73. 'rows' => array($value),
  74. 'attributes' => array(
  75. 'id' => '', // TODO: need to add an ID
  76. 'class' => 'tripal-data-vert-table'
  77. ),
  78. 'sticky' => FALSE,
  79. 'caption' => '',
  80. 'colgroups' => array(),
  81. 'empty' => '',
  82. ));
  83. }
  84. // Render field not in a group
  85. $ungrouped = '';
  86. if (count($no_group) != 0) {
  87. ksort($no_group);
  88. foreach ($no_group as $field) {
  89. $ungrouped .= render($field);
  90. }
  91. }
  92. $output = $horz_table . $vert_table . $ungrouped ;
  93. // If this is a base content, do not organize the content in a fieldset
  94. if ($panel->name == 'te_base') {
  95. $content .= $output;
  96. } else {
  97. $collapsible_item = array('element' => array());
  98. $collapsible_item['element']['#description'] = $output;
  99. $collapsible_item['element']['#title'] = $panel->label;
  100. $collapsible_item['element']['#children'] = '';
  101. $collapsible_item['element']['#attributes']['class'][] = 'collapsible';
  102. $collapsible_item['element']['#attributes']['class'][] = 'collapsed';
  103. $toc_item_id = $panel_id;
  104. $toc .= "<div class=\"tripal_toc_list_item\"><a id=\"" . $panel->name . "\" class=\"tripal_toc_list_item_link\" href=\"?pane=" . $panel->name . "\">" . $panel->label . "</a></div>";
  105. $content .= theme('fieldset', $collapsible_item);
  106. }
  107. }
  108. $bundle_type = ''; // TODO: need to add the bundle type ?>
  109. <table id ="tripal-<?php print $bundle_type?>-contents-table" class="tripal-contents-table">
  110. <tr class="tripal-contents-table-tr">
  111. <td nowrap class="tripal-contents-table-td tripal-contents-table-td-toc" align="left"><?php
  112. print $toc; ?>
  113. </td>
  114. <td class="tripal-contents-table-td-data" align="left" width="100%"> <?php
  115. // print the rendered content
  116. print $content; ?>
  117. </td>
  118. </tr>
  119. </table>