'textarea', '#title' => 'Export', '#description' => t('Simply copy the provided export into the Import text area on ' . 'another tripal views enabled website to port the integration between websites.'), '#rows' => 20, '#value' => $t, ]; return $form; } /** * Form: Imports a tripal views integration * * @ingroup tripal_chado_views */ function tripal_chado_views_integration_import_form() { $form = []; $form['name'] = [ '#type' => 'textfield', '#title' => 'Name (optional)', '#description' => t('A human-readable name for your integration.'), ]; $priorities = []; foreach (range(-10, 10) as $v) { $priorities[$v] = (string) $v; } $form['views_type']['row_priority'] = [ '#type' => 'select', '#title' => t('Priority (optional)'), '#description' => t('The level of priority your Views integration has in relation to the ' . 'default core and module definitions. The views integration definition with the ' . 'lightest priority will be used. For example, if there is a definition created by ' . 'core with a priority of 10 and another by a custom module of 5 and yours is -1 then ' . 'your definition will be used for that table because -1 is lighter than both 5 and 10.'), '#options' => $priorities, '#default_value' => -1, ]; $form['import'] = [ '#type' => 'textarea', '#title' => 'Import', '#description' => t('Simply copy the provided export into the text area to port the integration between websites.'), '#rows' => 20, ]; $form['submit'] = [ '#type' => 'submit', '#value' => 'Submit', ]; return $form; } /** * Submit: Imports a tripal views integration * * @param $form * @param $form_state * * @ingroup tripal_chado_views */ function tripal_chado_views_integration_import_form_submit($form, &$form_state) { //$defn_array = unserialize($form_state['values']['import']); // convert the array into a real PHP array $defn_array = []; eval("\$defn_array = " . $form_state['values']['import'] . ";"); // Add optional parameters if ($form_state['values']['name']) { $defn_array['name'] = $form_state['values']['name']; } if ($form_state['values']['row_priority']) { $defn_array['priority'] = $form_state['values']['row_priority']; } // Add the views integration $success = tripal_add_views_integration($defn_array); if ($success) { drupal_set_message(t("Successfully imported %name Integration", ['%name' => $defn_array['name']])); } else { drupal_set_message(t("Unable to import %name Integration", ['%name' => $defn_array['name']]), 'error'); } }