tripal_pub_base.tpl.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * The page generated by this template depends on the publication type. Each
  4. * publication type may appear differently. You can find the publication
  5. * templates for each type in the pub_types folder. The files have the same
  6. * name as the type. If a publication type is not found in that file then the
  7. * generic.inc template is used for display of the publication.
  8. */
  9. $pub = $variables['node']->pub;
  10. // expand the title
  11. $pub = chado_expand_var($pub, 'field', 'pub.title');
  12. $pub = chado_expand_var($pub, 'field', 'pub.volumetitle');
  13. // get the citation
  14. $values = array(
  15. 'pub_id' => $pub->pub_id,
  16. 'type_id' => array(
  17. 'name' => 'Citation',
  18. ),
  19. );
  20. $citation = chado_generate_var('pubprop', $values);
  21. $citation = chado_expand_var($citation, 'field', 'pubprop.value');
  22. // get the abstract
  23. $values = array(
  24. 'pub_id' => $pub->pub_id,
  25. 'type_id' => array(
  26. 'name' => 'Abstract',
  27. ),
  28. );
  29. $abstract = chado_generate_var('pubprop', $values);
  30. $abstract = chado_expand_var($abstract, 'field', 'pubprop.value');
  31. $abstract_text = '';
  32. if ($abstract) {
  33. $abstract_text = htmlspecialchars($abstract->value);
  34. }
  35. // get the author list
  36. $values = array(
  37. 'pub_id' => $pub->pub_id,
  38. 'type_id' => array(
  39. 'name' => 'Authors',
  40. ),
  41. );
  42. $authors = chado_generate_var('pubprop', $values);
  43. $authors = chado_expand_var($authors, 'field', 'pubprop.value');
  44. $authors_list = 'N/A';
  45. if ($authors) {
  46. $authors_list = $authors->value;
  47. }
  48. // get the first database cross-reference with a url
  49. $options = array('return_array' => 1);
  50. $pub = chado_expand_var($pub, 'table', 'pub_dbxref', $options);
  51. $dbxref = NULL;
  52. if ($pub->pub_dbxref) {
  53. foreach ($pub->pub_dbxref as $index => $pub_dbxref) {
  54. if ($pub_dbxref->dbxref_id->db_id->urlprefix) {
  55. $dbxref = $pub_dbxref->dbxref_id;
  56. }
  57. }
  58. }
  59. // get the URL
  60. // get the author list
  61. $values = array(
  62. 'pub_id' => $pub->pub_id,
  63. 'type_id' => array(
  64. 'name' => 'URL',
  65. ),
  66. );
  67. $options = array('return_array' => 1);
  68. $urls = chado_generate_var('pubprop', $values, $options);
  69. $urls = chado_expand_var($urls, 'field', 'pubprop.value');
  70. $url = '';
  71. if (count($urls) > 0) {
  72. $url = $urls[0]->value;
  73. } ?>
  74. <div class="tripal_pub-data-block-desc tripal-data-block-desc"></div> <?php
  75. // To simplify the template, we have a subdirectory named 'pub_types'. This directory
  76. // should have include files each specific to a publication type. If the type is
  77. // not present then the base template will be used, otherwise the template in the
  78. // include file is used.
  79. $inc_name = strtolower(preg_replace('/ /', '_', $pub->type_id->name)) . '.inc';
  80. $inc_path = DRUPAL_ROOT . '/' . drupal_get_path('module', 'tripal_pub') . "/theme/templates/pub_types/$inc_name";
  81. if (file_exists($inc_path)) {
  82. require_once "pub_types/$inc_name";
  83. }
  84. else {
  85. require_once "pub_types/default.inc";
  86. }