tripal_featuremap_publication.tpl.php

  1. 2.x tripal_featuremap/theme/templates/tripal_featuremap_publication.tpl.php
  2. 3.x legacy/tripal_featuremap/theme/templates/tripal_featuremap_publication.tpl.php
1 theme call to tripal_featuremap_publication.tpl.php
tripal_featuremap_node_view in legacy/tripal_featuremap/includes/tripal_featuremap.chado_node.inc
Implements hook_node_view(). Acts on all content types.

File

legacy/tripal_featuremap/theme/templates/tripal_featuremap_publication.tpl.php
View source
  1. <?php
  2. $featuremap = $variables['node']->featuremap;
  3. // expand featuremap to include pubs
  4. $options = array('return_array' => 1);
  5. $featuremap = chado_expand_var($featuremap, 'table', 'featuremap_pub', $options);
  6. $featuremap_pubs = $featuremap->featuremap_pub;
  7. if (count($featuremap_pubs) > 0) { ?>
  8. <div class="tripal_featuremap_pub-data-block-desc tripal-data-block-desc"></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('Year', 'Publication');
  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. foreach ($featuremap_pubs as $featuremap_pub) {
  19. $pub = $featuremap_pub->pub_id;
  20. $pub = chado_expand_var($pub, 'field', 'pub.title');
  21. $citation = $pub->title; // use the title as the default citation
  22. // get the citation for this pub if it exists
  23. $values = array(
  24. 'pub_id' => $pub->pub_id,
  25. 'type_id' => array(
  26. 'name' => 'Citation',
  27. ),
  28. );
  29. $options = array('return_array' => 1);
  30. $citation_prop = chado_generate_var('pubprop', $values, $options);
  31. if (count($citation_prop) == 1) {
  32. $citation_prop = chado_expand_var($citation_prop, 'field', 'pubprop.value');
  33. $citation = $citation_prop[0]->value;
  34. }
  35. // if the publication is synced then link to it
  36. if (property_exists($pub, 'nid')) {
  37. // replace the title with a link
  38. $link = l($pub->title, 'node/' . $pub->nid ,array('attributes' => array('target' => '_blank')));
  39. $patterns = array(
  40. '/(\()/', '/(\))/',
  41. '/(\])/', '/(\[)/',
  42. '/(\{)/', '/(\})/',
  43. '/(\+)/', '/(\.)/', '/(\?)/',
  44. );
  45. $fixed_title = preg_replace($patterns, "\\\\$1", $pub->title);
  46. $citation = preg_replace('/' . str_replace('/', ' ', $fixed_title) . '/', $link, $citation);
  47. }
  48. $rows[] = array(
  49. $pub->pyear,
  50. $citation,
  51. );
  52. }
  53. // the $table array contains the headers and rows array as well as other
  54. // options for controlling the display of the table. Additional
  55. // documentation can be found here:
  56. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  57. $table = array(
  58. 'header' => $headers,
  59. 'rows' => $rows,
  60. 'attributes' => array(
  61. 'id' => 'tripal_featuremap-table-publications',
  62. 'class' => 'tripal-data-table'
  63. ),
  64. 'sticky' => FALSE,
  65. 'caption' => '',
  66. 'colgroups' => array(),
  67. 'empty' => '',
  68. );
  69. // once we have our table array structure defined, we call Drupal's theme_table()
  70. // function to generate the table.
  71. print theme_table($table);
  72. }