tripal_project_base.tpl.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. $project = $variables['node']->project;
  3. // get the project description. The first iteration of the project
  4. // module incorrectly stored the project description in the Drupal
  5. // node->body field. Also, the project.descriptin field is only 255
  6. // characters which is not large neough. Therefore, we store the description
  7. // in the chado.projectprop table. For backwards compatibility, we
  8. // will check if the node->body is empty and if not we'll use that instead.
  9. // If there is data in the project.description field then we will use that, but
  10. // if there is data in the projectprop table for a descrtion then that takes
  11. // precedence
  12. $description = '';
  13. if (property_exists($node, 'body')) {
  14. $description = $node->body;
  15. }
  16. if ($project->description) {
  17. $description = $project->description;
  18. }
  19. else {
  20. $record = [
  21. 'table' => 'project',
  22. 'id' => $project->project_id,
  23. ];
  24. $property = [
  25. 'type_name' => 'Project Description',
  26. 'cv_name' => 'project_property',
  27. ];
  28. $projectprop = chado_get_property($record, $property);
  29. $description = $projectprop->value;
  30. } ?>
  31. <div class="tripal_project-data-block-desc tripal-data-block-desc"></div><?php
  32. // the $headers array is an array of fields to use as the colum headers.
  33. // additional documentation can be found here
  34. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  35. // This table for the project has a vertical header (down the first column)
  36. // so we do not provide headers here, but specify them in the $rows array below.
  37. $headers = [];
  38. // the $rows array contains an array of rows where each row is an array
  39. // of values for each column of the table in that row. Additional documentation
  40. // can be found here:
  41. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  42. $rows = [];
  43. // Project Name row
  44. $rows[] = [
  45. [
  46. 'data' => 'Project Name',
  47. 'header' => TRUE,
  48. 'width' => '20%',
  49. ],
  50. $project->name,
  51. ];
  52. // allow site admins to see the feature ID
  53. if (user_access('view ids')) {
  54. // Project ID
  55. $rows[] = [
  56. [
  57. 'data' => 'Project ID',
  58. 'header' => TRUE,
  59. 'class' => 'tripal-site-admin-only-table-row',
  60. ],
  61. [
  62. 'data' => $project->project_id,
  63. 'class' => 'tripal-site-admin-only-table-row',
  64. ],
  65. ];
  66. }
  67. // the $table array contains the headers and rows array as well as other
  68. // options for controlling the display of the table. Additional
  69. // documentation can be found here:
  70. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  71. $table = [
  72. 'header' => $headers,
  73. 'rows' => $rows,
  74. 'attributes' => [
  75. 'id' => 'tripal_project-table-base',
  76. 'class' => 'tripal-data-table',
  77. ],
  78. 'sticky' => FALSE,
  79. 'caption' => '',
  80. 'colgroups' => [],
  81. 'empty' => '',
  82. ];
  83. // once we have our table array structure defined, we call Drupal's theme_table()
  84. // function to generate the table.
  85. print theme_table($table);
  86. if ($description) { ?>
  87. <div style="text-align: justify"><?php print $description; ?></div> <?php
  88. }