tripal_project_contact.tpl.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. $project = $variables['node']->project;
  3. // expand the project object to include the contacts from the project_contact
  4. // table in chado.
  5. $project = chado_expand_var($project,'table','project_contact', array('return_array' => 1));
  6. $project_contacts = $project->project_contact;
  7. if (count($project_contacts) > 0) { ?>
  8. <div class="tripal_project-data-block-desc tripal-data-block-desc">The following indivuals or groups have particpated in development or execution of this project</div><?php
  9. // the $headers array is an array of fields to use as the colum headers.
  10. // additional documentation can be found here
  11. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  12. $headers = array('', 'Details');
  13. // the $rows array contains an array of rows where each row is an array
  14. // of values for each column of the table in that row. Additional documentation
  15. // can be found here:
  16. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  17. $rows = array();
  18. $i = 1;
  19. foreach ($project_contacts as $project_contact) {
  20. $contact = $project_contact->contact_id;
  21. $contact_name = $contact->name;
  22. if (property_exists($contact, 'nid')) {
  23. $contact_name = l($contact_name, 'node/' . $contact->nid, array('attributes' => array('target' => '_blank')));
  24. }
  25. // Get some additional details about this contact if they exists.
  26. $details = '';
  27. $options = array('return_array' => 1);
  28. $contact = chado_expand_var($contact, 'table', 'contactprop', $options);
  29. $properties = $contact->contactprop;
  30. $options = array('order_by' => array('rank' => 'ASC'));
  31. $properties = chado_expand_var($properties, 'field', 'contactprop.value', $options);
  32. if (is_array($properties)) {
  33. foreach ($properties as $property) {
  34. // skip the description and name properties
  35. if ($property->type_id->name == "contact_description" or
  36. $property->type_id->name == "Surname" or
  37. $property->type_id->name == "Given Name" or
  38. $property->type_id->name == "First Initials" or
  39. $property->type_id->name == "Suffix") {
  40. continue;
  41. }
  42. $details .= "<br>" . $property->type_id->name . " : " . $property->value;
  43. }
  44. }
  45. $rows[] = array(
  46. $i,
  47. $contact_name . $details,
  48. );
  49. $i++;
  50. }
  51. // the $table array contains the headers and rows array as well as other
  52. // options for controlling the display of the table. Additional
  53. // documentation can be found here:
  54. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  55. $table = array(
  56. 'header' => $headers,
  57. 'rows' => $rows,
  58. 'attributes' => array(
  59. 'id' => 'tripal_pub-table-contacts',
  60. 'class' => 'tripal-data-table'
  61. ),
  62. 'sticky' => FALSE,
  63. 'caption' => '',
  64. 'colgroups' => array(),
  65. 'empty' => '',
  66. );
  67. // once we have our table array structure defined, we call Drupal's theme_table()
  68. // function to generate the table.
  69. print theme_table($table);
  70. }