1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- // API.
- require_once 'includes/tripal_jbrowse_page.api.inc';
- /**
- * Implements hook_menu().
- */
- function tripal_jbrowse_page_menu() {
- $items = [];
- // Listing Page.
- $items['jbrowse'] = [
- 'title' => 'JBrowse',
- 'description' => 'A listing of available JBrowse instances.',
- 'page callback' => 'tripal_jbrowse_page_listing_page',
- 'access arguments' => ['access content'],
- 'file' => 'includes/tripal_jbrowse_page.listing.inc',
- 'type' => MENU_NORMAL_ITEM,
- ];
- // Pages for each JBrowse Instance.
- $instances = tripal_jbrowse_mgmt_get_instances();
- foreach ($instances as $instance) {
- // Create the menu item.
- $path = 'jbrowse/'.$instance->organism->genus . '-' . $instance->organism->species . '/' . $instance->id;
- $items[$path] = [
- 'title' => $instance->title,
- 'description' => $instance->description,
- 'page callback' => 'tripal_jbrowse_page_page',
- 'page arguments' => [1, 2],
- 'file' => 'includes/tripal_jbrowse_page.page.inc',
- 'type' => MENU_SUGGESTED_ITEM,
- ];
- if (tripal_jbrowse_page_is_instance_public($instance->id)) {
- $items[$path]['access arguments'] = ['access content'];
- }
- else {
- $items[$path]['access arguments'] = ['view private jbrowse page'];
- }
- }
- // Administration.
- $admin_path = 'admin/tripal/extension/tripal_jbrowse/management';
- $items[$admin_path.'/page-integration'] = [
- 'title' => 'Page Integration',
- 'description' => 'A listing of available JBrowse instances.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => ['tripal_jbrowse_page_settings_form'],
- 'access arguments' => ['access content'],
- 'file' => 'includes/tripal_jbrowse_page.admin.inc',
- 'type' => MENU_LOCAL_TASK,
- ];
- return $items;
- }
- /**
- * Implements hook_theme().
- */
- function tripal_jbrowse_page_theme($existing, $type, $theme, $path) {
- $items = array(
- 'jbrowse_instance_public_listing' => array(
- // Don't specify the path in the template name.
- // Unless you have your template inside a directory within this module.
- 'template' => 'theme/jbrowse-instance--public-listing',
- 'variables' => array('instances' => []),
- ),
- 'jbrowse_instance_embedded_page' => array(
- // Don't specify the path in the template name.
- // Unless you have your template inside a directory within this module.
- 'template' => 'theme/jbrowse-instance--embedded',
- 'variables' => array('url' => ''),
- ),
- );
- return $items;
- }
- /**
- * Implements hook_permission().
- */
- function tripal_jbrowse_page_permission() {
- $items = [];
- $items['view private jbrowse page'] = [
- 'title' => t('View excluded JBrowse pages'),
- '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.'),
- ];
- return $items;
- }
|