Browse Source

Tripal Views: Removed Views Data Export. Now in it's own extension module (tripal_data_export)

Lacey Sanderson 11 years ago
parent
commit
47f94bbed4

+ 0 - 41
tripal_views/patches/views_data_export-postgresql-1293788-2.patch

@@ -1,41 +0,0 @@
-diff --git a/plugins/views_data_export_plugin_display_export.inc b/plugins/views_data_export_plugin_display_export.inc
-index 3356a8c..bf6761a 100644
---- a/plugins/views_data_export_plugin_display_export.inc
-+++ b/plugins/views_data_export_plugin_display_export.inc
-@@ -544,7 +544,16 @@ class views_data_export_plugin_display_export extends views_plugin_display_feed
-         $select_aliases[] = "cl.$alias AS $hash";
-       }
- 
--      $insert_query = 'CREATE TABLE {' . $this->index_tablename() . '} SELECT @row := @row + 1 AS ' . $this->batched_execution_state->sandbox['weight_field_alias'] . ', ' . implode(', ', $select_aliases) . ' FROM (' . $query . ') AS cl, (SELECT @row := 0) AS r';
-+      if ($this->_get_database_driver() == 'pgsql') {
-+        // Create temporary sequence
-+        $seq_name = $this->index_tablename() . '_seq';
-+        $create_seq_query = 'CREATE TEMP sequence ' . $seq_name;
-+        // query uses sequence to create row number
-+        $insert_query = 'CREATE TABLE {' . $this->index_tablename() . "} AS SELECT nextval('".$seq_name."') AS " . $this->batched_execution_state->sandbox['weight_field_alias'] . ', ' . implode(', ', $select_aliases) . ' FROM (' . $query . ') AS cl';
-+      }
-+      else {
-+        $insert_query = 'CREATE TABLE {' . $this->index_tablename() . '} SELECT @row := @row + 1 AS ' . $this->batched_execution_state->sandbox['weight_field_alias'] . ', ' . implode(', ', $select_aliases) . ' FROM (' . $query . ') AS cl, (SELECT @row := 0) AS r';
-+      }
- 
-       // Allow for a view to query an external database.
-       if (isset($view->base_database)) {
-@@ -552,6 +561,9 @@ class views_data_export_plugin_display_export extends views_plugin_display_feed
-         $external = TRUE;
-       }
- 
-+      if ($this->_get_database_driver() == 'pgsql') {
-+        db_query($create_seq_query);
-+      }
-       db_query($insert_query, $args);
- 
-       // Now create an index for the weight field, otherwise the queries on the
-@@ -778,7 +790,7 @@ class views_data_export_plugin_display_export extends views_plugin_display_feed
-    */
-   function is_compatible() {
-     $incompatible_drivers = array (
--      'pgsql',
-+      //'pgsql',
-     );
-     $db_driver = $this->_get_database_driver();
-     return !in_array($db_driver, $incompatible_drivers);

+ 0 - 31
tripal_views/tripal_views.info

@@ -6,45 +6,14 @@ package = Tripal
 version = 7.x-2.0beta
 configure = admin/tripal/views-integration
 
-files[] = views/handlers/chado_views_handler_relationship.inc
-files[] = views/handlers/views_handler_join_chado_through_linking.inc
-files[] = views/handlers/views_handler_join_chado_through_linking.inc
-files[] = views/handlers/chado_views_handler_filter_string.inc
-files[] = views/handlers/chado_views_handler_filter_date.inc
 files[] = views/handlers/tripal_views_handler_filter_textarea.inc
-files[] = views/handlers/chado_views_handler_field_date.inc
-files[] = views/handlers/chado_views_handler_field_boolean.inc
-files[] = views/handlers/chado_views_handler_relationship_to_node.inc
-files[] = views/handlers/chado_views_handler_sort.inc
 files[] = views/handlers/tripal_views_handler_filter_file_upload.inc
-files[] = views/handlers/chado_views_handler_field_counter.inc
-files[] = views/handlers/chado_views_handler_field_custom.inc
-files[] = views/handlers/chado_views_handler_field_math.inc
 files[] = views/handlers/tripal_views_handler_field_sequence.inc
 files[] = views/handlers/tripal_views_handler_filter_no_results.inc
-files[] = views/handlers/chado_views_handler_field_numeric.inc
-files[] = views/handlers/chado_views_handler_filter_numeric.inc
 files[] = views/handlers/tripal_views_handler_filter_sequence.inc
-files[] = views/handlers/chado_views_handler_field.inc
-files[] = views/handlers/chado_views_handler_filter_float.inc
-files[] = views/handlers/views_handler_join_chado_aggregator.inc
-files[] = views/handlers/views_handler_join_chado_aggregator.inc
 files[] = views/handlers/tripal_views_handler_filter_select_cvterm.inc
-files[] = views/handlers/deprecated/views_handler_field_chado_count.inc
-files[] = views/handlers/deprecated/views_handler_field_readable_date.inc
-files[] = views/handlers/deprecated/views_handler_field_dbxref_accession_link.inc
-files[] = views/handlers/deprecated/views_handler_filter_chado_boolean.inc
-files[] = views/handlers/deprecated/views_handler_filter_chado_select_string.inc
-files[] = views/handlers/deprecated/views_handler_filter_chado_select_cvterm_name.inc
-files[] = views/handlers/deprecated/views_handler_field_node_optional.inc
-files[] = views/handlers/chado_views_handler_field_markup.inc
-files[] = views/handlers/chado_views_handler_filter_boolean_operator.inc
 files[] = views/handlers/tripal_views_handler_filter_select_string.inc
-files[] = views/handlers/chado_views_handler_filter_equality.inc
 files[] = views/handlers/tripal_views_handler_field_aggregate.inc
 
-files[] = views_data_export/plugins/tripal_views_plugin_style_export_fasta.inc
-
 dependencies[] = views
-;dependencies[] = views_data_export
 dependencies[] = tripal_core

+ 0 - 4
tripal_views/tripal_views.module

@@ -178,10 +178,6 @@ function tripal_views_theme($existing, $type, $theme, $path) {
       'template'  => 'tripal_views_integration_fields_form',
       'render element'=> 'form',
     ),
-    'tripal_views_data_export_download_form' => array(
-      'render element'=> 'form',
-      'template'  => 'tripal_views_data_export_download_form',
-    ),
     'file_upload_combo' => array(
       'variables' => array('element' => NULL)
     ),

+ 1 - 146
tripal_views/tripal_views.views.inc

@@ -109,12 +109,6 @@ function tripal_views_views_pre_render(&$view) {
   // view has populated the $view->exposed_input variable
   unset($view->exposed_input);
 
-  // we want to add to the bottom of the views the form for downloading
-  // results in other formats (e.g. Excel, FASTA, CSV, etc.).  The Views Data
-  // Export module provides small images at the bottom, but we want to provide
-  // a more intutitive interface for getting different file formats
-  // $form = drupal_get_form('tripal_views_data_export_download_form', $view, $display_id, $args);
-  // $view->attachment_after = $form;
 }
 
 /**
@@ -438,50 +432,6 @@ function tripal_views_views_data_alter(&$data) {
     return $data;
 }
 
-/**
- * Implementation of hook_views_plugins().
- */
-function tripal_views_views_plugins() {
-  $tc_path = drupal_get_path('module', 'tripal_views');
-
-  $style_defaults = array(
-    'path' => $tc_path . '/views_data_export/plugins',
-    'parent' => 'views_data_export',
-    'theme' => 'views_data_export',
-    'theme path' => $tc_path . '/views_data_export/theme',
-    'theme file' => 'tripal_views_data_export.theme.inc',
-    'uses row plugin' => FALSE,
-    'uses fields' => TRUE,
-    'uses options' => TRUE,
-    'type' => 'data_export',
-  );
-
-  // add FASTA format as a new style for the existing views_export_data Display
-  return array(
-    'style' => array(
-      'views_data_export_fasta' => array(
-        'title' => t('FASTA file'),
-        'help' => t('Display results in FASTA format. All fields in results are on the definition line while the feature.residues field must be present .'),
-        'handler' => 'tripal_views_plugin_style_export_fasta',
-        // Views Data Export element that will be used to set additional headers when serving the feed.
-        'export headers' => array('Content-type: text/plain; charset=utf-8'),
-        // Views Data Export element mostly used for creating some additional classes and template names.
-        'export feed type' => 'fasta',
-        'export feed text' => 'FASTA',
-        'export feed file' => '%view.fna',
-        'export feed icon' => $tc_path . '/views_data_export/images/fasta.png',
-        'additional themes' => array(
-          'views_data_export_fasta_header' => 'style',
-          'views_data_export_fasta_body' => 'style',
-          'views_data_export_fasta_footer' => 'style',
-        ),
-        'additional themes base' => 'views_data_export_fasta',
-      ) + $style_defaults,
-    ),
-  );
-}
-*/
-
 /**
  * Implementation of hook_views_pre_view().
  */
@@ -492,99 +442,4 @@ function tripal_views_views_pre_view(&$view, &$display_id, &$args) {
   // file uploads require $_POST. We need to make sure these two modules
   // have access to everything needed for this view to work properly
   $_GET = array_merge($_GET, $_POST);
-}
-
-/**
- * Implementation of hook_views_pre_build().
- */
-/* function tripal_views_views_pre_render(&$view, &$display_id, &$args){
-  // we want to add to the bottom of the views the form for downloading
-  // results in other formats (e.g. Excel, FASTA, CSV, etc.).  The Views Data
-  // Export module provides small images at the bottom, but we want to provide
-  // a more intutitive interface for getting different file formats
-  $form = drupal_get_form('tripal_views_data_export_download_form',$view,$display_id,$args);
-  $view->attachment_after = $form;
-}*/
-
-/**
- * the Download Views data export form
-function tripal_views_data_export_download_form(&$form_state, $view, $display_id, $args) {
-  $form = array();
-  $urls = array();
-
-  // get any export_data_export displays
-  $displays = $view->display;
-  $options = array();
-  $default = '';
-  $current_display = $view->current_display;
-  foreach ($displays as $name => $display) {
-    if (preg_match("/^views_data_export/", $name)) {
-
-      // only add this display to the form if it is attached
-      $display_options = $display->display_options;
-      if (strcmp($display_options['displays'][$current_display], $current_display) != 0) {
-         continue;
-      }
-
-      // set the first item as default
-      if (!$default) {
-        $default = $display->id;
-      }
-
-      $path = $display->display_options['path'];
-      $query = $view->get_exposed_input();  // retrieves elements in $_GET array
-
-      $urls[$display->id]['path'] = $path;
-      $urls[$display->id]['query'] = $query;
-
-      // add the new item to the options array
-      $options[$display->id] = $display->display_title;
-    }
-  }
-
-  // only generate the form if we have views_data_export displays attached
-  // to this view
-  if (count($options) > 0) {
-
-    $form_state['storage']['urls'] = $urls;
-    $form['#cache'] = TRUE;
-
-    // we want the form to redirect to a new window
-    $form['#attributes']['target'] = "_blank";
-
-    // now build the form elements
-    $form['downloads'] = array(
-      '#type' => 'fieldset',
-      '#title' => 'Download Results',
-      '#collapsible' => TRUE,
-      '#collapsed' => FALSE
-    );
-    $form['downloads']['file_type'] = array(
-      '#title' => t('File format'),
-      '#type' => 'radios',
-      '#options' => $options,
-      '#required' => TRUE,
-      '#default_value' => $default,
-      '#description' => t('Please select a file format to download'),
-    );
-    $form['downloads']['submit'] = array(
-      '#value' => t('Download Results'),
-      '#type' => 'submit',
-    );
-  }
-  return $form;
-}
-*/
-
-/**
- * Submit for the Download Views data export form
-function tripal_views_data_export_download_form_submit($form, &$form_state) {
-  $urls = $form_state['storage']['urls'];
-  $display_id = $form_state['values']['file_type'];
-  drupal_goto($urls[$display_id]['path'], $urls[$display_id]['query']);
-}
-*/
-
-
-
-
+}

+ 0 - 12
tripal_views/tripal_views_data_export_download_form.tpl.php

@@ -1,12 +0,0 @@
-<?php
-
-/**
- * @file
- * Render the views data export form on views pages
- * Allows you to select a download type without using Feed icons
- */
-print drupal_render($form);
-
-?>
-
-<!-- END -->

BIN
tripal_views/views_data_export/images/fasta.png


+ 0 - 92
tripal_views/views_data_export/plugins/tripal_views_plugin_style_export_fasta.inc

@@ -1,92 +0,0 @@
-<?php
-/**
- * @file
- * Plugin include file for export style plugin.
- */
-
-/**
- * Generalized style plugin for export plugins.
- *
- * @ingroup views_style_plugins
- */
-class tripal_views_plugin_style_export_fasta extends views_data_export_plugin_style_export {
-
-  /**
-   * Set options fields and default values.
-   *
-   * @return
-   * An array of options information.
-   */
-  function option_definition() {
-    $options = parent::option_definition();
-
-
-    return $options;
-  }
-
-  /**
-   * Options form mini callback.
-   *
-   * @param $form
-   * Form array to add additional fields to.
-   * @param $form_state
-   * State of the form.
-   * @return
-   * None.
-   */
-  function options_form(&$form, &$form_state) {
-    parent::options_form($form, $form_state);
-
-
-    $form['display'] = array(
-      '#type' => 'fieldset',
-      '#title' => 'Format Output',
-    );
-    
-    $form['display']['residues_colname'] = array(
-      '#type' => 'textfield',
-      '#title' => t('The name of the residues column'),
-      '#description' => t("The name of the column that contains the sequence ".
-         "residues. To discover this field edit the feature residues field ".
-         "and click the checkbox \"Rewrite ".
-         "the output of this field\".  In the replacement patterns section are ".
-         "field names.  The field name for the residues column should be the ".
-         "last one"),
-      '#required' => TRUE,
-      '#default_value' => $this->options['display']['residues_colname'],
-    );
-    
-    $form['display']['use_residues'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Use the value as is'),
-      '#description' => t('Check this box if you do not want the FASTA exporter ' .
-         'to provide a definition line or add line breaks to the sequence. This is '.
-         'useful when the field options provided for the residues column has '.
-         'already been formatted'),
-      '#default_value' => $this->options['display']['use_residues'],
-    );
-
-
-    $form['display']['num_bases_per_line'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Number of bases per line'),
-      '#description' => t('Specify the number of bases per line. If no value is ' .
-        'provided. The sequence will be one long string (default)'),
-      '#default_value' => $this->options['display']['num_bases_per_line'],
-    );
-    
-    $form['display']['defline_fields'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Defenition line fields'),
-      '#default_value' => $this->options['display']['defline_fields'],
-      '#description' => t("This field controls the information present in the definition ".
-         "line for each sequence. Any of the fields in the view can be used in the ".
-         "definition line.  To discover these fields, add the feature residues as the ".
-         "last field in the view.  Then edit the field and click the checkbox \"Rewrite ".
-         "the output of this field\".  In the replacement patterns section are the ".
-         "field replacement tokens that can be used in this field. You may include any ".
-         "additional text to separte or qualify these fields.  Only fields that have not ".
-         "been excluded from the display will appear."),
-    );
-  }
-}

+ 0 - 31
tripal_views/views_data_export/theme/tripal_views_data_export.theme.inc

@@ -1,31 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains template preprocessing functions
- */
-
-/**
- * Preprocess the variables for the FASTA views data export -body template
- *   - replace the field tokens in the fasta record definition lines
- *
- * @param $vars
- *   The variables available to the template
- */
-function template_preprocess_views_data_export_fasta_body(&$vars) {
-  _views_data_export_header_shared_preprocess($vars);
-  _views_data_export_body_shared_preprocess($vars);
-  
-  // get export settings
-  $defline_tpl = $vars['options']['display']['defline_fields'];
-
-  // iterate through the rows and replace the field tokens with values
-  // to generate the definition line  
-  foreach ($vars['themed_rows'] as $i => $fields) {
-    $defline = $defline_tpl;
-    foreach ($fields as $key => $value) {
-      $defline = preg_replace("/\[$key\]/", $value, $defline);
-    }
-    $vars['themed_rows'][$i]['defline'] = $defline;
-  }
-}

+ 0 - 49
tripal_views/views_data_export/theme/views-data-export-fasta-body.tpl.php

@@ -1,49 +0,0 @@
-<?php
-
-/**
- * @file
- * Renders the body portion of a FASTA views data export
- */
-$defline_tpl = $variables['options']['display']['defline_fields'];
-$num_bases_per_line = $variables['options']['display']['num_bases_per_line'];
-$use_residues = $variables['options']['display']['use_residues'];
-$residues_colname = $variables['options']['display']['residues_colname'];
-
-if(!$num_bases_per_line){
-   $num_bases_per_line = 50;
-}
-
-// foreach row in the views table
-foreach ($themed_rows as $index => $fields) {
-  $defline = array();
-  $residues = '';
-  
-  // if we're using the residues as is then we assume the residues are already
-  // formatted in FASTA format.   We just need to print
-  if ($use_residues) {
-     print "$fields[$residues_colname]\r\n";
-  }
-  // if we're not using the residues as is then wrap the residues
-  // and generate a proper FASTA format
-  else {
-  
-    foreach ($fields as $key => $value) {
-
-      // if the setup indicates, wrap the sequence 
-      if (strcmp($key, $residues_colname) == 0) {
-        $residues = wordwrap($value, $num_bases_per_line, "\r\n", TRUE);
-      }
-
-      // set the FASTA header
-      if (strcmp($key, 'defline') == 0) {
-        $defline = $value;
-      }
-    }
-
-    // print the FASTA record
-    print ">$defline\r\n";
-    print "$residues\r\n";
-  }
-}
-
-

+ 0 - 7
tripal_views/views_data_export/theme/views-data-export-fasta-footer.tpl.php

@@ -1,7 +0,0 @@
-<?php
-
-/**
- * @file
- * Renders the footer of a FASTA views data export
- * FASTA files don't have a footer.
- */

+ 0 - 7
tripal_views/views_data_export/theme/views-data-export-fasta-header.tpl.php

@@ -1,7 +0,0 @@
-<?php
-
-/**
- * @file
- * Renders the header of a FASTA views data export
- * FASTA files don't have a header.
- */