tripal_fields_layout_generic.tpl.php 3.0 KB

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