tripal_project.base.tpl.php 3.1 KB

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