Browse Source

Created tripal_sites table. Added menu items for adding/editing Tripal sites

Chun-Huai Cheng 8 years ago
parent
commit
26c11a3a1a
3 changed files with 99 additions and 0 deletions
  1. 20 0
      tripal_ws/includes/tripal_ws.admin.inc
  2. 56 0
      tripal_ws/tripal_ws.install
  3. 23 0
      tripal_ws/tripal_ws.module

+ 20 - 0
tripal_ws/includes/tripal_ws.admin.inc

@@ -0,0 +1,20 @@
+<?php
+/**
+ * Provide form to store information of other Tripal sites
+ * 
+ * @param unknown $form
+ * @param unknown $form_state
+ */
+function tripal_ws_tripal_sites_form($form, &$form_state) {
+  $form = array();
+  $form['add_tripal_site'] = array(
+    '#markup' => l('Add Tripal site', '/admin/tripal/ws/tripal_sites/add') 
+  );
+  $sites = array('Select a Tripal site');
+  $form['edit_tripal_site'] = array(
+    '#type' => 'select',
+    '#description' => 'Make change to an existing Tripal site',
+    '#options' => $sites
+  );
+  return $form;
+}

+ 56 - 0
tripal_ws/tripal_ws.install

@@ -0,0 +1,56 @@
+<?php
+
+/**
+ * Implementation of hook_schema().
+ *
+ * @ingroup tripal
+ */
+function tripal_ws_schema() {
+  $schema = array();
+  $schema['tripal_sites'] = tripal_ws_tripal_sites_schema();
+  return $schema;
+}
+
+/**
+ * The base table for TripalVocab schema.
+ *
+ * Table to store information about other Tripal sites.
+ */
+function tripal_ws_tripal_sites_schema() {
+  $schema = array(
+    'description' => 'The table for other Tripal sites.',
+    'fields' => array(
+      'id' => array(
+        'description' => 'The primary identifier for a record.',
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+      'name' => array(
+        'description' => 'Name of the Tripal site',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+      ),
+      'url' => array(
+        'description' => 'The URL of the Tripal site.',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+      ),
+      'description' => array(
+        'description' => 'The description of the Tripal site.',
+        'type' => 'varchar',
+        'length' => 255,
+      ),
+    ),
+    'indexes' => array(
+      'name' => array('name'),
+      'url' => array('url'),
+      'description' => array('description'),
+    ),
+    'unique keys' => array('name' => array('name')),
+    'primary key' => array('id'),
+  );
+  return $schema;
+}

+ 23 - 0
tripal_ws/tripal_ws.module

@@ -37,6 +37,29 @@ function tripal_ws_menu() {
     'type' => MENU_CALLBACK,
   );
 
+  // Tripal Web Services setting groups
+  $items['admin/tripal/ws'] = array(
+    'title' => 'Web Services',
+    'description' => t("Exchange data between Tripal sites using the web services."),
+    'weight' => 20,
+    'page callback' => 'system_admin_menu_block_page',
+    'access arguments' => array('administer tripal'),
+    'file' => 'system.admin.inc',
+    'file path' => drupal_get_path('module', 'system'),
+  );
+  $items['admin/tripal/ws/tripal_sites'] = array(
+    'title' => 'Other Tripal Sites',
+    'description' => t('Provides information about other Tripal sites.
+        This allows data exchange and communication betwen Tripal
+        enabled sites through the web services.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_ws_tripal_sites_form'),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_NORMAL_ITEM,
+    'weight' => 0,
+    'file' => 'includes/tripal_ws.admin.inc',
+    'file path' => drupal_get_path('module', 'tripal_ws'),
+  );
   return $items;
 }