function tripal_pub_importers_list

2.x tripal_pub.pub_importers.inc tripal_pub_importers_list()
3.x tripal_chado.pub_importers.inc tripal_pub_importers_list()
1.x pub_importers.inc tripal_pub_importers_list()

A function to generate a table containing the list of publication importers

Related topics

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

File

tripal_pub/includes/tripal_pub.pub_importers.inc, line 12
Management of importers

Code

function tripal_pub_importers_list() {

  // Check to make sure that the tripal_pub vocabulary is loaded. If not, then
  // warn the user that they should load it before continuing.
  $pub_cv = chado_select_record('cv', array('cv_id'), array('name' => 'tripal_pub'));
  if (count($pub_cv) == 0) {
    drupal_set_message(t('The Tripal Pub vocabulary is currently not loaded. ' .
      'This vocabulary is required to be loaded before importing of ' .
      'publications.  <br>Please !import', 
    array('!import' => l('load the Tripal Publication vocabulary', 'admin/tripal/loaders/obo_loader'))), 'warning');
  }

  // 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");

  while ($importer = $importers->fetchObject()) {
    $criteria = unserialize($importer->criteria);
    $num_criteria = $criteria['num_criteria'];
    $criteria_str = '';
    for ($i = 1; $i <= $num_criteria; $i++) {
      $search_terms = $criteria['criteria'][$i]['search_terms'];
      $scope = $criteria['criteria'][$i]['scope'];
      $is_phrase = $criteria['criteria'][$i]['is_phrase'];
      $operation = $criteria['criteria'][$i]['operation'];
      $criteria_str .= "$operation ($scope: $search_terms) ";
    }

    $rows[] = array(
      array(
        'data' => l(t('Edit/Test'), "admin/tripal/chado/tripal_pub/import/edit/$importer->pub_import_id") . '<br>' .
          l(t('Import Pubs'), "admin/tripal/chado/tripal_pub/import/submit/$importer->pub_import_id"),
        'nowrap' => 'nowrap'
      ),
      $importer->name,
      $criteria['remote_db'],
      $criteria_str,
      $importer->disabled ? 'Yes' : 'No',
      $importer->do_contact ? 'Yes' : 'No',
      l(t('Delete'), "admin/tripal/chado/tripal_pub/import/delete/$importer->pub_import_id"),
    );
  }


  $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.  You can import publications in one of two ways:
     <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
          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
     set the importers to run automatically.") . '</li>
     </ol><br>';

  $page .= theme('table', array('header' => $header, 'rows' => $rows));

  return $page;
}