function tripal_views_integration_setup_list

2.x tripal_views_integration_UI.inc tripal_views_integration_setup_list()
1.x tripal_views_integration.inc tripal_views_integration_setup_list()

Purpose: Generates a themable table containing the list of integrated tables The look-and-feel of the table can be altered by overriding the theme for tables.

Return value

a themed HTML table

1 string reference to 'tripal_views_integration_setup_list'
tripal_views_menu in tripal_views/tripal_views.module
Implements hook_menu()

File

tripal_views/includes/tripal_views_integration.inc, line 18
Functions related to the UI for integrating tables with views

Code

function tripal_views_integration_setup_list() {
  $output = '';

  $output .= l(t('Add a New Entry'), "admin/tripal/views/integration/new");

  $output .= '<p>' . t('The following tables are available for integration with Drupal Views. If '
    . 'a table is integrated more than once, then the setup with the lightest '
    . 'priority will be used. For example, if you have created a custom setup with a priority of -5 then '
    . 'that will be used instead of the default setup with priority 10. '
    . 'Priorities range from -10 to +10  where a setup with -10 has '
    . 'greater precedent than any other and +10 has the least.') . '</p>';


  // Start with materialized views
  $output .= '<br /><h3>Legacy Materialized Views</h3>';
  $header = array('', 'Drupal Views Type Name', 'Table Name', 'Is Legacy?', 'Priority', 'Comment');
  $rows = array();

  // get the list of materialized views
  $tviews = db_query('SELECT tv.setup_id, tv.name, tv.table_name, tc.table_id, tv.priority, tv.comment '
    . 'FROM {tripal_views} tv '
    . 'LEFT JOIN {tripal_custom_tables} tc ON tc.table_name=tv.table_name '
    . 'WHERE tv.mview_id IS NOT NULL '
    . 'ORDER BY tv.table_name ASC, tv.priority ASC');
  while ($tview = db_fetch_object($tviews)) {
    $rows[] = array(
      l(t('Edit'), "admin/tripal/views/integration/edit/" . $tview->setup_id) . "<br />"
        . l(t('Export'), "admin/tripal/views/integration/export/" . $tview->setup_id) . "<br />"
        . l(t('Delete'), "admin/tripal/views/integration/delete/" . $tview->setup_id),
      $tview->name,
      $tview->table_name,
      ($tview->table_id) ? 'No' : 'Yes',
      $tview->priority,
      $tview->comment,
    );
  }

  if ($rows) {
    $output .= theme('table', $header, $rows);
  }
  else {
    $output .= '<p>There are currently no Materialized Views defined. ';
    $output .= l(t('Add a New Entry'), "admin/tripal/views/integration/new") . '</p>';

  }

  // Now list non-mview custom tables
  $output .= '<br /><h3>Custom Tables & Non-Legacy Materialized Views</h3>';
  $header = array('', 'Drupal Views Type Name', 'Table Name', 'Priority', 'Comment');
  $rows = array();

  // get the list of chado tables
  $tviews = db_query('SELECT tv.setup_id, tv.name, tv.table_name, tv.priority, tv.comment '
    . 'FROM {tripal_views} tv '
    . 'LEFT JOIN {tripal_custom_tables} tc ON tc.table_name=tv.table_name '
    . 'WHERE mview_id IS NULL AND tc.table_id IS NOT NULL '
    . 'ORDER BY table_name ASC, priority ASC');
  while ($tview = db_fetch_object($tviews)) {
    $rows[] = array(
      l(t('Edit'), "admin/tripal/views/integration/edit/" . $tview->setup_id) . "<br />"
        . l(t('Export'), "admin/tripal/views/integration/export/" . $tview->setup_id) . "<br />"
        . l(t('Delete'), "admin/tripal/views/integration/delete/" . $tview->setup_id),
      $tview->name,
      $tview->table_name,
      $tview->priority,
      $tview->comment,
    );
  }

  if ($rows) {
    $output .= theme('table', $header, $rows);
  }
  else {
    $output .= '<p>There are currently no non-Materialized View Custom Tables defined.</p>';
  }

  // Now list chado tables
  $output .= '<br /><h3>Chado Tables</h3>';
  $header = array('', 'Drupal Views Type Name', 'Table Name', 'Priority', 'Comment');
  $rows = array();

  // get the list of chado tables
  $tviews = db_query('SELECT tv.setup_id, tv.name, tv.table_name, tv.priority, tv.comment '
    . 'FROM {tripal_views} tv '
    . 'LEFT JOIN {tripal_custom_tables} tc ON tc.table_name=tv.table_name '
    . 'WHERE mview_id IS NULL AND tc.table_id IS NULL '
    . 'ORDER BY table_name ASC, priority ASC');
  while ($tview = db_fetch_object($tviews)) {
    $rows[] = array(
      l(t('Edit'), "admin/tripal/views/integration/edit/" . $tview->setup_id) . "<br />"
        . l(t('Export'), "admin/tripal/views/integration/export/" . $tview->setup_id) . "<br />"
        . l(t('Delete'), "admin/tripal/views/integration/delete/" . $tview->setup_id),
      $tview->name,
      $tview->table_name,
      $tview->priority,
      $tview->comment,
    );
  }

  $output .= theme('table', $header, $rows);
  return $output;
}