function tripal_pub_admin

2.x tripal_pub.admin.inc tripal_pub_admin()
3.x tripal_pub.admin.inc tripal_pub_admin()
1.x tripal_pub.admin.inc tripal_pub_admin()

Administrative settings form

Related topics

1 string reference to 'tripal_pub_admin'
tripal_pub_menu in legacy/tripal_pub/tripal_pub.module
Implements hook_menu().

File

legacy/tripal_pub/includes/tripal_pub.admin.inc, line 47
Administration of publications

Code

function tripal_pub_admin() {
  $form = array();

  // If your module is using the Chado Node: Title & Path API to allow custom titles
  // for your node type then you need to add the configuration form for this functionality.
  $details = array(
    'module' => 'tripal_pub', // the name of the MODULE implementing the content type
    'content_type' => 'chado_pub', // the name of the content type
    // An array of options to use under "Page Titles"
    // the key should be the token and the value should be the human-readable option
    'options' => array(
      '[pub.title]' => 'Publication Title',
      // there should always be one options matching the unique constraint.
      '[pub.uniquename]' => 'Unique Contraint: Citation of the Publication.'
    ),
    // the token indicating the unique constraint in the options array
    'unique_option' => '[pub.uniquename]'
  );
  // This call adds the configuration form to your current form
  // This sub-form handles it's own validation & submit
  chado_add_admin_form_set_title($form, $form_state, $details);

  // -----------------------------------------
  // add the field set for syncing publications
  $form['import'] = array(
    '#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'] = array(
    '#type' => 'radios',
    '#title' => t('Unique Constraint'),
    '#options' => array(
      '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'),
  );

  // -----------------------------------------
  // get the list of publication types.  In the Tripal publication
  // ontologies these are all grouped under the term 'Publication Type'
  // we want the default to be 'Journal Article'
  $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 = array();
  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;
    }
  }

  // override the default by using the stored variable
  $d_type_id = variable_get('tripal_pub_default_type', $d_type_id);

  $form['default_type'] = array(
    '#type' => 'fieldset',
    '#title' => t('Default Publication Type'),
  );
  $form['default_type']['type_id'] = array(
    '#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);
}