123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <?php
- function tripal_pub_admin_pub_view() {
- $output = '';
-
- $breadcrumb = [];
- $breadcrumb[] = l('Home', '<front>');
- $breadcrumb[] = l('Administration', 'admin');
- $breadcrumb[] = l('Tripal', 'admin/tripal');
- $breadcrumb[] = l('Chado', 'admin/tripal/legacy');
- $breadcrumb[] = l('Publications', 'admin/tripal/legacy/tripal_pub');
- drupal_set_breadcrumb($breadcrumb);
-
- $view = views_embed_view('tripal_pub_admin_publications', 'default');
- if (isset($view)) {
- $output .= $view;
- }
- else {
- $output .= '<p>The Publications module uses primarily views to provide an '
- . 'administrative interface. Currently one or more views needed for this '
- . 'administrative interface are disabled. <strong>Click each of the following links to '
- . 'enable the pertinent views</strong>:</p>';
- $output .= '<ul>';
- $output .= '<li>' . l('Publications View', 'admin/tripal/legacy/tripal_pub/views/pubs/enable') . '</li>';
- $output .= '</ul>';
- }
- return $output;
- }
- function tripal_pub_admin() {
- $form = [];
-
-
- $details = [
- 'module' => 'tripal_pub',
-
- 'content_type' => 'chado_pub',
-
-
-
- 'options' => [
- '[pub.title]' => 'Publication Title',
-
- '[pub.uniquename]' => 'Unique Contraint: Citation of the Publication.',
- ],
-
- 'unique_option' => '[pub.uniquename]',
- ];
-
-
- chado_add_admin_form_set_title($form, $form_state, $details);
-
-
- $form['import'] = [
- '#type' => 'fieldset',
- '#title' => t('Import Settings'),
- '#description' => t('During import, Tripal will attempt to find duplicate publications,
- and will not try to insert a publication that already exists in the database. It can
- find duplicates using the title, year, series name (e.g. Journal Name) and media type
- (e.g. Journal Article etc.).
- There are several options for how to find a duplicate publication. Choose the
- option that best suits your needs.'),
- ];
- $form['import']['import_duplicate_check'] = [
- '#type' => 'radios',
- '#title' => t('Unique Constraint'),
- '#options' => [
- 'title_year' => t('Title and Year'),
- 'title_year_media' => t('Title, Year, Media name (e.g. Journal Name, etc.)'),
- 'title_year_type' => t('Title, Year, Media type (e.g. Journal, Conference Proceedings, etc.'),
- ],
- '#default_value' => variable_get('tripal_pub_import_duplicate_check', 'title_year_media'),
- ];
-
-
-
-
- $d_type_id = '';
- $sql = "
- SELECT
- CVTS.cvterm_id, CVTS.name
- 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 Type' AND
- NOT CVTS.is_obsolete = 1
- ORDER BY CVTS.name ASC
- ";
- $results = chado_query($sql);
- $pub_types = [];
- while ($pub_type = $results->fetchObject()) {
- $pub_types[$pub_type->cvterm_id] = $pub_type->name;
- if (strcmp($pub_type->name, "Journal Article") == 0) {
- $d_type_id = $pub_type->cvterm_id;
- }
- }
-
- $d_type_id = variable_get('tripal_pub_default_type', $d_type_id);
- $form['default_type'] = [
- '#type' => 'fieldset',
- '#title' => t('Default Publication Type'),
- ];
- $form['default_type']['type_id'] = [
- '#type' => 'select',
- '#title' => t('Publication Type'),
- '#options' => $pub_types,
- '#description' => t('Please set a default publiation type used for manual entry of a new
- publication. This is useful in the event that someone is manually adding the same
- publication type repetitively'),
- '#default_value' => $d_type_id,
- ];
- return system_settings_form($form);
- }
- function tripal_pub_admin_validate($form, &$form_state) {
- global $user;
- $job_args = [];
- $import_duplicate_check = $form_state['values']['import_duplicate_check'];
- variable_set('tripal_pub_import_duplicate_check', $import_duplicate_check);
- $default_type = $form_state['values']['type_id'];
- variable_set('tripal_pub_default_type', $default_type);
- }
- function tripal_pub_set_pub_url($node, $pub_id) {
- $node_url = "node/$node->nid";
- $url_alias = "pub/$pub_id";
-
- db_query("DELETE FROM {url_alias} WHERE source = :source", [':source' => $node_url]);
-
- $path_alias = ["source" => $node_url, "alias" => $url_alias];
- path_save($path_alias);
- return $url_alias;
- }
|