tripal_pub_features.tpl.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. $pub = $variables['node']->pub;
  3. $features = array();
  4. // expand the pub object to include the records from the pub_dbxref table
  5. // specify the number of genotypes to show by default and the unique pager ID
  6. $num_results_per_page = 25;
  7. $feature_pager_id = 5;
  8. // get the genotypes from the feature_genotype table
  9. $options = array(
  10. 'return_array' => 1,
  11. 'pager' => array('limit' => $num_results_per_page, 'element' => $feature_pager_id),
  12. );
  13. $pub = tripal_core_expand_chado_vars($pub, 'table', 'feature_pub', $options);
  14. $feature_pubs = $pub->feature_pub;
  15. if (count($feature_pubs) > 0 ) {
  16. foreach ($feature_pubs as $feature_pub) {
  17. $features[] = $feature_pub->feature_id;
  18. }
  19. }
  20. // create the pager.
  21. global $pager_total_items;
  22. $feature_pager = theme('pager', array(), $num_results_per_page, $feature_pager_id, array('block' => 'features'));
  23. $total_features = $pager_total_items[$feature_pager_id];
  24. if(count($features) > 0){ ?>
  25. <div id="tripal_pub-features-box" class="tripal_pub-info-box tripal-info-box">
  26. <div class="tripal_pub-info-box-title tripal-info-box-title">Features</div>
  27. <div class="tripal_pub-info-box-desc tripal-info-box-desc">This publication contains information about <?php print number_format($total_features) ?> features:</div>
  28. <table id="tripal_pub-feature-table" class="tripal_pub-table tripal-table tripal-table-horz">
  29. <tr>
  30. <th>Feature Name</th>
  31. <th>Type</th>
  32. </tr> <?php
  33. $i = 0;
  34. foreach ($features as $feature){
  35. $class = 'tripal_pub-table-odd-row tripal-table-odd-row';
  36. if($i % 2 == 0 ){
  37. $class = 'tripal_pub-table-even-row tripal-table-even-row';
  38. } ?>
  39. <tr class="<?php print $class ?>">
  40. <td> <?php
  41. if ($feature->nid) {
  42. print l($feature->name, 'node/' . $feature->nid, array('attributes' => array('target' => '_blank')));
  43. }
  44. else {
  45. print $feature->name;
  46. } ?>
  47. </td>
  48. <td><?php print $feature->type_id->name ?></td>
  49. </tr> <?php
  50. $i++;
  51. } ?>
  52. </table> <?php
  53. print $feature_pager ?>
  54. </div><?php
  55. }?>