Browse Source

Adding an admin page for viewing extensions from the RSS feed

Stephen Ficklin 10 years ago
parent
commit
ff056b6df2

+ 5 - 7
tripal_core/api/tripal_core.chado_schema.api.inc

@@ -108,7 +108,7 @@ function chado_add_index($table, $name, $fields) {
 }
 }
 
 
 /**
 /**
- * Check that any given schema exists
+ * Check that any given schema exists.
  *
  *
  * @param $schema
  * @param $schema
  *   The name of the schema to check the existence of
  *   The name of the schema to check the existence of
@@ -120,7 +120,6 @@ function chado_add_index($table, $name, $fields) {
  */
  */
 function chado_dbschema_exists($schema) {
 function chado_dbschema_exists($schema) {
 
 
-  // check that the chado schema now exists
   $sql = "
   $sql = "
     SELECT nspname
     SELECT nspname
     FROM pg_namespace
     FROM pg_namespace
@@ -129,12 +128,11 @@ function chado_dbschema_exists($schema) {
       nspname = :nspname
       nspname = :nspname
     ORDER BY nspname
     ORDER BY nspname
   ";
   ";
-  $results = db_query($sql, array(':nspname' => $schema));
-  $name = $results->fetchObject();
-  if (strcmp($name->nspname, $schema) != 0) {
-    return FALSE;
+  $schema = db_query($sql, array(':nspname' => $schema))->fetchField();
+  if ($schema) {
+    return TRUE;
   }
   }
-  return TRUE;
+  return FALSE;
 }
 }
 
 
 /**
 /**

+ 71 - 0
tripal_core/includes/tripal_core.extensions.inc

@@ -0,0 +1,71 @@
+<?php
+
+function tripal_core_extensions_form($form, &$form_state = NULL) {
+
+  // Get the RSS feed XML from the tripa.info website.
+  $content = file_get_contents("http://tripal.info/rss/extensions.xml");
+  $xml = new SimpleXmlElement($content);
+  $namespace = "http://tripal.info/rss/extensions/";
+
+  // Parse the items into an array indexed by category and compatible versions.
+  $items = array();
+  foreach ($xml->channel->item as $item) {
+    $category = (string) $item->category;
+    // In order to get fields in the 'tripal_extension' name space we must
+    // pass in the $namespace to the children function.  We first get the
+    // Tripal versions, then the chado versions and organize the elements
+    // accordintly.
+    $tvs = preg_split('/, /', (string) $item->children($namespace)->tripal_version);
+    foreach($tvs as $tv) {
+      $cvs = preg_split('/, /', (string) $item->children($namespace)->chado_version);
+      foreach($cvs as $cv) {
+        // Index the items by category, tripal version and chado version
+        $items[$tv][$cv][$category][] = $item;
+      }
+    }
+  }
+
+  // Get the Chado version and convert to the expected format
+  $chado_version = chado_get_version(TRUE);
+  $chado_version = preg_replace('/^(\d\.\d).*$/', "v$1x", $chado_version);
+
+  // Get the Tripal version. This is the version set in the tripal_core.info
+  $info = system_get_info('module', 'tripal_core');
+  $tripal_version = $info['version'];
+  $tripal_version = preg_replace('/^.*?-(\d\.\d+).*$/', "v$1", $tripal_version);
+
+  $form['type_select'] = array(
+    '#type' => 'select',
+    '#options' => array(
+      'Bulk Loader Templates' => 'Bulk Loader Templates',
+      'Materialized View' => 'Materialized View',
+      'Extension Module' => 'Extension Module',
+    ),
+    '#default_value' => 'Extension Module',
+  );
+
+  // Iterate through the compatible extensions
+  foreach ($items[$tripal_version][$chado_version] as $category) {
+     $markup = '';
+     switch ($category) {
+       case 'Bulk Loader Template':
+         break;
+       case 'Materialized View':
+         break;
+       case 'Extension Module':
+         break;
+       default:
+         break;
+     }
+  }
+
+  return $form;
+}
+
+function tripal_core_extensions_form_validate($form, &$form_state) {
+
+}
+
+function tripal_core_extensions_form_submit($form, &$form_state) {
+
+}

+ 1 - 4
tripal_core/tripal_core.install

@@ -529,14 +529,11 @@ function tripal_core_get_tripal_vars_schema() {
     ),
     ),
     'indexes' => array (
     'indexes' => array (
       'tripal_node_variables_idx1' => array (
       'tripal_node_variables_idx1' => array (
-        0 => 'node_variable_id',
-      ),
-      'tripal_node_variables_idx2' => array (
         0 => 'variable_id',
         0 => 'variable_id',
       ),
       ),
     ),
     ),
     'foreign keys' => array (
     'foreign keys' => array (
-      'tripal_terms' => array (
+      'tripal_variables' => array (
         'table' => 'tripal_variables',
         'table' => 'tripal_variables',
         'columns' => array (
         'columns' => array (
           'variable_id' => 'variable_id',
           'variable_id' => 'variable_id',

+ 24 - 14
tripal_core/tripal_core.module

@@ -37,7 +37,7 @@ require_once 'api/tripal_core.tripal_variables.api.inc';
 
 
 require_once 'api/tripal_core.DEPRECATED.inc';
 require_once 'api/tripal_core.DEPRECATED.inc';
 
 
-// INCLUDES 
+// INCLUDES
 require_once 'includes/tripal_core.jobs.inc';
 require_once 'includes/tripal_core.jobs.inc';
 require_once 'includes/tripal_core.mviews.inc';
 require_once 'includes/tripal_core.mviews.inc';
 require_once 'includes/tripal_core.custom_tables.inc';
 require_once 'includes/tripal_core.custom_tables.inc';
@@ -163,12 +163,22 @@ function tripal_core_menu() {
     'weight' => -4
     'weight' => -4
   );
   );
   $items['admin/tripal/extension'] = array(
   $items['admin/tripal/extension'] = array(
-    'title' => 'Extension Modules',
-    'description' => t('Configuration for Tripal extension modules.'),
+    'title' => 'Extensions',
+    'description' => t('Configuration for Tripal extensions.'),
     'access arguments' => array('administer tripal'),
     'access arguments' => array('administer tripal'),
     'type' => MENU_NORMAL_ITEM,
     'type' => MENU_NORMAL_ITEM,
     'weight' => 0
     'weight' => 0
   );
   );
+  $items['admin/tripal/extension/available'] = array(
+    'title' => 'Available Extensions',
+    'description' => 'Queries the tripal.info site to find extensions that may be compatible with this site.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_core_extensions_form'),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_LOCAL_TASK,
+    'file' =>  'includes/tripal_core.extensions.inc',
+    'file path' => drupal_get_path('module', 'tripal_core'),
+  );
 
 
   // Tripal Setup
   // Tripal Setup
   $items['admin/tripal/setup'] = array(
   $items['admin/tripal/setup'] = array(
@@ -366,7 +376,7 @@ function tripal_core_menu() {
     'access arguments' => array('access content'),
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK
     'type' => MENU_CALLBACK
   );
   );
-  
+
   // The node's TOC tab
   // The node's TOC tab
   $items['node/%node/tripal_toc'] = array(
   $items['node/%node/tripal_toc'] = array(
     'title' => 'TOC',
     'title' => 'TOC',
@@ -377,7 +387,7 @@ function tripal_core_menu() {
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'file' => '/includes/tripal_core.toc.inc',
     'file' => '/includes/tripal_core.toc.inc',
   );
   );
-  
+
   // Web Services API callbacks.
   // Web Services API callbacks.
 //   $items['ws/chado/v0.1'] = array(
 //   $items['ws/chado/v0.1'] = array(
 //     'title' => 'Tripal Web Services API v0.1',
 //     'title' => 'Tripal Web Services API v0.1',
@@ -401,7 +411,7 @@ function tripal_core_menu() {
  */
  */
 function tripal_core_access_node_toc_form($node) {
 function tripal_core_access_node_toc_form($node) {
   $types = module_invoke_all('node_info');
   $types = module_invoke_all('node_info');
-  if (array_key_exists($node->type, $types) and 
+  if (array_key_exists($node->type, $types) and
       array_key_exists('chado_node_api', $types[$node->type])) {
       array_key_exists('chado_node_api', $types[$node->type])) {
     return user_access('administer tripal');
     return user_access('administer tripal');
   }
   }
@@ -429,18 +439,18 @@ function tripal_core_permission() {
     ),
     ),
     'view dev helps' => array(
     'view dev helps' => array(
       'title' => t('View Developer Hints'),
       'title' => t('View Developer Hints'),
-      'description' => t('Tripal will provide blue shaded boxes that provide 
-          instructions for how to customize or setup specific pages on a 
-          site.  This permission should be enabled for developers. But can 
+      'description' => t('Tripal will provide blue shaded boxes that provide
+          instructions for how to customize or setup specific pages on a
+          site.  This permission should be enabled for developers. But can
           be disabled once developers are accustomed to these hints.'),
           be disabled once developers are accustomed to these hints.'),
       'restrict access' => TRUE,
       'restrict access' => TRUE,
     ),
     ),
     'view ids' => array(
     'view ids' => array(
       'title' => t('View Internal IDs'),
       'title' => t('View Internal IDs'),
       'description' => t('On content pages Tripal will typically provide
       'description' => t('On content pages Tripal will typically provide
-          a table of information pulled from the Chado database but the 
-          primary key IDs for that data is typically not shown.  The 
-          default Tripal templates can show the primary key ID inside of a 
+          a table of information pulled from the Chado database but the
+          primary key IDs for that data is typically not shown.  The
+          default Tripal templates can show the primary key ID inside of a
           blue shaded table row if this permission is enabled. This can
           blue shaded table row if this permission is enabled. This can
           be useful for site developers who might want these IDs when working
           be useful for site developers who might want these IDs when working
           with the underlying database.'),
           with the underlying database.'),
@@ -503,7 +513,7 @@ function tripal_core_theme($existing, $type, $theme, $path) {
       'function' => 'theme_tripal_admin_message',
       'function' => 'theme_tripal_admin_message',
       'variables' => array('message' => NULL),
       'variables' => array('message' => NULL),
     ),
     ),
-    
+
     // Form and form element themes.
     // Form and form element themes.
     // --------------------------------
     // --------------------------------
     'tripal_node_toc_items_table' => array(
     'tripal_node_toc_items_table' => array(
@@ -595,7 +605,7 @@ function tripal_core_node_view_alter(&$build) {
 
 
 /**
 /**
  * Implements hook_node_view()
  * Implements hook_node_view()
- * 
+ *
  * @ingroup tripal_core
  * @ingroup tripal_core
  */
  */
 function tripal_core_node_view($node, $view_mode, $langcode) {
 function tripal_core_node_view($node, $view_mode, $langcode) {