tripal_jbrowse_page.module 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. // API.
  3. require_once 'includes/tripal_jbrowse_page.api.inc';
  4. /**
  5. * Implements hook_menu().
  6. */
  7. function tripal_jbrowse_page_menu() {
  8. $items = [];
  9. // Listing Page.
  10. $items['jbrowse'] = [
  11. 'title' => 'JBrowse',
  12. 'description' => 'A listing of available JBrowse instances.',
  13. 'page callback' => 'tripal_jbrowse_page_listing_page',
  14. 'access arguments' => ['access content'],
  15. 'file' => 'includes/tripal_jbrowse_page.listing.inc',
  16. 'type' => MENU_NORMAL_ITEM,
  17. ];
  18. // Pages for each JBrowse Instance.
  19. $instances = tripal_jbrowse_mgmt_get_instances();
  20. foreach ($instances as $instance) {
  21. if (tripal_jbrowse_page_is_instance_public($instance->id)) {
  22. // Create the menu item.
  23. $path = 'jbrowse/'.$instance->organism->genus . '-' . $instance->organism->species;
  24. $items[$path] = [
  25. 'title' => $instance->title,
  26. 'description' => $instance->description,
  27. 'page callback' => 'tripal_jbrowse_page_page',
  28. 'page arguments' => [1],
  29. 'access arguments' => ['access content'],
  30. 'file' => 'includes/tripal_jbrowse_page.page.inc',
  31. 'type' => MENU_SUGGESTED_ITEM,
  32. ];
  33. }
  34. }
  35. // Administration.
  36. $admin_path = 'admin/tripal/extension/tripal_jbrowse/management';
  37. $items[$admin_path.'/page-integration'] = [
  38. 'title' => 'Page Integration',
  39. 'description' => 'A listing of available JBrowse instances.',
  40. 'page callback' => 'drupal_get_form',
  41. 'page arguments' => ['tripal_jbrowse_page_settings_form'],
  42. 'access arguments' => ['access content'],
  43. 'file' => 'includes/tripal_jbrowse_page.admin.inc',
  44. 'type' => MENU_LOCAL_TASK,
  45. ];
  46. return $items;
  47. }
  48. /**
  49. * Implements hook_theme().
  50. */
  51. function tripal_jbrowse_page_theme($existing, $type, $theme, $path) {
  52. $items = array(
  53. 'jbrowse_instance_public_listing' => array(
  54. // Don't specify the path in the template name.
  55. // Unless you have your template inside a directory within this module.
  56. 'template' => 'theme/jbrowse-instance--public-listing',
  57. 'variables' => array('instances' => []),
  58. ),
  59. 'jbrowse_instance_embedded_page' => array(
  60. // Don't specify the path in the template name.
  61. // Unless you have your template inside a directory within this module.
  62. 'template' => 'theme/jbrowse-instance--embedded',
  63. 'variables' => array('url' => ''),
  64. ),
  65. );
  66. return $items;
  67. }