|
@@ -7,12 +7,68 @@
|
|
|
* in Chado.
|
|
|
*/
|
|
|
|
|
|
+function tripal_chado_pub_search_admin_form($form, &$form_state) {
|
|
|
+ // -----------------------------------------
|
|
|
+ // add in the fields for selecting which fields are used when search for pubs
|
|
|
+ $form['searching'] = array(
|
|
|
+ '#type' => 'fieldset',
|
|
|
+ '#title' => t('Searching Options'),
|
|
|
+ '#description' => t("The list of checkboxes below indicate which fields a user
|
|
|
+ can search with when using the publication search tool. Check the fields that you want
|
|
|
+ to allow users to search with. Click the 'Save configuration' button below to save changes."),
|
|
|
+ );
|
|
|
+
|
|
|
+ // get publication properties list
|
|
|
+ $properties = array();
|
|
|
+ $properties[] = 'Any Field';
|
|
|
+ $sql = "
|
|
|
+ SELECT DISTINCT CVTS.cvterm_id, CVTS.name, CVTS.definition
|
|
|
+ FROM {cvtermpath} CVTP
|
|
|
+ INNER JOIN {cvterm} CVTS ON CVTP.subject_id = CVTS.cvterm_id
|
|
|
+ INNER JOIN {cvterm} CVTO ON CVTP.object_id = CVTO.cvterm_id
|
|
|
+ INNER JOIN {cv} ON CVTO.cv_id = CV.cv_id
|
|
|
+ WHERE CV.name = 'tripal_pub' and
|
|
|
+ (CVTO.name = 'Publication Details' or CVTS.name = 'Publication Type') and
|
|
|
+ NOT CVTS.is_obsolete = 1
|
|
|
+ ORDER BY CVTS.name ASC
|
|
|
+ ";
|
|
|
+ $prop_types = chado_query($sql);
|
|
|
+ while ($prop = $prop_types->fetchObject()) {
|
|
|
+ $properties[$prop->cvterm_id] = $prop->name;
|
|
|
+ }
|
|
|
+ $form['allowed_search_fields'] = array(
|
|
|
+ '#type' => 'checkboxes',
|
|
|
+ '#options' => $properties,
|
|
|
+ '#default_value' => variable_get('tripal_pub_allowed_search_fields', array()),
|
|
|
+ );
|
|
|
+
|
|
|
+ $form['button'] = array(
|
|
|
+ '#type' => 'submit',
|
|
|
+ '#value' => 'Save configuration',
|
|
|
+ '#name' => 'sumbit',
|
|
|
+ );
|
|
|
+ return $form;
|
|
|
+}
|
|
|
+/**
|
|
|
+ *
|
|
|
+ */
|
|
|
+function tripal_chado_pub_search_admin_form_submit($form, &$form_state) {
|
|
|
+ // set the allowed search fields
|
|
|
+ $allowed_fields = $form_state['values']['allowed_search_fields'];
|
|
|
+ foreach ($allowed_fields as $cvterm_id => $selected) {
|
|
|
+ if (!$selected) {
|
|
|
+ unset($allowed_fields[$cvterm_id]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ variable_set('tripal_pub_allowed_search_fields', $allowed_fields);
|
|
|
+ drupal_set_message('Changes saved.');
|
|
|
+}
|
|
|
/**
|
|
|
* The page that contains the publication search form and the results for the search
|
|
|
*
|
|
|
* @ingroup tripal_pub
|
|
|
*/
|
|
|
-function tripal_pub_search_page() {
|
|
|
+function tripal_chado_pub_search_page() {
|
|
|
|
|
|
// This line may not be required, but on some sites the $_SESSION
|
|
|
// variable wasn't being set for anonymous users. This line solves that
|
|
@@ -22,117 +78,111 @@ function tripal_pub_search_page() {
|
|
|
$limit = 25;
|
|
|
|
|
|
// generate the search form
|
|
|
- $form = drupal_get_form('tripal_pub_search_form');
|
|
|
+ $form = drupal_get_form('tripal_chado_pub_search_form');
|
|
|
$output = drupal_render($form);
|
|
|
|
|
|
// retrieve any results
|
|
|
- if (array_key_exists('tripal_pub_search_form', $_SESSION) and
|
|
|
- $_SESSION['tripal_pub_search_form']['perform_search']) {
|
|
|
- $num_criteria = $_SESSION['tripal_pub_search_form']['num_criteria'];
|
|
|
- $from_year = $_SESSION['tripal_pub_search_form']['from_year'];
|
|
|
- $to_year = $_SESSION['tripal_pub_search_form']['to_year'];
|
|
|
-
|
|
|
- $search_array = array();
|
|
|
- $search_array['num_criteria'] = $num_criteria;
|
|
|
- $search_array['from_year'] = $from_year;
|
|
|
- $search_array['to_year'] = $to_year;
|
|
|
- for ($i = 0; $i <= $num_criteria; $i++) {
|
|
|
- $search_array['criteria'][$i]['search_terms'] = $_SESSION['tripal_pub_search_form']['criteria'][$i]['search_terms'];
|
|
|
- $search_array['criteria'][$i]['scope'] = $_SESSION['tripal_pub_search_form']['criteria'][$i]['scope'];
|
|
|
- $search_array['criteria'][$i]['mode'] = $_SESSION['tripal_pub_search_form']['criteria'][$i]['mode'];
|
|
|
- $search_array['criteria'][$i]['operation'] = $_SESSION['tripal_pub_search_form']['criteria'][$i]['operation'];
|
|
|
- }
|
|
|
+ if (array_key_exists('tripal_chado_pub_search_form', $_SESSION) and
|
|
|
+ $_SESSION['tripal_chado_pub_search_form']['perform_search']) {
|
|
|
+ $num_criteria = $_SESSION['tripal_chado_pub_search_form']['num_criteria'];
|
|
|
+ $from_year = $_SESSION['tripal_chado_pub_search_form']['from_year'];
|
|
|
+ $to_year = $_SESSION['tripal_chado_pub_search_form']['to_year'];
|
|
|
+
|
|
|
+ $search_array = array();
|
|
|
+ $search_array['num_criteria'] = $num_criteria;
|
|
|
+ $search_array['from_year'] = $from_year;
|
|
|
+ $search_array['to_year'] = $to_year;
|
|
|
+ for ($i = 0; $i <= $num_criteria; $i++) {
|
|
|
+ $search_array['criteria'][$i]['search_terms'] = $_SESSION['tripal_chado_pub_search_form']['criteria'][$i]['search_terms'];
|
|
|
+ $search_array['criteria'][$i]['scope'] = $_SESSION['tripal_chado_pub_search_form']['criteria'][$i]['scope'];
|
|
|
+ $search_array['criteria'][$i]['mode'] = $_SESSION['tripal_chado_pub_search_form']['criteria'][$i]['mode'];
|
|
|
+ $search_array['criteria'][$i]['operation'] = $_SESSION['tripal_chado_pub_search_form']['criteria'][$i]['operation'];
|
|
|
+ }
|
|
|
+
|
|
|
+ // get the list of publications from the remote database using the search criteria.
|
|
|
+ $page = isset($_GET['page']) ? $_GET['page'] : '0';
|
|
|
+ $offset = $page * $limit;
|
|
|
+ $total_records = 0;
|
|
|
+ $pubs = tripal_search_publications($search_array, $offset, $limit, $total_records);
|
|
|
+ pager_default_initialize($total_records, $limit, 0);
|
|
|
+
|
|
|
+ // iterate through the results and construct the table displaying the publications
|
|
|
+ $rows = array();
|
|
|
+ $i = $page * $limit + 1;
|
|
|
+ foreach ($pubs as $pub) {
|
|
|
+ // get the citation for this publication
|
|
|
+ $values = array(
|
|
|
+ 'pub_id' => $pub->pub_id,
|
|
|
+ 'type_id' => array(
|
|
|
+ 'name' => 'Citation',
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ $citation_rec = chado_generate_var('pubprop', $values);
|
|
|
+ $citation_rec = chado_expand_var($citation_rec, 'field', 'pubprop.value');
|
|
|
+
|
|
|
+ // if we have the citation then use it, otherwise, just use the title
|
|
|
+ $title = htmlspecialchars($pub->title);
|
|
|
+ $result = $title;
|
|
|
+ $link = NULL;
|
|
|
+
|
|
|
+ // tripal v2 link (node)
|
|
|
+ if (module_exists('tripal_pub')) {
|
|
|
+ $nid = chado_get_nid_from_id ('pub', $pub->pub_id);
|
|
|
+ if ($nid) {
|
|
|
+ $link = "/node/$nid";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // try tripal v3 link (entity), if it exists, update the link to entity
|
|
|
+ $entity_id = tripal_get_chado_entity_id ('pub', $pub->pub_id);
|
|
|
+ if ($entity_id) {
|
|
|
+ $link = "/bio_data/$entity_id";
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($link) {
|
|
|
+ $result = l($title , $link, array('attributes' => array('target' => '_blank')));
|
|
|
+ }
|
|
|
+ if ($citation_rec->value) {
|
|
|
+ $citation = htmlspecialchars($citation_rec->value);
|
|
|
+ $result .= '<br>' . $citation;
|
|
|
+ }
|
|
|
+ $rows[] = array(
|
|
|
+ number_format($i) . ".",
|
|
|
+ $pub->pyear,
|
|
|
+ $result
|
|
|
+ );
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+
|
|
|
+ $headers = array('', 'Year', 'Reference');
|
|
|
+ $table = array(
|
|
|
+ 'header' => $headers,
|
|
|
+ 'rows' => $rows,
|
|
|
+ 'attributes' => array(
|
|
|
+ 'id' => 'tripal-pub-search-results-table',
|
|
|
+ 'border' => '0',
|
|
|
+ 'class' => array('tripal-data-table')
|
|
|
+ ),
|
|
|
+ 'sticky' => TRUE,
|
|
|
+ 'caption' => '',
|
|
|
+ 'colgroups' => array(),
|
|
|
+ 'empty' => 'No publications found',
|
|
|
+ );
|
|
|
+ $results = theme_table($table);
|
|
|
+
|
|
|
+ // generate the pager
|
|
|
+ $pager = array(
|
|
|
+ 'tags' => array(),
|
|
|
+ 'element' => 0,
|
|
|
+ 'parameters' => array(),
|
|
|
+ 'quantity' => $limit,
|
|
|
+ );
|
|
|
+ $pager = theme_pager($pager);
|
|
|
|
|
|
- // get the list of publications from the remote database using the search criteria.
|
|
|
- $page = isset($_GET['page']) ? $_GET['page'] : '0';
|
|
|
- $offset = $page * $limit;
|
|
|
- $total_records = 0;
|
|
|
- $pubs = tripal_search_publications($search_array, $offset, $limit, $total_records);
|
|
|
- pager_default_initialize($total_records, $limit, 0);
|
|
|
-
|
|
|
- // iterate through the results and construct the table displaying the publications
|
|
|
- $rows = array();
|
|
|
- $i = $page * $limit + 1;
|
|
|
- foreach ($pubs as $pub) {
|
|
|
- // get the citation for this publication
|
|
|
- $values = array(
|
|
|
- 'pub_id' => $pub->pub_id,
|
|
|
- 'type_id' => array(
|
|
|
- 'name' => 'Citation',
|
|
|
- ),
|
|
|
- );
|
|
|
- $citation_rec = chado_generate_var('pubprop', $values);
|
|
|
- $citation_rec = chado_expand_var($citation_rec, 'field', 'pubprop.value');
|
|
|
-
|
|
|
- // if we have the citation then use it, otherwise, just use the title
|
|
|
- $title = htmlspecialchars($pub->title);
|
|
|
- $result = $title;
|
|
|
- $link = NULL;
|
|
|
- // tripal v2 link (node)
|
|
|
- $nid = chado_get_nid_from_id ('pub', $pub->pub_id);
|
|
|
- if ($nid) {
|
|
|
- $link = "/node/$nid";
|
|
|
- }
|
|
|
- // try tripal v3 link (entity), if it exists, update the link to entity
|
|
|
- $entity_id = tripal_get_chado_entity_id ('pub', $pub->pub_id);
|
|
|
- if ($entity_id) {
|
|
|
- $link = "/bio_data/$entity_id";
|
|
|
+ // join all to form the results
|
|
|
+ $output .= "<p><b>Found " . number_format($total_records) .
|
|
|
+ " Results</b></br>" . $results . $pager;
|
|
|
}
|
|
|
-
|
|
|
- if ($link) {
|
|
|
- $result = l($title , $link, array('attributes' => array('target' => '_blank')));
|
|
|
- }
|
|
|
- if ($citation_rec->value) {
|
|
|
- $citation = htmlspecialchars($citation_rec->value);
|
|
|
- $result .= '<br>' . $citation;
|
|
|
- }
|
|
|
- $rows[] = array(
|
|
|
- number_format($i) . ".",
|
|
|
- $pub->pyear,
|
|
|
- $result
|
|
|
- );
|
|
|
- $i++;
|
|
|
- }
|
|
|
-
|
|
|
- if (count($rows) == 0) {
|
|
|
- $rows[] = array(
|
|
|
- array(
|
|
|
- 'data' => 'No results found',
|
|
|
- 'colspan' => 3
|
|
|
- )
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- $headers = array('', 'Year', 'Publication');
|
|
|
- $table = array(
|
|
|
- 'header' => $headers,
|
|
|
- 'rows' => $rows,
|
|
|
- 'attributes' => array(
|
|
|
- 'id' => 'tripal-pub-search-results-table',
|
|
|
- 'border' => '0',
|
|
|
- 'class' => array('tripal-data-table')
|
|
|
- ),
|
|
|
- 'sticky' => TRUE,
|
|
|
- 'caption' => '',
|
|
|
- 'colgroups' => array(),
|
|
|
- 'empty' => '',
|
|
|
- );
|
|
|
- $results = theme_table($table);
|
|
|
-
|
|
|
- // generate the pager
|
|
|
- $pager = array(
|
|
|
- 'tags' => array(),
|
|
|
- 'element' => 0,
|
|
|
- 'parameters' => array(),
|
|
|
- 'quantity' => $limit,
|
|
|
- );
|
|
|
- $pager = theme_pager($pager);
|
|
|
-
|
|
|
- // join all to form the results
|
|
|
- $output .= "<p><b>Found " . number_format($total_records) .
|
|
|
- " Results</b></br>" . $results . $pager;
|
|
|
- }
|
|
|
- return $output;
|
|
|
+ return $output;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -140,7 +190,7 @@ function tripal_pub_search_page() {
|
|
|
*
|
|
|
* @ingroup tripal_pub
|
|
|
*/
|
|
|
-function tripal_pub_search_form($form, &$form_state) {
|
|
|
+function tripal_chado_pub_search_form($form, &$form_state) {
|
|
|
// Default values can come in the following ways:
|
|
|
//
|
|
|
// 1) as elements of the $pub_importer object. This occurs when editing an existing importer
|
|
@@ -162,10 +212,10 @@ function tripal_pub_search_form($form, &$form_state) {
|
|
|
if (array_key_exists('storage', $form_state)) {
|
|
|
$num_criteria = $form_state['storage']['num_criteria'];
|
|
|
}
|
|
|
- if (array_key_exists('tripal_pub_search_form', $_SESSION)) {
|
|
|
- $num_criteria = $_SESSION['tripal_pub_search_form']['num_criteria'] ? $_SESSION['tripal_pub_search_form']['num_criteria'] : $num_criteria;
|
|
|
- $from_year = $_SESSION['tripal_pub_search_form']['from_year'] ? $_SESSION['tripal_pub_search_form']['from_year'] : '';
|
|
|
- $to_year = $_SESSION['tripal_pub_search_form']['to_year'] ? $_SESSION['tripal_pub_search_form']['to_year'] : '';
|
|
|
+ if (array_key_exists('tripal_chado_pub_search_form', $_SESSION)) {
|
|
|
+ $num_criteria = $_SESSION['tripal_chado_pub_search_form']['num_criteria'] ? $_SESSION['tripal_chado_pub_search_form']['num_criteria'] : $num_criteria;
|
|
|
+ $from_year = $_SESSION['tripal_chado_pub_search_form']['from_year'] ? $_SESSION['tripal_chado_pub_search_form']['from_year'] : '';
|
|
|
+ $to_year = $_SESSION['tripal_chado_pub_search_form']['to_year'] ? $_SESSION['tripal_chado_pub_search_form']['to_year'] : '';
|
|
|
}
|
|
|
if (array_key_exists('values', $form_state)) {
|
|
|
$from_year = $form_state['values']['from_year'] ? $form_state['values']['from_year'] : $from_year;
|
|
@@ -178,27 +228,27 @@ function tripal_pub_search_form($form, &$form_state) {
|
|
|
|
|
|
if (array_key_exists('triggering_element', $form_state) and
|
|
|
$form_state['triggering_element']['#name'] == 'add') {
|
|
|
- $num_criteria++;
|
|
|
+ $num_criteria++;
|
|
|
}
|
|
|
if (array_key_exists('triggering_element', $form_state) and
|
|
|
$form_state['triggering_element']['#name'] == 'remove') {
|
|
|
- $num_criteria--;
|
|
|
+ $num_criteria--;
|
|
|
}
|
|
|
|
|
|
$form_state['storage']['num_criteria'] = $num_criteria;
|
|
|
|
|
|
$form['admin-instructions'] = array(
|
|
|
'#markup' => tripal_set_message(
|
|
|
- t('Administrators, you can select the fields with which a user can use to search, by checking the desired fields on the ' .
|
|
|
- l('Publication Module Settings Page', 'admin/tripal/legacy/tripal_pub/configuration', array('attributes' => array('target' => '_blank'))) . '
|
|
|
- in the section titled "Search Options". The selected fields will appear in the dropdowns below.'),
|
|
|
+ t('Administrators, you can select the fields with which a user can use to search, by checking the desired fields on the ' .
|
|
|
+ l('Publication Search Settings Page', 'admin/tripal/storage/chado/pub-search-config', array('attributes' => array('target' => '_blank'))) . '
|
|
|
+ in the section titled "Search Options". The selected fields will appear in the dropdowns below.'),
|
|
|
TRIPAL_INFO,
|
|
|
array('return_html' => 1)),
|
|
|
);
|
|
|
$form['instructions'] = array(
|
|
|
'#markup' => t('To search for publications enter keywords in the text boxes below.
|
|
|
- You can limit your search by selecting the field in the dropdown box. Click the
|
|
|
- add and remove buttons to add additional fields for searching. '),
|
|
|
+ You can limit your search by selecting the field in the dropdown box. Click the
|
|
|
+ add and remove buttons to add additional fields for searching. '),
|
|
|
);
|
|
|
|
|
|
// get publication properties list
|
|
@@ -230,11 +280,11 @@ function tripal_pub_search_form($form, &$form_state) {
|
|
|
$mode = '';
|
|
|
|
|
|
// first populate defaults using any values in the SESSION variable
|
|
|
- if (array_key_exists('tripal_pub_search_form', $_SESSION)) {
|
|
|
- $search_terms = $_SESSION['tripal_pub_search_form']['criteria'][$i]['search_terms'] ? $_SESSION['tripal_pub_search_form']['criteria'][$i]['search_terms'] : $search_terms;
|
|
|
- $scope = $_SESSION['tripal_pub_search_form']['criteria'][$i]['scope'] ? $_SESSION['tripal_pub_search_form']['criteria'][$i]['scope'] : $scope;
|
|
|
- $mode = $_SESSION['tripal_pub_search_form']['criteria'][$i]['mode'] ? $_SESSION['tripal_pub_search_form']['criteria'][$i]['mode'] : $mode;
|
|
|
- $operation = $_SESSION['tripal_pub_search_form']['criteria'][$i]['operation'] ? $_SESSION['tripal_pub_search_form']['criteria'][$i]['operation'] : $operation;
|
|
|
+ if (array_key_exists('tripal_chado_pub_search_form', $_SESSION)) {
|
|
|
+ $search_terms = $_SESSION['tripal_chado_pub_search_form']['criteria'][$i]['search_terms'] ? $_SESSION['tripal_chado_pub_search_form']['criteria'][$i]['search_terms'] : $search_terms;
|
|
|
+ $scope = $_SESSION['tripal_chado_pub_search_form']['criteria'][$i]['scope'] ? $_SESSION['tripal_chado_pub_search_form']['criteria'][$i]['scope'] : $scope;
|
|
|
+ $mode = $_SESSION['tripal_chado_pub_search_form']['criteria'][$i]['mode'] ? $_SESSION['tripal_chado_pub_search_form']['criteria'][$i]['mode'] : $mode;
|
|
|
+ $operation = $_SESSION['tripal_chado_pub_search_form']['criteria'][$i]['operation'] ? $_SESSION['tripal_chado_pub_search_form']['criteria'][$i]['operation'] : $operation;
|
|
|
}
|
|
|
if (array_key_exists('values', $form_state)) {
|
|
|
$search_terms = array_key_exists("search_terms-$i", $form_state['values']) ? $form_state['values']["search_terms-$i"] : $search_terms;
|
|
@@ -306,8 +356,8 @@ function tripal_pub_search_form($form, &$form_state) {
|
|
|
// 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_search_form_ajax_button_submit'),
|
|
|
- '#validate' => array('tripal_pub_search_form_ajax_button_validate'),
|
|
|
+ '#submit' => array('tripal_chado_pub_search_form_ajax_button_submit'),
|
|
|
+ '#validate' => array('tripal_chado_pub_search_form_ajax_button_validate'),
|
|
|
'#limit_validation_errors' => array(),
|
|
|
);
|
|
|
}
|
|
@@ -329,16 +379,16 @@ function tripal_pub_search_form($form, &$form_state) {
|
|
|
// 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_search_form_ajax_button_submit'),
|
|
|
- '#validate' => array('tripal_pub_search_form_ajax_button_validate'),
|
|
|
+ '#submit' => array('tripal_chado_pub_search_form_ajax_button_submit'),
|
|
|
+ '#validate' => array('tripal_chado_pub_search_form_ajax_button_validate'),
|
|
|
'#limit_validation_errors' => array(),
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
$form['criteria']["date"] = array(
|
|
|
- '#type' => 'select',
|
|
|
- '#options' => array('Years' => 'Years'),
|
|
|
- '#attributes' => array('class' => array('tripal-pub-search-form-scope-select')),
|
|
|
+ '#type' => 'select',
|
|
|
+ '#options' => array('Years' => 'Years'),
|
|
|
+ '#attributes' => array('class' => array('tripal-pub-search-form-scope-select')),
|
|
|
);
|
|
|
$form['criteria']["from_year"] = array(
|
|
|
'#type' => 'textfield',
|
|
@@ -366,7 +416,7 @@ function tripal_pub_search_form($form, &$form_state) {
|
|
|
'#value' => t('Reset'),
|
|
|
);
|
|
|
|
|
|
- $form['criteria']['#theme'] = 'tripal_pub_search_setup_form_elements';
|
|
|
+ $form['criteria']['#theme'] = 'tripal_chado_pub_search_setup_form_elements';
|
|
|
|
|
|
return $form;
|
|
|
}
|
|
@@ -379,7 +429,7 @@ function tripal_pub_search_form($form, &$form_state) {
|
|
|
*
|
|
|
* @ingroup tripal_pub
|
|
|
*/
|
|
|
-function tripal_pub_search_form_ajax_button_submit() {
|
|
|
+function tripal_chado_pub_search_form_ajax_button_submit() {
|
|
|
$form_state['rebuild'] = TRUE;
|
|
|
}
|
|
|
|
|
@@ -388,16 +438,16 @@ function tripal_pub_search_form_ajax_button_submit() {
|
|
|
*
|
|
|
* @ingroup tripal_pub
|
|
|
*/
|
|
|
-function tripal_pub_search_form_ajax_button_validate() {
|
|
|
+function tripal_chado_pub_search_form_ajax_button_validate() {
|
|
|
// do nothing
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Validate the tripal_pub_search_form form
|
|
|
+ * Validate the tripal_chado_pub_search_form form
|
|
|
*
|
|
|
* @ingroup tripal_pub
|
|
|
*/
|
|
|
-function tripal_pub_search_form_validate($form, &$form_state) {
|
|
|
+function tripal_chado_pub_search_form_validate($form, &$form_state) {
|
|
|
$num_criteria = $form_state['storage']['num_criteria'];
|
|
|
$from_year = $form_state['values']['from_year'];
|
|
|
$to_year = $form_state['values']['to_year'];
|
|
@@ -423,11 +473,11 @@ function tripal_pub_search_form_validate($form, &$form_state) {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Submit the tripal_pub_search_form form
|
|
|
+ * Submit the tripal_chado_pub_search_form form
|
|
|
*
|
|
|
* @ingroup tripal_pub
|
|
|
*/
|
|
|
-function tripal_pub_search_form_submit($form, &$form_state) {
|
|
|
+function tripal_chado_pub_search_form_submit($form, &$form_state) {
|
|
|
$num_criteria = $form_state['storage']['num_criteria'];
|
|
|
$from_year = $form_state['values']['from_year'];
|
|
|
$to_year = $form_state['values']['to_year'];
|
|
@@ -435,8 +485,8 @@ function tripal_pub_search_form_submit($form, &$form_state) {
|
|
|
|
|
|
// set the session variables
|
|
|
if($op == 'Search') {
|
|
|
- $_SESSION['tripal_pub_search_form']['num_criteria'] = $num_criteria;
|
|
|
- unset($_SESSION['tripal_pub_search_form']['criteria']);
|
|
|
+ $_SESSION['tripal_chado_pub_search_form']['num_criteria'] = $num_criteria;
|
|
|
+ unset($_SESSION['tripal_chado_pub_search_form']['criteria']);
|
|
|
for ($i = 0; $i <= $num_criteria; $i++) {
|
|
|
$search_terms = '';
|
|
|
$scope = '';
|
|
@@ -453,7 +503,7 @@ function tripal_pub_search_form_submit($form, &$form_state) {
|
|
|
}
|
|
|
//$mode = $form_state['values']["mode-$i"];
|
|
|
|
|
|
- $_SESSION['tripal_pub_search_form']['criteria'][$i] = array(
|
|
|
+ $_SESSION['tripal_chado_pub_search_form']['criteria'][$i] = array(
|
|
|
'search_terms' => $search_terms,
|
|
|
'scope' => $scope,
|
|
|
'mode' => $mode,
|
|
@@ -461,12 +511,12 @@ function tripal_pub_search_form_submit($form, &$form_state) {
|
|
|
);
|
|
|
|
|
|
}
|
|
|
- $_SESSION['tripal_pub_search_form']['from_year'] = $from_year;
|
|
|
- $_SESSION['tripal_pub_search_form']['to_year'] = $to_year;
|
|
|
- $_SESSION['tripal_pub_search_form']['perform_search'] = 1;
|
|
|
+ $_SESSION['tripal_chado_pub_search_form']['from_year'] = $from_year;
|
|
|
+ $_SESSION['tripal_chado_pub_search_form']['to_year'] = $to_year;
|
|
|
+ $_SESSION['tripal_chado_pub_search_form']['perform_search'] = 1;
|
|
|
}
|
|
|
if($op == 'Reset') {
|
|
|
- unset($_SESSION['tripal_pub_search_form']);
|
|
|
+ unset($_SESSION['tripal_chado_pub_search_form']);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -486,11 +536,11 @@ function tripal_pubs_search_form_ajax_update($form, $form_state) {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Theme the tripal_pub_search_setup_form form
|
|
|
+ * Theme the tripal_chado_pub_search_setup_form form
|
|
|
*
|
|
|
* @ingroup tripal_pub
|
|
|
*/
|
|
|
-function theme_tripal_pub_search_setup_form_elements($variables) {
|
|
|
+function theme_tripal_chado_pub_search_setup_form_elements($variables) {
|
|
|
$form = $variables['form'];
|
|
|
|
|
|
$rows = array();
|
|
@@ -516,13 +566,13 @@ function theme_tripal_pub_search_setup_form_elements($variables) {
|
|
|
drupal_render($form['date']),
|
|
|
array(
|
|
|
'data' =>
|
|
|
- "<div id=\"pub-search-form-dates-row\">
|
|
|
- <div id=\"pub-search-form-dates\"> ".
|
|
|
- drupal_render($form['from_year']) .
|
|
|
- drupal_render($form['to_year']) . "
|
|
|
- </div>
|
|
|
+ "<div id=\"pub-search-form-dates-row\">
|
|
|
+ <div id=\"pub-search-form-dates\"> ".
|
|
|
+ drupal_render($form['from_year']) .
|
|
|
+ drupal_render($form['to_year']) . "
|
|
|
</div>
|
|
|
- ",
|
|
|
+ </div>
|
|
|
+ ",
|
|
|
),
|
|
|
''
|
|
|
);
|
|
@@ -551,19 +601,21 @@ function theme_tripal_pub_search_setup_form_elements($variables) {
|
|
|
/**
|
|
|
* Builds the SQL statement need to search Chado for the publications
|
|
|
* that match the user supplied criteria. Tpyically, this function is
|
|
|
- * called by the search form generated by the tripal_pub_search_form() function
|
|
|
- * but this function is included in the API for calling by anyone.
|
|
|
+ * called by the search form generated by the tripal_chado_pub_search_form()
|
|
|
+ * function but this function is included in the API for calling by anyone.
|
|
|
*
|
|
|
* @param $search_array
|
|
|
* An array of search criteria provided by the user. The search array is
|
|
|
* an associative array with the following keys:
|
|
|
- * 'num_criteria': an integer indicating the number of search criteria supplied
|
|
|
+ * 'num_criteria': an integer indicating the number of search criteria
|
|
|
+ * supplied
|
|
|
* 'from_year': filters records by a start year
|
|
|
* 'to_year': filters records by an end year
|
|
|
* 'criteria': an array of criteria. Each criteria is an associative
|
|
|
* array with the following keys:
|
|
|
* 'search_terms': The text used for searching
|
|
|
- * 'scope': The cvterm_id of the property used for filtering
|
|
|
+ * 'scope': The cvterm_id of the property used for
|
|
|
+ * filtering
|
|
|
* 'mode': The operation (e.g. AND, OR or NOT)
|
|
|
* @param $offset
|
|
|
* The offset for paging records. The first record returned will be
|
|
@@ -584,15 +636,12 @@ function theme_tripal_pub_search_setup_form_elements($variables) {
|
|
|
*/
|
|
|
function tripal_search_publications($search_array, $offset, $limit, &$total_records) {
|
|
|
|
|
|
- // build the SQL based on the criteria provided by the user
|
|
|
- $select = "SELECT DISTINCT P.*, CP.nid ";
|
|
|
- $from = "FROM {pub} P
|
|
|
- LEFT JOIN [chado_pub] CP on P.pub_id = CP.pub_id
|
|
|
- INNER JOIN {cvterm} CVT on CVT.cvterm_id = P.type_id
|
|
|
- ";
|
|
|
- $where = "WHERE (NOT P.title = 'null') "; // always exclude the dummy pub
|
|
|
+ // Build the SQL based on the criteria provided by the user
|
|
|
+ $select = "SELECT DISTINCT P.* ";
|
|
|
+ $from = "FROM {pub} P INNER JOIN {cvterm} CVT on CVT.cvterm_id = P.type_id ";
|
|
|
+ $where = "WHERE (NOT P.title = 'null') ";
|
|
|
$order = "ORDER BY P.pyear DESC, P.title ASC";
|
|
|
- $args = array(); // arguments for where clause
|
|
|
+ $args = array();
|
|
|
$join = 0;
|
|
|
|
|
|
$num_criteria = $search_array['num_criteria'];
|