node--chado-generic.tpl.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. // Purpose: This template provides a generic layout for all Tripal nodes (page)
  3. // get the template type of node (e.g. if type == chado_organism then template type == organism)
  4. $ttype = $variables['type'];
  5. $ttype = preg_replace('/chado_/','', $ttype);
  6. // get the template settings
  7. $template_settings = theme_get_setting('tripal');
  8. // toggle the sidebar if desired
  9. $no_sidebar = 0;
  10. if (is_array($template_settings['tripal_no_sidebar']) and
  11. $template_settings['tripal_no_sidebar'][$ttype]) {
  12. $no_sidebar = 1;
  13. }
  14. if ($teaser) {
  15. print theme('tripal_' . $ttype . '_teaser', $variables);
  16. }
  17. else { ?>
  18. <script type="text/javascript">
  19. (function ($) {
  20. Drupal.behaviors.<?php print $ttype?>Behavior = {
  21. attach: function (context, settings){ <?php
  22. // hide the resource sidbar if requested and strech the details section
  23. if ($no_sidebar) { ?>
  24. $(".tripal_toc").hide();
  25. $(".tripal_details").addClass("tripal_details_full");
  26. $(".tripal_details_full").removeClass("tripal_details"); <?php
  27. }
  28. // use default resource sidebar
  29. else { ?>
  30. $(".tripal-info-box").hide(); <?php
  31. } ?>
  32. // iterate through all of the info boxes and add their titles
  33. // to the table of contents
  34. $(".tripal-info-box-title").each(function(){
  35. var parent = $(this).parent();
  36. var id = $(parent).attr('id');
  37. var title = $(this).text();
  38. $('#tripal_<?php print $ttype?>_toc_list').append('<li><a href="#'+id+'" class="tripal_<?php print $ttype?>_toc_item">'+title+'</a></li>');
  39. });
  40. // when a title in the table of contents is clicked, then
  41. // show the corresponding item in the details box
  42. $(".tripal_<?php print $ttype?>_toc_item").click(function(){
  43. $(".tripal-info-box").hide();
  44. href = $(this).attr('href');
  45. if(href.match(/^#/)){
  46. //alert("correct: " + href);
  47. }
  48. else{
  49. tmp = href.replace(/^.*?#/, "#");
  50. href = tmp;
  51. //alert("fixed: " + href);
  52. }
  53. $(href).fadeIn('slow');
  54. return false;
  55. });
  56. // we want the base details to show up when the page is first shown
  57. // unless we're using the feature browser then we want that page to show
  58. var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
  59. if(block == null){
  60. block = window.location.href.match(/[\?|\&]block=(.+)/)
  61. }
  62. if(block != null){
  63. $("#tripal_<?php print $ttype?>-"+block[1]+"-box").show();
  64. }
  65. else {
  66. $("#tripal_<?php print $ttype?>-base-box").show();
  67. }
  68. }
  69. };
  70. })(jQuery);
  71. </script>
  72. <div id="tripal_<?php print $ttype?>_content" class="tripal_contents">
  73. <table id="tripal_contents_table">
  74. <tr class="tripal_contents_table_tr">
  75. <td nowrap class="tripal_contents_table_td" align="left">
  76. <div id="tripal_<?php print $ttype?>_toc" class="tripal_toc">
  77. <ul id="tripal_<?php print $ttype?>_toc_list" class="tripal_toc_list">
  78. <!-- Resource Links CCK elements --><?php
  79. if(property_exists($node, 'field_resource_links')) {
  80. for($i = 0; $i < count($node->field_resource_links); $i++){
  81. if($node->field_resource_links[$i]['value']){
  82. $matches = preg_split("/\|/",$node->field_resource_links[$i]['value']);?>
  83. <li><a href="<?php print $matches[1] ?>" target="_blank"><?php print $matches[0] ?></a></li><?php
  84. }
  85. }
  86. }
  87. ?>
  88. </ul>
  89. </div>
  90. </td>
  91. <td class="tripal_contents_table_td" align="left" width="100%">
  92. <div id="tripal_<?php print $ttype?>_details" class="tripal_details">
  93. <!-- Resource Blocks CCK elements --> <?php
  94. if (property_exists($node, 'field_resource_titles')) {
  95. for ($i = 0; $i < count($node->field_resource_titles); $i++){
  96. if ($node->field_resource_titles[$i]['value']){ ?>
  97. <div id="tripal_<?php print $ttype?>-resource_<?php print $i?>-box" class="tripal_<?php print $ttype?>-info-box tripal-info-box">
  98. <div class="tripal_<?php print $ttype?>-info-box-title tripal-info-box-title"><?php print $node->field_resource_titles[$i]['value'] ?></div>
  99. <?php print $node->field_resource_blocks[$i]['value']; ?>
  100. </div> <?php
  101. }
  102. }
  103. }?>
  104. <!-- Let modules add more content -->
  105. <?php
  106. foreach ($content as $key => $values) {
  107. if (array_key_exists('#value', $values)) {
  108. print $content[$key]['#value'];
  109. }
  110. }
  111. ?>
  112. </div>
  113. </td>
  114. </tr>
  115. </table>
  116. </div>
  117. <?php
  118. } ?>