tripal_pub_libraries.tpl.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. $pub = $variables['node']->pub;
  3. $libraries = 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. $library_pager_id = 5;
  8. // get the genotypes from the library_genotype table
  9. $options = array(
  10. 'return_array' => 1,
  11. 'pager' => array('limit' => $num_results_per_page, 'element' => $library_pager_id),
  12. );
  13. $pub = tripal_core_expand_chado_vars($pub, 'table', 'library_pub', $options);
  14. $library_pubs = $pub->library_pub;
  15. if (count($library_pubs) > 0 ) {
  16. foreach ($library_pubs as $library_pub) {
  17. $libraries[] = $library_pub->library_id;
  18. }
  19. }
  20. // create the pager.
  21. global $pager_total_items;
  22. $library_pager = theme('pager', array(), $num_results_per_page, $library_pager_id, array('block' => 'libraries'));
  23. $total_libraries = $pager_total_items[$library_pager_id];
  24. if(count($libraries) > 0){ ?>
  25. <div id="tripal_pub-libraries-box" class="tripal_pub-info-box tripal-info-box">
  26. <div class="tripal_pub-info-box-title tripal-info-box-title">Libraries</div>
  27. <div class="tripal_pub-info-box-desc tripal-info-box-desc">This publication contains information about <?php print number_format($total_libraries) ?> libraries:</div>
  28. <table id="tripal_pub-library-table" class="tripal_pub-table tripal-table tripal-table-horz">
  29. <tr>
  30. <th>Library Name</th>
  31. <th>Species</th>
  32. <th>Type</th>
  33. </tr> <?php
  34. $i = 0;
  35. foreach ($libraries as $library){
  36. $class = 'tripal_pub-table-odd-row tripal-table-odd-row';
  37. if($i % 2 == 0 ){
  38. $class = 'tripal_pub-table-even-row tripal-table-even-row';
  39. } ?>
  40. <tr class="<?php print $class ?>">
  41. <td> <?php
  42. if ($library->nid) {
  43. print l($library->name, 'node/' . $library->nid, array('attributes' => array('target' => '_blank')));
  44. }
  45. else {
  46. print $library->name;
  47. } ?>
  48. </td>
  49. <td><?php print $library->type_id->name ?></td>
  50. <td><?php print $library->organism_id->genus ?> <?php print $library->organism_id->species ?></td>
  51. </tr> <?php
  52. $i++;
  53. } ?>
  54. </table> <?php
  55. print $library_pager ?>
  56. </div><?php
  57. }?>