Quellcode durchsuchen

Merge branch '6.x-0.4-dev' of git.drupal.org:sandbox/spficklin/1337878 into 6.x-0.4-dev

spficklin vor 13 Jahren
Ursprung
Commit
d7a14510dd

+ 3 - 2
base/tripal_analysis/tripal_analysis.module

@@ -140,6 +140,7 @@ function tripal_analysis_node_info() {
  */
 function chado_analysis_insert($node){
 	global $user;
+
 	// Create a timestamp so we can insert it into the chado database
 	$time = $node->timeexecuted;
 	$month = $time['month'];
@@ -151,8 +152,8 @@ function chado_analysis_insert($node){
 	$analysis_id = $node->analysis_id;
 	if ($analysis_id) {
 		$sql = "SELECT analysis_id ".
-               "FROM {Analysis} ".
-               "WHERE analysis_id = %d ";
+             "FROM {Analysis} ".
+             "WHERE analysis_id = %d ";
 		$previous_db = tripal_db_set_active('chado');
 		$analysis = db_fetch_object(db_query($sql, $node->analysis_id));
 		tripal_db_set_active($previous_db);

+ 16 - 0
base/tripal_analysis/views/chado_analysis.views.inc

@@ -25,6 +25,22 @@ function retrieve_chado_analysis_views_data () {
   // Basic table definition
   $data['chado_analysis']['table'] = array(
     'field' => 'nid',
+    'group' => 'Chado Analysis'
+  );
+
+  $data['chado_analysis']['nid'] = array(
+    'title' => t('Analysis Node ID'),
+    'help' => t('The node ID for this analysis'),
+    'field' => array(
+     	'handler' => 'views_handler_field_numeric',
+ 		  'click sortable' => TRUE,
+    ),
+    'filter' => array(
+     	'handler' => 'views_handler_filter_numeric',
+    ),
+    'sort' => array(
+     	'handler' => 'views_handler_sort',
+    ),
   );
   
   // Note: No joins need to be made from $data['analysis']['table']

+ 148 - 25
base/tripal_core/mviews.php

@@ -30,7 +30,7 @@
  *
  * @ingroup tripal_mviews_api
  */
-function tripal_add_mview ($name,$modulename,$mv_table,$mv_specs,$indexed,$query,$special_index){
+function tripal_add_mview ($name,$modulename,$mv_table,$mv_specs,$indexed,$query,$special_index,$comment=NULL){
 
    $record = new stdClass();
    $record->name = $name;
@@ -41,6 +41,7 @@ function tripal_add_mview ($name,$modulename,$mv_table,$mv_specs,$indexed,$query
    $record->indexed = $indexed;
    $record->query = $query;
    $record->special_index = $special_index;
+   $record->comment = $comment;
 
    // add the record to the tripal_mviews table and if successful
    // create the new materialized view in the chado schema
@@ -54,12 +55,20 @@ function tripal_add_mview ($name,$modulename,$mv_table,$mv_specs,$indexed,$query
       }
       tripal_db_set_active($previous_db);  // now use drupal database
       
-      // now add the table for this view
+      // now construct the indexes
       $index = '';
       if($indexed){
-         $index = ", CONSTRAINT ". $mv_table . "_index UNIQUE ($indexed) ";
+        // add to the array of values
+        $vals = preg_split("/[\n,]+/",$indexed);
+        $index = '';
+        foreach ($vals as $field){
+           $field = trim($field);
+           $index .= "CREATE INDEX idx_${mv_table}_${field} ON $mv_table ($field);";
+        }
       }
-      $sql = "CREATE TABLE {$mv_table} ($mv_specs $index)"; 
+
+      // add the table to the database
+      $sql = "CREATE TABLE {$mv_table} ($mv_specs); $index"; 
       $previous_db = tripal_db_set_active('chado');  // use chado database
       $results = db_query($sql);
       tripal_db_set_active($previous_db);  // now use drupal database
@@ -74,6 +83,94 @@ function tripal_add_mview ($name,$modulename,$mv_table,$mv_specs,$indexed,$query
       }
    }
 }
+/**
+ * Edits a materialized view to the chado database to help speed data access.
+ *
+ * @param $mview_id 
+ *   The mview_id of the materialized view to edit
+ * @param $name 
+ *   The name of the materialized view.
+ * @param $modulename 
+ *   The name of the module submitting the materialized view (e.g. 'tripal_library')
+ * @param $mv_table 
+ *   The name of the table to add to chado. This is the table that can be queried.
+ * @param $mv_specs 
+ *   The table definition 
+ * @param $indexed 
+ *   The columns that are to be indexed
+ * @param $query 
+ *   The SQL query that loads the materialized view with data
+ * @param $special_index  
+ *   function
+ *
+ * @ingroup tripal_mviews_api
+ */
+function tripal_edit_mview ($mview_id,$name,$modulename,$mv_table,$mv_specs,$indexed,$query,$special_index,$comment){
+
+   $record = new stdClass();
+   $record->mview_id = $mview_id;
+   $record->name = $name;
+   $record->modulename = $modulename;
+   $record->mv_schema = 'DUMMY';
+   $record->mv_table = $mv_table;
+   $record->mv_specs = $mv_specs;
+   $record->indexed = $indexed;
+   $record->query = $query;
+   $record->special_index = $special_index;
+   $record->last_update = 0;
+   $record->status = '';
+   $record->comment = $comment;
+
+   // drop the table from chado if it exists
+   $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = $mview_id ";
+   $mview = db_fetch_object(db_query($sql));
+   $previous_db = tripal_db_set_active('chado');  // use chado database
+   if (db_table_exists($mview->mv_table)) {
+      $sql = "DROP TABLE $mview->mv_table";
+      db_query($sql);
+   }
+   tripal_db_set_active($previous_db);  // now use drupal database
+
+   // update the record to the tripal_mviews table and if successful
+   // create the new materialized view in the chado schema
+   if(drupal_write_record('tripal_mviews',$record,'mview_id')){
+
+      // drop the table from chado if it exists
+      $previous_db = tripal_db_set_active('chado');  // use chado database
+      if (db_table_exists($mv_table)) {
+         $sql = "DROP TABLE $mv_table";
+         db_query($sql);
+      }
+      tripal_db_set_active($previous_db);  // now use drupal database
+      
+      // now construct the indexes
+      $index = '';
+      if($indexed){
+        // add to the array of values
+        $vals = preg_split("/[\n,]+/",$indexed);
+        $index = '';
+        foreach ($vals as $field){
+           $field = trim($field);
+           $index .= "CREATE INDEX idx_${mv_table}_${field} ON $mv_table ($field);";
+        }
+      }
+
+      // recreate the view
+      $sql = "CREATE TABLE {$mv_table} ($mv_specs); $index"; 
+      $previous_db = tripal_db_set_active('chado');  // use chado database
+      $results = db_query($sql);
+      tripal_db_set_active($previous_db);  // now use drupal database
+      if($results){
+         drupal_set_message(t("View '$name' edited and saved.  All results cleared. Please re-populate the view."));
+      } else {
+         // if we failed to create the view in chado then
+         // remove the record from the tripal_jobs table
+         $sql = "DELETE FROM {tripal_mviews} ".
+                "WHERE mview_id = $record->mview_id";
+         db_query($sql);
+      }
+   }
+}
 /**
  * Retrieve the materialized view_id given the name
  *
@@ -116,7 +213,7 @@ function tripal_mviews_action ($op,$mview_id,$redirect=0){
    
    // add a job or perform the action based on the given operation
    if($op == 'update'){
-      tripal_add_job("Update materialized view '$mview->name'",'tripal_core',
+      tripal_add_job("Populate materialized view '$mview->name'",'tripal_core',
          'tripal_update_mview',$args,$user->uid);
 	}
    if($op == 'delete'){
@@ -157,14 +254,22 @@ function tripal_update_mview ($mview_id){
       $results = db_query("INSERT INTO $mview->mv_table ($mview->query)");
       tripal_db_set_active($previous_db);  // now use drupal database
       if($results){
+         $sql = "SELECT count(*) as cnt FROM $mview->mv_table";
+         $count = db_fetch_object(db_query($sql));
 	      $record = new stdClass();
          $record->mview_id = $mview_id;
          $record->last_update = time();
+         $record->status = "Populated with " . number_format($count->cnt) . " rows";
 		   drupal_write_record('tripal_mviews',$record,'mview_id');
 		   return 1;
       } else {
-	     // TODO -- error handling
-	     return 0;
+         # print and save the error message
+	      $record = new stdClass();
+         $record->mview_id = $mview_id;
+         $record->status = "ERROR populating. See Drupal's recent log entries for details.";
+         print $record->status . "\n";
+		   drupal_write_record('tripal_mviews',$record,'mview_id');
+	      return 0;
 	  }
    }
 }
@@ -247,7 +352,7 @@ function tripal_mview_report ($mview_id) {
    $edit_url = url("admin/tripal/mviews/edit/$mview->mview_id");
 
    $output .= "<tr><th>Actions</th>".
-              "<td> <a href='$update_url'>Update</a>, ".
+              "<td> <a href='$update_url'>Populate</a>, ".
               "     <a href='$edit_url'>Edit</a>, ".
               "     <a href='$delete_url'>Delete</a></td></tr>";
 
@@ -262,7 +367,7 @@ function tripal_mview_report ($mview_id) {
 */
 function tripal_mviews_report () {
 
-   $header = array('','MView Name','Last Update','');
+   $header = array('','MView Name','Last Update','Status','Description','');
    $rows = array();
 
    $mviews = db_query("SELECT * FROM {tripal_mviews} ORDER BY name");  
@@ -274,19 +379,24 @@ function tripal_mviews_report () {
       }
       $rows[] = array(
          l('View',"admin/tripal/mviews/report/$mview->mview_id") ." | ".
-            l('Update',"admin/tripal/mviews/action/update/$mview->mview_id"),
+         l('Edit',"admin/tripal/mviews/edit/$mview->mview_id") ." | ".
+         l('Populate',"admin/tripal/mviews/action/update/$mview->mview_id"),
          $mview->name,
          $update,
+         $mview->status,
+         $mview->comment,
          l('Delete',"admin/tripal/mviews/action/delete/$mview->mview_id"),
       );
    }
    $rows[] = array(
       'data' => array( 
          array('data' => l('Create a new materialized view.',"admin/tripal/mviews/new"), 
-               'colspan' => 4),
+               'colspan' => 6),
          )
    );
-   return theme('table', $header, $rows);
+   $page = theme('table', $header, $rows);
+
+   return $page;
 }
 /**
 *
@@ -298,15 +408,14 @@ function tripal_mviews_form(&$form_state = NULL,$mview_id = NULL){
    if(!$mview_id){
       $action = 'Add';
    } else {
-      $action = 'Update';
+      $action = 'Edit';
    }
 
    // get this requested view
-   if(strcmp($action,'Update')==0){
+   if(strcmp($action,'Edit')==0){
       $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = $mview_id ";
       $mview = db_fetch_object(db_query($sql));
 
-
       # set the default values.  If there is a value set in the 
       # form_state then let's use that, otherwise, we'll pull 
       # the values from the database 
@@ -316,6 +425,7 @@ function tripal_mviews_form(&$form_state = NULL,$mview_id = NULL){
       $default_indexed = $form_state['values']['indexed'];
       $default_mvquery = $form_state['values']['mvquery'];
       $default_special_index = $form_state['values']['special_index'];
+      $default_comment = $form_state['values']['cpmment'];
       if(!$default_name){
          $default_name = $mview->name;
       }
@@ -334,6 +444,9 @@ function tripal_mviews_form(&$form_state = NULL,$mview_id = NULL){
       if(!$default_special_index){
          $default_special_index = $mview->special_index;
       }
+      if(!$default_comment){
+         $default_comment = $mview->comment;
+      }
    }
    // Build the form
    $form['action'] = array(
@@ -395,10 +508,24 @@ function tripal_mviews_form(&$form_state = NULL,$mview_id = NULL){
       '#weight'        => 7
    );
 */
+   $form['comment']= array(
+      '#type'          => 'textarea',
+      '#title'         => t('MView Description'),
+      '#description'   => t('Optional.  Please provide a description of the purpose for this materialized vieww.'),
+      '#required'      => FALSE,
+      '#default_value' => $default_comment,
+      '#weight'        => 8
+   );
+   if($action == 'Edit'){
+      $value = 'Save';
+   }
+   if($action == 'Add'){
+      $value = 'Add';
+   }
    $form['submit'] = array (
      '#type'         => 'submit',
-     '#value'        => t($action),
-     '#weight'       => 8,
+     '#value'        => t($value),
+     '#weight'       => 9,
      '#executes_submit_callback' => TRUE,
    );
 
@@ -420,17 +547,13 @@ function tripal_mviews_form_submit($form, &$form_state){
    $indexed = $form_state['values']['indexed'];
    $query = $form_state['values']['mvquery'];
    $special_index = $form_state['values']['special_index'];
+   $comment = $form_state['values']['comment'];
 
-   if(strcmp($action,'Update')==0){
-      // updating the materialized view consits of deleting the old entry
-      // and readding.  This is necessary because a change to any of the fields
-      // other than the query changes the nature of table so it needs to be 
-      // rebuilt
-      tripal_mviews_action ('delete',$mview_id);
-      tripal_add_mview ($name, 'tripal_core',$mv_table, $mv_specs,$indexed,$query,$special_index);
+   if(strcmp($action,'Edit')==0){
+      tripal_edit_mview($mview_id,$name, 'tripal_core',$mv_table, $mv_specs,$indexed,$query,$special_index,$comment);
    }
    else if(strcmp($action,'Add')==0){
-      tripal_add_mview ($name, 'tripal_core',$mv_table, $mv_specs,$indexed,$query,$special_index);
+      tripal_add_mview ($name, 'tripal_core',$mv_table, $mv_specs,$indexed,$query,$special_index,$comment);
    }
    else {
         drupal_set_message("No action performed.");

+ 18 - 1
base/tripal_core/tripal_core.install

@@ -21,7 +21,22 @@ function tripal_core_install(){
   drupal_install_schema('tripal_core');
 
 }
-
+/**
+*  Update for Drupal 6.x, Tripal 0.4
+*  This update adjusts the materialized view by adding a 'cvterm_id' column
+*
+* @ingroup tripal_feature
+*/
+function tripal_core_update_6000(){
+   // recreate the materialized view
+   db_add_field($ret, 'tripal_mviews', 'status', array('type' => 'text', 'size' => 'normal', 'not null' => FALSE));
+   db_add_field($ret, 'tripal_mviews', 'comment', array('type' => 'text', 'size' => 'normal', 'not null' => FALSE));
+   $ret = array(
+      '#finished' => 1,
+   );
+   
+   return $ret;
+}
 /************************************************************************
 * Implementation of hook_schema().
 *
@@ -81,6 +96,8 @@ function tripal_core_mviews_schema(){
          'query'         => array('type' => 'text', 'size' => 'normal', 'not null' => TRUE),
          'special_index' => array('type' => 'text', 'size' => 'normal', 'not null' => FALSE),
          'last_update'   => array('type' => 'int', 'not null' => FALSE, 'description' => 'UNIX integer time'),
+         'status'        => array('type' => 'text', 'size' => 'normal', 'not null' => FALSE),
+         'comment'       => array('type' => 'text', 'size' => 'normal', 'not null' => FALSE),
       ),
       'indexes' => array(
          'mview_id' => array('mview_id')

+ 17 - 1
base/tripal_feature/views/chado_feature.views.inc

@@ -24,8 +24,24 @@ function retrieve_chado_feature_views_data () {
   // Basic table definition
   $data['chado_feature']['table'] = array(
     'field' => 'nid',
+    'group' => 'Chado Feature'
   );
   
+  $data['chado_feature']['nid'] = array(
+    'title' => t('Feature Node ID'),
+    'help' => t('The node ID for this feature'),
+    'field' => array(
+     	'handler' => 'views_handler_field_numeric',
+ 		  'click sortable' => TRUE,
+    ),
+    'filter' => array(
+     	'handler' => 'views_handler_filter_numeric',
+    ),
+    'sort' => array(
+     	'handler' => 'views_handler_sort',
+    ),
+  );
+
   // Note: No joins need to be made from $data['feature']['table']
   
   // Join the chado feature table to feature
@@ -78,6 +94,6 @@ function retrieve_chado_feature_views_data () {
       'base field' => 'nid'
     ),
   );
-  
+
 	return $data;
 }

+ 16 - 0
base/tripal_library/views/chado_library.views.inc

@@ -24,8 +24,24 @@ function retrieve_chado_library_views_data () {
   // Basic table definition
   $data['chado_library']['table'] = array(
     'field' => 'nid',
+    'group' => 'Chado Library'
   );
   
+  $data['chado_library']['nid'] = array(
+    'title' => t('Library Node ID'),
+    'help' => t('The node ID for this library'),
+    'field' => array(
+     	'handler' => 'views_handler_field_numeric',
+ 		  'click sortable' => TRUE,
+    ),
+    'filter' => array(
+     	'handler' => 'views_handler_filter_numeric',
+    ),
+    'sort' => array(
+     	'handler' => 'views_handler_sort',
+    ),
+  );
+
   // Note: No joins need to be made from $data['library']['table']
   
   // Join the chado library table to library

+ 18 - 2
base/tripal_organism/views/chado_organism.views.inc

@@ -24,8 +24,24 @@ function retrieve_chado_organism_views_data () {
   // Basic table definition
   $data['chado_organism']['table'] = array(
     'field' => 'nid',
+    'group' => 'Chado Organism'
   );
   
+  $data['chado_organism']['nid'] = array(
+    'title' => t('Organism Node ID'),
+    'help' => t('The node ID for this organism'),
+    'field' => array(
+     	'handler' => 'views_handler_field_numeric',
+ 		  'click sortable' => TRUE,
+    ),
+    'filter' => array(
+     	'handler' => 'views_handler_filter_numeric',
+    ),
+    'sort' => array(
+     	'handler' => 'views_handler_sort',
+    ),
+  );
+
   // Note: No joins need to be made from $data['organism']['table']
   
   // Join the chado organism table to organism
@@ -62,7 +78,7 @@ function retrieve_chado_organism_views_data () {
       'base field' => 'organism_id'
     ),
   );
-
+/*
   // Add node relationship to organism
   $data['chado_organism']['nid'] = array(
     'group' => 'Organism',
@@ -78,6 +94,6 @@ function retrieve_chado_organism_views_data () {
       'base field' => 'nid'
     ),
   );
-  
+*/  
 	return $data;
 }

+ 17 - 2
base/tripal_stock/views/chado_stock.views.inc

@@ -27,7 +27,22 @@ function retrieve_chado_stock_views_data () {
   // Basic table definition
   $data['chado_stock']['table'] = array(
     'field' => 'stock_id',
-    'group' => 'Chado Stock Node',
+    'group' => 'Chado Stock',
+  );
+
+  $data['chado_stock']['nid'] = array(
+    'title' => t('Stock Node ID'),
+    'help' => t('The node ID for this analysis'),
+    'field' => array(
+     	'handler' => 'views_handler_field_numeric',
+ 		  'click sortable' => TRUE,
+    ),
+    'filter' => array(
+     	'handler' => 'views_handler_filter_numeric',
+    ),
+    'sort' => array(
+     	'handler' => 'views_handler_sort',
+    ),
   );
   
   // Note: No joins need to be made from $data['stock']['table']
@@ -84,4 +99,4 @@ function retrieve_chado_stock_views_data () {
   );
   
 	return $data;
-}
+}

+ 4 - 0
base/tripal_views/tripal_views.module

@@ -2,6 +2,7 @@
 
 require_once "tripal_views_integration.inc";
 require_once "tripal_views.views.inc";
+require_once "tripal_views_form_elements.inc";
 
 /**
  * Implements hook_menu()
@@ -100,5 +101,8 @@ function tripal_views_theme () {
          'arguments' => array('form' => NULL),
          'template'  => 'tripal_views_data_export_download_form',
 	   ),
+      'file_upload_combo' => array(
+        'arguments' => array('element' => NULL)
+      ),
    );
 }

+ 20 - 6
base/tripal_views/tripal_views.views.inc

@@ -197,6 +197,12 @@ function tripal_views_views_pre_render	(&$view) {
 		// @see file: tripal_views.views.inc
 		tripal_views_add_node_ids_to_view ($view);
 		
+   // we want to add to the bottom of the views the form for downloading 
+   // results in other formats (e.g. Excel, FASTA, CSV, etc.).  The Views Data
+   // Export module provides small images at the bottom, but we want to provide
+   // a more intutitive interface for getting different file formats
+   $form = drupal_get_form('tripal_views_data_export_download_form',$view,$display_id,$args);
+   $view->attachment_after = $form;
 }
 
 /**
@@ -517,7 +523,6 @@ function tripal_views_views_data(){
         }
       }
     }
-//dpm($data);
     return $data;
 }
 /**
@@ -631,15 +636,18 @@ function tripal_views_views_pre_view(&$view,&$display_id,&$args){
    // file uploads require $_POST. We need to make sure these two modules
    // have access to everything needed for this view to work properlys
    $_GET = array_merge($_GET, $_POST);
-
-
+}
+/**
+ * Implementation of hook_views_pre_build().
+ */
+/*function tripal_views_views_pre_render(&$view, &$display_id, &$args){
    // we want to add to the bottom of the views the form for downloading 
    // results in other formats (e.g. Excel, FASTA, CSV, etc.).  The Views Data
    // Export module provides small images at the bottom, but we want to provide
    // a more intutitive interface for getting different file formats
    $form = drupal_get_form('tripal_views_data_export_download_form',$view,$display_id,$args);
    $view->attachment_after = $form;
-}
+}*/
 /**
  * 
  */
@@ -657,8 +665,14 @@ function tripal_views_data_export_download_form(&$form_state, $view,$display_id,
          if(!$default){
             $default = $display->id;
          }
-         // add the data export URL to the URLs array
-         $query = $view->get_exposed_input();
+         // add the data export URL to the URLs array.  We need to first unset
+         // the exposed_input for the view so we can repopulate that variable
+         // this is necessary if we're using the file_upload_combo 
+         // custom form element which adds the file_path variable to the $_GET after the
+         // view has populated the $view->exposed_input variable 
+         unset($view->exposed_input);
+         $query = $view->get_exposed_input();  // retrieves elements in $_GET array
+
          $path = $display->display_options['path'];
          $urls[$display->id]['path'] = $path;
          $urls[$display->id]['query'] = $query;

+ 72 - 0
base/tripal_views/tripal_views_form_elements.inc

@@ -0,0 +1,72 @@
+<?php
+
+/**
+ * Register form elements
+ */
+function tripal_views_elements() {
+
+   $type['file_upload_combo'] = array(
+      '#input' => TRUE,
+      '#process' => array('expand_file_upload_combo'),
+      '#element_validate' => array('file_upload_combo_validate'),
+   );
+   return $type;
+}
+/**
+ * 
+ */
+function expand_file_upload_combo ($element, $edit, $form_state, $complete_form) {
+
+	if (empty($element['#value'])) {
+    	$element['#value'] = array(
+         'items' => '',
+         'items_file' => '',
+         'file_path' => '',
+    	);
+  	}
+   //dpm($form_state);
+
+	$element['#tree'] = TRUE;
+
+	$parents = $element['#parents'];
+   $parents[] = 'items';
+   $element['items'] = array(
+      '#type' => 'textarea',
+		'#default_value' => $element['#value']['items'],
+   ); 
+	$parents = $element['#parents'];
+   $parents[] = 'items_file';
+   $element['items_file'] = array(
+      '#type' => 'file',
+      '#title' =>  'File upload',
+		'#default_value' => $element['#value']['items_file'],
+   ); 
+
+	$parents = $element['#parents'];
+   $parents[] = 'file_path';
+   $element['file_path'] = array(
+      '#type' => 'hidden',
+		'#default_value' => $element['#value']['file_path'],
+   );
+   return $element;
+}
+
+/**
+ * 
+ */
+function theme_file_upload_combo($element) {
+  	return theme('form_element', $element, '<div class="container-inline">'. $element['#children'] .'</div>');
+}
+
+/**
+ * 
+ */
+function file_upload_combo_validate($element,&$form) {
+    $file = file_save_upload($element['#name'],array());
+    if($file) {
+       $form['values'][$element['#name']]['file_path'] = $file->filepath;
+       // we need to add our file path to the $_GET element as if it were
+       // submitted along with the rest of the form 
+       $_GET[$element['#name']]['file_path'] = $file->filepath;
+    }
+}

+ 3 - 2
base/tripal_views/views/handlers/views_handler_filter_chado_select_string.inc

@@ -54,13 +54,14 @@ class views_handler_filter_chado_select_string extends views_handler_filter_stri
     } else {
       // Get Options
       if ($this->options['optional']) {
-        $options['<select '.$this->table.'>'] = '--None--';
+        //$options['<select '.$this->table.'>'] = '--None--';
         $options['All'] = '--Any--';
       }
       $results = tripal_core_chado_select(
         $this->table,
         array($this->field),
-        array()
+        array(),
+        array('order_by' => array($this->field => 'ASC'))
       );
       $max_length = 40;
       foreach ($results as $r) {

+ 22 - 24
base/tripal_views/views/handlers/views_handler_filter_file_upload.inc

@@ -25,22 +25,15 @@ class views_handler_filter_file_upload extends views_handler_filter {
   function value_form(&$form, &$form_state) {
     parent::value_form($form, $form_state);
     
-    // we'll provide a single text area for this field.
-    // in the exposed_form function we'll add in the file upload button
-    $form['value'] = array(
-       '#type' => 'textarea',
+    $this->value_form = array(
+       '#type' => 'file_upload_combo',
        '#title' => $this->options['expose']['label'],
        '#default_value' => $this->value,
        '#multiple' => FALSE,
        '#description' => t('Provide search values for ' . $this->options['expose']['label'] . 
          '. Please place each search item on a separate line or separated by commas.'),
-    ); 
-    $form[$this->options['field'] . '_upload'] = array(
-      '#type' => 'file',
-      '#title' => $this->options['expose']['label'] . ' File upload',
-      '#description' => t('Upload a file to provide search values for ' . $this->options['expose']['label'] . 
-         '. Please place each search item on a separate line.'),
     );
+    $form['value'] = &$this->value_form;
   }
 
   /**
@@ -81,40 +74,45 @@ class views_handler_filter_file_upload extends views_handler_filter {
    *
    */
   function query() {
-    $this->ensure_my_table();
-
+     $this->ensure_my_table();
      $field = "$this->table.$this->real_field";
+
+     // get the form element value
+     $value = $this->value[0];
+
+     // the form element value has sub values, so get those
+     $items =  $value['items'];
+     $file_path = $value['file_path'];
+
      $holders = array();
      $values = array();
 
      // get the file upload content if one has been provided
-     $file = file_save_upload($this->field.'_upload',array());
-     if($file){
-        $fh = fopen($file->filepath,'r');
-
+     if($file_path){
+        $fh = fopen($file_path,'r');
         while($line = fgets($fh)){
           $line = trim($line);
           $values[] = $line;
         }
      } 
      // if a file upload has not been provided then use the value in the textarea
-     if($this->value[0]){
-        $items = $this->value[0];
+     if($items){
+
         // remove extra spaces and new lines
         $items = preg_replace("/\s+,/",",",$items);
         $items = preg_replace("/\s+\n/","\n",$items);
         $items = preg_replace("/,\n/","\n",$items);
-        // add to the array of values
+
+        // in the event the user uploaded a file and provided items in the
+        // textbox then we need to merge these two lists
         $vals = preg_split("/[\n,]+/",$items);
         $values = array_merge($values,$vals);
      }
+     // iterate through all of the values and generate the corresponding
+     // sprintf style holders
      for($i = 0 ; $i < count($values); $i++){
         $values[$i] = trim($values[$i]);
-        if (preg_match('/^[\d\.]+$/',$values[$i])) {
-           $holders[] = '%d';
-        } else {
-           $holders[] = "'%s'";
-        }
+        $holders[] = "'%s'";
      }
      // if we have any values supplied then update the where clause for
      // the views query

+ 14 - 0
extensions/mainlab_search/mainlab_search.info

@@ -0,0 +1,14 @@
+name = Mainlab Searches
+description = Provides basic searching tools for a whole genome website. Allows for searching by gene (mRNA, unigene contig), homology, GO termrs, KEGG terms and InterPro terms.  This module was develoepd at the Main Bioinformatics Lab at Washington State University.
+core = 6.x
+project = mainlab_search
+package = Tripal Extensions
+dependencies[] = tripal_core
+dependencies[] = tripal_feature
+dependencies[] = tripal_analysis
+dependencies[] = tripal_organism
+dependencies[] = tripal_analysis_go
+dependencies[] = tripal_analysis_blast
+dependencies[] = tripal_analysis_interpro
+dependencies[] = tripal_analysis_kegg
+dependencies[] = tripal_views

+ 0 - 0
extensions/mainlab_search/mainlab_search.install


+ 0 - 0
extensions/mainlab_search/mainlab_search.module