|
@@ -7,7 +7,7 @@
|
|
|
function tripal_pub_importers_list() {
|
|
|
// clear out the session variable when we view the list.
|
|
|
unset($_SESSION['tripal_pub_import']);
|
|
|
-
|
|
|
+
|
|
|
$header = array('', 'Importer Name', 'Database', 'Search String', 'Disabled', 'Create Contact', '');
|
|
|
$rows = array();
|
|
|
$importers = db_query("SELECT * FROM {tripal_pub_import} ORDER BY name");
|
|
@@ -35,30 +35,35 @@ function tripal_pub_importers_list() {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- $rows[] = array(
|
|
|
- 'data' => array(
|
|
|
- array('data' => l(t('Create a new publication importer.'), "admin/tripal/chado/tripal_pub/import/new"),
|
|
|
- 'colspan' => 7),
|
|
|
- )
|
|
|
- );
|
|
|
|
|
|
$page = "<ul class='action-links'>";
|
|
|
$page .= ' <li>' . l('New Importer', 'admin/tripal/chado/tripal_pub/import/new') . '</li>';
|
|
|
$page .= '</ul>';
|
|
|
+
|
|
|
+ $page .= '<p>' . t(
|
|
|
+ "A publication importer is used to create a set of search criteria that can be used
|
|
|
+ to query a remote database, find publications that match the specified criteria
|
|
|
+ and then import those publications into the Chado database. An example use case would
|
|
|
+ be to peridocially add new publications to this Tripal site that have appeared in PubMed
|
|
|
+ in the last 30 days. See the " .
|
|
|
+ l("Pub Module help instructions", "admin/tripal/chado/tripal_pub/help") . " to learn how to
|
|
|
+ set the importers to run automatically.") . '</p>';
|
|
|
|
|
|
$page .= theme('table', array('header' => $header, 'rows' => $rows));
|
|
|
+
|
|
|
return $page;
|
|
|
}
|
|
|
|
|
|
-/*
|
|
|
- *
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @param action
|
|
|
+ * @param $pub_import_id
|
|
|
+ *
|
|
|
+ *
|
|
|
*/
|
|
|
function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL) {
|
|
|
- global $pager_total, $pager_total_items;
|
|
|
-
|
|
|
- $pager_id = 0;
|
|
|
- $limit = 20;
|
|
|
-
|
|
|
+ global $base_path;
|
|
|
+
|
|
|
// make sure the tripal_pub and tripal_contact ontologies are loaded
|
|
|
$values = array('name' => 'tripal_pub');
|
|
|
$tpub_cv = tripal_core_chado_select('cv', array('cv_id'), $values);
|
|
@@ -70,6 +75,10 @@ function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL)
|
|
|
if (count($tpub_cv) == 0) {
|
|
|
drupal_set_message(t('If you want to create contact pages for authors, you must first ') . l(t('load the Tripal Contact Ontology'), 'admin/tripal/tripal_cv/obo_loader'), 'error');
|
|
|
}
|
|
|
+
|
|
|
+ if(!extension_loaded ('yaz')){
|
|
|
+ drupal_set_message(t('<b>Note:</b> In order to create an importer using the USDA National Agricultural Library (AGL) you must install the yaz libraries. See the ') . l(t('Pub Module help page'), 'admin/tripal/chado/tripal_pub/help') . ' for assistance. If you do not want to use AGL you can ignore this warning.', 'warning');
|
|
|
+ }
|
|
|
|
|
|
// generate the search form
|
|
|
$form = drupal_get_form('tripal_pub_importer_setup_form', $pub_import_id, $action);
|
|
@@ -77,62 +86,100 @@ function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL)
|
|
|
$output = l("Return to publication importers list", "admin/tripal/chado/tripal_pub/import_list");
|
|
|
$output .= drupal_render($form);
|
|
|
|
|
|
- /*
|
|
|
// retrieve any results
|
|
|
- $remote_db = $_SESSION['tripal_pub_import']['remote_db'];
|
|
|
- $num_criteria = $_SESSION['tripal_pub_import']['num_criteria'];
|
|
|
- $days = $_SESSION['tripal_pub_import']['days'];
|
|
|
-
|
|
|
- $search_array = array();
|
|
|
- $search_array['remote_db'] = $remote_db;
|
|
|
- $search_array['num_criteria'] = $num_criteria;
|
|
|
- $search_array['days'] = $days;
|
|
|
- for ($i = 1; $i <= $num_criteria; $i++) {
|
|
|
- $search_array['criteria'][$i]['search_terms'] = $_SESSION['tripal_pub_import']['criteria'][$i]['search_terms'];
|
|
|
- $search_array['criteria'][$i]['scope'] = $_SESSION['tripal_pub_import']['criteria'][$i]['scope'];
|
|
|
- $search_array['criteria'][$i]['is_phrase'] = $_SESSION['tripal_pub_import']['criteria'][$i]['is_phrase'];
|
|
|
- $search_array['criteria'][$i]['operation'] = $_SESSION['tripal_pub_import']['criteria'][$i]['operation'];
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if ($_SESSION['tripal_pub_import']['perform_search']) {
|
|
|
- // get the list of publications from the remote database using the search criteria.
|
|
|
- $pubs = tripal_pub_get_remote_search_results($remote_db, $search_array, $limit, $pager_id);
|
|
|
- //dpm($pubs);
|
|
|
-
|
|
|
- // generate the pager
|
|
|
- $total_pages = $pager_total[$pager_id];
|
|
|
- $total_items = $pager_total_items[$pager_id];
|
|
|
- $page = isset($_GET['page']) ? $_GET['page'] : '0';
|
|
|
- $pager = theme('pager');
|
|
|
-
|
|
|
- // iterate through the results and construct the table displaying the publications
|
|
|
- $rows = array();
|
|
|
- $i = $page * $limit + 1;
|
|
|
- if (count($pubs) > 0) {
|
|
|
- foreach ($pubs as $pub) {
|
|
|
- $citation = htmlspecialchars($pub['Citation']);
|
|
|
- $raw_link = '';
|
|
|
- if($pub['Publication Dbxref']) {
|
|
|
- $raw_link = l('raw', 'admin/tripal/chado/tripal_pub/import/raw/' . $pub['Publication Dbxref'], array('attributes' => array('target' => '_blank')));
|
|
|
+ if (array_key_exists('tripal_pub_import', $_SESSION)) {
|
|
|
+ $remote_db = $_SESSION['tripal_pub_import']['remote_db'];
|
|
|
+ $num_criteria = $_SESSION['tripal_pub_import']['num_criteria'];
|
|
|
+ $days = $_SESSION['tripal_pub_import']['days'];
|
|
|
+
|
|
|
+ $search_array = array();
|
|
|
+ $search_array['remote_db'] = $remote_db;
|
|
|
+ $search_array['num_criteria'] = $num_criteria;
|
|
|
+ $search_array['days'] = $days;
|
|
|
+ for ($i = 1; $i <= $num_criteria; $i++) {
|
|
|
+ $search_array['criteria'][$i]['search_terms'] = $_SESSION['tripal_pub_import']['criteria'][$i]['search_terms'];
|
|
|
+ $search_array['criteria'][$i]['scope'] = $_SESSION['tripal_pub_import']['criteria'][$i]['scope'];
|
|
|
+ $search_array['criteria'][$i]['is_phrase'] = $_SESSION['tripal_pub_import']['criteria'][$i]['is_phrase'];
|
|
|
+ $search_array['criteria'][$i]['operation'] = $_SESSION['tripal_pub_import']['criteria'][$i]['operation'];
|
|
|
+ }
|
|
|
+
|
|
|
+ // if the form has been submitted with the 'test' button then get the results
|
|
|
+ if ($_SESSION['tripal_pub_import']['perform_search']) {
|
|
|
+
|
|
|
+ $limit = 25;
|
|
|
+
|
|
|
+ // get the list of publications from the remote database using the search criteria.
|
|
|
+ $page = isset($_GET['page']) ? $_GET['page'] : '0';
|
|
|
+ $results = tripal_pub_get_remote_search_results($remote_db, $search_array, $limit, $page);
|
|
|
+ $total_records = $results['total_records'];
|
|
|
+ $search_str = $results['search_str'];
|
|
|
+ $pubs = $results['pubs'];
|
|
|
+
|
|
|
+ // iterate through the results and construct the table displaying the publications
|
|
|
+ $rows = array();
|
|
|
+ $i = $page * $limit + 1;
|
|
|
+ if (count($pubs) > 0) {
|
|
|
+ foreach ($pubs as $pub) {
|
|
|
+ $citation = htmlspecialchars($pub['Citation']);
|
|
|
+ $raw_link = '';
|
|
|
+ if($pub['Publication Dbxref']) {
|
|
|
+ $raw_link = l('raw', 'admin/tripal/chado/tripal_pub/import/raw/' . $pub['Publication Dbxref'], array('attributes' => array('target' => '_blank')));
|
|
|
+ }
|
|
|
+ $rows[] = array(
|
|
|
+ number_format($i),
|
|
|
+ $citation,
|
|
|
+ $raw_link,
|
|
|
+ );
|
|
|
+ $i++;
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ if (count($rows) == 0) {
|
|
|
$rows[] = array(
|
|
|
- number_format($i),
|
|
|
- $citation,
|
|
|
- $raw_link,
|
|
|
+ array(
|
|
|
+ 'data' => 'No results found',
|
|
|
+ 'colspan' => 3,
|
|
|
+ ),
|
|
|
);
|
|
|
- $i++;
|
|
|
}
|
|
|
+
|
|
|
+ $headers = array('', 'Publication', 'Raw Results');
|
|
|
+ $table = array(
|
|
|
+ 'header' => $headers,
|
|
|
+ 'rows' => $rows,
|
|
|
+ 'attributes' => array(
|
|
|
+ 'id' => 'tripal_pub-importer-test',
|
|
|
+ ),
|
|
|
+ 'sticky' => FALSE,
|
|
|
+ 'caption' => '',
|
|
|
+ 'colgroups' => array(),
|
|
|
+ 'empty' => '',
|
|
|
+ );
|
|
|
+ // once we have our table array structure defined, we call Drupal's theme_table()
|
|
|
+ // function to generate the table.
|
|
|
+ $table = theme_table($table);
|
|
|
+
|
|
|
+ // generate the pager
|
|
|
+ pager_default_initialize($total_records, $limit);
|
|
|
+ $pager = array(
|
|
|
+ 'tags' => array(),
|
|
|
+ 'element' => 0,
|
|
|
+ 'parameters' => array(),
|
|
|
+ 'quantity' => $limit,
|
|
|
+ );
|
|
|
+ $pager = theme_pager($pager);
|
|
|
+
|
|
|
+ // because this is an ajax callback, the theme_pager will set the URL to be
|
|
|
+ // "system/ajax", so we need to reset that
|
|
|
+ $pager = str_replace($base_path . "system/ajax", "", $pager) ;
|
|
|
+
|
|
|
+ // join all to form the results
|
|
|
+ $total_pages = (int) ($total_records / $limit) + 1;
|
|
|
+ $page = isset($_GET['page']) ? $_GET['page'] : '0';
|
|
|
+ $output .= "$pager<br><b>Found " . number_format($total_records) . " publications. Page " . ($page + 1) . " of $total_pages.</b> " .
|
|
|
+ "<br>$remote_db Search String: $search_str $table<br>$pager";
|
|
|
}
|
|
|
- $headers = array('', 'Publication', '');
|
|
|
- $table = theme('table', array('header' => $headers, 'rows' => $rows));
|
|
|
-
|
|
|
- // join all to form the results
|
|
|
- $output .= "<br><p><b>Found " . number_format($total_items) .
|
|
|
- ". Page " . ($page + 1) . " of $total_pages. " .
|
|
|
- " Results</b></br>" . $table . '</p>' . $pager;
|
|
|
}
|
|
|
- */
|
|
|
return $output;
|
|
|
}
|
|
|
|
|
@@ -142,6 +189,7 @@ function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL)
|
|
|
* @ingroup tripal_pub
|
|
|
*/
|
|
|
function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_id = NULL, $action = 'new') {
|
|
|
+
|
|
|
// Default values can come in the following ways:
|
|
|
//
|
|
|
// 1) as elements of the $pub_importer object. This occurs when editing an existing importer
|
|
@@ -151,8 +199,7 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
|
|
|
// form elements and the form is being rebuilt
|
|
|
//
|
|
|
// set form field defaults
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
// Set the default values. If the pub_import_id isn't already defined by the form values
|
|
|
// and one is provided then look it up in the database
|
|
|
$criteria = NULL;
|
|
@@ -160,7 +207,7 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
|
|
|
$days = '';
|
|
|
$disabled = '';
|
|
|
$do_contact = '';
|
|
|
- $num_criteria = '';
|
|
|
+ $num_criteria = 1;
|
|
|
$loader_name = '';
|
|
|
|
|
|
// if this is an edit the we are pulling an import object from the database
|
|
@@ -176,6 +223,17 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
|
|
|
$num_criteria = $criteria['num_criteria'];
|
|
|
$loader_name = $criteria['loader_name'];
|
|
|
}
|
|
|
+
|
|
|
+ // if there are any session variables then use those
|
|
|
+ if (array_key_exists('tripal_pub_import', $_SESSION)) {
|
|
|
+ $remote_db = $_SESSION['tripal_pub_import']['remote_db'];
|
|
|
+ $days = $_SESSION['tripal_pub_import']['days'];
|
|
|
+ $disabled = $_SESSION['tripal_pub_import']['disabled'];
|
|
|
+ $do_contact = $_SESSION['tripal_pub_import']['do_contact'];
|
|
|
+ $num_criteria = $_SESSION['tripal_pub_import']['num_criteria'];
|
|
|
+ $loader_name = $_SESSION['tripal_pub_import']['loader_name'];
|
|
|
+ }
|
|
|
+
|
|
|
// if we are re constructing the form from a failed validation or ajax callback
|
|
|
// then use the $form_state['values'] values
|
|
|
if (array_key_exists('values', $form_state)) {
|
|
@@ -193,45 +251,47 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
|
|
|
$days = $form_state['input']['days'];
|
|
|
$disabled = $form_state['input']['disabled'];
|
|
|
$do_contact = $form_state['input']['do_contact'];
|
|
|
- $num_criteria = $form_state['input']['num_criteria'];
|
|
|
$loader_name = $form_state['input']['loader_name'];
|
|
|
+
|
|
|
+ // because the num_criteria is a value and not a visible or hidden form
|
|
|
+ // element it is not part of the ['input'] array, so we need to get it from the form
|
|
|
+ $num_criteria = $form_state['complete form']['num_criteria']['#value'];
|
|
|
}
|
|
|
|
|
|
- // check if the pub_import_id in the session variable is not the same as the one we've been provided
|
|
|
- // if so, then clear the session variable
|
|
|
-// if ($pub_import_id and $pub_import_id != $_SESSION['tripal_pub_import']['pub_import_id']) {
|
|
|
-// unset($_SESSION['tripal_pub_import']);
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
- // change the number of criteria based on form_state post data.
|
|
|
- if (!$num_criteria) {
|
|
|
- $num_criteria = 1;
|
|
|
- }
|
|
|
-/*
|
|
|
- if($form_state['post']["add-$num_criteria"]) {
|
|
|
+ if (array_key_exists('triggering_element', $form_state) and
|
|
|
+ $form_state['triggering_element']['#name'] == 'add') {
|
|
|
$num_criteria++;
|
|
|
}
|
|
|
- if($form_state['post']["remove-$num_criteria"]) {
|
|
|
+ if (array_key_exists('triggering_element', $form_state) and
|
|
|
+ $form_state['triggering_element']['#name'] == 'remove') {
|
|
|
$num_criteria--;
|
|
|
}
|
|
|
-*/
|
|
|
|
|
|
+ // check if the pub_import_id in the session variable is not the same as the one we've been provided
|
|
|
+ // if so, then clear the session variable
|
|
|
+ if ($pub_import_id and $pub_import_id != $_SESSION['tripal_pub_import']['pub_import_id']) {
|
|
|
+ unset($_SESSION['tripal_pub_import']);
|
|
|
+ }
|
|
|
+
|
|
|
+ // set the values we need for later but that should not be shown on the form
|
|
|
+ $form['num_criteria']= array(
|
|
|
+ '#type' => 'value',
|
|
|
+ '#value' => $num_criteria,
|
|
|
+ );
|
|
|
$form['pub_import_id'] = array(
|
|
|
- '#type' => 'hidden',
|
|
|
- '#value' => $pub_import_id,
|
|
|
- '#required' => TRUE,
|
|
|
+ '#type' => 'value',
|
|
|
+ '#value' => $pub_import_id,
|
|
|
);
|
|
|
$form['action'] = array(
|
|
|
- '#type' => 'hidden',
|
|
|
- '#value' => $action,
|
|
|
- '#required' => TRUE,
|
|
|
+ '#type' => 'value',
|
|
|
+ '#value' => $action,
|
|
|
);
|
|
|
|
|
|
+ // add in the elements that will be organized via a theme function
|
|
|
$form['themed_element']['loader_name'] = array(
|
|
|
'#type' => 'textfield',
|
|
|
'#title' => t('Loader Name'),
|
|
|
- '#description' => t('Please provide a name for this loader setup..'),
|
|
|
+ '#description' => t('Please provide a name for this loader setup.'),
|
|
|
'#default_value' => $loader_name,
|
|
|
'#required' => TRUE,
|
|
|
);
|
|
@@ -261,16 +321,6 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
|
|
|
'method' => 'replace',
|
|
|
),
|
|
|
);
|
|
|
-
|
|
|
- $form['num_criteria']= array(
|
|
|
- '#type' => 'hidden',
|
|
|
- '#default_value' => $num_criteria,
|
|
|
- );
|
|
|
- $form['pub_import_id']= array(
|
|
|
- '#type' => 'hidden',
|
|
|
- '#default_value' => $pub_import_id,
|
|
|
- );
|
|
|
-
|
|
|
$form['themed_element']['days'] = array(
|
|
|
'#type' => 'textfield',
|
|
|
'#title' => t('Days since record modified'),
|
|
@@ -295,28 +345,29 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
|
|
|
// add in the form for the criteria
|
|
|
tripal_pub_importer_setup_add_criteria_fields($form, $form_state, $num_criteria, $criteria);
|
|
|
|
|
|
- $form['test'] = array(
|
|
|
- '#type' => 'submit',
|
|
|
- '#value' => t('Test Importer'),
|
|
|
- );
|
|
|
+ // add in the buttons
|
|
|
$form['save'] = array(
|
|
|
'#type' => 'submit',
|
|
|
'#value' => t('Save Importer'),
|
|
|
);
|
|
|
- /*
|
|
|
- $form['import'] = array(
|
|
|
+ $form['test'] = array(
|
|
|
'#type' => 'submit',
|
|
|
- '#value' => t('Save & Import Now'),
|
|
|
+ '#value' => t('Test Importer'),
|
|
|
);
|
|
|
- */
|
|
|
$form['delete'] = array(
|
|
|
'#type' => 'submit',
|
|
|
'#value' => t('Delete Importer'),
|
|
|
+ '#attributes' => array('style' => 'float: right;')
|
|
|
+ );
|
|
|
+
|
|
|
+ // add in the section where the test results will appear
|
|
|
+ $form['results'] = array(
|
|
|
+ '#markup' => '<div id="tripal-pub-importer-test-section"></div>',
|
|
|
);
|
|
|
|
|
|
// allow the selected remote database to make changes to the form if needed
|
|
|
$callback = "tripal_pub_remote_alter_form_$remote_db";
|
|
|
- $form = call_user_func($callback, $form, $form_state);
|
|
|
+ $form = call_user_func($callback, $form, $form_state, $num_criteria);
|
|
|
|
|
|
$form['themed_element']['#theme'] = 'tripal_pub_importer_setup_form_elements';
|
|
|
|
|
@@ -367,15 +418,15 @@ function tripal_pub_importer_setup_add_criteria_fields(&$form, &$form_state, $nu
|
|
|
$is_phrase = $criteria['criteria'][$i]['is_phrase'];
|
|
|
$operation = $criteria['criteria'][$i]['operation'];
|
|
|
}
|
|
|
+
|
|
|
+ // if the criteria comes the session
|
|
|
+ if (array_key_exists('tripal_pub_import', $_SESSION)) {
|
|
|
+ $search_terms = isset($_SESSION['tripal_pub_import']['criteria'][$i]['search_terms']) ? $_SESSION['tripal_pub_import']['criteria'][$i]['search_terms'] : $search_terms;
|
|
|
+ $scope = isset($_SESSION['tripal_pub_import']['criteria'][$i]['scope']) ? $_SESSION['tripal_pub_import']['criteria'][$i]['scope'] : $scope;
|
|
|
+ $is_phrase = isset($_SESSION['tripal_pub_import']['criteria'][$i]['is_phrase']) ? $_SESSION['tripal_pub_import']['criteria'][$i]['is_phrase'] : $is_phrase;
|
|
|
+ $operation = isset($_SESSION['tripal_pub_import']['criteria'][$i]['operation']) ? $_SESSION['tripal_pub_import']['criteria'][$i]['operation'] : $operation;
|
|
|
+ }
|
|
|
|
|
|
-/*
|
|
|
- // if we're here because the form was posted then load from the session variable (we lost the form state)
|
|
|
- $search_terms = isset($_SESSION['tripal_pub_import']['criteria'][$i]['search_terms']) ? $_SESSION['tripal_pub_import']['criteria'][$i]['search_terms'] : $search_terms;
|
|
|
- $scope = isset($_SESSION['tripal_pub_import']['criteria'][$i]['scope']) ? $_SESSION['tripal_pub_import']['criteria'][$i]['scope'] : $scope;
|
|
|
- $is_phrase = isset($_SESSION['tripal_pub_import']['criteria'][$i]['is_phrase']) ? $_SESSION['tripal_pub_import']['criteria'][$i]['is_phrase'] : $is_phrase;
|
|
|
- $operation = isset($_SESSION['tripal_pub_import']['criteria'][$i]['operation']) ? $_SESSION['tripal_pub_import']['criteria'][$i]['operation'] : $operation;
|
|
|
-*/
|
|
|
-
|
|
|
// If the form_state has variables then use those. This happens when an error occurs on the form or the
|
|
|
// form is resbumitted using AJAX
|
|
|
if (array_key_exists('values', $form_state)) {
|
|
@@ -394,7 +445,7 @@ function tripal_pub_importer_setup_add_criteria_fields(&$form, &$form_state, $nu
|
|
|
'#type' => 'textfield',
|
|
|
'#description' => t('<span style="white-space: normal">Please provide a list of words for searching. You may use
|
|
|
conjunctions such as "AND" or "OR" to separate words if they are expected in
|
|
|
- the same scope, but do not mix ANDs and ORs. Uncheck the "Is Phrase" checkbox to use conjunctions</span>'),
|
|
|
+ the same scope, but do not mix ANDs and ORs. Check the "Is Phrase" checkbox to use conjunctions as part of the text to search</span>'),
|
|
|
'#default_value' => $search_terms,
|
|
|
'#required' => TRUE,
|
|
|
'#maxlength' => 2048,
|
|
@@ -440,8 +491,8 @@ function tripal_pub_importer_setup_add_criteria_fields(&$form, &$form_state, $nu
|
|
|
// but we need it or Drupal will run the default validate anyway.
|
|
|
// we also set #limit_validation_errors to empty so fields that
|
|
|
// are required that don't have values won't generate warnings.
|
|
|
- '#submit' => array('tripal_pub_setup_form_criteria_button_submit'),
|
|
|
- '#validate' => array('tripal_pub_setup_form_criteria_button_validate'),
|
|
|
+ '#submit' => array('tripal_pub_setup_form_ajax_button_submit'),
|
|
|
+ '#validate' => array('tripal_pub_setup_form_ajax_button_validate'),
|
|
|
'#limit_validation_errors' => array(),
|
|
|
);
|
|
|
}
|
|
@@ -463,8 +514,8 @@ function tripal_pub_importer_setup_add_criteria_fields(&$form, &$form_state, $nu
|
|
|
// but we need it or Drupal will run the default validate anyway.
|
|
|
// we also set #limit_validation_errors to empty so fields that
|
|
|
// are required that don't have values won't generate warnings.
|
|
|
- '#submit' => array('tripal_pub_setup_form_criteria_button_submit'),
|
|
|
- '#validate' => array('tripal_pub_setup_form_criteria_button_validate'),
|
|
|
+ '#submit' => array('tripal_pub_setup_form_ajax_button_submit'),
|
|
|
+ '#validate' => array('tripal_pub_setup_form_ajax_button_validate'),
|
|
|
'#limit_validation_errors' => array(),
|
|
|
);
|
|
|
}
|
|
@@ -476,13 +527,13 @@ function tripal_pub_importer_setup_add_criteria_fields(&$form, &$form_state, $nu
|
|
|
* the validate and submit routines on the form button. Therefore, this function
|
|
|
* only needs to tell Drupal to rebuild the form
|
|
|
*/
|
|
|
-function tripal_pub_setup_form_criteria_button_validate($form, &$form_state){
|
|
|
+function tripal_pub_setup_form_ajax_button_validate($form, &$form_state){
|
|
|
$form_state['rebuild'] = TRUE;
|
|
|
}
|
|
|
/**
|
|
|
* This function is just a dummy to override the default form submit on ajax calls for buttons
|
|
|
*/
|
|
|
-function tripal_pub_setup_form_criteria_button_submit($form, &$form_state){
|
|
|
+function tripal_pub_setup_form_ajax_button_submit($form, &$form_state){
|
|
|
// do nothing
|
|
|
}
|
|
|
/**
|
|
@@ -500,7 +551,10 @@ function tripal_pub_importer_setup_form_validate($form, &$form_state) {
|
|
|
$search_terms = trim($form_state['values']["search_terms-$i"]);
|
|
|
$scope = $form_state['values']["scope-$i"];
|
|
|
$is_phrase = $form_state['values']["is_phrase-$i"];
|
|
|
- $operation = $form_state['values']["operation-$i"];
|
|
|
+ $operation = '';
|
|
|
+ if($i > 1) {
|
|
|
+ $operation = $form_state['values']["operation-$i"];
|
|
|
+ }
|
|
|
|
|
|
if (!$is_phrase) {
|
|
|
if (preg_match('/and/i', $search_terms) and preg_match('/or/i', $search_terms)) {
|
|
@@ -545,7 +599,10 @@ function tripal_pub_importer_setup_form_submit($form, &$form_state) {
|
|
|
$search_terms = trim($form_state['values']["search_terms-$i"]);
|
|
|
$scope = $form_state['values']["scope-$i"];
|
|
|
$is_phrase = $form_state['values']["is_phrase-$i"];
|
|
|
- $operation = $form_state['values']["operation-$i"];
|
|
|
+ $operation = '';
|
|
|
+ if ($i > 1) {
|
|
|
+ $operation = $form_state['values']["operation-$i"];
|
|
|
+ }
|
|
|
|
|
|
$_SESSION['tripal_pub_import']['criteria'][$i] = array(
|
|
|
'search_terms' => $search_terms,
|
|
@@ -629,10 +686,12 @@ function theme_tripal_pub_importer_setup_form_elements($variables) {
|
|
|
|
|
|
// first render the fields at the top of the form
|
|
|
$markup = '';
|
|
|
- $markup .= '<div>' . drupal_render($form['remote_db']) . '</div>';
|
|
|
- $markup .= '<div id="pub-search-form-row1">';
|
|
|
- $markup .= ' <div id="pub-search-form-col1">' . drupal_render($form['loader_name']) . '</div>';
|
|
|
- $markup .= ' <div id="pub-search-form-col3">' . drupal_render($form['days']) . '</div>';
|
|
|
+ $markup .= '<div id="pub-search-form-row0">';
|
|
|
+ $markup .= ' <div id="pub-search-form-row0-col1" style="float: left">' . drupal_render($form['remote_db']) . '</div>';
|
|
|
+ $markup .= ' <div id="pub-search-form-row0-col2" style="float: left; margin-left: 10px">' . drupal_render($form['loader_name']) . '</div>';
|
|
|
+ $markup .= '</div>';
|
|
|
+ $markup .= '<div id="pub-search-form-row1" style="clear:both">';
|
|
|
+ $markup .= ' <div id="pub-search-form-row1-col1">' . drupal_render($form['days']) . '</div>';
|
|
|
$markup .= '</div>';
|
|
|
$markup .= '<div id="pub-search-form-row2">' . drupal_render($form['disabled']) . '</div>';
|
|
|
$markup .= '<div id="pub-search-form-row3">' . drupal_render($form['do_contact']) . '</div>';
|