tripal_project_base.tpl.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. $projectprop = tripal_project_get_property($project->project_id, 'Project Description');
  21. $description = $projectprop->value;
  22. } ?>
  23. <div class="tripal_project-data-block-desc tripal-data-block-desc"></div><?php
  24. // the $headers array is an array of fields to use as the colum headers.
  25. // additional documentation can be found here
  26. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  27. // This table for the project has a vertical header (down the first column)
  28. // so we do not provide headers here, but specify them in the $rows array below.
  29. $headers = array();
  30. // the $rows array contains an array of rows where each row is an array
  31. // of values for each column of the table in that row. Additional documentation
  32. // can be found here:
  33. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  34. $rows = array();
  35. // Project Name row
  36. $rows[] = array(
  37. array(
  38. 'data' => 'Project Name',
  39. 'header' => TRUE
  40. ),
  41. $project->name
  42. );
  43. // allow site admins to see the feature ID
  44. if (user_access('access administration pages')) {
  45. // Project ID
  46. $rows[] = array(
  47. array(
  48. 'data' => 'Project ID',
  49. 'header' => TRUE,
  50. 'class' => 'tripal-site-admin-only-table-row',
  51. ),
  52. array(
  53. 'data' => $project->project_id,
  54. 'class' => 'tripal-site-admin-only-table-row',
  55. ),
  56. );
  57. }
  58. // the $table array contains the headers and rows array as well as other
  59. // options for controlling the display of the table. Additional
  60. // documentation can be found here:
  61. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  62. $table = array(
  63. 'header' => $headers,
  64. 'rows' => $rows,
  65. 'attributes' => array(
  66. 'id' => 'tripal_project-table-base',
  67. ),
  68. 'sticky' => FALSE,
  69. 'caption' => '',
  70. 'colgroups' => array(),
  71. 'empty' => '',
  72. );
  73. // once we have our table array structure defined, we call Drupal's theme_table()
  74. // function to generate the table.
  75. print theme_table($table);
  76. if ($description) { ?>
  77. <div style="text-align: justify"><?php print $description; ?></div> <?php
  78. }