Просмотр исходного кода

Added form for setting up semantic web terms

Chun-Huai Cheng 8 лет назад
Родитель
Сommit
e0a6c08566
2 измененных файлов с 100 добавлено и 1 удалено
  1. 85 1
      tripal_chado/includes/tripal_chado.semweb.inc
  2. 15 0
      tripal_chado/tripal_chado.module

+ 85 - 1
tripal_chado/includes/tripal_chado.semweb.inc

@@ -261,4 +261,88 @@ function tripal_chado_populate_chado_semweb_table() {
   tripal_associate_chado_semweb_term('stock', 'name', $alternate_name);
 
 
-}
+}
+
+/**
+ * Adds defaults to the chado_semweb table.
+ */
+function tripal_chado_semweb_form($form, &$form_state) {
+
+  $chado_table = '';
+  if (array_key_exists('values', $form_state)) {
+    $chado_table = $form_state['values']['chado_table'];
+  }
+
+  $chado_tables = chado_get_table_names(TRUE);
+  $chado_tables = array_merge(array('Select a Chado Table'), $chado_tables);
+
+  $form['chado_table'] = array(
+    '#type' => 'select',
+    '#title' => 'Chado Table',
+    '#description' => t('Select a chado table to set web services terms used for its columns.'),
+    '#options' => $chado_tables,
+    '#default_value' => $chado_table,
+    '#ajax' => array(
+      'callback' => "tripal_chado_semweb_form_ajax_callback",
+      'wrapper' => "tripal-chado-semweb-form",
+      'effect' => 'fade',
+      'method' => 'replace'
+    ),
+  );
+
+  // If the user has selected a content type, then we need to
+  // show some filters.
+  if ($chado_table) {
+    $form['filters'] = array(
+      '#type' => 'fieldset',
+      '#title' => 'Filters',
+      '#description' => t('Please provide any filters for limiting
+          the records. Only those that match the filters specified
+          below will be published.  To publish all records of this
+          type, leave all filters blank.'),
+      '#collapsed' => TRUE,
+      '#collapsible' => TRUE,
+    );
+
+    $form['publish_btn'] = array(
+      '#type' => 'submit',
+      '#name' => 'publish_btn',
+      '#value' => 'Publish',
+    );
+  }
+
+
+  $form['#prefix'] = '<div id="tripal-chado-publish-form">';
+  $form['#suffix'] = '</div>';
+  return $form;
+}
+
+function tripal_chado_semweb_form_validate($form, &$form_state) {
+
+}
+
+function tripal_chado_semweb_form_submit($form, &$form_state) {
+  if ($form_state['clicked_button']['#name'] == 'publish_btn') {
+    global $user;
+
+    $chado_table = $form_state['values']['chado_table'];
+    $bundle_name = 'bio_data_' . $chado_table;
+    $bundle = tripal_load_bundle_entity(array('name' => $bundle_name));
+    $args = array(
+      array('bundle_name' => $bundle_name),
+    );
+    $includes = array(
+      module_load_include('inc', 'tripal_chado', 'includes/tripal_chado.publish'),
+    );
+    return tripal_add_job("Publish " . $bundle->label . " records.",
+      'tripal_chado', 'tripal_chado_publish_records', $args,
+      $user->uid, 10, $includes);
+  }
+}
+/**
+ *
+ */
+function tripal_chado_semweb_form_ajax_callback($form, $form_state) {
+  return $form;
+}
+    

+ 15 - 0
tripal_chado/tripal_chado.module

@@ -476,6 +476,21 @@ function tripal_chado_menu() {
     'file path' => drupal_get_path('module', 'tripal_chado'),
     'weight' => 10
   );
+  
+  //////////////////////////////////////////////////////////////////////////////
+  //                           Semantic Web Settings
+  //////////////////////////////////////////////////////////////////////////////
+  $items['admin/tripal/storage/chado/semweb'] = array(
+    'title' => 'Semantic Web',
+    'description' => t('Semantic web settings. Set terms used for the web services.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_chado_semweb_form'),
+    'type' => MENU_NORMAL_ITEM,
+    'access arguments' => array('administer tripal'),
+    'file' => 'includes/tripal_chado.semweb.inc',
+    'file path' => drupal_get_path('module', 'tripal_chado'),
+    'weight' => 10
+  );
 
   //////////////////////////////////////////////////////////////////////////////
   //                           Auto Completes