tripal_organism_stocks.tpl.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. $organism = $variables['node']->organism;
  3. // expand the featuremap object to include the records from the featurepos table
  4. // specify the number of features to show by default and the unique pager ID
  5. $num_results_per_page = 25;
  6. $pager_id = 3;
  7. // get the features aligned on this map
  8. $options = array(
  9. 'return_array' => 1,
  10. 'order_by' => array('name' => 'ASC'),
  11. 'pager' => array('limit' => $num_results_per_page, 'element' => $pager_id),
  12. 'include_fk' => array(
  13. 'type_id' => 1
  14. ),
  15. );
  16. $organism = tripal_core_expand_chado_vars($organism, 'table', 'stock', $options);
  17. $stocks = $organism->stock;
  18. // create the pager.
  19. global $pager_total_items;
  20. $pager = theme('pager', array(), $num_results_per_page, $pager_id, array('block' => 'stocks'));
  21. $total_features = $pager_total_items[$pager_id];
  22. if (count($stocks) > 0) { ?>
  23. <div id="tripal_organism-stocks-box" class="tripal_organism-info-box tripal-info-box">
  24. <div class="tripal_organism-info-box-title tripal-info-box-title">Stocks</div>
  25. <div class="tripal_organism-info-box-desc tripal-info-box-desc">This organism is associated with <?php print number_format($total_features) ?> stock(s):</div>
  26. <table id="tripal_organism-table-stocks" class="tripal_organism-table tripal-table tripal-table-horz">
  27. <tr class="tripal_organism-table-odd-row tripal-table-even-row">
  28. <th>Name</th>
  29. <th>Type</th>
  30. </tr> <?php
  31. foreach ($stocks as $stock){
  32. $class = 'tripal_organism-table-odd-row tripal-table-odd-row';
  33. if ($i % 2 == 0 ) {
  34. $class = 'tripal_organism-table-odd-row tripal-table-even-row';
  35. } ?>
  36. <tr class="<?php print $class ?>">
  37. <td><?php
  38. $name = $stock->name;
  39. if (!$stock->name) {
  40. $name = $stock->uniquename;
  41. }
  42. if ($stock->nid) {
  43. print l($name, "node/$stock->nid", array('attributes' => array('target' => '_blank')));
  44. } else {
  45. print $name;
  46. }?>
  47. </td>
  48. <td><?php print $stock->type_id->name?></td>
  49. </tr><?php
  50. $i++;
  51. } ?>
  52. </table>
  53. <?php print $pager ?>
  54. </div> <?php
  55. }