tripal_jbrowse_page.module 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. // The type of menu needs to be determined.
  23. $create_links = variable_get('trpjbrowse_page_create_menu_items', 1);
  24. $menu_type = MENU_CALLBACK;
  25. if ($create_links) {
  26. $menu_type = MENU_NORMAL_ITEM;
  27. }
  28. // Create the menu item.
  29. $path = 'jbrowse/'.$instance->organism->genus . '/' . $instance->organism->species;
  30. $items[$path] = [
  31. 'title' => $instance->title,
  32. 'description' => $instance->description,
  33. 'page callback' => 'tripal_jbrowse_page_page',
  34. 'page arguments' => [1, 2],
  35. 'access arguments' => ['access content'],
  36. 'file' => 'includes/tripal_jbrowse_page.page.inc',
  37. 'type' => $menu_type,
  38. ];
  39. }
  40. }
  41. // Administration.
  42. $admin_path = 'admin/tripal/extension/tripal_jbrowse/management';
  43. $items[$admin_path.'/page-integration'] = [
  44. 'title' => 'Page Integration',
  45. 'description' => 'A listing of available JBrowse instances.',
  46. 'page callback' => 'drupal_get_form',
  47. 'page arguments' => ['tripal_jbrowse_page_settings_form'],
  48. 'access arguments' => ['access content'],
  49. 'file' => 'includes/tripal_jbrowse_page.admin.inc',
  50. 'type' => MENU_LOCAL_TASK,
  51. ];
  52. return $items;
  53. }
  54. /**
  55. * Implements hook_theme().
  56. */
  57. function tripal_jbrowse_page_theme($existing, $type, $theme, $path) {
  58. $items = array(
  59. 'jbrowse_instance_public_listing' => 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--public-listing',
  63. 'variables' => array('instances' => []),
  64. ),
  65. 'jbrowse_instance_embedded_page' => array(
  66. // Don't specify the path in the template name.
  67. // Unless you have your template inside a directory within this module.
  68. 'template' => 'theme/jbrowse-instance--embedded',
  69. 'variables' => array('url' => ''),
  70. ),
  71. );
  72. return $items;
  73. }