Ver código fonte

Stock: Added default admin view for new UI

Lacey Sanderson 11 anos atrás
pai
commit
6d483419b9

+ 59 - 25
tripal_stock/includes/tripal_stock.admin.inc

@@ -4,6 +4,40 @@
  * @todo Add file header description
  * @todo Add file header description
  */
  */
 
 
+/**
+ *
+ */
+function tripal_stock_admin_stock_view() {
+  $output = '';
+
+  // set the breadcrumb
+  $breadcrumb = array();
+  $breadcrumb[] = l('Home', '<front>');
+  $breadcrumb[] = l('Administration', 'admin');
+  $breadcrumb[] = l('Tripal', 'admin/tripal');
+  $breadcrumb[] = l('Chado', 'admin/tripal/chado');
+  $breadcrumb[] = l('Stocks', 'admin/tripal/chado/tripal_stock');
+  drupal_set_breadcrumb($breadcrumb);
+
+  // Add the view
+  $view = views_embed_view('tripal_stock_admin_stocks','default');
+  if (isset($view)) {
+    $output .= $view;
+  }
+  else {
+    $output .= '<p>The Stock module uses primarily views to provide an '
+      . 'administrative interface. Currently one or more views needed for this '
+      . 'administrative interface are disabled. <strong>Click each of the following links to '
+      . 'enable the pertinent views</strong>:</p>';
+    $output .= '<ul>';
+      $output .= '<li>'.l('Stocks View', 'admin/tripal/chado/tripal_stock/views/stocks/enable').'</li>';
+    $output .= '</ul>';
+  }
+
+  return $output;
+}
+
+
 /**
 /**
  * Purpose: Provide administration options for chado_stocks
  * Purpose: Provide administration options for chado_stocks
  *
  *
@@ -17,9 +51,9 @@ function tripal_stock_admin() {
 
 
   get_tripal_stock_admin_form_title_set($form);
   get_tripal_stock_admin_form_title_set($form);
   get_tripal_stock_admin_form_url_set($form);
   get_tripal_stock_admin_form_url_set($form);
-  get_tripal_stock_admin_form_vocabulary_set($form);       
+  get_tripal_stock_admin_form_vocabulary_set($form);
   get_tripal_stock_admin_form_cleanup_set($form);
   get_tripal_stock_admin_form_cleanup_set($form);
-  
+
 
 
   return system_settings_form($form);
   return system_settings_form($form);
 
 
@@ -41,18 +75,18 @@ function tripal_stock_admin_validate($form, &$form_state) {
 
 
   variable_set('chado_stock_types_cv', $form_state['values']['stock_types_cv']);
   variable_set('chado_stock_types_cv', $form_state['values']['stock_types_cv']);
   variable_set('chado_stock_prop_types_cv', $form_state['values']['stock_prop_types_cv']);
   variable_set('chado_stock_prop_types_cv', $form_state['values']['stock_prop_types_cv']);
-  variable_set('chado_stock_relationship_cv', $form_state['values']['stock_relationship_cv']);  
+  variable_set('chado_stock_relationship_cv', $form_state['values']['stock_relationship_cv']);
   variable_set('chado_stock_url_string', $form_state['values']['chado_stock_url_string']);
   variable_set('chado_stock_url_string', $form_state['values']['chado_stock_url_string']);
-  
+
   switch ($form_state['values']['op']) {
   switch ($form_state['values']['op']) {
-    case  t('Set Controlled Vacabularies') :      
+    case  t('Set Controlled Vacabularies') :
       break;
       break;
-      
+
     case t('Clean up orphaned stocks') :
     case t('Clean up orphaned stocks') :
       tripal_add_job('Cleanup orphaned stocks', 'tripal_stock',
       tripal_add_job('Cleanup orphaned stocks', 'tripal_stock',
          'tripal_stock_cleanup', $job_args, $user->uid);
          'tripal_stock_cleanup', $job_args, $user->uid);
       break;
       break;
-    
+
     case t('Set Stock URLs') :
     case t('Set Stock URLs') :
       tripal_add_job('Set Stock URLs', 'tripal_stock',
       tripal_add_job('Set Stock URLs', 'tripal_stock',
         'tripal_stock_set_urls', $job_args, $user->uid);
         'tripal_stock_set_urls', $job_args, $user->uid);
@@ -62,7 +96,7 @@ function tripal_stock_admin_validate($form, &$form_state) {
 }
 }
 
 
 /**
 /**
- * 
+ *
  * @param $form
  * @param $form
  */
  */
 function get_tripal_stock_admin_form_title_set(&$form) {
 function get_tripal_stock_admin_form_title_set(&$form) {
@@ -76,9 +110,9 @@ function get_tripal_stock_admin_form_title_set(&$form) {
   $form['title']['desc'] = array(
   $form['title']['desc'] = array(
     '#type'  => 'markup',
     '#type'  => 'markup',
     '#value' => t('Each synced stock must have a unique page title, however, stocks
     '#value' => t('Each synced stock must have a unique page title, however, stocks
-      may have the same name if they are of different types or from different 
-      organisms.  Therefore, we must be sure that the page titles can uniquely 
-      identify the stock being viewed.  Select an option below that will 
+      may have the same name if they are of different types or from different
+      organisms.  Therefore, we must be sure that the page titles can uniquely
+      identify the stock being viewed.  Select an option below that will
       uniquely identify all stocks on your site.'),
       uniquely identify all stocks on your site.'),
   );
   );
   $options = array(
   $options = array(
@@ -89,9 +123,9 @@ function get_tripal_stock_admin_form_title_set(&$form) {
   $form['title']['chado_stock_title'] = array(
   $form['title']['chado_stock_title'] = array(
     '#title'         => t('Stock Page Titles'),
     '#title'         => t('Stock Page Titles'),
     '#type'          => 'radios',
     '#type'          => 'radios',
-    '#description'   => t('Choose a title type  from the list above that is 
-      guaranteed to be unique for all stocks If in doubt it is safest to choose 
-      the last option as that guarantees uniqueness. Click the 
+    '#description'   => t('Choose a title type  from the list above that is
+      guaranteed to be unique for all stocks If in doubt it is safest to choose
+      the last option as that guarantees uniqueness. Click the
       \'Save Configuration\' button at the bottom to save your selection.'),
       \'Save Configuration\' button at the bottom to save your selection.'),
     '#required'      => FALSE,
     '#required'      => FALSE,
     '#options'       => $options,
     '#options'       => $options,
@@ -99,7 +133,7 @@ function get_tripal_stock_admin_form_title_set(&$form) {
   );
   );
 }
 }
 /**
 /**
- * 
+ *
  * @param  $form
  * @param  $form
  */
  */
 function get_tripal_stock_admin_form_url_set(&$form) {
 function get_tripal_stock_admin_form_url_set(&$form) {
@@ -121,7 +155,7 @@ function get_tripal_stock_admin_form_url_set(&$form) {
     '[name]'       => '[name]:' . t('The stock name'),
     '[name]'       => '[name]:' . t('The stock name'),
     'reset'        => t('Reset'),
     'reset'        => t('Reset'),
   );
   );
-  
+
 
 
   $form['url']['chado_stock_url_string'] = array(
   $form['url']['chado_stock_url_string'] = array(
     '#title' => 'URL Syntax',
     '#title' => 'URL Syntax',
@@ -129,15 +163,15 @@ function get_tripal_stock_admin_form_url_set(&$form) {
     '#description' => t('You may rearrange elements in this text box to
     '#description' => t('You may rearrange elements in this text box to
       customize the URLs.  The available tags include: [id],
       customize the URLs.  The available tags include: [id],
       [uniquename]. [name], [species], [genus], [type]. You can separate or
       [uniquename]. [name], [species], [genus], [type]. You can separate or
-      include any text between the tags. Click the "Set Stock URLs" button to 
+      include any text between the tags. Click the "Set Stock URLs" button to
       reset the URLs for all stock pages.  Click the "Save Configuration" button to
       reset the URLs for all stock pages.  Click the "Save Configuration" button to
       simply save this setup. <b>Important</b>: be sure that whatever you choose will always be unique even considering
       simply save this setup. <b>Important</b>: be sure that whatever you choose will always be unique even considering
-      future data that may be added.  If you include the Chado table name, genus, species, type 
+      future data that may be added.  If you include the Chado table name, genus, species, type
       and uniquename you are guaranteed to have a unique URL. For example stock/[genus]/[species]/[type]/[uniquename]'),
       and uniquename you are guaranteed to have a unique URL. For example stock/[genus]/[species]/[type]/[uniquename]'),
     '#size' => 150,
     '#size' => 150,
-    '#default_value' => variable_get('chado_stock_url_string', '/stock/[genus]/[species]/[type]/[uniquename]'), 
+    '#default_value' => variable_get('chado_stock_url_string', '/stock/[genus]/[species]/[type]/[uniquename]'),
   );
   );
-  
+
   $form['url']['chado_stock_url'] = array(
   $form['url']['chado_stock_url'] = array(
     '#title'         => t('URL components'),
     '#title'         => t('URL components'),
     '#type'          => 'checkboxes',
     '#type'          => 'checkboxes',
@@ -150,21 +184,21 @@ function get_tripal_stock_admin_form_url_set(&$form) {
         if (this.value == \'reset\') {
         if (this.value == \'reset\') {
           box.val(\'\');
           box.val(\'\');
         }
         }
-        else {        
-          box.val(box.val() + "/" + this.value);          
+        else {
+          box.val(box.val() + "/" + this.value);
         }
         }
         this.checked = false;
         this.checked = false;
       ',
       ',
     ),
     ),
-  );  
-  
+  );
+
   $form['url']['button'] = array(
   $form['url']['button'] = array(
     '#type' => 'submit',
     '#type' => 'submit',
     '#value' => t('Set Stock URLs'),
     '#value' => t('Set Stock URLs'),
   );
   );
 }
 }
 /**
 /**
- * 
+ *
  * @param $form
  * @param $form
  */
  */
 function get_tripal_stock_admin_form_vocabulary_set(&$form) {
 function get_tripal_stock_admin_form_vocabulary_set(&$form) {

+ 0 - 0
tripal_stock/theme/tripal_stock_admin.tpl.php → tripal_stock/theme/tripal_stock_help.tpl.php


+ 101 - 90
tripal_stock/tripal_stock.module

@@ -41,31 +41,42 @@ function tripal_stock_menu() {
   $items = array();
   $items = array();
 
 
   //Administrative settings menu-----------------
   //Administrative settings menu-----------------
-  $items['admin/tripal/tripal_stock'] = array(
+  $items['admin/tripal/chado/tripal_stock'] = array(
     'title' => 'Stocks',
     'title' => 'Stocks',
-    'description' => 'Basic Description of Tripal Stock Module Functionality',
-    'page callback' => 'theme',
-    'page arguments' => array('tripal_stock_help'),
+    'description' => 'A stock is the physical entities of an organism, either living or preserved.',
+    'page callback' => 'tripal_stock_admin_stock_view',
     'access arguments' => array('administer tripal stocks'),
     'access arguments' => array('administer tripal stocks'),
     'type' => MENU_NORMAL_ITEM
     'type' => MENU_NORMAL_ITEM
   );
   );
 
 
-  $items['admin/tripal/tripal_stock/configuration'] = array(
-    'title' => 'Configuration',
+  $items['admin/tripal/chado/tripal_stock/configuration'] = array(
+    'title' => 'Settings',
     'description' => 'Settings for Chado Stocks',
     'description' => 'Settings for Chado Stocks',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tripal_stock_help'),
     'page arguments' => array('tripal_stock_help'),
     'access arguments' => array('administer tripal stocks'),
     'access arguments' => array('administer tripal stocks'),
-    'type' => MENU_NORMAL_ITEM
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 5
   );
   );
-  
-  $items['admin/tripal/tripal_stock/sync'] = array(
-    'title' => ' Sync Stocks',
+
+  $items['admin/tripal/chado/tripal_stock/sync'] = array(
+    'title' => ' Sync',
     'description' => 'Sync stocks from Chado with Drupal',
     'description' => 'Sync stocks from Chado with Drupal',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tripal_stock_sync_form'),
     'page arguments' => array('tripal_stock_sync_form'),
     'access arguments' => array('administer tripal stocks'),
     'access arguments' => array('administer tripal stocks'),
-    'type' => MENU_NORMAL_ITEM,
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 0
+  );
+
+  $items['admin/tripal/chado/tripal_stock/help'] = array(
+    'title' => 'Help',
+    'description' => 'Basic Description of Tripal Stock Module Functionality',
+    'page callback' => 'theme',
+    'page arguments' => array('tripal_stock_help'),
+    'access arguments' => array('administer tripal stocks'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 10
   );
   );
 
 
   // Adding Secondary Properties-----------------
   // Adding Secondary Properties-----------------
@@ -126,7 +137,7 @@ function tripal_stock_menu() {
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 10,
     'weight' => 10,
   );
   );
-  
+
   // the menu link for addressing any stock (by name, uniquename, synonym)
   // the menu link for addressing any stock (by name, uniquename, synonym)
   $items['stock/%'] = array(
   $items['stock/%'] = array(
     'page callback' => 'tripal_stock_match_stocks_page',
     'page callback' => 'tripal_stock_match_stocks_page',
@@ -203,7 +214,7 @@ function tripal_stock_permissions() {
  * Implement hook_access().
  * Implement hook_access().
  *
  *
  * This hook allows node modules to limit access to the node types they define.
  * This hook allows node modules to limit access to the node types they define.
- * 
+ *
  *  @param $node
  *  @param $node
  *  The node on which the operation is to be performed, or, if it does not yet exist, the
  *  The node on which the operation is to be performed, or, if it does not yet exist, the
  *  type of node to be created
  *  type of node to be created
@@ -217,7 +228,7 @@ function tripal_stock_permissions() {
  *  @return
  *  @return
  *  If the permission for the specified operation is not set then return FALSE. If the
  *  If the permission for the specified operation is not set then return FALSE. If the
  *  permission is set then return NULL as this allows other modules to disable
  *  permission is set then return NULL as this allows other modules to disable
- *  access.  The only exception is when the $op == 'create'.  We will always 
+ *  access.  The only exception is when the $op == 'create'.  We will always
  *  return TRUE if the permission is set.
  *  return TRUE if the permission is set.
  *
  *
  * @ingroup tripal_stock
  * @ingroup tripal_stock
@@ -335,18 +346,18 @@ function tripal_stock_theme() {
       'arguments' => array('node' => NULL),
       'arguments' => array('node' => NULL),
       'template' => 'tripal_stock_locations',
       'template' => 'tripal_stock_locations',
       'path' => "$theme_path/tripal_stock",
       'path' => "$theme_path/tripal_stock",
-    ),    
+    ),
     // tripal_organism templates
     // tripal_organism templates
     'tripal_organism_stocks' => array(
     'tripal_organism_stocks' => array(
       'arguments' => array('node' => NULL),
       'arguments' => array('node' => NULL),
       'template' => 'tripal_organism_stocks',
       'template' => 'tripal_organism_stocks',
       'path' => "$theme_path/tripal_organism",
       'path' => "$theme_path/tripal_organism",
-    ),    
+    ),
     // help template
     // help template
     'tripal_stock_help' => array(
     'tripal_stock_help' => array(
-      'template' => 'tripal_stock_help',  
-      'arguments' =>  array(NULL),  
-      'path' => $theme_path, 
+      'template' => 'tripal_stock_help',
+      'arguments' =>  array(NULL),
+      'path' => $theme_path,
     ),
     ),
   );
   );
   return $items;
   return $items;
@@ -395,12 +406,12 @@ function chado_stock_load($node) {
 
 
   // get the stock details from chado
   // get the stock details from chado
   $stock_id = chado_get_id_for_node('stock', $node->nid);
   $stock_id = chado_get_id_for_node('stock', $node->nid);
-  
+
   // build the variable with all the stock details
   // build the variable with all the stock details
   $values = array('stock_id' => $stock_id);
   $values = array('stock_id' => $stock_id);
   $stock = tripal_core_generate_chado_var('stock', $values);
   $stock = tripal_core_generate_chado_var('stock', $values);
-  
-  
+
+
   // by default, the titles are saved using the unique constraint.  We will
   // by default, the titles are saved using the unique constraint.  We will
   // keep it the same, but remove the duplicate name if the unique name and name
   // keep it the same, but remove the duplicate name if the unique name and name
   // are identical
   // are identical
@@ -409,10 +420,10 @@ function chado_stock_load($node) {
     if (strcmp($stock->name, $stock->uniquename)==0) {
     if (strcmp($stock->name, $stock->uniquename)==0) {
       $node->title = $stock->name . " (" . $stock->type_id->name . ") " . $stock->organism_id->genus . " " . $stock->organism_id->species ;
       $node->title = $stock->name . " (" . $stock->type_id->name . ") " . $stock->organism_id->genus . " " . $stock->organism_id->species ;
     }
     }
-    // in previous version of Tripal, the stock title was simply the unique name. 
+    // in previous version of Tripal, the stock title was simply the unique name.
     // so, we recreate the title just to be sure all of our stock pages are consistent
     // so, we recreate the title just to be sure all of our stock pages are consistent
     else {
     else {
-      $node->title = $stock->name . ", " . $stock->uniquename . " (" . $stock->type_id->name . ") " . $stock->organism_id->genus . " " . $stock->organism_id->species ;  
+      $node->title = $stock->name . ", " . $stock->uniquename . " (" . $stock->type_id->name . ") " . $stock->organism_id->genus . " " . $stock->organism_id->species ;
     }
     }
   }
   }
   // set the title to be the stock name or uniquename as configured
   // set the title to be the stock name or uniquename as configured
@@ -420,9 +431,9 @@ function chado_stock_load($node) {
     $node->title = $stock->name;
     $node->title = $stock->name;
   }
   }
   if($title_type == 'stock_unique_name') {
   if($title_type == 'stock_unique_name') {
-    $node->title = $stock->uniquename;  
+    $node->title = $stock->uniquename;
   }
   }
-  
+
   // add this to the node
   // add this to the node
   $additions = new stdClass();
   $additions = new stdClass();
   $additions->stock = $stock;
   $additions->stock = $stock;
@@ -518,10 +529,10 @@ function chado_stock_form($node, $form_state) {
   $type_options = tripal_cv_get_cvterm_options( variable_get('chado_stock_types_cv', 'NULL') );
   $type_options = tripal_cv_get_cvterm_options( variable_get('chado_stock_types_cv', 'NULL') );
   $type_options[0] = 'Select a Type';
   $type_options[0] = 'Select a Type';
   if ($node->nid == '') {
   if ($node->nid == '') {
-    $type_default = 0; 
+    $type_default = 0;
   }
   }
-  else { 
-    $type_default = $node->stock->type_id->cvterm_id; 
+  else {
+    $type_default = $node->stock->type_id->cvterm_id;
   }
   }
   $form['details']['type_id'] = array(
   $form['details']['type_id'] = array(
     '#type' => 'select',
     '#type' => 'select',
@@ -531,7 +542,7 @@ function chado_stock_form($node, $form_state) {
     '#required'    => TRUE,
     '#required'    => TRUE,
   );
   );
 
 
- 
+
   // get the list of organisms
   // get the list of organisms
   $sql = "SELECT * FROM {Organism} ORDER BY genus, species";
   $sql = "SELECT * FROM {Organism} ORDER BY genus, species";
   $org_rset = chado_query($sql);
   $org_rset = chado_query($sql);
@@ -612,12 +623,12 @@ function chado_stock_validate($node, &$form) {
       SELECT *
       SELECT *
       FROM {stock} S
       FROM {stock} S
         INNER JOIN {cvterm} CVT ON S.type_id = CVT.cvterm_id
         INNER JOIN {cvterm} CVT ON S.type_id = CVT.cvterm_id
-      WHERE 
-        uniquename = :uname AND organism_id = :organism_id AND 
+      WHERE
+        uniquename = :uname AND organism_id = :organism_id AND
         CVT.name = :cvtname AND NOT stock_id = :stock_id
         CVT.name = :cvtname AND NOT stock_id = :stock_id
     ";
     ";
-    $result = chado_query($sql, array(':uname' => $node->uniquename, 
-      ':organism_id' => $node->organism_id, ':cvtname' => $node->stock_type, 
+    $result = chado_query($sql, array(':uname' => $node->uniquename,
+      ':organism_id' => $node->organism_id, ':cvtname' => $node->stock_type,
       ':stock_id' => $node->stock_id))->fetchObject();
       ':stock_id' => $node->stock_id))->fetchObject();
     if ($result) {
     if ($result) {
       form_set_error('uniquename', t("Stock update cannot proceed. The stock name '$node->uniquename' is not unique for this organism. Please provide a unique name for this stock."));
       form_set_error('uniquename', t("Stock update cannot proceed. The stock name '$node->uniquename' is not unique for this organism. Please provide a unique name for this stock."));
@@ -632,13 +643,13 @@ function chado_stock_validate($node, &$form) {
       FROM {Stock} S
       FROM {Stock} S
         INNER JOIN {cvterm} CVT ON S.type_id = CVT.cvterm_id
         INNER JOIN {cvterm} CVT ON S.type_id = CVT.cvterm_id
       WHERE uniquename = :uname'AND organism_id = :organism_id AND CVT.name = :cvtname";
       WHERE uniquename = :uname'AND organism_id = :organism_id AND CVT.name = :cvtname";
-    $result = chado_query($sql, array(':uname' => $node->uniquename, 
+    $result = chado_query($sql, array(':uname' => $node->uniquename,
       ':organism_id' => $node->organism_id, ':cvtname' => $node->stock_type))->fetchObject();
       ':organism_id' => $node->organism_id, ':cvtname' => $node->stock_type))->fetchObject();
     if ($result) {
     if ($result) {
       form_set_error('uniquename', t("Stock insert cannot proceed. The stock name '$node->uniquename' already exists for this organism. Please provide a unique name for this stock."));
       form_set_error('uniquename', t("Stock insert cannot proceed. The stock name '$node->uniquename' already exists for this organism. Please provide a unique name for this stock."));
     }
     }
   }
   }
-  
+
 
 
   // Check Type of Stock is valid cvterm_id in chado ( $form['values']['details']['type_id'] )
   // Check Type of Stock is valid cvterm_id in chado ( $form['values']['details']['type_id'] )
   if ( $node->type_id == 0) {
   if ( $node->type_id == 0) {
@@ -695,7 +706,7 @@ function chado_stock_validate($node, &$form) {
  * @ingroup tripal_stock
  * @ingroup tripal_stock
  */
  */
 function chado_stock_insert($node) {
 function chado_stock_insert($node) {
-  
+
   // If the chado stock exists (e.g. this is only a syncing operation)
   // If the chado stock exists (e.g. this is only a syncing operation)
   // then don't create but simply link to node
   // then don't create but simply link to node
   if ($node->chado_stock_exists) {
   if ($node->chado_stock_exists) {
@@ -703,7 +714,7 @@ function chado_stock_insert($node) {
       $sql = "INSERT INTO {chado_stock} (nid, vid, stock_id) VALUES (:nid, :vid, :stock_id)";
       $sql = "INSERT INTO {chado_stock} (nid, vid, stock_id) VALUES (:nid, :vid, :stock_id)";
       db_query($sql, array(':nid' => $node->nid, ':vid' => $node->vid, ':stock_id' => $node->stock_id));
       db_query($sql, array(':nid' => $node->nid, ':vid' => $node->vid, ':stock_id' => $node->stock_id));
     }
     }
-    
+
     return $node;
     return $node;
   }
   }
 
 
@@ -729,7 +740,7 @@ function chado_stock_insert($node) {
           );
           );
         }
         }
       }
       }
-      else { 
+      else {
         $dbxref_status = 1;
         $dbxref_status = 1;
       }
       }
     }
     }
@@ -762,11 +773,11 @@ function chado_stock_insert($node) {
     );
     );
     $stock = tripal_core_chado_insert('stock', $values);
     $stock = tripal_core_chado_insert('stock', $values);
   }
   }
-  
+
   // if the stock creation was succesful then add the URL and the entry in the
   // if the stock creation was succesful then add the URL and the entry in the
   // chado_stock table
   // chado_stock table
   if (is_array($stock)) {
   if (is_array($stock)) {
-    
+
     // convert the stock into an object
     // convert the stock into an object
     $stock = (object) $stock;
     $stock = (object) $stock;
 
 
@@ -778,7 +789,7 @@ function chado_stock_insert($node) {
     if ($node->simulate_multipart) {
     if ($node->simulate_multipart) {
       $next_stage_path = preg_replace('/%node/', $node->nid, $node->next_step_path);
       $next_stage_path = preg_replace('/%node/', $node->nid, $node->next_step_path);
       $_REQUEST['destination'] = $next_stage_path;
       $_REQUEST['destination'] = $next_stage_path;
-    }    
+    }
   }
   }
   else {
   else {
     drupal_set_message(t('Error during stock creation.'), 'error');
     drupal_set_message(t('Error during stock creation.'), 'error');
@@ -888,7 +899,7 @@ function chado_stock_update($node) {
     );
     );
   }
   }
   $status = tripal_core_chado_update('stock', array('stock_id' => $node->stock_id), $update_values);
   $status = tripal_core_chado_update('stock', array('stock_id' => $node->stock_id), $update_values);
-    
+
 
 
   if (!$status) {
   if (!$status) {
     drupal_set_message(t('Unable to update stock'), 'error');
     drupal_set_message(t('Unable to update stock'), 'error');
@@ -902,7 +913,7 @@ function chado_stock_update($node) {
   else {
   else {
     // set the URL for this stock page
     // set the URL for this stock page
     $values = array('stock_id' => $node->stock_id);
     $values = array('stock_id' => $node->stock_id);
-    $stock = tripal_core_chado_select('stock', array('*'), $values);    
+    $stock = tripal_core_chado_select('stock', array('*'), $values);
   }
   }
 }
 }
 
 
@@ -946,26 +957,26 @@ function tripal_stock_block_info() {
 
 
   $blocks['synonyms']['info'] = t('Tripal Stock Synonyms');
   $blocks['synonyms']['info'] = t('Tripal Stock Synonyms');
   $blocks['synonyms']['cache'] = BLOCK_NO_CACHE;
   $blocks['synonyms']['cache'] = BLOCK_NO_CACHE;
-  
+
   $blocks['collections']['info'] = t('Tripal Stock Collections');
   $blocks['collections']['info'] = t('Tripal Stock Collections');
   $blocks['collections']['cache'] = BLOCK_NO_CACHE;
   $blocks['collections']['cache'] = BLOCK_NO_CACHE;
-  
+
   $blocks['phenotypes']['info'] = t('Tripal Stock Phenotypes');
   $blocks['phenotypes']['info'] = t('Tripal Stock Phenotypes');
   $blocks['phenotypes']['cache'] = BLOCK_NO_CACHE;
   $blocks['phenotypes']['cache'] = BLOCK_NO_CACHE;
-  
+
   $blocks['genotypes']['info'] = t('Tripal Stock Genotypes');
   $blocks['genotypes']['info'] = t('Tripal Stock Genotypes');
   $blocks['genotypes']['cache'] = BLOCK_NO_CACHE;
   $blocks['genotypes']['cache'] = BLOCK_NO_CACHE;
-  
+
   $blocks['locations']['info'] = t('Tripal Stock Locations');
   $blocks['locations']['info'] = t('Tripal Stock Locations');
   $blocks['locations']['cache'] = BLOCK_NO_CACHE;
   $blocks['locations']['cache'] = BLOCK_NO_CACHE;
-  
+
   $blocks['orgstocks']['info'] = t('Tripal Organism Stocks');
   $blocks['orgstocks']['info'] = t('Tripal Organism Stocks');
   $blocks['orgstocks']['cache'] = BLOCK_NO_CACHE;
   $blocks['orgstocks']['cache'] = BLOCK_NO_CACHE;
 
 
   return $blocks;
   return $blocks;
 }
 }
 /**
 /**
- * 
+ *
  * @ingroup tripal_stock
  * @ingroup tripal_stock
  */
  */
 function tripal_stock_block_view($delta = '') {
 function tripal_stock_block_view($delta = '') {
@@ -973,59 +984,59 @@ function tripal_stock_block_view($delta = '') {
   if (user_access('access chado_stock content') and arg(0) == 'node' and is_numeric(arg(1))) {
   if (user_access('access chado_stock content') and arg(0) == 'node' and is_numeric(arg(1))) {
     $nid = arg(1);
     $nid = arg(1);
     $node = node_load($nid);
     $node = node_load($nid);
-  
+
     $block = array();
     $block = array();
     switch ($delta) {
     switch ($delta) {
       case 'base':
       case 'base':
         $block['subject'] = t('Stock Details');
         $block['subject'] = t('Stock Details');
         $block['content'] = theme('tripal_stock_base', $node);
         $block['content'] = theme('tripal_stock_base', $node);
         break;
         break;
-  
+
       case 'properties':
       case 'properties':
         $block['subject'] = t('Properties');
         $block['subject'] = t('Properties');
         $block['content'] = theme('tripal_stock_properties', $node);
         $block['content'] = theme('tripal_stock_properties', $node);
         break;
         break;
-  
+
       case 'references':
       case 'references':
         $block['subject'] = t('References');
         $block['subject'] = t('References');
         $block['content'] = theme('tripal_stock_references', $node);
         $block['content'] = theme('tripal_stock_references', $node);
         break;
         break;
-  
+
       case 'relationships':
       case 'relationships':
         $block['subject'] = t('Relationships');
         $block['subject'] = t('Relationships');
         $block['content'] = theme('tripal_stock_relationships', $node);
         $block['content'] = theme('tripal_stock_relationships', $node);
         break;
         break;
-  
+
       case 'synonyms':
       case 'synonyms':
         $block['subject'] = t('Synonyms');
         $block['subject'] = t('Synonyms');
         $block['content'] = theme('tripal_stock_synonyms', $node);
         $block['content'] = theme('tripal_stock_synonyms', $node);
         break;
         break;
-        
+
       case 'collections':
       case 'collections':
         $block['subject'] = t('Stock Collections');
         $block['subject'] = t('Stock Collections');
         $block['content'] = theme('tripal_stock_collections', $node);
         $block['content'] = theme('tripal_stock_collections', $node);
         break;
         break;
-        
+
       case 'phenotypes':
       case 'phenotypes':
         $block['subject'] = t('Stock Phenotypes');
         $block['subject'] = t('Stock Phenotypes');
         $block['content'] = theme('tripal_stock_phenotypes', $node);
         $block['content'] = theme('tripal_stock_phenotypes', $node);
         break;
         break;
-        
+
       case 'genotypes':
       case 'genotypes':
         $block['subject'] = t('Stock Genotypes');
         $block['subject'] = t('Stock Genotypes');
         $block['content'] = theme('tripal_stock_genotypes', $node);
         $block['content'] = theme('tripal_stock_genotypes', $node);
         break;
         break;
-        
+
       case 'locations':
       case 'locations':
         $block['subject'] = t('Stock Locations');
         $block['subject'] = t('Stock Locations');
         $block['content'] = theme('tripal_stock_locations', $node);
         $block['content'] = theme('tripal_stock_locations', $node);
         break;
         break;
-        
+
       case 'orgstocks':
       case 'orgstocks':
         $block['subject'] = t('Organism Stocks');
         $block['subject'] = t('Organism Stocks');
         $block['content'] = theme('tripal_organism_stocks', $node);
         $block['content'] = theme('tripal_organism_stocks', $node);
         break;
         break;
-  
+
     }
     }
     return $block;
     return $block;
   }
   }
@@ -1039,14 +1050,14 @@ function tripal_stock_block_view($delta = '') {
 function tripal_stock_preprocess_tripal_stock_relationships(&$variables) {
 function tripal_stock_preprocess_tripal_stock_relationships(&$variables) {
   // we want to provide a new variable that contains the matched stocks.
   // we want to provide a new variable that contains the matched stocks.
   $stock = $variables['node']->stock;
   $stock = $variables['node']->stock;
-   
+
   // normally we would use tripal_core_expand_chado_vars to expand our
   // normally we would use tripal_core_expand_chado_vars to expand our
   // organism object and add in the relationships, however whan a large
   // organism object and add in the relationships, however whan a large
   // number of relationships are present this significantly slows the
   // number of relationships are present this significantly slows the
   // query, therefore we will manually perform the query
   // query, therefore we will manually perform the query
   $sql = "
   $sql = "
-    SELECT 
-      S.name, S.uniquename, S.stock_id, CS.nid, 
+    SELECT
+      S.name, S.uniquename, S.stock_id, CS.nid,
       CVT.name as rel_type, CVTs.name as obj_type,
       CVT.name as rel_type, CVTs.name as obj_type,
       SR.value
       SR.value
     FROM {stock_relationship} SR
     FROM {stock_relationship} SR
@@ -1058,8 +1069,8 @@ function tripal_stock_preprocess_tripal_stock_relationships(&$variables) {
   ";
   ";
   $as_subject = chado_query($sql, array(':stock_id' => $stock->stock_id));
   $as_subject = chado_query($sql, array(':stock_id' => $stock->stock_id));
   $sql = "
   $sql = "
-    SELECT 
-      S.name, S.uniquename,  S.stock_id, CS.nid, 
+    SELECT
+      S.name, S.uniquename,  S.stock_id, CS.nid,
       CVT.name as rel_type, CVTs.name as sub_type,
       CVT.name as rel_type, CVTs.name as sub_type,
       SR.value
       SR.value
     FROM {stock_relationship} SR
     FROM {stock_relationship} SR
@@ -1070,45 +1081,45 @@ function tripal_stock_preprocess_tripal_stock_relationships(&$variables) {
     WHERE SR.object_id = :stock_id
     WHERE SR.object_id = :stock_id
   ";
   ";
   $as_object = chado_query($sql, array(':stock_id' => $stock->stock_id));
   $as_object = chado_query($sql, array(':stock_id' => $stock->stock_id));
-  
+
   // combine both object and subject relationshisp into a single array
   // combine both object and subject relationshisp into a single array
   $relationships = array();
   $relationships = array();
   $relationships['object'] = array();
   $relationships['object'] = array();
   $relationships['subject'] = array();
   $relationships['subject'] = array();
-  
+
   // iterate through the object relationships
   // iterate through the object relationships
   while ($relationship = $as_object->fetchObject()) {
   while ($relationship = $as_object->fetchObject()) {
-     
+
      // get the relationship and child types
      // get the relationship and child types
      $rel_type = t(preg_replace('/_/', " ", $relationship->rel_type));
      $rel_type = t(preg_replace('/_/', " ", $relationship->rel_type));
      $sub_type = t(preg_replace('/_/', " ", $relationship->sub_type));
      $sub_type = t(preg_replace('/_/', " ", $relationship->sub_type));
-     
+
      if (!array_key_exists($rel_type, $relationships['object'])) {
      if (!array_key_exists($rel_type, $relationships['object'])) {
-       $relationships['object'][$rel_type] = array();   
+       $relationships['object'][$rel_type] = array();
      }
      }
      if (!array_key_exists($sub_type, $relationships['object'][$rel_type])) {
      if (!array_key_exists($sub_type, $relationships['object'][$rel_type])) {
-       $relationships['object'][$rel_type][$sub_type] = array();   
+       $relationships['object'][$rel_type][$sub_type] = array();
      }
      }
-     $relationships['object'][$rel_type][$sub_type][] = $relationship;     
+     $relationships['object'][$rel_type][$sub_type][] = $relationship;
   }
   }
-  
+
   // now add in the subject relationships
   // now add in the subject relationships
   while ($relationship = $as_subject->fetchObject()) {
   while ($relationship = $as_subject->fetchObject()) {
-     
+
      // get the relationship and child types
      // get the relationship and child types
      $rel_type = t(preg_replace('/_/', " ", $relationship->rel_type));
      $rel_type = t(preg_replace('/_/', " ", $relationship->rel_type));
      $obj_type = t(preg_replace('/_/', " ", $relationship->obj_type));
      $obj_type = t(preg_replace('/_/', " ", $relationship->obj_type));
-     
+
      if (!array_key_exists($rel_type, $relationships['subject'])) {
      if (!array_key_exists($rel_type, $relationships['subject'])) {
-       $relationships['subject'][$rel_type] = array();   
+       $relationships['subject'][$rel_type] = array();
      }
      }
      if (!array_key_exists($obj_type, $relationships['subject'][$rel_type])) {
      if (!array_key_exists($obj_type, $relationships['subject'][$rel_type])) {
-       $relationships['subject'][$rel_type][$obj_type] = array();   
+       $relationships['subject'][$rel_type][$obj_type] = array();
      }
      }
-     $relationships['subject'][$rel_type][$obj_type][] = $relationship;     
+     $relationships['subject'][$rel_type][$obj_type][] = $relationship;
   }
   }
-  
-  
+
+
   $stock->all_relationships = $relationships;
   $stock->all_relationships = $relationships;
 
 
 }
 }
@@ -1138,10 +1149,10 @@ function tripal_stock_node_insert($node) {
         $chado_stock = db_query($sql, array(':nid' => $node->nid))->fetchObject();
         $chado_stock = db_query($sql, array(':nid' => $node->nid))->fetchObject();
         $node->stock_id = $chado_stock->stock_id;
         $node->stock_id = $chado_stock->stock_id;
       }
       }
-      
+
       // remove any previous alias
       // remove any previous alias
       db_query("DELETE FROM {url_alias} WHERE src = :src", array(':src' => "node/$node->nid"));
       db_query("DELETE FROM {url_alias} WHERE src = :src", array(':src' => "node/$node->nid"));
-      
+
       // set the URL for this stock page
       // set the URL for this stock page
       $url_alias = tripal_stock_get_stock_url($node);
       $url_alias = tripal_stock_get_stock_url($node);
       path_set_alias("node/$node->nid", $url_alias);
       path_set_alias("node/$node->nid", $url_alias);
@@ -1155,10 +1166,10 @@ function tripal_stock_node_update($node) {
 
 
   switch ($node->type) {
   switch ($node->type) {
     case 'chado_stock':
     case 'chado_stock':
-      
+
       // remove any previous alias
       // remove any previous alias
       db_query("DELETE FROM {url_alias} WHERE src = :src", array(':src' => "node/$node->nid"));
       db_query("DELETE FROM {url_alias} WHERE src = :src", array(':src' => "node/$node->nid"));
-      
+
       // set the URL for this stock page
       // set the URL for this stock page
       $url_alias = tripal_stock_get_stock_url($node);
       $url_alias = tripal_stock_get_stock_url($node);
       path_set_alias("node/$node->nid", $url_alias);
       path_set_alias("node/$node->nid", $url_alias);
@@ -1190,19 +1201,19 @@ function tripal_stock_node_view($node, $view_mode, $langcode) {
  * stocks is shown.
  * stocks is shown.
  */
  */
 function tripal_stock_match_stocks_page($id) {
 function tripal_stock_match_stocks_page($id) {
-  
+
   // if the URL alias configuration is set such that the URL
   // if the URL alias configuration is set such that the URL
   // always begins with 'stock' then we want to use the ID as it is and
   // always begins with 'stock' then we want to use the ID as it is and
   // forward it on. Otherwise, try to find the matching stock.
   // forward it on. Otherwise, try to find the matching stock.
-  $url_alias = variable_get('chado_stock_url_string', '/stock/[genus]/[species]/[type]/[uniquename]'); 
+  $url_alias = variable_get('chado_stock_url_string', '/stock/[genus]/[species]/[type]/[uniquename]');
   if (!$url_alias) {
   if (!$url_alias) {
     $url_alias = '/stock/[genus]/[species]/[type]/[uniquename]';
     $url_alias = '/stock/[genus]/[species]/[type]/[uniquename]';
-  } 
-  $url_alias = preg_replace('/^\//', '', $url_alias); // remove any preceeding forward slash  
+  }
+  $url_alias = preg_replace('/^\//', '', $url_alias); // remove any preceeding forward slash
   if (preg_match('/^stock\//', $url_alias)) {
   if (preg_match('/^stock\//', $url_alias)) {
     drupal_goto($id);
     drupal_goto($id);
   }
   }
-  
+
 
 
   $sql = "
   $sql = "
     SELECT
     SELECT

+ 217 - 378
tripal_stock/tripal_stock.views_default.inc

@@ -7,400 +7,239 @@
 function tripal_stock_views_default_views() {
 function tripal_stock_views_default_views() {
   $views = array();
   $views = array();
 
 
-  if (!module_exists('tripal_views')) {
-    return $views;
-  }
+  $view = tripal_stock_defaultview_admin_stocks();
+  $views[$view->name] = $view;
+
+  return $views;
+}
 
 
-  // Main default view
-  $view = new view;
-  $view->name = 'stock_listing';
-  $view->description = 'This view lists all stocks by default.';
-  $view->tag = 'chado default';
+function tripal_stock_defaultview_admin_stocks() {
+
+  $view = new view();
+  $view->name = 'tripal_stock_admin_stocks';
+  $view->description = 'DO NOT DISABLE';
+  $view->tag = 'tripal admin';
   $view->base_table = 'stock';
   $view->base_table = 'stock';
+  $view->human_name = 'Stock Admin';
   $view->core = 0;
   $view->core = 0;
-  $view->api_version = '2';
+  $view->api_version = '3.0';
   $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
   $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+
+  /* Display: Defaults */
   $handler = $view->new_display('default', 'Defaults', 'default');
   $handler = $view->new_display('default', 'Defaults', 'default');
-  $handler->override_option('fields', array(
+  $handler->display->display_options['title'] = 'Stocks';
+  $handler->display->display_options['use_more_always'] = FALSE;
+  $handler->display->display_options['access']['type'] = 'perm';
+  $handler->display->display_options['access']['perm'] = 'access chado_stock content';
+  $handler->display->display_options['cache']['type'] = 'none';
+  $handler->display->display_options['query']['type'] = 'views_query';
+  $handler->display->display_options['exposed_form']['type'] = 'basic';
+  $handler->display->display_options['pager']['type'] = 'full';
+  $handler->display->display_options['pager']['options']['items_per_page'] = '25';
+  $handler->display->display_options['pager']['options']['offset'] = '0';
+  $handler->display->display_options['pager']['options']['id'] = '0';
+  $handler->display->display_options['pager']['options']['quantity'] = '9';
+  $handler->display->display_options['style_plugin'] = 'table';
+  $handler->display->display_options['style_options']['grouping'] = '';
+  $handler->display->display_options['style_options']['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',
+  );
+  $handler->display->display_options['style_options']['default'] = '-1';
+  $handler->display->display_options['style_options']['info'] = array(
     'uniquename' => 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',
+      'sortable' => 1,
+      'separator' => '',
     ),
     ),
     'name_2' => array(
     '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',
+      'sortable' => 1,
+      'separator' => '',
     ),
     ),
     'name' => array(
     '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',
-    ),
-  ));
-  $handler->override_option('sorts', array(
-    'common_name' => array(
-      'order' => 'ASC',
-      'id' => 'common_name',
-      'table' => 'organism',
-      'field' => 'common_name',
-      'relationship' => 'none',
+      'sortable' => 1,
+      'separator' => '',
     ),
     ),
-    'uniquename' => array(
-      'order' => 'ASC',
-      'id' => 'uniquename',
-      'table' => 'stock',
-      'field' => 'uniquename',
-      'relationship' => 'none',
-    ),
-  ));
-  $handler->override_option('filters', array(
     'common_name' => array(
     'common_name' => array(
-      'operator' => '=',
-      'value' => array(),
-      'group' => '0',
-      'exposed' => TRUE,
-      'expose' => array(
-        'use_operator' => 0,
-        'operator' => 'common_name_op',
-        'identifier' => 'organism_common_name',
-        'label' => 'Organism',
-        'remember' => 0,
-      ),
-      'case' => 1,
-      'id' => 'common_name',
-      'table' => 'organism',
-      'field' => 'common_name',
-      'relationship' => 'none',
-      'values_form_type' => 'select',
-      'multiple' => 1,
-      'optional' => 0,
-      'agg' => array(
-        'records_with' => 1,
-        'aggregates_with' => 1,
-      ),
-    ),
-    'search_results' => array(
-      'operator' => '=',
-      'value' => '',
-      'group' => '0',
-      'exposed' => FALSE,
-      'expose' => array(
-        'operator' => FALSE,
-        'label' => '',
-      ),
-      'id' => 'search_results',
-      'table' => 'views',
-      'field' => 'search_results',
-      'relationship' => 'none',
-      'apply_button' => 'Show',
-      'no_results_text' => 'Click "Show" to see a list of all stocks matching the entered criteria. If you leave a any of the criteria blank then the stocks will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all stocks will be listed.',
+      'sortable' => 1,
+      'separator' => '',
     ),
     ),
-    'type_id' => array(
-      'operator' => '=',
-      'value' => '',
-      'group' => '0',
-      'exposed' => TRUE,
-      'expose' => array(
-        'use_operator' => 0,
-        'operator' => 'type_id_op',
-        'identifier' => 'type_id',
-        'label' => 'Type',
-        'remember' => 0,
-      ),
-      'case' => 1,
-      'id' => 'type_id',
-      'table' => 'stock',
-      'field' => 'type_id',
-      'relationship' => 'none',
-      'values_form_type' => 'select',
-      'multiple' => 1,
-      'optional' => 0,
-      'show_all' => 0,
-      'agg' => array(
-        'records_with' => 1,
-        'aggregates_with' => 1,
-      ),
-    ),
-    'name' => array(
-      'operator' => '~',
-      'value' => '',
-      'group' => '0',
-      'exposed' => TRUE,
-      'expose' => array(
-        'use_operator' => 0,
-        'operator' => 'name_op',
-        'identifier' => 'name',
-        'label' => 'Name Contains',
-        'remember' => 0,
-      ),
-      'case' => 0,
-      'id' => 'name',
-      'table' => 'stock',
-      'field' => 'name',
-      'relationship' => 'none',
-      'agg' => array(
-        'records_with' => 1,
-        'aggregates_with' => 1,
-      ),
+    '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('header', 'Click "Show" to see a list of all stocks matching the entered criteria. If you leave a any of the criteria blank then the stocks will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all stocks will be listed.');
-  $handler->override_option('header_format', '2');
-  $handler->override_option('header_empty', 0);
-  $handler->override_option('empty', 'No stocks match the supplied criteria.');
-  $handler->override_option('empty_format', '1');
-  $handler->override_option('items_per_page', 50);
-  $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' => '',
     ),
     ),
-    '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' => '',
-      ),
+    'all_relationships' => array(
+      'separator' => '',
     ),
     ),
-    'default' => '-1',
-  ));
-  $default_handler = $handler;
+  );
+  /* Header: Global: Action Links */
+  $handler->display->display_options['header']['action_links_area']['id'] = 'action_links_area';
+  $handler->display->display_options['header']['action_links_area']['table'] = 'views';
+  $handler->display->display_options['header']['action_links_area']['field'] = 'action_links_area';
+  $handler->display->display_options['header']['action_links_area']['label'] = 'Action Links';
+  $handler->display->display_options['header']['action_links_area']['empty'] = TRUE;
+  $handler->display->display_options['header']['action_links_area']['link-1'] = array(
+    'label-1' => 'Add Stock',
+    'path-1' => 'node/add/tripal-stock',
+  );
+  $handler->display->display_options['header']['action_links_area']['link-2'] = array(
+    'label-2' => '',
+    'path-2' => '',
+  );
+  $handler->display->display_options['header']['action_links_area']['link-3'] = array(
+    'label-3' => '',
+    'path-3' => '',
+  );
+  $handler->display->display_options['header']['action_links_area']['link-4'] = array(
+    'label-4' => '',
+    'path-4' => '',
+  );
+  /* No results behavior: Global: Text area */
+  $handler->display->display_options['empty']['text']['id'] = 'area';
+  $handler->display->display_options['empty']['text']['table'] = 'views';
+  $handler->display->display_options['empty']['text']['field'] = 'area';
+  $handler->display->display_options['empty']['text']['content'] = 'No stocks match the supplied criteria.';
+  $handler->display->display_options['empty']['text']['format'] = '1';
+  /* Relationship: Stock: Stock => Node */
+  $handler->display->display_options['relationships']['stock_id']['id'] = 'stock_id';
+  $handler->display->display_options['relationships']['stock_id']['table'] = 'chado_stock';
+  $handler->display->display_options['relationships']['stock_id']['field'] = 'stock_id';
+  /* Field: Content: Nid */
+  $handler->display->display_options['fields']['nid']['id'] = 'nid';
+  $handler->display->display_options['fields']['nid']['table'] = 'node';
+  $handler->display->display_options['fields']['nid']['field'] = 'nid';
+  $handler->display->display_options['fields']['nid']['exclude'] = TRUE;
+  /* Field: Chado Stock: Uniquename */
+  $handler->display->display_options['fields']['uniquename']['id'] = 'uniquename';
+  $handler->display->display_options['fields']['uniquename']['table'] = 'stock';
+  $handler->display->display_options['fields']['uniquename']['field'] = 'uniquename';
+  $handler->display->display_options['fields']['uniquename']['label'] = 'Unique Name';
+  /* Field: Chado Stock: Name */
+  $handler->display->display_options['fields']['name_2']['id'] = 'name_2';
+  $handler->display->display_options['fields']['name_2']['table'] = 'stock';
+  $handler->display->display_options['fields']['name_2']['field'] = 'name';
+  /* Field: Chado Cvterm: Name */
+  $handler->display->display_options['fields']['name']['id'] = 'name';
+  $handler->display->display_options['fields']['name']['table'] = 'cvterm';
+  $handler->display->display_options['fields']['name']['field'] = 'name';
+  $handler->display->display_options['fields']['name']['label'] = 'Type';
+  /* Field: Chado Organism: Common Name */
+  $handler->display->display_options['fields']['common_name']['id'] = 'common_name';
+  $handler->display->display_options['fields']['common_name']['table'] = 'organism';
+  $handler->display->display_options['fields']['common_name']['field'] = 'common_name';
+  $handler->display->display_options['fields']['common_name']['label'] = 'Organism';
+  /* Field: Content: Delete link */
+  $handler->display->display_options['fields']['delete_node']['id'] = 'delete_node';
+  $handler->display->display_options['fields']['delete_node']['table'] = 'views_entity_node';
+  $handler->display->display_options['fields']['delete_node']['field'] = 'delete_node';
+  $handler->display->display_options['fields']['delete_node']['relationship'] = 'stock_id';
+  $handler->display->display_options['fields']['delete_node']['exclude'] = TRUE;
+  /* Field: Content: Edit link */
+  $handler->display->display_options['fields']['edit_node']['id'] = 'edit_node';
+  $handler->display->display_options['fields']['edit_node']['table'] = 'views_entity_node';
+  $handler->display->display_options['fields']['edit_node']['field'] = 'edit_node';
+  $handler->display->display_options['fields']['edit_node']['relationship'] = 'stock_id';
+  $handler->display->display_options['fields']['edit_node']['exclude'] = TRUE;
+  /* Field: Global: Custom text */
+  $handler->display->display_options['fields']['nothing']['id'] = 'nothing';
+  $handler->display->display_options['fields']['nothing']['table'] = 'views';
+  $handler->display->display_options['fields']['nothing']['field'] = 'nothing';
+  $handler->display->display_options['fields']['nothing']['label'] = '';
+  $handler->display->display_options['fields']['nothing']['alter']['text'] = '[edit_node]   [delete_node]';
+  $handler->display->display_options['fields']['nothing']['element_label_colon'] = FALSE;
+  /* Sort criterion: Chado Organism: Common Name */
+  $handler->display->display_options['sorts']['common_name']['id'] = 'common_name';
+  $handler->display->display_options['sorts']['common_name']['table'] = 'organism';
+  $handler->display->display_options['sorts']['common_name']['field'] = 'common_name';
+  /* Sort criterion: Chado Stock: Uniquename */
+  $handler->display->display_options['sorts']['uniquename']['id'] = 'uniquename';
+  $handler->display->display_options['sorts']['uniquename']['table'] = 'stock';
+  $handler->display->display_options['sorts']['uniquename']['field'] = 'uniquename';
+  /* Filter criterion: Chado Organism: Common Name */
+  $handler->display->display_options['filters']['common_name']['id'] = 'common_name';
+  $handler->display->display_options['filters']['common_name']['table'] = 'organism';
+  $handler->display->display_options['filters']['common_name']['field'] = 'common_name';
+  $handler->display->display_options['filters']['common_name']['value'] = 'All';
+  $handler->display->display_options['filters']['common_name']['group'] = '0';
+  $handler->display->display_options['filters']['common_name']['exposed'] = TRUE;
+  $handler->display->display_options['filters']['common_name']['expose']['operator_id'] = 'common_name_op';
+  $handler->display->display_options['filters']['common_name']['expose']['label'] = 'Organism';
+  $handler->display->display_options['filters']['common_name']['expose']['operator'] = 'common_name_op';
+  $handler->display->display_options['filters']['common_name']['expose']['identifier'] = 'organism_common_name';
+  $handler->display->display_options['filters']['common_name']['expose']['remember_roles'] = array(
+    2 => '2',
+    1 => 0,
+    3 => 0,
+  );
+  /* Filter criterion: Chado Stock: Type Id */
+  $handler->display->display_options['filters']['type_id']['id'] = 'type_id';
+  $handler->display->display_options['filters']['type_id']['table'] = 'stock';
+  $handler->display->display_options['filters']['type_id']['field'] = 'type_id';
+  $handler->display->display_options['filters']['type_id']['value'] = 'All';
+  $handler->display->display_options['filters']['type_id']['group'] = '0';
+  $handler->display->display_options['filters']['type_id']['exposed'] = TRUE;
+  $handler->display->display_options['filters']['type_id']['expose']['operator_id'] = 'type_id_op';
+  $handler->display->display_options['filters']['type_id']['expose']['label'] = 'Type';
+  $handler->display->display_options['filters']['type_id']['expose']['operator'] = 'type_id_op';
+  $handler->display->display_options['filters']['type_id']['expose']['identifier'] = 'type_id';
+  $handler->display->display_options['filters']['type_id']['expose']['remember_roles'] = array(
+    2 => '2',
+    1 => 0,
+    3 => 0,
+  );
+  /* Filter criterion: Chado Stock: Name */
+  $handler->display->display_options['filters']['name']['id'] = 'name';
+  $handler->display->display_options['filters']['name']['table'] = 'stock';
+  $handler->display->display_options['filters']['name']['field'] = 'name';
+  $handler->display->display_options['filters']['name']['operator'] = 'contains';
+  $handler->display->display_options['filters']['name']['group'] = '0';
+  $handler->display->display_options['filters']['name']['exposed'] = TRUE;
+  $handler->display->display_options['filters']['name']['expose']['operator_id'] = 'name_op';
+  $handler->display->display_options['filters']['name']['expose']['label'] = 'Name Contains';
+  $handler->display->display_options['filters']['name']['expose']['operator'] = 'name_op';
+  $handler->display->display_options['filters']['name']['expose']['identifier'] = 'name';
+  $handler->display->display_options['filters']['name']['expose']['remember_roles'] = array(
+    2 => '2',
+    1 => 0,
+    3 => 0,
+  );
+
+  /** MANUALLY ADD since filter handler no exporting correctly */
+  $handler->display->display_options['filters']['common_name']['expose']['values_form_type'] = 'select';
+  $handler->display->display_options['filters']['common_name']['expose']['select_multiple'] = FALSE;
+  $handler->display->display_options['filters']['common_name']['expose']['select_optional'] = TRUE;
+  $handler->display->display_options['filters']['common_name']['expose']['max_length'] = 40;
+  $handler->display->display_options['filters']['type_id']['expose']['values_form_type'] = 'select';
+  $handler->display->display_options['filters']['type_id']['expose']['select_multiple'] = FALSE;
+  $handler->display->display_options['filters']['type_id']['expose']['select_optional'] = TRUE;
+  $handler->display->display_options['filters']['type_id']['expose']['max_length'] = 40;
+
+  /* Display: Page */
   $handler = $view->new_display('page', 'Page', 'page_1');
   $handler = $view->new_display('page', 'Page', 'page_1');
-  $handler->override_option('path', 'chado/stocks');
-  $handler->override_option('menu', array(
-    'type' => 'normal',
-    'title' => 'Stocks',
-    'description' => 'A stock is the physical entities, either living or preserved, held by collections and can be globally identified by the combination of organism, uniquename and stock type.',
-    'weight' => '10',
-    'name' => 'navigation',
-  ));
-  $handler->override_option('tab_options', array(
-    'type' => 'none',
-    'title' => '',
-    'description' => '',
-    'weight' => 0,
-    'name' => 'navigation',
-  ));
-  // Add code specific to a local chado installation
-  // NOTE: Edit $handler above to $default_handler for the default display
-  if (tripal_core_chado_schema_exists()) {
-    // Add nid field
-    $fields = $view->get_items('field', 'default');
-    $new_fields = array(
-      'nid' => array(
-        'label' => 'Nid',
-        'alter' => array(
-          'alter_text' => 0,
-          'text' => '',
-          'make_link' => 0,
-          'path' => '',
-          'absolute' => 0,
-          'link_class' => '',
-          'alt' => '',
-          'rel' => '',
-          '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,
-        'hide_alter_empty' => 1,
-        'link_to_node' => 0,
-        'exclude' => 1,
-        'id' => 'nid',
-        'table' => 'node',
-        'field' => 'nid',
-        'relationship' => 'none',
-      )
-    );
-    $fields = $new_fields + $fields;
-    // Change analysis.name to have a link to the node
-    $fields['name_2']['alter']['link_to_node'] = 1;
-    $default_handler->override_option('fields', $fields);
-    // Adds stock => Node relationship
-    $default_handler->override_option('relationships', array(
-      'nid' => array(
-        'label' => 'Stock to Node',
-        'required' => 0,
-        'id' => 'nid',
-        'table' => 'chado_stock',
-        'field' => 'nid',
-        'relationship' => 'none',
-      ),
-    ));
-    // Only show records with published nodes
-    /**
-    $filters = $view->get_items('filter', 'default');
-    $filters['status'] = array(
-      'operator' => '=',
-      'value' => '1',
-      'group' => '0',
-      'exposed' => FALSE,
-      'expose' => array(
-        'operator' => FALSE,
-        'label' => '',
-      ),
-      'id' => 'status',
-      'table' => 'node',
-      'field' => 'status',
-      'relationship' => 'none',
-    );
-    $default_handler->override_option('filters', $filters);
-    */
-  }
-  $views[$view->name] = $view;
+  $handler->display->display_options['path'] = 'admin/tripal/chado/tripal_stock/stocks';
+  $handler->display->display_options['menu']['type'] = 'default tab';
+  $handler->display->display_options['menu']['title'] = 'Stocks';
+  $handler->display->display_options['menu']['description'] = 'A stock is the physical entities, either living or preserved';
+  $handler->display->display_options['menu']['weight'] = '-10';
+  $handler->display->display_options['menu']['context'] = 0;
+  $handler->display->display_options['menu']['context_only_inline'] = 0;
+  $handler->display->display_options['tab_options']['weight'] = '0';
 
 
-  return $views;
+  /** MANUALLY ADD since filter handler no exporting correctly
+  $handler->display->display_options['filters']['common_name']['expose']['values_form_type'] = 'select';
+  $handler->display->display_options['filters']['common_name']['expose']['select_multiple'] = FALSE;
+  $handler->display->display_options['filters']['common_name']['expose']['select_optional'] = TRUE;
+  $handler->display->display_options['filters']['common_name']['expose']['max_length'] = 40;
+  $handler->display->display_options['filters']['type_id']['expose']['values_form_type'] = 'select';
+  $handler->display->display_options['filters']['type_id']['expose']['select_multiple'] = FALSE;
+  $handler->display->display_options['filters']['type_id']['expose']['select_optional'] = TRUE;
+  $handler->display->display_options['filters']['type_id']['expose']['max_length'] = 40;
+  */
+  return $view;
 }
 }