1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- function tripal_jbrowse_page_settings_form($form, $form_state) {
- $form['general'] = [
- '#type' => 'fieldset',
- '#title' => 'General Page Integration Settings'
- ];
- $form['general']['embed'] = [
- '#type' => 'checkbox',
- '#title' => 'Embed JBrowse in your Tripal Site',
- '#description' => 'Check this box if you would like to embed the JBrowse in your Tripal site. Conversely, uncheck it for links to go directly to the full-screen JBrowse.',
- '#default_value' => variable_get('trpjbrowse_page_embed', 1),
- ];
- $form['exclude_fieldset'] = [
- '#type' => 'fieldset',
- '#title' => 'Exclude JBrowse Instances from Page Integration',
- '#description' => 'To exclude a JBrowse instance from page integration (i.e. no embedded page will be shown and it won\'t show up in the listing), check the checkbox below.',
- ];
-
- $instances = tripal_jbrowse_mgmt_get_instances();
- $options = [];
- foreach ($instances as $instance) {
- $key = $instance->id;
- $options[$key] = [
- 'genus' => $instance->organism->genus,
- 'species' => $instance->organism->species,
- 'analysis' => $instance->analysis->name ?? 'Not Provided',
- 'description' => $instance->description,
- ];
- }
-
- $default_exclude = variable_get('trpjbrowse_page_exclude', []);
- if (!is_array($default_exclude)) {
- $default_exclude = unserialize($default_exclude);
- }
-
- $form['exclude_fieldset']['exclude'] = [
- '#type' => 'tableselect',
- '#header' => [
- 'genus' => t('Genus'),
- 'species' => t('Species'),
- 'analysis' => t('Sequence Assembly'),
- 'description' => t('Description')
- ],
- '#options' => $options,
- '#empty' => t('No JBrowse Instances available. Please add one through the "List Instances" page.'),
- '#default_value' => $default_exclude,
- ];
- $form['submit'] = [
- '#type' => 'submit',
- '#value' => 'Save Settings',
- ];
- return $form;
- }
- function tripal_jbrowse_page_settings_form_submit($form, $form_state) {
- $values = $form_state['values'];
-
- variable_set(
- 'trpjbrowse_page_embed',
- $values['embed']
- );
-
- variable_set(
- 'trpjbrowse_page_exclude',
- serialize($values['exclude'])
- );
-
- variable_set('menu_rebuild_needed', TRUE);
- }
|