Sfoglia il codice sorgente

Tripal: Bulk Loader -allow edit of record, specify not to insert record and sets default for new record name

laceysanderson 14 anni fa
parent
commit
82839d0e6f

+ 1 - 1
theme_tripal/tripal_bulk_loader/tripal_bulk_loader_modify_template_base_form.tpl.php

@@ -20,7 +20,7 @@
       $row[] = drupal_render($element['title']);
       $row[] = drupal_render($element['chado_table']);
       $row[] = drupal_render($element['new_priority']) . drupal_render($element['id']);
-      $row[] = drupal_render($element['submit-add_field']);
+      $row[] = drupal_render($element['submit-edit_record']) . '<br>' . drupal_render($element['submit-add_field']);
       $rows[] = array('data' => $row, 'class' => 'draggable');
     }
     

+ 267 - 22
tripal_bulk_loader/tripal_bulk_loader.admin.inc

@@ -160,6 +160,11 @@ function tripal_bulk_loader_modify_template_base_form ($form_state = NULL, $mode
             '#type' => 'hidden',
             '#value' => $priority,
           ),
+          'submit-edit_record' => array(
+            '#type' => 'submit',
+            '#name' => (string)$priority,
+            '#value' => 'Edit Record',
+          ),          
           'submit-add_field' => array(
             '#type' => 'submit',
             '#name' => (string)$priority,
@@ -327,6 +332,14 @@ function tripal_bulk_loader_modify_template_base_form_submit($form, &$form_state
       );
       drupal_goto('admin/tripal/tripal_bulk_loader_template/add_field', $query);    
     break;
+
+    case 'Edit Record':
+      $query = array(
+        'template_id'=> $form_state['storage']['template_id'], 
+        'record_id' => $form_state['clicked_button']['#name'],
+      );
+      drupal_goto('admin/tripal/tripal_bulk_loader_template/edit_record', $query);
+    break;
     
     case 'Add Field':
       $query = array(
@@ -373,6 +386,10 @@ function tripal_bulk_loader_modify_template_base_form_submit($form, &$form_state
 // Delete Template
 //////////////////////////////////////////////////////////////////////////////////////
 
+/**
+ * Delete Template Form
+ * This form allows admin to delete already existing templates
+ */
 function tripal_bulk_loader_delete_template_base_form () {
 	$form = array();
 
@@ -400,11 +417,35 @@ function tripal_bulk_loader_delete_template_base_form () {
 	return $form;
 }
 
+/**
+ * Delete Template Form Submit
+ *
+ * @param $form
+ *   The form that was submitted
+ * @param $form_state
+ *   The values and storage that were submitted
+ */
 function tripal_bulk_loader_delete_template_base_form_submit ($form, &$form_state) {
 	$sql = "DELETE FROM {tripal_bulk_loader_template} WHERE template_id=%d";
 	db_query($sql, $form_state['values']['template_name']);
 }
 
+/**
+ * Import/Export Template Form
+ *
+ * On export, simply selects the serialized array from the db for a given template 
+ * and presents it to the user. On import, a serialized template array and a name is 
+ * supplied and a template record is created.
+ *
+ * @todo Make array presented to the user more readable. (ie: unserialize and print to the screen)
+ *
+ * @param $form_state
+ *   The values and storage for the form
+ * @param $mode
+ *   Either 'import' or 'export' to indicate which function is being performed
+ * @return
+ *   A form array to be rendered by drupal_get_form
+ */
 function tripal_bulk_loader_import_export_template_form ($form_state = NULL, $mode) {
   $form = array();
 
@@ -456,13 +497,20 @@ function tripal_bulk_loader_import_export_template_form ($form_state = NULL, $mo
   return $form;
 }
 
+/**
+ * Import/Export Template Form Submit
+ *
+ * @param $form
+ *   The form that was submitted
+ * @param $form_state
+ *   The values and storage that were submitted
+ */
 function tripal_bulk_loader_import_export_template_form_submit ($form, &$form_state) {
   switch ($form_state['values']['mode']) {
     case 'export':
       $record = db_fetch_object(db_query("SELECT * FROM {tripal_bulk_loader_template} WHERE template_id=%d", $form_state['values']['template_id']));
       $form_state['storage']['template_array'] = $record->template_array;
       $form_state['storage']['template_id'] = $form_state['values']['template_id'];
-      dpm($record, 'record');
     break;
     case 'import':
       $record = array(
@@ -478,25 +526,213 @@ function tripal_bulk_loader_import_export_template_form_submit ($form, &$form_st
 }
 
 //////////////////////////////////////////////////////////////////////////////////////
-// Add/Edit Field Forms (meant to be returned as part of a larger form)
+// Add/Edit Field/Record Forms
 //////////////////////////////////////////////////////////////////////////////////////
 
+/**
+ * Edit Record Form
+ *
+ * This form is meant to be called from a bulk loader form. The following should be set 
+ * in the query section of the path:
+ *  - template_id=\d+: the template which the edited record is part of
+ *  - record_id=\d+: the priority or key in the template array of the record to be edited
+ *
+ * @param $form_state
+ *   Contains the values and storage for the form
+ * @return
+ *   A form array to be rendered by drupal_get_form
+ */
+function tripal_bulk_loader_edit_template_record_form (&$form_state = NULL) {
+ 	$form['#cache'] = TRUE; // Make sure the form is cached.
+  
+ 	// get template id from path
+ 	$template_id = ($_GET['template_id'] !== NULL) ? $_GET['template_id'] : $form_state['values']['template_id'];
+ 	
+ 	// if there is no template supplied don't return rest of form
+ 	if (!$template_id) {
+ 	  return $form;
+ 	}
+
+  // Pre-process values/defaults ---------------------------
+
+ 	// If this is the first load of the form (no form state) we need to initialize some variables
+ 	if (!$form_state['storage']['template']) {
+    $sql = "SELECT * FROM {tripal_bulk_loader_template} WHERE template_id=%d";
+    $template = db_fetch_object(db_query($sql, $template_id));
+    $form_state['storage']['template_array'] = unserialize($template->template_array);
+    $form_state['storage']['template'] = $template;
+    
+    $form_state['storage']['record2priority'] = array();
+    foreach ($form_state['storage']['template_array'] as $priority => $record_array) {
+      if (!is_array($record_array)) { continue; }
+      $form_state['storage']['record2priority'][$record_array['record_id']] = $priority;
+    }
+    
+    $form_state['storage']['referring URL'] = $_SERVER["HTTP_REFERER"];
+  } else {
+    $template = $form_state['storage']['template'];
+  }
+
+ 	// get the record_id from the path
+ 	if ($_GET['record_id'] !== NULL) {
+   	$form_state['values']['field_group'] = $_GET['record_id'];
+   	$form_state['storage']['original_priority'] = $_GET['record_id'];
+  }
+  
+  
+  // Tables and default table
+  $tables = tripal_core_get_chado_tables();
+  if ($form_state['values']['chado_table']) {
+    $table = $form_state['values']['chado_table'];
+  } else {
+    $table = $form_state['storage']['template_array'][$form_state['storage']['original_priority']]['table'];  
+  }
+
+  //dpm($form_state, 'form state');
+  
+ 	// Form Proper ------------------------------------------- 	
+  $form['template_name'] = array(
+    '#type' => 'item',
+    '#title' => 'Template',
+    '#value' => $template->name,
+  );
+
+  $form['template_id'] = array(
+    '#type' => 'hidden',
+    '#value' => $template_id,
+  );
+  
+  $form['edit_record'] = array(
+    '#type' => 'fieldset',
+  );
+
+  // check template array for records then add one more
+  if (!$form_state['storage']['record2priority']) { 
+    $groups = array();
+  } else {
+    $groups = array_flip($form_state['storage']['record2priority']);
+  }
+  $priority_default = $form_state['values']['field_group'];
+  $form['edit_record']['field_group']  = array(
+    '#type' => 'select',
+    '#title' => 'Record',
+    '#description' => 'By Changing the record here, you can move all the fields from the current record into the selected record.',
+    '#options' => $groups,
+    '#default_value' => $priority_default,
+    '#required' => TRUE,
+  );
+  
+  $form['edit_record']['record_name'] = array(
+    '#type' => 'textfield',
+    '#title' => 'Unique Record Name',
+    '#default_value' => $groups[$priority_default],
+  );
+
+  $form['edit_record']['chado_table'] = array(
+    '#type' => 'select',
+    '#title' => t('Chado Table'),
+    '#description' => 'This changes the chado table for all fields in this record.',
+    '#options' => $tables,
+    '#default_value' => $table,
+  );
+  
+  $form['edit_record']['mode'] = array(
+    '#type' => 'radios',
+    '#title' => 'Action to take when Loading Record',
+    '#options' => array(
+      'insert' => 'Insert the record if it doesn\'t already exist',
+      'select' => 'Don\'t insert this record: it\'s used to define a foreign key in another record',
+    ),
+    '#default_value' => 'insert'
+  );
+  
+  $form['edit_record']['submit-edit_record'] = array(
+      '#type' => 'submit',
+      '#value' => 'Edit Record'
+  );
+
+  $form['edit_record']['submit-cancel'] = array(
+      '#type' => 'submit',
+      '#value' => 'Cancel'
+  );
+  
+  return $form;
+}
+
+
+/**
+ * Edit Record Form Submit
+ *
+ * @param $form
+ *   The form that was submitted
+ * @param $form_state
+ *   Contains the values and storage for the form
+ */
+function tripal_bulk_loader_edit_template_record_form_submit ($form, &$form_state) {
+  //dpm($form_state, 'form state -start submit');
+  
+  if (!$form_state['ahah_submission']) {
+    if ($form_state['values']['op'] ==  'Edit Record') {
+
+      $template = $form_state['storage']['template_array'];
+      
+      // Edit Record
+      $record = $template[ $form_state['storage']['original_priority'] ];
+      $record['record_id'] = $form_state['values']['record_name'];
+      $record['mode'] = $form_state['values']['mode'];
+      $record['table'] = $form_state['values']['chado_table'];
+      
+      if ($form_state['storage']['original_priority'] != $form_state['values']['field_group']) {
+        $record['fields'] = array_merge($record['fields'], $template[ $form_state['values']['field_group'] ]['fields']);
+        $template[ $form_state['values']['field_group'] ] = $record;
+        unset($template[ $form_state['storage']['original_priority'] ]);
+      } else {
+        $template[ $form_state['storage']['original_priority'] ] = $record;
+      }
+
+      // Save Template
+      $form_state['storage']['template']->template_array = serialize($template);
+      $success = drupal_write_record('tripal_bulk_loader_template', $form_state['storage']['template'], array('template_id'));
+  
+      if ($success) {
+        drupal_set_message('Successfully Updated Template Record');
+        drupal_set_message('Template Saved.'); 
+        
+        $path = explode('?',$form_state['storage']['referring URL']);
+        parse_str($path[1], $query);
+        $query['template_id'] = $form_state['storage']['template']->template_id;
+        drupal_goto($path[0], $query);
+      } else {
+        drupal_set_message('Unable to Save Template!', 'error');
+        watchdog('T_bulk_loader',
+          'Unable to save bulk loader template: %template',
+          array('%template' => print_r($form_state['storage']['template'], TRUE)),
+          WATCHDOG_ERROR
+        );
+      }
+    } elseif ($form_state['values']['op'] ==  'Cancel') {
+        $path = explode('?',$form_state['storage']['referring URL']);
+        parse_str($path[1], $query);
+        $query['template_id'] = $form_state['storage']['template']->template_id;
+        //dpm('Redirecting to: '.$path[0].'?'.print_r($query,TRUE).' where the referring URL:'.$form_state['storage']['referring URL']);
+        drupal_goto($path[0], $query);    
+    }
+  }  
+  
+}
+
 /**
  * Add Field Form
  *
- * This form meant to be part of a larger form. Currently it is part of the following:
- *  - tripal_bulk_loader_add_template_base_form
- *  - tripal_bulk_loader_edit_template_base_form
+ * This form is meant to be called from a bulk loader form. Blank Defaults are in place but you
+ * can use the following in the query of the path to set defaults for a given template:
+ *  - template_id=\d+: the template to add the field to
+ *  - record_id=\d+: the priority or key in the template array of the record to add the field to
  * 
  * @param $form_state
- *   The $form_state from the parent form
+ *   Contains the values and storage for the form
  * @return
- *   The parent form with the edit field fieldset added
- *
- * Usage:
- * @code
-    $form = array_merge($form, tripal_bulk_loader_add_template_field_form($form_state));
- * @endcode
+ *   A form array to be rendered by drupal_get_form
  */
 function tripal_bulk_loader_add_template_field_form (&$form_state = NULL) {
   $form = array();
@@ -551,7 +787,7 @@ function tripal_bulk_loader_add_template_field_form (&$form_state = NULL) {
   }
 
  	// get the record_id from the path
- 	if ($_GET['record_id']) {
+ 	if ($_GET['record_id'] !== NULL) {
    	$form_state['values']['field_group'] = $_GET['record_id'];
     if (preg_match('/\d+/', $_GET['record_id'])) {
       $priority = $form_state['values']['field_group'];
@@ -676,6 +912,7 @@ function tripal_bulk_loader_add_template_field_form (&$form_state = NULL) {
     '#title' => 'Unique Record Name',
     '#prefix' => '<div id="tripal_bulk_loader_template-add_record">',
     '#suffix' => '</div>',
+    '#default_value' => $form_state['values']['record_name'],
   );
   
   $form['add_fields']['field_title'] = array(
@@ -785,11 +1022,10 @@ function tripal_bulk_loader_add_template_field_form (&$form_state = NULL) {
 /**
  * Add Field Submit
  * 
+ * @param $form
+ *   The form that was submitted
  * @param $form_state
- *   The $form_state from the parent submit
- * @return
- *   The parent form_state with any changes made
- *
+ *   The values and storage for the form
  */
 function tripal_bulk_loader_add_template_field_form_submit ($form, &$form_state) {
   
@@ -879,11 +1115,19 @@ function tripal_bulk_loader_add_template_field_form_submit ($form, &$form_state)
 
 /**
  * Edit Field Form
+ *
+ * This form is meant to be called from a bulk loader form. The following should be set 
+ * in the query section of the path:
+ *  - template_id=\d+: the template which the edited field is part of
+ *  - record_id=\d+: the priority or key in the template array of the record the field 
+ *      is currently part of
+ *  - field_index=\d+: the key of the field in the fields array of the previously
+ *      specified record
  * 
  * @param $form_state
- *   The $form_state from the parent form
+ *   Contains the values and storage for the form
  * @return
- *   The parent form with the edit field fieldset added
+ *   A form array to be rendered by drupal_get_form
  */
 function tripal_bulk_loader_edit_template_field_form (&$form_state = NULL) {
   $form = array();
@@ -1045,6 +1289,7 @@ function tripal_bulk_loader_edit_template_field_form (&$form_state = NULL) {
     '#title' => 'Unique Record Name',
     '#prefix' => '<div id="tripal_bulk_loader_template-edit_record">',
     '#suffix' => '</div>',
+    '#default_value' => $form_state['values']['record_name'],
   );
   
   $form['edit_fields']['field_title'] = array(
@@ -1155,10 +1400,10 @@ function tripal_bulk_loader_edit_template_field_form (&$form_state = NULL) {
 /**
  * Edit Field Form Submit
  * 
+ * @param $form
+ *   The form that was submitted
  * @param $form_state
- *   The $form_state from the parent form
- * @return
- *   The parent form with the edit field fieldset added
+ *   The values and storage for the form
  */
 function tripal_bulk_loader_edit_template_field_form_submit ($form, &$form_state) {
 

+ 10 - 0
tripal_bulk_loader/tripal_bulk_loader.module

@@ -33,6 +33,7 @@ function tripal_bulk_loader_menu() {
       'type' => MENU_NORMAL_ITEM,   
 		  'file' => 'tripal_bulk_loader.admin.inc',
 	);
+	// Create/Edit Template -------
   $items['admin/tripal/tripal_bulk_loader_template/create'] = array(
       'title' => 'Create Bulk Loader Template',
       'description' => 'Create loader template for loading tab-delimited data',
@@ -51,6 +52,15 @@ function tripal_bulk_loader_menu() {
       'type' => MENU_NORMAL_ITEM,   
 		  'file' => 'tripal_bulk_loader.admin.inc',  
   );
+	$items['admin/tripal/tripal_bulk_loader_template/edit_record'] = array(
+      'title' => 'Edit Template Record',
+      'description' => 'Edit a record in an existing tripal bulk loader template.',
+      'page callback' => 'drupal_get_form',
+      'page arguments' => array('tripal_bulk_loader_edit_template_record_form'),
+      'access arguments' => array('administer site configuration'),
+      'type' => MENU_CALLBACK,   
+		'file' => 'tripal_bulk_loader.admin.inc',
+	);
 	$items['admin/tripal/tripal_bulk_loader_template/add_field'] = array(
       'title' => 'Add Template Field',
       'description' => 'Add a template field to an existing tripal bulk loader template.',

+ 354 - 354
tripal_stock/tripal_stock.views.inc

@@ -184,376 +184,376 @@ function tripal_stock_views_pre_render	(&$view) {
 function tripal_stock_views_default_views() {
   $views = array();
   
-$view = new view;
-$view->name = 'all_stocks';
-$view->description = 'This view lists all stocks by default. There are exposed filters available but no arguments are used.';
-$view->tag = 'chado';
-$view->view_php = '';
-$view->base_table = 'stock';
-$view->is_cacheable = FALSE;
-$view->api_version = 2;
-$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
-$handler = $view->new_display('default', 'Defaults', 'default');
-$handler->override_option('fields', array(
-  'uniquename' => array(
-    'label' => 'Unique Name',
-    'alter' => array(
-      'alter_text' => 0,
-      'text' => '',
-      'make_link' => 0,
-      'path' => '',
-      'link_class' => '',
-      'alt' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'target' => '',
-      'help' => '',
-      'trim' => 0,
-      'max_length' => '',
-      'word_boundary' => 1,
-      'ellipsis' => 1,
-      'html' => 0,
-      'strip_tags' => 0,
-    ),
-    'empty' => '',
-    'hide_empty' => 0,
-    'empty_zero' => 0,
-    'link_to_node' => 1,
-    'exclude' => 0,
-    'id' => 'uniquename',
-    'table' => 'stock',
-    'field' => 'uniquename',
-    'relationship' => 'none',
-  ),
-  'name_2' => array(
-    'label' => 'Name',
-    'alter' => array(
-      'alter_text' => 0,
-      'text' => '',
-      'make_link' => 0,
-      'path' => '',
-      'link_class' => '',
-      'alt' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'target' => '',
-      'help' => '',
-      'trim' => 0,
-      'max_length' => '',
-      'word_boundary' => 1,
-      'ellipsis' => 1,
-      'html' => 0,
-      'strip_tags' => 0,
-    ),
-    'empty' => '',
-    'hide_empty' => 0,
-    'empty_zero' => 0,
-    'link_to_node' => 1,
-    'exclude' => 0,
-    'id' => 'name_2',
-    'table' => 'stock',
-    'field' => 'name',
-    'relationship' => 'none',
-  ),
-  'name' => array(
-    'label' => 'Type',
-    'alter' => array(
-      'alter_text' => 0,
-      'text' => '',
-      'make_link' => 0,
-      'path' => '',
-      'link_class' => '',
-      'alt' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'target' => '',
-      'help' => '',
-      'trim' => 0,
-      'max_length' => '',
-      'word_boundary' => 1,
-      'ellipsis' => 1,
-      'html' => 0,
-      'strip_tags' => 0,
-    ),
-    'empty' => '',
-    'hide_empty' => 0,
-    'empty_zero' => 0,
-    'exclude' => 0,
-    'id' => 'name',
-    'table' => 'cvterm',
-    'field' => 'name',
-    'relationship' => 'none',
-  ),
-  'common_name' => array(
-    'label' => 'Organism',
-    'alter' => array(
-      'alter_text' => 0,
-      'text' => '',
-      'make_link' => 0,
-      'path' => '',
-      'link_class' => '',
-      'alt' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'target' => '',
-      'help' => '',
-      'trim' => 0,
-      'max_length' => '',
-      'word_boundary' => 1,
-      'ellipsis' => 1,
-      'html' => 0,
-      'strip_tags' => 0,
-    ),
-    'empty' => '',
-    'hide_empty' => 0,
-    'empty_zero' => 0,
-    'link_to_node' => 1,
-    'exclude' => 0,
-    'id' => 'common_name',
-    'table' => 'organism',
-    'field' => 'common_name',
-    'relationship' => 'none',
-  ),
-  'all_dbxref' => array(
-    'label' => 'All Database References',
-    'alter' => array(
-      'alter_text' => 0,
-      'text' => '',
-      'make_link' => 0,
-      'path' => '',
-      'link_class' => '',
-      'alt' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'target' => '',
-      'help' => '',
-      'trim' => 0,
-      'max_length' => '',
-      'word_boundary' => 1,
-      'ellipsis' => 1,
-      'html' => 0,
-      'strip_tags' => 0,
+  $view = new view;
+  $view->name = 'all_stocks';
+  $view->description = 'This view lists all stocks by default. There are exposed filters available but no arguments are used.';
+  $view->tag = 'chado';
+  $view->view_php = '';
+  $view->base_table = 'stock';
+  $view->is_cacheable = FALSE;
+  $view->api_version = 2;
+  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+  $handler = $view->new_display('default', 'Defaults', 'default');
+  $handler->override_option('fields', array(
+    'uniquename' => array(
+      'label' => 'Unique Name',
+      'alter' => array(
+        'alter_text' => 0,
+        'text' => '',
+        'make_link' => 0,
+        'path' => '',
+        'link_class' => '',
+        'alt' => '',
+        'prefix' => '',
+        'suffix' => '',
+        'target' => '',
+        'help' => '',
+        'trim' => 0,
+        'max_length' => '',
+        'word_boundary' => 1,
+        'ellipsis' => 1,
+        'html' => 0,
+        'strip_tags' => 0,
+      ),
+      'empty' => '',
+      'hide_empty' => 0,
+      'empty_zero' => 0,
+      'link_to_node' => 1,
+      'exclude' => 0,
+      'id' => 'uniquename',
+      'table' => 'stock',
+      'field' => 'uniquename',
+      'relationship' => 'none',
     ),
-    'empty' => '',
-    'hide_empty' => 0,
-    'empty_zero' => 0,
-    'type' => 'ul',
-    'separator' => ', ',
-    'exclude' => 0,
-    'id' => 'all_dbxref',
-    'table' => 'stock',
-    'field' => 'all_dbxref',
-    'relationship' => 'none',
-  ),
-  'all_properties' => array(
-    'label' => 'All Properties',
-    'alter' => array(
-      'alter_text' => 0,
-      'text' => '',
-      'make_link' => 0,
-      'path' => '',
-      'link_class' => '',
-      'alt' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'target' => '',
-      'help' => '',
-      'trim' => 0,
-      'max_length' => '',
-      'word_boundary' => 1,
-      'ellipsis' => 1,
-      'html' => 0,
-      'strip_tags' => 0,
+    'name_2' => array(
+      'label' => 'Name',
+      'alter' => array(
+        'alter_text' => 0,
+        'text' => '',
+        'make_link' => 0,
+        'path' => '',
+        'link_class' => '',
+        'alt' => '',
+        'prefix' => '',
+        'suffix' => '',
+        'target' => '',
+        'help' => '',
+        'trim' => 0,
+        'max_length' => '',
+        'word_boundary' => 1,
+        'ellipsis' => 1,
+        'html' => 0,
+        'strip_tags' => 0,
+      ),
+      'empty' => '',
+      'hide_empty' => 0,
+      'empty_zero' => 0,
+      'link_to_node' => 1,
+      'exclude' => 0,
+      'id' => 'name_2',
+      'table' => 'stock',
+      'field' => 'name',
+      'relationship' => 'none',
     ),
-    'empty' => '',
-    'hide_empty' => 0,
-    'empty_zero' => 0,
-    'type' => 'ul',
-    'separator' => ', ',
-    'exclude' => 0,
-    'id' => 'all_properties',
-    'table' => 'stock',
-    'field' => 'all_properties',
-    'relationship' => 'none',
-  ),
-  'all_relationships' => array(
-    'label' => 'All Relationships',
-    'alter' => array(
-      'alter_text' => 0,
-      'text' => '',
-      'make_link' => 0,
-      'path' => '',
-      'link_class' => '',
-      'alt' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'target' => '',
-      'help' => '',
-      'trim' => 0,
-      'max_length' => '',
-      'word_boundary' => 1,
-      'ellipsis' => 1,
-      'html' => 0,
-      'strip_tags' => 0,
+    'name' => array(
+      'label' => 'Type',
+      'alter' => array(
+        'alter_text' => 0,
+        'text' => '',
+        'make_link' => 0,
+        'path' => '',
+        'link_class' => '',
+        'alt' => '',
+        'prefix' => '',
+        'suffix' => '',
+        'target' => '',
+        'help' => '',
+        'trim' => 0,
+        'max_length' => '',
+        'word_boundary' => 1,
+        'ellipsis' => 1,
+        'html' => 0,
+        'strip_tags' => 0,
+      ),
+      'empty' => '',
+      'hide_empty' => 0,
+      'empty_zero' => 0,
+      'exclude' => 0,
+      'id' => 'name',
+      'table' => 'cvterm',
+      'field' => 'name',
+      'relationship' => 'none',
     ),
-    'empty' => '',
-    'hide_empty' => 0,
-    'empty_zero' => 0,
-    'type' => 'ul',
-    'separator' => ', ',
-    'exclude' => 0,
-    'id' => 'all_relationships',
-    'table' => 'stock',
-    'field' => 'all_relationships',
-    'relationship' => 'none',
-  ),
-));
-$handler->override_option('sorts', array(
-  'common_name' => array(
-    'order' => 'ASC',
-    'id' => 'common_name',
-    'table' => 'organism',
-    'field' => 'common_name',
-    'relationship' => 'none',
-  ),
-  'uniquename' => array(
-    'order' => 'ASC',
-    'id' => 'uniquename',
-    'table' => 'stock',
-    'field' => 'uniquename',
-    'relationship' => 'none',
-  ),
-));
-$handler->override_option('filters', array(
-  'common_name' => array(
-    'operator' => '=',
-    'value' => 'All',
-    'group' => '0',
-    'exposed' => TRUE,
-    'expose' => array(
-      'use_operator' => 0,
-      'operator' => 'common_name_op',
-      'identifier' => 'organism_common_name',
+    'common_name' => array(
       'label' => 'Organism',
-      'optional' => 1,
-      'remember' => 0,
+      'alter' => array(
+        'alter_text' => 0,
+        'text' => '',
+        'make_link' => 0,
+        'path' => '',
+        'link_class' => '',
+        'alt' => '',
+        'prefix' => '',
+        'suffix' => '',
+        'target' => '',
+        'help' => '',
+        'trim' => 0,
+        'max_length' => '',
+        'word_boundary' => 1,
+        'ellipsis' => 1,
+        'html' => 0,
+        'strip_tags' => 0,
+      ),
+      'empty' => '',
+      'hide_empty' => 0,
+      'empty_zero' => 0,
+      'link_to_node' => 1,
+      'exclude' => 0,
+      'id' => 'common_name',
+      'table' => 'organism',
+      'field' => 'common_name',
+      'relationship' => 'none',
+    ),
+    'all_dbxref' => array(
+      'label' => 'All Database References',
+      'alter' => array(
+        'alter_text' => 0,
+        'text' => '',
+        'make_link' => 0,
+        'path' => '',
+        'link_class' => '',
+        'alt' => '',
+        'prefix' => '',
+        'suffix' => '',
+        'target' => '',
+        'help' => '',
+        'trim' => 0,
+        'max_length' => '',
+        'word_boundary' => 1,
+        'ellipsis' => 1,
+        'html' => 0,
+        'strip_tags' => 0,
+      ),
+      'empty' => '',
+      'hide_empty' => 0,
+      'empty_zero' => 0,
+      'type' => 'ul',
+      'separator' => ', ',
+      'exclude' => 0,
+      'id' => 'all_dbxref',
+      'table' => 'stock',
+      'field' => 'all_dbxref',
+      'relationship' => 'none',
     ),
-    'case' => 1,
-    'id' => 'common_name',
-    'table' => 'organism',
-    'field' => 'common_name',
-    'relationship' => 'none',
-  ),
-  'name' => array(
-    'operator' => '=',
-    'value' => 'All',
-    'group' => '0',
-    'exposed' => TRUE,
-    'expose' => array(
-      'use_operator' => 0,
-      'operator' => 'name_op',
-      'identifier' => 'name',
-      'label' => 'Chado CV Terms: Name',
-      'optional' => 1,
-      'remember' => 0,
+    'all_properties' => array(
+      'label' => 'All Properties',
+      'alter' => array(
+        'alter_text' => 0,
+        'text' => '',
+        'make_link' => 0,
+        'path' => '',
+        'link_class' => '',
+        'alt' => '',
+        'prefix' => '',
+        'suffix' => '',
+        'target' => '',
+        'help' => '',
+        'trim' => 0,
+        'max_length' => '',
+        'word_boundary' => 1,
+        'ellipsis' => 1,
+        'html' => 0,
+        'strip_tags' => 0,
+      ),
+      'empty' => '',
+      'hide_empty' => 0,
+      'empty_zero' => 0,
+      'type' => 'ul',
+      'separator' => ', ',
+      'exclude' => 0,
+      'id' => 'all_properties',
+      'table' => 'stock',
+      'field' => 'all_properties',
+      'relationship' => 'none',
     ),
-    'case' => 1,
-    'id' => 'name',
-    'table' => 'cvterm',
-    'field' => 'name',
-    'relationship' => 'none',
-  ),
-  'status' => array(
-    'operator' => '=',
-    'value' => '1',
-    'group' => '0',
-    'exposed' => FALSE,
-    'expose' => array(
-      'operator' => FALSE,
-      'label' => '',
+    'all_relationships' => array(
+      'label' => 'All Relationships',
+      'alter' => array(
+        'alter_text' => 0,
+        'text' => '',
+        'make_link' => 0,
+        'path' => '',
+        'link_class' => '',
+        'alt' => '',
+        'prefix' => '',
+        'suffix' => '',
+        'target' => '',
+        'help' => '',
+        'trim' => 0,
+        'max_length' => '',
+        'word_boundary' => 1,
+        'ellipsis' => 1,
+        'html' => 0,
+        'strip_tags' => 0,
+      ),
+      'empty' => '',
+      'hide_empty' => 0,
+      'empty_zero' => 0,
+      'type' => 'ul',
+      'separator' => ', ',
+      'exclude' => 0,
+      'id' => 'all_relationships',
+      'table' => 'stock',
+      'field' => 'all_relationships',
+      'relationship' => 'none',
     ),
-    'id' => 'status',
-    'table' => 'node',
-    'field' => 'status',
-    'override' => array(
-      'button' => 'Override',
+  ));
+  $handler->override_option('sorts', array(
+    'common_name' => array(
+      'order' => 'ASC',
+      'id' => 'common_name',
+      'table' => 'organism',
+      'field' => 'common_name',
+      'relationship' => 'none',
     ),
-    'relationship' => 'none',
-  ),
-));
-$handler->override_option('access', array(
-  'type' => 'perm',
-  'perm' => 'access chado_stock content',
-));
-$handler->override_option('cache', array(
-  'type' => 'none',
-));
-$handler->override_option('title', 'Stocks');
-$handler->override_option('empty', 'There are no stocks that match this criteria. If you think there should be, ensure that all stocks in chado are sync\'d with your website.');
-$handler->override_option('empty_format', '1');
-$handler->override_option('items_per_page', 25);
-$handler->override_option('use_pager', '1');
-$handler->override_option('style_plugin', 'table');
-$handler->override_option('style_options', array(
-  'grouping' => '',
-  'override' => 1,
-  'sticky' => 0,
-  'order' => 'asc',
-  'columns' => array(
-    'uniquename' => 'uniquename',
-    'name_2' => 'name_2',
-    'name' => 'name',
-    'common_name' => 'common_name',
-    'all_dbxref' => 'all_dbxref',
-    'all_properties' => 'all_properties',
-    'all_relationships' => 'all_relationships',
-  ),
-  'info' => array(
     'uniquename' => array(
-      'sortable' => 1,
-      'separator' => '',
+      'order' => 'ASC',
+      'id' => 'uniquename',
+      'table' => 'stock',
+      'field' => 'uniquename',
+      'relationship' => 'none',
     ),
-    'name_2' => array(
-      'sortable' => 1,
-      'separator' => '',
+  ));
+  $handler->override_option('filters', array(
+    'common_name' => array(
+      'operator' => '=',
+      'value' => 'All',
+      'group' => '0',
+      'exposed' => TRUE,
+      'expose' => array(
+        'use_operator' => 0,
+        'operator' => 'common_name_op',
+        'identifier' => 'organism_common_name',
+        'label' => 'Organism',
+        'optional' => 1,
+        'remember' => 0,
+      ),
+      'case' => 1,
+      'id' => 'common_name',
+      'table' => 'organism',
+      'field' => 'common_name',
+      'relationship' => 'none',
     ),
     'name' => array(
-      'sortable' => 1,
-      'separator' => '',
+      'operator' => '=',
+      'value' => 'All',
+      'group' => '0',
+      'exposed' => TRUE,
+      'expose' => array(
+        'use_operator' => 0,
+        'operator' => 'name_op',
+        'identifier' => 'name',
+        'label' => 'Chado CV Terms: Name',
+        'optional' => 1,
+        'remember' => 0,
+      ),
+      'case' => 1,
+      'id' => 'name',
+      'table' => 'cvterm',
+      'field' => 'name',
+      'relationship' => 'none',
     ),
-    'common_name' => array(
-      'sortable' => 1,
-      'separator' => '',
+    'status' => array(
+      'operator' => '=',
+      'value' => '1',
+      'group' => '0',
+      'exposed' => FALSE,
+      'expose' => array(
+        'operator' => FALSE,
+        'label' => '',
+      ),
+      'id' => 'status',
+      'table' => 'node',
+      'field' => 'status',
+      'override' => array(
+        'button' => 'Override',
+      ),
+      'relationship' => 'none',
     ),
-    'all_dbxref' => array(
-      'separator' => '',
+  ));
+  $handler->override_option('access', array(
+    'type' => 'perm',
+    'perm' => 'access chado_stock content',
+  ));
+  $handler->override_option('cache', array(
+    'type' => 'none',
+  ));
+  $handler->override_option('title', 'Stocks');
+  $handler->override_option('empty', 'There are no stocks that match this criteria. If you think there should be, ensure that all stocks in chado are sync\'d with your website.');
+  $handler->override_option('empty_format', '1');
+  $handler->override_option('items_per_page', 25);
+  $handler->override_option('use_pager', '1');
+  $handler->override_option('style_plugin', 'table');
+  $handler->override_option('style_options', array(
+    'grouping' => '',
+    'override' => 1,
+    'sticky' => 0,
+    'order' => 'asc',
+    'columns' => array(
+      'uniquename' => 'uniquename',
+      'name_2' => 'name_2',
+      'name' => 'name',
+      'common_name' => 'common_name',
+      'all_dbxref' => 'all_dbxref',
+      'all_properties' => 'all_properties',
+      'all_relationships' => 'all_relationships',
     ),
-    'all_properties' => array(
-      'separator' => '',
-    ),
-    'all_relationships' => array(
-      'separator' => '',
+    'info' => array(
+      'uniquename' => array(
+        'sortable' => 1,
+        'separator' => '',
+      ),
+      'name_2' => array(
+        'sortable' => 1,
+        'separator' => '',
+      ),
+      'name' => array(
+        'sortable' => 1,
+        'separator' => '',
+      ),
+      'common_name' => array(
+        'sortable' => 1,
+        'separator' => '',
+      ),
+      'all_dbxref' => array(
+        'separator' => '',
+      ),
+      'all_properties' => array(
+        'separator' => '',
+      ),
+      'all_relationships' => array(
+        'separator' => '',
+      ),
     ),
-  ),
-  'default' => '-1',
-));
-$handler = $view->new_display('page', 'Page', 'page_1');
-$handler->override_option('path', 'stocks');
-$handler->override_option('menu', array(
-  'type' => 'normal',
-  'title' => 'Stocks',
-  'description' => 'A full listing of all chado stocks',
-  'weight' => '0',
-  'name' => 'primary-links',
-));
-$handler->override_option('tab_options', array(
-  'type' => 'none',
-  'title' => '',
-  'description' => '',
-  'weight' => 0,
-  'name' => 'navigation',
-));
-$views[$view->name] = $view;  
+    'default' => '-1',
+  ));
+  $handler = $view->new_display('page', 'Page', 'page_1');
+  $handler->override_option('path', 'stocks');
+  $handler->override_option('menu', array(
+    'type' => 'normal',
+    'title' => 'Stocks',
+    'description' => 'A full listing of all chado stocks',
+    'weight' => '0',
+    'name' => 'primary-links',
+  ));
+  $handler->override_option('tab_options', array(
+    'type' => 'none',
+    'title' => '',
+    'description' => '',
+    'weight' => 0,
+    'name' => 'navigation',
+  ));
+  $views[$view->name] = $view;  
   
   return $views;
 }