|
@@ -1,4 +1,9 @@
|
|
<?php
|
|
<?php
|
|
|
|
+/**
|
|
|
|
+ * @file
|
|
|
|
+ * Management of importers
|
|
|
|
+ */
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* A function to generate a table containing the list of publication importers
|
|
* A function to generate a table containing the list of publication importers
|
|
*
|
|
*
|
|
@@ -7,7 +12,7 @@
|
|
function tripal_pub_importers_list() {
|
|
function tripal_pub_importers_list() {
|
|
// clear out the session variable when we view the list.
|
|
// clear out the session variable when we view the list.
|
|
unset($_SESSION['tripal_pub_import']);
|
|
unset($_SESSION['tripal_pub_import']);
|
|
-
|
|
|
|
|
|
+
|
|
$header = array('', 'Importer Name', 'Database', 'Search String', 'Disabled', 'Create Contact', '');
|
|
$header = array('', 'Importer Name', 'Database', 'Search String', 'Disabled', 'Create Contact', '');
|
|
$rows = array();
|
|
$rows = array();
|
|
$importers = db_query("SELECT * FROM {tripal_pub_import} ORDER BY name");
|
|
$importers = db_query("SELECT * FROM {tripal_pub_import} ORDER BY name");
|
|
@@ -43,37 +48,38 @@ function tripal_pub_importers_list() {
|
|
$page = "<ul class='action-links'>";
|
|
$page = "<ul class='action-links'>";
|
|
$page .= ' <li>' . l('New Importer', 'admin/tripal/chado/tripal_pub/import/new') . '</li>';
|
|
$page .= ' <li>' . l('New Importer', 'admin/tripal/chado/tripal_pub/import/new') . '</li>';
|
|
$page .= '</ul>';
|
|
$page .= '</ul>';
|
|
-
|
|
|
|
|
|
+
|
|
$page .= '<p>' . t(
|
|
$page .= '<p>' . t(
|
|
"A publication importer is used to create a set of search criteria that can be used
|
|
"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
|
|
|
|
|
|
+ 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
|
|
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
|
|
be to peridocially add new publications to this Tripal site that have appeared in PubMed
|
|
in the last 30 days. You can import publications in one of two ways:
|
|
in the last 30 days. You can import publications in one of two ways:
|
|
<ol>
|
|
<ol>
|
|
<li>Create a new importer by clicking the 'New Importer' link above, and after saving it should appear in the list below. Click the
|
|
<li>Create a new importer by clicking the 'New Importer' link above, and after saving it should appear in the list below. Click the
|
|
link labeled 'Import Pubs' to schedule a job to import the publications</li>
|
|
link labeled 'Import Pubs' to schedule a job to import the publications</li>
|
|
- <li>The first method only performs the import once. However, you can schedule the
|
|
|
|
- importer to run peridically by adding a cron job. See the " .
|
|
|
|
- l("Pub Module help instructions", "admin/tripal/chado/tripal_pub/help") . " to learn how to
|
|
|
|
|
|
+ <li>The first method only performs the import once. However, you can schedule the
|
|
|
|
+ importer to run peridically by adding a cron job. See the " .
|
|
|
|
+ l("Pub Module help instructions", "admin/tripal/chado/tripal_pub/help") . " to learn how to
|
|
set the importers to run automatically.") . '</li>
|
|
set the importers to run automatically.") . '</li>
|
|
</ol><br>';
|
|
</ol><br>';
|
|
|
|
|
|
$page .= theme('table', array('header' => $header, 'rows' => $rows));
|
|
$page .= theme('table', array('header' => $header, 'rows' => $rows));
|
|
-
|
|
|
|
|
|
+
|
|
return $page;
|
|
return $page;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- *
|
|
|
|
- * @param action
|
|
|
|
|
|
+ * @stephen
|
|
|
|
+ *
|
|
|
|
+ * @param $action
|
|
* @param $pub_import_id
|
|
* @param $pub_import_id
|
|
- *
|
|
|
|
- *
|
|
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_pub
|
|
*/
|
|
*/
|
|
function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL) {
|
|
function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL) {
|
|
global $base_path;
|
|
global $base_path;
|
|
-
|
|
|
|
|
|
+
|
|
// make sure the tripal_pub and tripal_contact ontologies are loaded
|
|
// make sure the tripal_pub and tripal_contact ontologies are loaded
|
|
$values = array('name' => 'tripal_pub');
|
|
$values = array('name' => 'tripal_pub');
|
|
$tpub_cv = chado_select_record('cv', array('cv_id'), $values);
|
|
$tpub_cv = chado_select_record('cv', array('cv_id'), $values);
|
|
@@ -85,7 +91,7 @@ function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL)
|
|
if (count($tpub_cv) == 0) {
|
|
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');
|
|
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')){
|
|
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');
|
|
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');
|
|
}
|
|
}
|
|
@@ -101,7 +107,7 @@ function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL)
|
|
$remote_db = $_SESSION['tripal_pub_import']['remote_db'];
|
|
$remote_db = $_SESSION['tripal_pub_import']['remote_db'];
|
|
$num_criteria = $_SESSION['tripal_pub_import']['num_criteria'];
|
|
$num_criteria = $_SESSION['tripal_pub_import']['num_criteria'];
|
|
$days = $_SESSION['tripal_pub_import']['days'];
|
|
$days = $_SESSION['tripal_pub_import']['days'];
|
|
-
|
|
|
|
|
|
+
|
|
$search_array = array();
|
|
$search_array = array();
|
|
$search_array['remote_db'] = $remote_db;
|
|
$search_array['remote_db'] = $remote_db;
|
|
$search_array['num_criteria'] = $num_criteria;
|
|
$search_array['num_criteria'] = $num_criteria;
|
|
@@ -112,19 +118,19 @@ function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL)
|
|
$search_array['criteria'][$i]['is_phrase'] = $_SESSION['tripal_pub_import']['criteria'][$i]['is_phrase'];
|
|
$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'];
|
|
$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 the form has been submitted with the 'test' button then get the results
|
|
if ($_SESSION['tripal_pub_import']['perform_search']) {
|
|
if ($_SESSION['tripal_pub_import']['perform_search']) {
|
|
-
|
|
|
|
|
|
+
|
|
$limit = 25;
|
|
$limit = 25;
|
|
-
|
|
|
|
|
|
+
|
|
// get the list of publications from the remote database using the search criteria.
|
|
// get the list of publications from the remote database using the search criteria.
|
|
$page = isset($_GET['page']) ? $_GET['page'] : '0';
|
|
$page = isset($_GET['page']) ? $_GET['page'] : '0';
|
|
$results = tripal_pub_get_remote_search_results($remote_db, $search_array, $limit, $page);
|
|
$results = tripal_pub_get_remote_search_results($remote_db, $search_array, $limit, $page);
|
|
$total_records = $results['total_records'];
|
|
$total_records = $results['total_records'];
|
|
$search_str = $results['search_str'];
|
|
$search_str = $results['search_str'];
|
|
$pubs = $results['pubs'];
|
|
$pubs = $results['pubs'];
|
|
-
|
|
|
|
|
|
+
|
|
// iterate through the results and construct the table displaying the publications
|
|
// iterate through the results and construct the table displaying the publications
|
|
$rows = array();
|
|
$rows = array();
|
|
$i = $page * $limit + 1;
|
|
$i = $page * $limit + 1;
|
|
@@ -143,7 +149,7 @@ function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL)
|
|
$i++;
|
|
$i++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (count($rows) == 0) {
|
|
if (count($rows) == 0) {
|
|
$rows[] = array(
|
|
$rows[] = array(
|
|
array(
|
|
array(
|
|
@@ -152,7 +158,7 @@ function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL)
|
|
),
|
|
),
|
|
);
|
|
);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
$headers = array('', 'Publication', 'Raw Results');
|
|
$headers = array('', 'Publication', 'Raw Results');
|
|
$table = array(
|
|
$table = array(
|
|
'header' => $headers,
|
|
'header' => $headers,
|
|
@@ -168,7 +174,7 @@ function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL)
|
|
// once we have our table array structure defined, we call Drupal's theme_table()
|
|
// once we have our table array structure defined, we call Drupal's theme_table()
|
|
// function to generate the table.
|
|
// function to generate the table.
|
|
$table = theme_table($table);
|
|
$table = theme_table($table);
|
|
-
|
|
|
|
|
|
+
|
|
// generate the pager
|
|
// generate the pager
|
|
pager_default_initialize($total_records, $limit);
|
|
pager_default_initialize($total_records, $limit);
|
|
$pager = array(
|
|
$pager = array(
|
|
@@ -178,11 +184,11 @@ function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL)
|
|
'quantity' => $limit,
|
|
'quantity' => $limit,
|
|
);
|
|
);
|
|
$pager = theme_pager($pager);
|
|
$pager = theme_pager($pager);
|
|
-
|
|
|
|
|
|
+
|
|
// because this is an ajax callback, the theme_pager will set the URL to be
|
|
// because this is an ajax callback, the theme_pager will set the URL to be
|
|
// "system/ajax", so we need to reset that
|
|
// "system/ajax", so we need to reset that
|
|
$pager = str_replace($base_path . "system/ajax", "", $pager) ;
|
|
$pager = str_replace($base_path . "system/ajax", "", $pager) ;
|
|
-
|
|
|
|
|
|
+
|
|
// join all to form the results
|
|
// join all to form the results
|
|
$total_pages = (int) ($total_records / $limit) + 1;
|
|
$total_pages = (int) ($total_records / $limit) + 1;
|
|
$page = isset($_GET['page']) ? $_GET['page'] : '0';
|
|
$page = isset($_GET['page']) ? $_GET['page'] : '0';
|
|
@@ -194,7 +200,14 @@ function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL)
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Purpose: Provides the form to search pubmed
|
|
|
|
|
|
+ * Provides the form to search pubmed
|
|
|
|
+ *
|
|
|
|
+ * @stephen
|
|
|
|
+ *
|
|
|
|
+ * @param $form
|
|
|
|
+ * @param $form_state
|
|
|
|
+ * @param $pub_import_id
|
|
|
|
+ * @param $action
|
|
*
|
|
*
|
|
* @ingroup tripal_pub
|
|
* @ingroup tripal_pub
|
|
*/
|
|
*/
|
|
@@ -202,14 +215,14 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
|
|
|
|
|
|
// Default values can come in the following ways:
|
|
// Default values can come in the following ways:
|
|
//
|
|
//
|
|
- // 1) as elements of the $pub_importer object. This occurs when editing an existing importer
|
|
|
|
|
|
+ // 1) as elements of the $pub_importer object. This occurs when editing an existing importer
|
|
// 2) in the $form_state['values'] array which occurs on a failed validation or
|
|
// 2) in the $form_state['values'] array which occurs on a failed validation or
|
|
// ajax callbacks from non submit form elements
|
|
// ajax callbacks from non submit form elements
|
|
// 3) in the $form_state['input'] array which occurs on ajax callbacks from submit
|
|
// 3) in the $form_state['input'] array which occurs on ajax callbacks from submit
|
|
// form elements and the form is being rebuilt
|
|
// form elements and the form is being rebuilt
|
|
//
|
|
//
|
|
// set form field defaults
|
|
// set form field defaults
|
|
-
|
|
|
|
|
|
+
|
|
// Set the default values. If the pub_import_id isn't already defined by the form values
|
|
// 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
|
|
// and one is provided then look it up in the database
|
|
$criteria = NULL;
|
|
$criteria = NULL;
|
|
@@ -219,7 +232,7 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
|
|
$do_contact = '';
|
|
$do_contact = '';
|
|
$num_criteria = 1;
|
|
$num_criteria = 1;
|
|
$loader_name = '';
|
|
$loader_name = '';
|
|
-
|
|
|
|
|
|
+
|
|
// if this is an edit the we are pulling an import object from the database
|
|
// if this is an edit the we are pulling an import object from the database
|
|
if ($action == "edit") {
|
|
if ($action == "edit") {
|
|
$sql = "SELECT * FROM {tripal_pub_import} WHERE pub_import_id = :pub_import_id";
|
|
$sql = "SELECT * FROM {tripal_pub_import} WHERE pub_import_id = :pub_import_id";
|
|
@@ -233,7 +246,7 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
|
|
$num_criteria = $criteria['num_criteria'];
|
|
$num_criteria = $criteria['num_criteria'];
|
|
$loader_name = $criteria['loader_name'];
|
|
$loader_name = $criteria['loader_name'];
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// if there are any session variables then use those
|
|
// if there are any session variables then use those
|
|
if (array_key_exists('tripal_pub_import', $_SESSION)) {
|
|
if (array_key_exists('tripal_pub_import', $_SESSION)) {
|
|
$remote_db = $_SESSION['tripal_pub_import']['remote_db'];
|
|
$remote_db = $_SESSION['tripal_pub_import']['remote_db'];
|
|
@@ -242,14 +255,14 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
|
|
$do_contact = $_SESSION['tripal_pub_import']['do_contact'];
|
|
$do_contact = $_SESSION['tripal_pub_import']['do_contact'];
|
|
$num_criteria = $_SESSION['tripal_pub_import']['num_criteria'];
|
|
$num_criteria = $_SESSION['tripal_pub_import']['num_criteria'];
|
|
$loader_name = $_SESSION['tripal_pub_import']['loader_name'];
|
|
$loader_name = $_SESSION['tripal_pub_import']['loader_name'];
|
|
-
|
|
|
|
|
|
+
|
|
// check if the pub_import_id in the session variable is not the same as the one we've been provided
|
|
// 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 so, then clear the session variable
|
|
if ($pub_import_id and $pub_import_id != $_SESSION['tripal_pub_import']['pub_import_id']) {
|
|
if ($pub_import_id and $pub_import_id != $_SESSION['tripal_pub_import']['pub_import_id']) {
|
|
unset($_SESSION['tripal_pub_import']);
|
|
unset($_SESSION['tripal_pub_import']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// if we are re constructing the form from a failed validation or ajax callback
|
|
// if we are re constructing the form from a failed validation or ajax callback
|
|
// then use the $form_state['values'] values
|
|
// then use the $form_state['values'] values
|
|
if (array_key_exists('values', $form_state)) {
|
|
if (array_key_exists('values', $form_state)) {
|
|
@@ -268,7 +281,7 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
|
|
$disabled = $form_state['input']['disabled'];
|
|
$disabled = $form_state['input']['disabled'];
|
|
$do_contact = $form_state['input']['do_contact'];
|
|
$do_contact = $form_state['input']['do_contact'];
|
|
$loader_name = $form_state['input']['loader_name'];
|
|
$loader_name = $form_state['input']['loader_name'];
|
|
-
|
|
|
|
|
|
+
|
|
// because the num_criteria is a value and not a visible or hidden form
|
|
// 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
|
|
// 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'];
|
|
$num_criteria = $form_state['complete form']['num_criteria']['#value'];
|
|
@@ -282,9 +295,9 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
|
|
$form_state['triggering_element']['#name'] == 'remove') {
|
|
$form_state['triggering_element']['#name'] == 'remove') {
|
|
$num_criteria--;
|
|
$num_criteria--;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
// set the values we need for later but that should not be shown on the form
|
|
// set the values we need for later but that should not be shown on the form
|
|
$form['num_criteria']= array(
|
|
$form['num_criteria']= array(
|
|
'#type' => 'value',
|
|
'#type' => 'value',
|
|
@@ -353,7 +366,7 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
|
|
additional information such as affilation, etc. Otherwise, only authors names are retrieved.'),
|
|
additional information such as affilation, etc. Otherwise, only authors names are retrieved.'),
|
|
'#default_value' => $do_contact,
|
|
'#default_value' => $do_contact,
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
// add in the form for the criteria
|
|
// add in the form for the criteria
|
|
tripal_pub_importer_setup_add_criteria_fields($form, $form_state, $num_criteria, $criteria);
|
|
tripal_pub_importer_setup_add_criteria_fields($form, $form_state, $num_criteria, $criteria);
|
|
|
|
|
|
@@ -371,30 +384,33 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
|
|
'#value' => t('Delete Importer'),
|
|
'#value' => t('Delete Importer'),
|
|
'#attributes' => array('style' => 'float: right;')
|
|
'#attributes' => array('style' => 'float: right;')
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
// add in the section where the test results will appear
|
|
// add in the section where the test results will appear
|
|
$form['results'] = array(
|
|
$form['results'] = array(
|
|
'#markup' => '<div id="tripal-pub-importer-test-section"></div>',
|
|
'#markup' => '<div id="tripal-pub-importer-test-section"></div>',
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
// allow the selected remote database to make changes to the form if needed
|
|
// allow the selected remote database to make changes to the form if needed
|
|
$callback = "tripal_pub_remote_alter_form_$remote_db";
|
|
$callback = "tripal_pub_remote_alter_form_$remote_db";
|
|
$form = call_user_func($callback, $form, $form_state, $num_criteria);
|
|
$form = call_user_func($callback, $form, $form_state, $num_criteria);
|
|
-
|
|
|
|
|
|
+
|
|
$form['themed_element']['#theme'] = 'tripal_pub_importer_setup_form_elements';
|
|
$form['themed_element']['#theme'] = 'tripal_pub_importer_setup_form_elements';
|
|
-
|
|
|
|
|
|
+
|
|
return $form;
|
|
return $form;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- *
|
|
|
|
|
|
+ * @stephen
|
|
|
|
+ *
|
|
* @param $form
|
|
* @param $form
|
|
* @param $form_state
|
|
* @param $form_state
|
|
* @param $num_criteria
|
|
* @param $num_criteria
|
|
* @param $criteria
|
|
* @param $criteria
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_pub
|
|
*/
|
|
*/
|
|
function tripal_pub_importer_setup_add_criteria_fields(&$form, &$form_state, $num_criteria, $criteria){
|
|
function tripal_pub_importer_setup_add_criteria_fields(&$form, &$form_state, $num_criteria, $criteria){
|
|
-
|
|
|
|
|
|
+
|
|
// choices array
|
|
// choices array
|
|
$scope_choices = array(
|
|
$scope_choices = array(
|
|
'any' => 'Any Field',
|
|
'any' => 'Any Field',
|
|
@@ -404,7 +420,7 @@ function tripal_pub_importer_setup_add_criteria_fields(&$form, &$form_state, $nu
|
|
'title' => 'Title',
|
|
'title' => 'Title',
|
|
'journal' => 'Journal Name'
|
|
'journal' => 'Journal Name'
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
$first_op_choices = array(
|
|
$first_op_choices = array(
|
|
'' => '',
|
|
'' => '',
|
|
'NOT' => 'NOT'
|
|
'NOT' => 'NOT'
|
|
@@ -414,15 +430,15 @@ function tripal_pub_importer_setup_add_criteria_fields(&$form, &$form_state, $nu
|
|
'OR' => 'OR',
|
|
'OR' => 'OR',
|
|
'NOT' => 'NOT'
|
|
'NOT' => 'NOT'
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
for($i = 1; $i <= $num_criteria; $i++) {
|
|
for($i = 1; $i <= $num_criteria; $i++) {
|
|
$is_phrase = 1;
|
|
$is_phrase = 1;
|
|
-
|
|
|
|
|
|
+
|
|
$search_terms = '';
|
|
$search_terms = '';
|
|
$scope = '';
|
|
$scope = '';
|
|
$is_phrase = '';
|
|
$is_phrase = '';
|
|
$operation = '';
|
|
$operation = '';
|
|
-
|
|
|
|
|
|
+
|
|
// if we have criteria supplied from the database then use that as the initial defaults
|
|
// if we have criteria supplied from the database then use that as the initial defaults
|
|
if ($criteria) {
|
|
if ($criteria) {
|
|
$search_terms = $criteria['criteria'][$i]['search_terms'];
|
|
$search_terms = $criteria['criteria'][$i]['search_terms'];
|
|
@@ -438,7 +454,7 @@ function tripal_pub_importer_setup_add_criteria_fields(&$form, &$form_state, $nu
|
|
$is_phrase = isset($_SESSION['tripal_pub_import']['criteria'][$i]['is_phrase']) ? $_SESSION['tripal_pub_import']['criteria'][$i]['is_phrase'] : $is_phrase;
|
|
$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;
|
|
$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
|
|
// 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
|
|
// form is resbumitted using AJAX
|
|
if (array_key_exists('values', $form_state)) {
|
|
if (array_key_exists('values', $form_state)) {
|
|
@@ -467,7 +483,7 @@ function tripal_pub_importer_setup_add_criteria_fields(&$form, &$form_state, $nu
|
|
'#title' => t('Is Phrase?'),
|
|
'#title' => t('Is Phrase?'),
|
|
'#default_value' => $is_phrase,
|
|
'#default_value' => $is_phrase,
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
if ($i == 1) {
|
|
if ($i == 1) {
|
|
/*
|
|
/*
|
|
$form['criteria'][$i]["operation-$i"] = array(
|
|
$form['criteria'][$i]["operation-$i"] = array(
|
|
@@ -533,23 +549,32 @@ function tripal_pub_importer_setup_add_criteria_fields(&$form, &$form_state, $nu
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* This function is used to rebuild the form if an ajax call is made vai a button.
|
|
* This function is used to rebuild the form if an ajax call is made vai a button.
|
|
* The button causes the form to be submitted. We don't want this so we override
|
|
* The button causes the form to be submitted. We don't want this so we override
|
|
* the validate and submit routines on the form button. Therefore, this function
|
|
* the validate and submit routines on the form button. Therefore, this function
|
|
* only needs to tell Drupal to rebuild the form
|
|
* only needs to tell Drupal to rebuild the form
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_pub
|
|
*/
|
|
*/
|
|
function tripal_pub_setup_form_ajax_button_validate($form, &$form_state){
|
|
function tripal_pub_setup_form_ajax_button_validate($form, &$form_state){
|
|
$form_state['rebuild'] = TRUE;
|
|
$form_state['rebuild'] = TRUE;
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* This function is just a dummy to override the default form submit on ajax calls for buttons
|
|
* This function is just a dummy to override the default form submit on ajax calls for buttons
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_pub
|
|
*/
|
|
*/
|
|
function tripal_pub_setup_form_ajax_button_submit($form, &$form_state){
|
|
function tripal_pub_setup_form_ajax_button_submit($form, &$form_state){
|
|
// do nothing
|
|
// do nothing
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
|
|
+ * Validate the tripal_pub_importer_setup_form form
|
|
*
|
|
*
|
|
|
|
+ * @ingroup tripal_pub
|
|
*/
|
|
*/
|
|
function tripal_pub_importer_setup_form_validate($form, &$form_state) {
|
|
function tripal_pub_importer_setup_form_validate($form, &$form_state) {
|
|
$num_criteria = $form_state['values']['num_criteria'];
|
|
$num_criteria = $form_state['values']['num_criteria'];
|
|
@@ -564,7 +589,7 @@ function tripal_pub_importer_setup_form_validate($form, &$form_state) {
|
|
$scope = $form_state['values']["scope-$i"];
|
|
$scope = $form_state['values']["scope-$i"];
|
|
$is_phrase = $form_state['values']["is_phrase-$i"];
|
|
$is_phrase = $form_state['values']["is_phrase-$i"];
|
|
$operation = '';
|
|
$operation = '';
|
|
- if($i > 1) {
|
|
|
|
|
|
+ if($i > 1) {
|
|
$operation = $form_state['values']["operation-$i"];
|
|
$operation = $form_state['values']["operation-$i"];
|
|
}
|
|
}
|
|
|
|
|
|
@@ -586,7 +611,9 @@ function tripal_pub_importer_setup_form_validate($form, &$form_state) {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * Submit the tripal_pub_importer_setup_form form
|
|
*
|
|
*
|
|
|
|
+ * @ingroup tripal_pub
|
|
*/
|
|
*/
|
|
function tripal_pub_importer_setup_form_submit($form, &$form_state) {
|
|
function tripal_pub_importer_setup_form_submit($form, &$form_state) {
|
|
|
|
|
|
@@ -681,18 +708,21 @@ function tripal_pub_importer_setup_form_submit($form, &$form_state) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * AJAX callback for updating the form.
|
|
|
|
|
|
+ * AJAX callback for updating the form.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_pub
|
|
*/
|
|
*/
|
|
function tripal_pubs_setup_form_ajax_update($form, $form_state) {
|
|
function tripal_pubs_setup_form_ajax_update($form, $form_state) {
|
|
return $form['themed_element'];
|
|
return $form['themed_element'];
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- *
|
|
|
|
- * @param $form
|
|
|
|
|
|
+ * Theme the tripal_pub_importer_setup_form form.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_pub
|
|
*/
|
|
*/
|
|
-
|
|
|
|
function theme_tripal_pub_importer_setup_form_elements($variables) {
|
|
function theme_tripal_pub_importer_setup_form_elements($variables) {
|
|
$form = $variables['form'];
|
|
$form = $variables['form'];
|
|
|
|
|
|
@@ -721,7 +751,7 @@ function theme_tripal_pub_importer_setup_form_elements($variables) {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
$headers = array('Operation','Scope', 'Search Terms', '','');
|
|
$headers = array('Operation','Scope', 'Search Terms', '','');
|
|
$table = array(
|
|
$table = array(
|
|
'header' => $headers,
|
|
'header' => $headers,
|
|
@@ -734,34 +764,36 @@ function theme_tripal_pub_importer_setup_form_elements($variables) {
|
|
);
|
|
);
|
|
$criteria_table = theme_table($table);
|
|
$criteria_table = theme_table($table);
|
|
$markup .= $criteria_table;
|
|
$markup .= $criteria_table;
|
|
-
|
|
|
|
|
|
+
|
|
// add the rendered form
|
|
// add the rendered form
|
|
$form = array(
|
|
$form = array(
|
|
'#markup' => $markup,
|
|
'#markup' => $markup,
|
|
'#prefix' => '<div id="tripal-pubs-importer-setup">',
|
|
'#prefix' => '<div id="tripal-pubs-importer-setup">',
|
|
'#suffix' => '</div>',
|
|
'#suffix' => '</div>',
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
return drupal_render($form);
|
|
return drupal_render($form);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* Add a job to import publications
|
|
* Add a job to import publications
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param $pub_importer_id
|
|
* @param $pub_importer_id
|
|
|
|
+ * The id of the importer to submit a job to update
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_pub
|
|
*/
|
|
*/
|
|
function tripal_pub_importer_submit_job($import_id) {
|
|
function tripal_pub_importer_submit_job($import_id) {
|
|
global $user;
|
|
global $user;
|
|
-
|
|
|
|
|
|
+
|
|
// get all of the loaders
|
|
// get all of the loaders
|
|
$args = array(':import_id' => $import_id);
|
|
$args = array(':import_id' => $import_id);
|
|
$sql = "SELECT * FROM {tripal_pub_import} WHERE pub_import_id = :import_id ";
|
|
$sql = "SELECT * FROM {tripal_pub_import} WHERE pub_import_id = :import_id ";
|
|
$import = db_query($sql, $args)->fetchObject();
|
|
$import = db_query($sql, $args)->fetchObject();
|
|
-
|
|
|
|
|
|
+
|
|
$args = array($import_id);
|
|
$args = array($import_id);
|
|
tripal_add_job("Import publications $import->name", 'tripal_pub',
|
|
tripal_add_job("Import publications $import->name", 'tripal_pub',
|
|
'tripal_pub_import_publications_by_import_id', $args, $user->uid);
|
|
'tripal_pub_import_publications_by_import_id', $args, $user->uid);
|
|
-
|
|
|
|
|
|
+
|
|
drupal_goto('admin/tripal/chado/tripal_pub/import_list');
|
|
drupal_goto('admin/tripal/chado/tripal_pub/import_list');
|
|
}
|
|
}
|
|
-
|
|
|