tripal_jbrowse_page.page.inc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * @file
  4. * Builds the Tripal JBrowse page.
  5. */
  6. /**
  7. * Redirect to the JBrowse Instance.
  8. */
  9. function tripal_jbrowse_page_page($scientific_name, $instance_id = NULL) {
  10. if($instance_id){
  11. $instance = tripal_jbrowse_mgmt_get_instance($instance_id);
  12. }
  13. else{
  14. list($genus, $species) = explode('-', $scientific_name);
  15. $instance = tripal_jbrowse_page_get_instance_id([
  16. 'genus' => $genus,
  17. 'species' => $species
  18. ],
  19. ['load_instance' => TRUE]);
  20. }
  21. // Determine Query paramters.
  22. $query_params = tripal_jbrowse_mgmt_build_http_query($instance);
  23. $page_q = drupal_get_query_parameters();
  24. foreach ($page_q as $qkey => $qvalue) {
  25. $query_params[$qkey] = $qvalue;
  26. }
  27. // Build the URL.
  28. $settings = tripal_jbrowse_mgmt_get_settings();
  29. $url = url($settings['link'],['query' => $query_params]);
  30. // Either embed the page or redirect to the full JBrowse based on configuration.
  31. if (variable_get('trpjbrowse_page_embed', 1)) {
  32. drupal_add_css(drupal_get_path('module', 'tripal_jbrowse_page') . '/theme/tripal_jbrowse_page.css');
  33. return theme('jbrowse_instance_embedded_page', ['url' => $url, 'instance' => $instance]);
  34. }
  35. else {
  36. drupal_goto($url, array('external' => TRUE));
  37. }
  38. }