tripal_pub_properties.tpl.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. $pub = $node->pub;
  3. // expand the pub to include the properties.
  4. $options = array(
  5. 'return_array' => 1,
  6. 'order_by' => array('rank' => 'ASC'),
  7. );
  8. $pub = chado_expand_var($pub,'table', 'pubprop', $options);
  9. $pubprops = $pub->pubprop;
  10. $properties = array();
  11. if (is_array($pubprops)) {
  12. foreach ($pubprops as $property) {
  13. // skip the following properties as those are already on other templates
  14. if ($property->type_id->name == 'Abstract' or
  15. $property->type_id->name == 'Citation' or
  16. $property->type_id->name == 'Publication Dbxref' or
  17. $property->type_id->name == 'Authors' or
  18. $property->type_id->name == 'Structured Abstract Part') {
  19. continue;
  20. }
  21. $property = chado_expand_var($property,'field','pubprop.value');
  22. $properties[] = $property;
  23. }
  24. }
  25. // we'll keep track of the keywords so we can lump them into a single row
  26. $keywords = array();
  27. if (count($properties)) { ?>
  28. <div class="tripal_pub-data-block-desc tripal-data-block-desc">Additional details for this publication include:</div> <?php
  29. // the $headers array is an array of fields to use as the colum headers.
  30. // additional documentation can be found here
  31. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  32. $headers = array('Property Name', 'Value');
  33. // the $rows array contains an array of rows where each row is an array
  34. // of values for each column of the table in that row. Additional documentation
  35. // can be found here:
  36. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  37. $rows = array();
  38. $keywords = array();
  39. foreach ($properties as $property) {
  40. // each keyword is stored as a seperate properties. We want to show them
  41. // only in a single field not as a bunc of individual properties, so when we see one,
  42. // save it in an array for later and down't add it yet to the table yet.
  43. if ($property->type_id->name == 'Keywords') {
  44. $keywords[] = $property->value;
  45. continue;
  46. }
  47. $rows[] = array(
  48. $property->type_id->name,
  49. $property->value
  50. );
  51. }
  52. // now add in a single row for all keywords
  53. if (count($keywords) > 0) {
  54. $rows[] = array(
  55. 'Keywords',
  56. implode(', ', $keywords),
  57. );
  58. }
  59. // the $table array contains the headers and rows array as well as other
  60. // options for controlling the display of the table. Additional
  61. // documentation can be found here:
  62. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  63. $table = array(
  64. 'header' => $headers,
  65. 'rows' => $rows,
  66. 'attributes' => array(
  67. 'id' => 'tripal_pub-table-properties',
  68. 'class' => 'tripal-data-table'
  69. ),
  70. 'sticky' => FALSE,
  71. 'caption' => '',
  72. 'colgroups' => array(),
  73. 'empty' => '',
  74. );
  75. // once we have our table array structure defined, we call Drupal's theme_table()
  76. // function to generate the table.
  77. print theme_table($table);
  78. }