tripal_jbrowse_page.module 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. // Create the menu item.
  22. $path = 'jbrowse/'.$instance->organism->genus . '-' . $instance->organism->species . '/' . $instance->id;
  23. $items[$path] = [
  24. 'title' => $instance->title,
  25. 'description' => $instance->description,
  26. 'page callback' => 'tripal_jbrowse_page_page',
  27. 'page arguments' => [1, 2],
  28. 'file' => 'includes/tripal_jbrowse_page.page.inc',
  29. 'type' => MENU_SUGGESTED_ITEM,
  30. ];
  31. if (tripal_jbrowse_page_is_instance_public($instance->id)) {
  32. $items[$path]['access arguments'] = ['access content'];
  33. }
  34. else {
  35. $items[$path]['access arguments'] = ['view private jbrowse page'];
  36. }
  37. }
  38. // Administration.
  39. $admin_path = 'admin/tripal/extension/tripal_jbrowse/management';
  40. $items[$admin_path.'/page-integration'] = [
  41. 'title' => 'Page Integration',
  42. 'description' => 'A listing of available JBrowse instances.',
  43. 'page callback' => 'drupal_get_form',
  44. 'page arguments' => ['tripal_jbrowse_page_settings_form'],
  45. 'access arguments' => ['access content'],
  46. 'file' => 'includes/tripal_jbrowse_page.admin.inc',
  47. 'type' => MENU_LOCAL_TASK,
  48. ];
  49. return $items;
  50. }
  51. /**
  52. * Implements hook_theme().
  53. */
  54. function tripal_jbrowse_page_theme($existing, $type, $theme, $path) {
  55. $items = array(
  56. 'jbrowse_instance_public_listing' => array(
  57. // Don't specify the path in the template name.
  58. // Unless you have your template inside a directory within this module.
  59. 'template' => 'theme/jbrowse-instance--public-listing',
  60. 'variables' => array('instances' => []),
  61. ),
  62. 'jbrowse_instance_embedded_page' => array(
  63. // Don't specify the path in the template name.
  64. // Unless you have your template inside a directory within this module.
  65. 'template' => 'theme/jbrowse-instance--embedded',
  66. 'variables' => array('url' => ''),
  67. ),
  68. );
  69. return $items;
  70. }
  71. /**
  72. * Implements hook_permission().
  73. */
  74. function tripal_jbrowse_page_permission() {
  75. $items = [];
  76. $items['view private jbrowse page'] = [
  77. 'title' => t('View excluded JBrowse pages'),
  78. 'description' => t('If users have this permission and know the link to the page, they will be able to see it. The instance will still not be included in the JBrowse instances list.'),
  79. ];
  80. return $items;
  81. }