tripal_fields_layout_generic.tpl.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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_fields = $fields[$panel_id];
  13. $collapsible_item = array('element' => array());
  14. // If the format is horizontal table then format the fields in tabular format.
  15. if ($horz_table) {
  16. // reorder the fields by its weight
  17. $ordered_fields = array();
  18. foreach ($panel_fields AS $field) {
  19. $ordered_fields[$field['#weight']] = $field;
  20. }
  21. ksort($ordered_fields);
  22. $rows = array();
  23. foreach ($ordered_fields as $field) {
  24. $rows[] = array(
  25. array(
  26. 'data' => $field['#title'],
  27. 'header' => TRUE,
  28. 'width' => '20%',
  29. 'nowrap' => 'nowrap'
  30. ),
  31. $field[0]['#markup']
  32. );
  33. }
  34. $collapsible_item['element']['#description'] = theme_table(array(
  35. 'header' => array(),
  36. 'rows' => $rows,
  37. 'attributes' => array(
  38. 'id' => '', // TODO: need to add an ID
  39. 'class' => 'tripal-data-table'
  40. ),
  41. 'sticky' => FALSE,
  42. 'caption' => '',
  43. 'colgroups' => array(),
  44. 'empty' => '',
  45. ));
  46. }
  47. // If no format is provided then use the default Drupal render.
  48. else {
  49. $collapsible_item['element']['#description'] = render($panel_fields);
  50. }
  51. // If this is not the base content then the field should be collapsible.
  52. if ($panel->name != 'te_base') {
  53. $collapsible_item['element']['#title'] = $panel->label;
  54. $collapsible_item['element']['#children'] = '';
  55. $collapsible_item['element']['#attributes']['class'][] = 'collapsible';
  56. $collapsible_item['element']['#attributes']['class'][] = 'collapsed';
  57. $toc_item_id = $panel_id;
  58. $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>";
  59. $content .= theme('fieldset', $collapsible_item);
  60. }
  61. // The base field should just be the fields
  62. else {
  63. $content .= render($panel_fields);
  64. }
  65. }
  66. $bundle_type = ''; // TODO: need to add the bundle type ?>
  67. <table id ="tripal-<?php print $bundle_type?>-contents-table" class="tripal-contents-table">
  68. <tr class="tripal-contents-table-tr">
  69. <td nowrap class="tripal-contents-table-td tripal-contents-table-td-toc" align="left"><?php
  70. print $toc; ?>
  71. </td>
  72. <td class="tripal-contents-table-td-data" align="left" width="100%"> <?php
  73. // print the rendered content
  74. print $content; ?>
  75. </td>
  76. </tr>
  77. </table>