tripal_pub_projects.tpl.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. $pub = $variables['node']->pub;
  3. $projects = 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. $project_pager_id = 5;
  8. // get the genotypes from the project_genotype table
  9. $options = array(
  10. 'return_array' => 1,
  11. 'pager' => array('limit' => $num_results_per_page, 'element' => $project_pager_id),
  12. );
  13. $pub = tripal_core_expand_chado_vars($pub, 'table', 'project_pub', $options);
  14. $project_pubs = $pub->project_pub;
  15. if (count($project_pubs) > 0 ) {
  16. foreach ($project_pubs as $project_pub) {
  17. $projects[] = $project_pub->project_id;
  18. }
  19. }
  20. // create the pager.
  21. global $pager_total_items;
  22. $project_pager = theme('pager', array(), $num_results_per_page, $project_pager_id, array('block' => 'projects'));
  23. $total_projects = $pager_total_items[$project_pager_id];
  24. if(count($projects) > 0){ ?>
  25. <div id="tripal_pub-projects-box" class="tripal_pub-info-box tripal-info-box">
  26. <div class="tripal_pub-info-box-title tripal-info-box-title">Projects</div>
  27. <div class="tripal_pub-info-box-desc tripal-info-box-desc">This publication contains information about <?php print number_format($total_projects) ?> projects:</div>
  28. <table id="tripal_pub-project-table" class="tripal_pub-table tripal-table tripal-table-horz">
  29. <tr>
  30. <th>Project Name</th>
  31. </tr> <?php
  32. $i = 0;
  33. foreach ($projects as $project){
  34. $class = 'tripal_pub-table-odd-row tripal-table-odd-row';
  35. if($i % 2 == 0 ){
  36. $class = 'tripal_pub-table-even-row tripal-table-even-row';
  37. } ?>
  38. <tr class="<?php print $class ?>">
  39. <td> <?php
  40. if ($project->nid) {
  41. print l($project->name, 'node/' . $project->nid, array('attributes' => array('target' => '_blank')));
  42. }
  43. else {
  44. print $project->name;
  45. } ?>
  46. </td>
  47. </tr> <?php
  48. $i++;
  49. } ?>
  50. </table> <?php
  51. print $project_pager ?>
  52. </div><?php
  53. }?>