Browse Source

Tripal Views: House-cleaning -removed all the chado_views_handlers which are no longer needed due to Views3 bug fixes :)

Lacey Sanderson 11 years ago
parent
commit
c458c175d0
28 changed files with 0 additions and 3297 deletions
  1. 0 97
      tripal_views/tripal_views.views.inc
  2. 0 152
      tripal_views/views/handlers/chado_views_handler_field.inc
  3. 0 121
      tripal_views/views/handlers/chado_views_handler_field_boolean.inc
  4. 0 95
      tripal_views/views/handlers/chado_views_handler_field_counter.inc
  5. 0 95
      tripal_views/views/handlers/chado_views_handler_field_custom.inc
  6. 0 111
      tripal_views/views/handlers/chado_views_handler_field_date.inc
  7. 0 95
      tripal_views/views/handlers/chado_views_handler_field_markup.inc
  8. 0 95
      tripal_views/views/handlers/chado_views_handler_field_math.inc
  9. 0 95
      tripal_views/views/handlers/chado_views_handler_field_numeric.inc
  10. 0 145
      tripal_views/views/handlers/chado_views_handler_filter_boolean_operator.inc
  11. 0 171
      tripal_views/views/handlers/chado_views_handler_filter_date.inc
  12. 0 91
      tripal_views/views/handlers/chado_views_handler_filter_equality.inc
  13. 0 97
      tripal_views/views/handlers/chado_views_handler_filter_float.inc
  14. 0 91
      tripal_views/views/handlers/chado_views_handler_filter_numeric.inc
  15. 0 150
      tripal_views/views/handlers/chado_views_handler_filter_string.inc
  16. 0 27
      tripal_views/views/handlers/chado_views_handler_relationship.inc
  17. 0 81
      tripal_views/views/handlers/chado_views_handler_relationship_to_node.inc
  18. 0 58
      tripal_views/views/handlers/chado_views_handler_sort.inc
  19. 0 116
      tripal_views/views/handlers/chado_wrapper_functions.inc
  20. 0 67
      tripal_views/views/handlers/deprecated/views_handler_field_chado_count.inc
  21. 0 48
      tripal_views/views/handlers/deprecated/views_handler_field_dbxref_accession_link.inc
  22. 0 97
      tripal_views/views/handlers/deprecated/views_handler_field_node_optional.inc
  23. 0 82
      tripal_views/views/handlers/deprecated/views_handler_field_readable_date.inc
  24. 0 93
      tripal_views/views/handlers/deprecated/views_handler_filter_chado_boolean.inc
  25. 0 260
      tripal_views/views/handlers/deprecated/views_handler_filter_chado_select_cvterm_name.inc
  26. 0 205
      tripal_views/views/handlers/deprecated/views_handler_filter_chado_select_string.inc
  27. 0 340
      tripal_views/views/handlers/views_handler_join_chado_aggregator.inc
  28. 0 122
      tripal_views/views/handlers/views_handler_join_chado_through_linking.inc

+ 0 - 97
tripal_views/tripal_views.views.inc

@@ -85,103 +85,6 @@ function tripal_views_views_handlers() {
         'parent' => 'chado_views_handler_filter_string',
       ),
       */
-
-      // Custom Tripal Field Handlers
-      /** D7 @todo: get handlers working
-      'tripal_views_handler_field_aggregate' => array(
-        'parent' => 'chado_views_handler_field',
-      ),
-      'tripal_views_handler_field_sequence' => array(
-        'parent' => 'chado_views_handler_field',
-      ),
-      */
-
-      // Join Handlers
-      /** D7 @todo: determine if we need these anymore :)
-      'views_handler_join_chado_aggregator' => array(
-        'parent' => 'views_join',
-      ),
-      'views_handler_join_chado_through_linking' => array(
-        'parent' => 'views_join',
-      ),
-      */
-
-      // Relationship Handlers
-      /** D7 @todo: determine if we need these anymore
-      'chado_views_handler_relationship' => array(
-        'parent' => 'views_handler_relationship'
-      ),
-      'chado_views_handler_relationship_to_node' => array(
-        'parent' => 'views_handler_relationship'
-      ),
-      */
-
-      // Wrappers for Default Views Handlers-----
-      /** D7 @todo: determine if we need these anymore :)
-      // Field Handlers
-      'chado_views_handler_field' => array(
-        'parent' => 'views_handler_field'
-      ),
-      'chado_views_handler_field_boolean' => array(
-        'parent' => 'views_handler_field_boolean'
-      ),
-      'chado_views_handler_field_counter' => array(
-        'parent' => 'views_handler_field_counter'
-      ),
-      'chado_views_handler_field_custom' => array(
-        'parent' => 'views_handler_field_custom'
-      ),
-      'chado_views_handler_field_date' => array(
-        'parent' => 'views_handler_field_date'
-      ),
-      'chado_views_handler_field_markup' => array(
-        'parent' => 'views_handler_field_markup'
-      ),
-      'chado_views_handler_field_math' => array(
-        'parent' => 'views_handler_field_math'
-      ),
-      'chado_views_handler_field_numeric' => array(
-        'parent' => 'views_handler_field_numeric'
-      ),
-      // Filter Handlers
-      'chado_views_handler_filter_string' => array(
-        'parent' => 'views_handler_filter_string',
-      ),
-      'chado_views_handler_filter_boolean_operator_string' => array(
-        'parent' => 'views_handler_filter_boolean_operator_string',
-      ),
-      'chado_views_handler_filter_boolean_operator' => array(
-        'parent' => 'views_handler_filter_boolean_operator',
-      ),
-      'chado_views_handler_filter_date' => array(
-        'parent' => 'views_handler_filter_date',
-      ),
-      'chado_views_handler_filter_equality' => array(
-        'parent' => 'views_handler_filter_equality',
-      ),
-      'chado_views_handler_filter_float' => array(
-        'parent' => 'views_handler_filter_float',
-      ),
-      'chado_views_handler_filter_numeric' => array(
-        'parent' => 'views_handler_filter_numeric',
-      ),
-      // Sort Handlers
-      'chado_views_handler_sort' => array(
-        'parent' => 'views_handler_sort'
-      ),
-      'chado_views_handler_sort_date' => array(
-        'parent' => 'views_handler_sort_date'
-      ),
-      'chado_views_handler_sort_formula' => array(
-        'parent' => 'views_handler_sort_formula'
-      ),
-      'chado_views_handler_sort_menu_hierarchy' => array(
-        'parent' => 'views_handler_sort_menu_hierarchy'
-      ),
-      'chado_views_handler_sort_random' => array(
-        'parent' => 'views_handler_sort_random'
-      ),
-      */
     ),
   );
 }

+ 0 - 152
tripal_views/views/handlers/chado_views_handler_field.inc

@@ -1,152 +0,0 @@
-<?php
-
-/**
- * @file
- * A chado wrapper for the views_handler_field.
- *
- * Handles fields which may be aggregated during the chado join process. This field
- * will render an aggregated field as a pre_rendered list and will dynamically detect
- * whether the field is aggregated or not.
- */
-class chado_views_handler_field extends views_handler_field {
-
-  function init(&$view, $options) {
-    include_once('chado_wrapper_functions.inc');
-    parent::init($view, $options);
-  }
-
-  /**
-   * Defines the defaults for the options form
-   */
-  function option_definition() {
-    $options = parent::option_definition();
-
-    $options['type'] = array('default' => 'separator');
-    $options['separator'] = array('default' => ', ');
-
-    return $options;
-  }
-
-  /**
-   * Defines the options form (form available to admin when they add a field to a view)
-   */
-  function options_form(&$form, &$form_state) {
-    parent::options_form($form, $form_state);
-
-    // Add a link to node checkbox
-    // but only if this base table is linked to a node and this field is from the base_table
-    if (tripal_core_is_tripal_node_type($this->table) && $this->table == $this->view->base_table) {
-      // If there is a Node: NID field then show a link to node checkbox
-      if (isset($this->view->display['default']->display_options['fields']['nid'])) {
-        $form['link_to_node'] = array(
-          '#type' => 'checkbox',
-          '#title' => t('Link to Node'),
-          '#description' => t('If a given row is associated with a drupal node then '
-            .'this field will appear as a link, linking the user to that node. Otherwise,'
-            .' no link will be displayed.'),
-          '#default_value' => $this->options['link_to_node'],
-        );
-      }
-      // Otherwise inform the user that they need to add a Node:Nid field
-      // to get this functionality
-      else {
-        $form['link_to_node'] = array(
-          '#type' => 'item',
-          '#value' => "This field has the ability to link to it's corresponding node. "
-            . "However, you first need to add the NID field associated with the node. "
-            . "Simple set the NID field to hidden when adding it to ensure it's not "
-            . "shown in the resulting view."
-        );
-      }
-    }
-
-    $form['type'] = array(
-      '#type' => 'radios',
-      '#title' => t('Display type'),
-      '#options' => array(
-        'ul' => t('Unordered list'),
-        'ol' => t('Ordered list'),
-        'separator' => t('Simple separator'),
-      ),
-      '#default_value' => $this->options['type'],
-    );
-
-    $form['separator'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Separator'),
-      '#default_value' => $this->options['separator'],
-      '#process' => array('views_process_dependency'),
-      '#dependency' => array('radio:options[type]' => array('separator')),
-    );
-  }
-
-  /**
-   * Determines whether the current field is aggregated or not
-   * Note: The parent::query() takes care of adding the field to the query, etc.
-   */
-  function query() {
-    parent::query();
-    $this->aggregated = chado_wrapper_is_aggregated_by_join($this);
-  }
-
-  /**
-   * Splits the aggregated values up for use in rendering
-   */
-  function pre_render(&$values) {
-
-    // further check the results to see if this field is a postgresql array
-    $this->aggregated = chado_wrapper_is_aggregated_by_result($this, $values);
-
-    // Split Aggregated Results
-    chado_wrapper_split_array_agg_results($this, $values);
-
-  }
-
-  /**
-   * Render the field.
-   *
-   * Note: Checks to see if we have an array or simple field. If we have an array, then
-   *   split it up and render each part using the parent render functionality.
-   *
-   * @param $values
-   *   The values retrieved from the database.
-   */
-  function render($values) {
-    if ($this->options['link_to_node']) {
-      $link_text = chado_wrapper_render_items($this, $values);
-      return $this->render_node_link($link_text, $values);
-    }
-    else {
-      return chado_wrapper_render_items($this, $values);
-    }
-  }
-
-  /**
-   * Will render the supplied text as a link to the node
-   *
-   * @param $link_text
-   *  The text to render as a link (ie; the text that would normally become underlined
-   *
-   * @return
-   *  A rendered link to the node based on the nid field
-   */
-  function render_node_link($link_text, $values) {
-
-    $node_field = $this->view->field['nid'];
-    if (isset($node_field->aliases['nid'])) {
-      $nid = $values->{$node_field->aliases['nid']};
-    }
-
-    if ($nid) {
-      return l($link_text, 'node/' . $nid);
-    }
-    else {
-      return $link_text;
-    }
-  }
-
-  function parent_render($val) {
-    return parent::render($val);
-  }
-
-}

+ 0 - 121
tripal_views/views/handlers/chado_views_handler_field_boolean.inc

@@ -1,121 +0,0 @@
-<?php
-
-/**
- * @file
- * A chado wrapper for the views_handler_field_boolean.
- *
- * Handles fields which may be aggregated during the chado join process. This field
- * will render an aggregated field as a pre_rendered list and will dynamically detect
- * whether the field is aggregated or not.
- */
-class chado_views_handler_field_boolean extends views_handler_field_boolean {
-
-  function init(&$view, $options) {
-    include_once('chado_wrapper_functions.inc');
-    parent::init($view, $options);
-  }
-
-  /**
-   * Defines the defaults for the options form
-   */
-  function option_definition() {
-    $options = parent::option_definition();
-
-    $options['type'] = array('default' => 'separator');
-    $options['separator'] = array('default' => ', ');
-
-    return $options;
-  }
-
-  /**
-   * Defines the options form (form available to admin when they add a field to a view)
-   */
-  function options_form(&$form, &$form_state) {
-    parent::options_form($form, $form_state);
-
-    $form['type'] = array(
-      '#type' => 'radios',
-      '#title' => t('Display type'),
-      '#options' => array(
-        'ul' => t('Unordered list'),
-        'ol' => t('Ordered list'),
-        'separator' => t('Simple separator'),
-      ),
-      '#default_value' => $this->options['type'],
-    );
-
-    $form['separator'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Separator'),
-      '#default_value' => $this->options['separator'],
-      '#process' => array('views_process_dependency'),
-      '#dependency' => array('radio:options[type]' => array('separator')),
-    );
-  }
-
-  /**
-   * Determines whether the current field is aggregated or not
-   * Note: The parent::query() takes care of adding the field to the query, etc.
-   */
-  function query() {
-    parent::query();
-    $this->aggregated = chado_wrapper_is_aggregated_by_join($this);
-  }
-
-  /**
-   * Splits the aggregated values up for use in rendering
-   */
-  function pre_render(&$values) {
-
-    // further check the results to see if this field is a postgresql array
-    $this->aggregated = chado_wrapper_is_aggregated_by_result($this, $values);
-
-    // Split Aggregated Results
-    chado_wrapper_split_array_agg_results($this, $values);
-
-  }
-
-  /**
-   * Render the field.
-   *
-   * Note: Checks to see if we have an array or simple field. If we have an array, then
-   *   split it up and render each part using the parent render functionality.
-   *
-   * @param $values
-   *   The values retrieved from the database.
-   */
-  function render($values) {
-
-    // check to see if this is a t/f boolean field or a 1/0 boolean field
-    // parent render expects 1/0 so need to translate to that form before rendering
-    if (!is_array($values->{$this->field_alias})) {
-      if (!preg_match('/[01]/', $values->{$this->field_alias})) {
-        if (preg_match('/^[tT]/', $values->{$this->field_alias})) {
-          $values->{$this->field_alias} = 1;
-        }
-        elseif (preg_match('/^[fF]/', $values->{$this->field_alias})) {
-          $values->{$this->field_alias} = 0;
-        }
-      }
-    }
-    else {
-      if (!preg_match('/[01]/', $values->{$this->field_alias}[0])) {
-        foreach ($values->{$this->field_alias} as $k => $v) {
-          if (preg_match('/^[tT]/', $v)) {
-            $values->{$this->field_alias}[$k] = 1;
-          }
-          elseif (preg_match('/^[fF]/', $v)) {
-            $values->{$this->field_alias}[$k] = 0;
-          }
-        }
-      }
-    }
-
-    return chado_wrapper_render_items($this, $values);
-  }
-
-  function parent_render($val) {
-    return parent::render($val);
-  }
-
-}

+ 0 - 95
tripal_views/views/handlers/chado_views_handler_field_counter.inc

@@ -1,95 +0,0 @@
-<?php
-
-/**
- * @file
- * A chado wrapper for the views_handler_field_counter.
- *
- * Handles fields which may be aggregated during the chado join process. This field
- * will render an aggregated field as a pre_rendered list and will dynamically detect
- * whether the field is aggregated or not.
- */
-class chado_views_handler_field_counter extends views_handler_field_counter {
-
-  function init(&$view, $options) {
-    include_once('chado_wrapper_functions.inc');
-    parent::init($view, $options);
-  }
-
-  /**
-   * Defines the defaults for the options form
-   */
-  function option_definition() {
-    $options = parent::option_definition();
-
-    $options['type'] = array('default' => 'separator');
-    $options['separator'] = array('default' => ', ');
-
-    return $options;
-  }
-
-  /**
-   * Defines the options form (form available to admin when they add a field to a view)
-   */
-  function options_form(&$form, &$form_state) {
-    parent::options_form($form, $form_state);
-
-    $form['type'] = array(
-      '#type' => 'radios',
-      '#title' => t('Display type'),
-      '#options' => array(
-        'ul' => t('Unordered list'),
-        'ol' => t('Ordered list'),
-        'separator' => t('Simple separator'),
-      ),
-      '#default_value' => $this->options['type'],
-    );
-
-    $form['separator'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Separator'),
-      '#default_value' => $this->options['separator'],
-      '#process' => array('views_process_dependency'),
-      '#dependency' => array('radio:options[type]' => array('separator')),
-    );
-  }
-
-  /**
-   * Determines whether the current field is aggregated or not
-   * Note: The parent::query() takes care of adding the field to the query, etc.
-   */
-  function query() {
-    parent::query();
-    $this->aggregated = chado_wrapper_is_aggregated_by_join($this);
-  }
-
-  /**
-   * Splits the aggregated values up for use in rendering
-   */
-  function pre_render(&$values) {
-
-    // further check the results to see if this field is a postgresql array
-    $this->aggregated = chado_wrapper_is_aggregated_by_result($this, $values);
-
-    // Split Aggregated Results
-    chado_wrapper_split_array_agg_results($this, $values);
-
-  }
-
-  /**
-   * Render the field.
-   *
-   * Note: Checks to see if we have an array or simple field. If we have an array, then
-   *   split it up and render each part using the parent render functionality.
-   *
-   * @param $values
-   *   The values retrieved from the database.
-   */
-  function render($values) {
-    return chado_wrapper_render_items($this, $values);
-  }
-
-  function parent_render($val) {
-    return parent::render($val);
-  }
-
-}

+ 0 - 95
tripal_views/views/handlers/chado_views_handler_field_custom.inc

@@ -1,95 +0,0 @@
-<?php
-
-/**
- * @file
- * A chado wrapper for the views_handler_field_custom.
- *
- * Handles fields which may be aggregated during the chado join process. This field
- * will render an aggregated field as a pre_rendered list and will dynamically detect
- * whether the field is aggregated or not.
- */
-class chado_views_handler_field_custom extends views_handler_field_custom {
-
-  function init(&$view, $options) {
-    include_once('chado_wrapper_functions.inc');
-    parent::init($view, $options);
-  }
-
-  /**
-   * Defines the defaults for the options form
-   */
-  function option_definition() {
-    $options = parent::option_definition();
-
-    $options['type'] = array('default' => 'separator');
-    $options['separator'] = array('default' => ', ');
-
-    return $options;
-  }
-
-  /**
-   * Defines the options form (form available to admin when they add a field to a view)
-   */
-  function options_form(&$form, &$form_state) {
-    parent::options_form($form, $form_state);
-
-    $form['type'] = array(
-      '#type' => 'radios',
-      '#title' => t('Display type'),
-      '#options' => array(
-        'ul' => t('Unordered list'),
-        'ol' => t('Ordered list'),
-        'separator' => t('Simple separator'),
-      ),
-      '#default_value' => $this->options['type'],
-    );
-
-    $form['separator'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Separator'),
-      '#default_value' => $this->options['separator'],
-      '#process' => array('views_process_dependency'),
-      '#dependency' => array('radio:options[type]' => array('separator')),
-    );
-  }
-
-  /**
-   * Determines whether the current field is aggregated or not
-   * Note: The parent::query() takes care of adding the field to the query, etc.
-   */
-  function query() {
-    parent::query();
-    $this->aggregated = chado_wrapper_is_aggregated_by_join($this);
-  }
-
-  /**
-   * Splits the aggregated values up for use in rendering
-   */
-  function pre_render(&$values) {
-
-    // further check the results to see if this field is a postgresql array
-    $this->aggregated = chado_wrapper_is_aggregated_by_result($this, $values);
-
-    // Split Aggregated Results
-    chado_wrapper_split_array_agg_results($this, $values);
-
-  }
-
-  /**
-   * Render the field.
-   *
-   * Note: Checks to see if we have an array or simple field. If we have an array, then
-   *   split it up and render each part using the parent render functionality.
-   *
-   * @param $values
-   *   The values retrieved from the database.
-   */
-  function render($values) {
-    return chado_wrapper_render_items($this, $values);
-  }
-
-  function parent_render($val) {
-    return parent::render($val);
-  }
-
-}

+ 0 - 111
tripal_views/views/handlers/chado_views_handler_field_date.inc

@@ -1,111 +0,0 @@
-<?php
-
-/**
- * @file
- * A chado wrapper for the views_handler_field_date.
- *
- * Handles fields which may be aggregated during the chado join process. This field
- * will render an aggregated field as a pre_rendered list and will dynamically detect
- * whether the field is aggregated or not.
- */
-class chado_views_handler_field_date extends views_handler_field_date {
-
-  function init(&$view, $options) {
-    include_once('chado_wrapper_functions.inc');
-    parent::init($view, $options);
-  }
-
-  /**
-   * Defines the defaults for the options form
-   */
-  function option_definition() {
-    $options = parent::option_definition();
-
-    $options['type'] = array('default' => 'separator');
-    $options['separator'] = array('default' => ', ');
-
-    return $options;
-  }
-
-  /**
-   * Defines the options form (form available to admin when they add a field to a view)
-   */
-  function options_form(&$form, &$form_state) {
-    parent::options_form($form, $form_state);
-
-    $form['type'] = array(
-      '#type' => 'radios',
-      '#title' => t('Display type'),
-      '#options' => array(
-        'ul' => t('Unordered list'),
-        'ol' => t('Ordered list'),
-        'separator' => t('Simple separator'),
-      ),
-      '#default_value' => $this->options['type'],
-    );
-
-    $form['separator'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Separator'),
-      '#default_value' => $this->options['separator'],
-      '#process' => array('views_process_dependency'),
-      '#dependency' => array('radio:options[type]' => array('separator')),
-    );
-  }
-
-  /**
-   * Determines whether the current field is aggregated or not
-   * Note: The parent::query() takes care of adding the field to the query, etc.
-   */
-  function query() {
-    parent::query();
-    $this->aggregated = chado_wrapper_is_aggregated_by_join($this);
-  }
-
-  /**
-   * Splits the aggregated values up for use in rendering
-   */
-  function pre_render(&$values) {
-
-    // further check the results to see if this field is a postgresql array
-    $this->aggregated = chado_wrapper_is_aggregated_by_result($this, $values);
-
-    // Split Aggregated Results
-    chado_wrapper_split_array_agg_results($this, $values);
-
-  }
-
-  /**
-   * Render the field.
-   *
-   * Note: Checks to see if we have an array or simple field. If we have an array, then
-   *   split it up and render each part using the parent render functionality.
-   *
-   * @param $values
-   *   The values retrieved from the database.
-   */
-  function render($values) {
-
-    // Check the format of the date is a UNIX timestamp and otherwise convert
-    if (!is_array($values->{$this->field_alias})) {
-      if (!preg_match('/^\d+$/', $values->{$this->field_alias})) {
-         $values->{$this->field_alias} = strtotime($values->{$this->field_alias});
-      }
-    }
-    else {
-      if (!preg_match('/^\d+$/', $values->{$this->field_alias}[0])) {
-        foreach ($values->{$this->field_alias} as $k => $v) {
-         $values->{$this->field_alias}[$k] = strtotime($v);
-        }
-      }
-    }
-
-    // render the items
-    return chado_wrapper_render_items($this, $values);
-  }
-
-  function parent_render($val) {
-    return parent::render($val);
-  }
-
-}

+ 0 - 95
tripal_views/views/handlers/chado_views_handler_field_markup.inc

@@ -1,95 +0,0 @@
-<?php
-
-/**
- * @file
- * A chado wrapper for the views_handler_field_markup.
- *
- * Handles fields which may be aggregated during the chado join process. This field
- * will render an aggregated field as a pre_rendered list and will dynamically detect
- * whether the field is aggregated or not.
- */
-class chado_views_handler_field_markup extends views_handler_field_markup {
-
-  function init(&$view, $options) {
-    include_once('chado_wrapper_functions.inc');
-    parent::init($view, $options);
-  }
-
-  /**
-   * Defines the defaults for the options form
-   */
-  function option_definition() {
-    $options = parent::option_definition();
-
-    $options['type'] = array('default' => 'separator');
-    $options['separator'] = array('default' => ', ');
-
-    return $options;
-  }
-
-  /**
-   * Defines the options form (form available to admin when they add a field to a view)
-   */
-  function options_form(&$form, &$form_state) {
-    parent::options_form($form, $form_state);
-
-    $form['type'] = array(
-      '#type' => 'radios',
-      '#title' => t('Display type'),
-      '#options' => array(
-        'ul' => t('Unordered list'),
-        'ol' => t('Ordered list'),
-        'separator' => t('Simple separator'),
-      ),
-      '#default_value' => $this->options['type'],
-    );
-
-    $form['separator'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Separator'),
-      '#default_value' => $this->options['separator'],
-      '#process' => array('views_process_dependency'),
-      '#dependency' => array('radio:options[type]' => array('separator')),
-    );
-  }
-
-  /**
-   * Determines whether the current field is aggregated or not
-   * Note: The parent::query() takes care of adding the field to the query, etc.
-   */
-  function query() {
-    parent::query();
-    $this->aggregated = chado_wrapper_is_aggregated_by_join($this);
-  }
-
-  /**
-   * Splits the aggregated values up for use in rendering
-   */
-  function pre_render(&$values) {
-
-    // further check the results to see if this field is a postgresql array
-    $this->aggregated = chado_wrapper_is_aggregated_by_result($this, $values);
-
-    // Split Aggregated Results
-    chado_wrapper_split_array_agg_results($this, $values);
-
-  }
-
-  /**
-   * Render the field.
-   *
-   * Note: Checks to see if we have an array or simple field. If we have an array, then
-   *   split it up and render each part using the parent render functionality.
-   *
-   * @param $values
-   *   The values retrieved from the database.
-   */
-  function render($values) {
-    return chado_wrapper_render_items($this, $values);
-  }
-
-  function parent_render($val) {
-    return parent::render($val);
-  }
-
-}

+ 0 - 95
tripal_views/views/handlers/chado_views_handler_field_math.inc

@@ -1,95 +0,0 @@
-<?php
-
-/**
- * @file
- * A chado wrapper for the views_handler_field_math.
- *
- * Handles fields which may be aggregated during the chado join process. This field
- * will render an aggregated field as a pre_rendered list and will dynamically detect
- * whether the field is aggregated or not.
- */
-class chado_views_handler_field_math extends views_handler_field_math {
-
-  function init(&$view, $options) {
-    include_once('chado_wrapper_functions.inc');
-    parent::init($view, $options);
-  }
-
-  /**
-   * Defines the defaults for the options form
-   */
-  function option_definition() {
-    $options = parent::option_definition();
-
-    $options['type'] = array('default' => 'separator');
-    $options['separator'] = array('default' => ', ');
-
-    return $options;
-  }
-
-  /**
-   * Defines the options form (form available to admin when they add a field to a view)
-   */
-  function options_form(&$form, &$form_state) {
-    parent::options_form($form, $form_state);
-
-    $form['type'] = array(
-      '#type' => 'radios',
-      '#title' => t('Display type'),
-      '#options' => array(
-        'ul' => t('Unordered list'),
-        'ol' => t('Ordered list'),
-        'separator' => t('Simple separator'),
-      ),
-      '#default_value' => $this->options['type'],
-    );
-
-    $form['separator'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Separator'),
-      '#default_value' => $this->options['separator'],
-      '#process' => array('views_process_dependency'),
-      '#dependency' => array('radio:options[type]' => array('separator')),
-    );
-  }
-
-  /**
-   * Determines whether the current field is aggregated or not
-   * Note: The parent::query() takes care of adding the field to the query, etc.
-   */
-  function query() {
-    parent::query();
-    $this->aggregated = chado_wrapper_is_aggregated_by_join($this);
-  }
-
-  /**
-   * Splits the aggregated values up for use in rendering
-   */
-  function pre_render(&$values) {
-
-    // further check the results to see if this field is a postgresql array
-    $this->aggregated = chado_wrapper_is_aggregated_by_result($this, $values);
-
-    // Split Aggregated Results
-    chado_wrapper_split_array_agg_results($this, $values);
-
-  }
-
-  /**
-   * Render the field.
-   *
-   * Note: Checks to see if we have an array or simple field. If we have an array, then
-   *   split it up and render each part using the parent render functionality.
-   *
-   * @param $values
-   *   The values retrieved from the database.
-   */
-  function render($values) {
-    return chado_wrapper_render_items($this, $values);
-  }
-
-  function parent_render($val) {
-    return parent::render($val);
-  }
-
-}

+ 0 - 95
tripal_views/views/handlers/chado_views_handler_field_numeric.inc

@@ -1,95 +0,0 @@
-<?php
-
-/**
- * @file
- * A chado wrapper for the views_handler_field_numeric.
- *
- * Handles fields which may be aggregated during the chado join process. This field
- * will render an aggregated field as a pre_rendered list and will dynamically detect
- * whether the field is aggregated or not.
- */
-class chado_views_handler_field_numeric extends views_handler_field_numeric {
-
-  function init(&$view, $options) {
-    include_once('chado_wrapper_functions.inc');
-    parent::init($view, $options);
-  }
-
-  /**
-   * Defines the defaults for the options form
-   */
-  function option_definition() {
-    $options = parent::option_definition();
-
-    $options['type'] = array('default' => 'separator');
-    $options['separator'] = array('default' => ', ');
-
-    return $options;
-  }
-
-  /**
-   * Defines the options form (form available to admin when they add a field to a view)
-   */
-  function options_form(&$form, &$form_state) {
-    parent::options_form($form, $form_state);
-
-    $form['type'] = array(
-      '#type' => 'radios',
-      '#title' => t('Display type'),
-      '#options' => array(
-        'ul' => t('Unordered list'),
-        'ol' => t('Ordered list'),
-        'separator' => t('Simple separator'),
-      ),
-      '#default_value' => $this->options['type'],
-    );
-
-    $form['separator'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Separator'),
-      '#default_value' => $this->options['separator'],
-      '#process' => array('views_process_dependency'),
-      '#dependency' => array('radio:options[type]' => array('separator')),
-    );
-  }
-
-  /**
-   * Determines whether the current field is aggregated or not
-   * Note: The parent::query() takes care of adding the field to the query, etc.
-   */
-  function query() {
-    parent::query();
-    $this->aggregated = chado_wrapper_is_aggregated_by_join($this);
-  }
-
-  /**
-   * Splits the aggregated values up for use in rendering
-   */
-  function pre_render(&$values) {
-
-    // further check the results to see if this field is a postgresql array
-    $this->aggregated = chado_wrapper_is_aggregated_by_result($this, $values);
-
-    // Split Aggregated Results
-    chado_wrapper_split_array_agg_results($this, $values);
-
-  }
-
-  /**
-   * Render the field.
-   *
-   * Note: Checks to see if we have an array or simple field. If we have an array, then
-   *   split it up and render each part using the parent render functionality.
-   *
-   * @param $values
-   *   The values retrieved from the database.
-   */
-  function render($values) {
-    return chado_wrapper_render_items($this, $values);
-  }
-
-  function parent_render($val) {
-    return parent::render($val);
-  }
-
-}

+ 0 - 145
tripal_views/views/handlers/chado_views_handler_filter_boolean_operator.inc

@@ -1,145 +0,0 @@
-<?php
-
-/**
- * @file
- * A chado wrapper for the views_handler_filter_boolean_operator.
- *
- * Handles fields which may be aggregated during the chado join process. There are options
- * to filter the base table based on an aggregated table or just filter the aggregated
- * table (showing blank for that field if there are no records in the aggregated table).
- */
-class chado_views_handler_filter_boolean_operator extends views_handler_filter_boolean_operator {
-
-  /**
-   * Defines the options form (form available to admin when they add a field to a view)
-   */
-  function options_form(&$form, &$form_state) {
-    $form['msg'] = array(
-      '#type' => 'item',
-      '#value' => '<b>If this filter applies to a table that is aggregated, additionally options may be ignored.</b>'
-    );
-
-    parent::options_form($form, $form_state);
-
-    $form['agg'] = array(
-      '#type' => 'fieldset',
-      '#title' => 'Apply to fields that are aggregated'
-    );
-
-    $form['agg']['records_with'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Filter base table records'),
-      '#description' => t('Filters %base_table to only those with the value in the aggregate array.', array('%base_table' => $this->view->base_table)),
-      '#default_value' => (isset($this->options['agg']['records_with'])) ? $this->options['agg']['records_with'] : TRUE,
-    );
-
-    $form['agg']['aggregates_with'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Filter aggregates displayed'),
-      '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of %base_table records.', array('%base_table' => $this->view->base_table)),
-      '#default_value' => (isset($this->options['agg']['aggregates_with'])) ? $this->options['agg']['aggregates_with'] : TRUE,
-    );
-
-  }
-
-  /**
-   * If the table to be filtered is not aggregated uses the parent::query()
-   * However, if it is uses postgresql any() function to compare
-   */
-  function query() {
-
-    // make optional
-    // if it is not set or empty then don't restrict the query
-    if ($this->value == 'All') {
-      return;
-    }
-
-    $this->ensure_my_table();
-
-    // determine whether it is aggregated or not
-    $table = $this->query->get_table_info($this->table);
-    if (preg_match('/aggregator/', $table['join']->definition['handler'])) {
-      $this->aggregated = TRUE;
-    }
-    else {
-      $this->aggregated = FALSE;
-    }
-
-    // check if its a t/f or 1/0 boolean
-    // D7 TODO: Check DBTNG changes work
-    $check = db_query(
-      "SELECT :field as val FROM :table LIMIT 1",
-      array(':field' => $this->real_field, ':table' => $this->table)
-    );
-    $check = $check->fetchObject();
-    if (preg_match('/^[tTfF]/', $check->val)) {
-      $true = 't';
-      $false = 'f';
-    }
-    else {
-      $true = 1;
-      $false = 0;
-    }
-
-    if (!$this->aggregated) {
-
-      // Only base records with value in the aggregated field
-      // This doesn't restrict the items in the aggregate field
-      if ($this->options['agg']['records_with']) {
-        $where = "$this->table_alias.$this->real_field ";
-        if (empty($this->value)) {
-          $where .= "= '" . $false . "'";
-          if ($this->accept_null) {
-            $where = '(' . $where . " OR $this->table_alias.$this->real_field IS NULL)";
-          }
-        }
-        else {
-          if (!empty($this->definition['use equal'])) {
-            $where .= "= '" . $true . "'";
-          }
-          else {
-            $where .= "<> '" . $false . "'";
-          }
-        }
-        $this->query->add_where($this->options['group'], $where);
-      }
-
-      // To restrict the items in the aggregate...
-      // Tell the join handler about the filter
-      // so it can be done in the join query
-      if ($this->options['agg']['aggregates_with']) {
-        //Do nothing b/c it's not aggregated!
-      }
-    }
-    else {
-
-      // Only base records with value in the aggregated field
-      // This doesn't restrict the items in the aggregate field
-      $this->ensure_my_table();
-      $field = "$this->table_alias.$this->real_field";
-      if ($this->options['agg']['records_with']) {
-        $where = "'%s' = ANY($field)";
-        if ($this->value) {
-          $this->query->add_where($this->options['group'], $where, $true);
-        }
-        else {
-          $this->query->add_where($this->options['group'], $where, $false);
-        }
-      }
-
-      // To restrict the items in the aggregate...
-      // Tell the join handler about the filter
-      // so it can be done in the join query
-      if ($this->options['agg']['aggregates_with']) {
-        if ($this->value) {
-          $table['join']->filter[] = $field . " = '" . $true . "'";
-        }
-        else {
-          $table['join']->filter[] = $field . " = '" . $false . "'";
-        }
-      }
-    }
-
-  }
-
-}

+ 0 - 171
tripal_views/views/handlers/chado_views_handler_filter_date.inc

@@ -1,171 +0,0 @@
-<?php
-
-/**
- * @file
- * A chado wrapper for the views_handler_filter_date.
- *
- * Handles fields which may be aggregated during the chado join process. There are options
- * to filter the base table based on an aggregated table or just filter the aggregated
- * table (showing blank for that field if there are no records in the aggregated table).
- *
- * @todo make handle aggregation
- */
-class chado_views_handler_filter_date extends views_handler_filter_date {
-
-  /**
-   * Defines the options form (form available to admin when they add a field to a view)
-   */
-  function options_form(&$form, &$form_state) {
-    $form['msg'] = array(
-      '#type' => 'item',
-      '#value' => '<b>If this filter applies to a table that is aggregated, additionally options may be ignored.</b>'
-    );
-
-    parent::options_form($form, $form_state);
-
-    $form['agg'] = array(
-      '#type' => 'fieldset',
-      '#title' => 'Apply to fields that are aggregated'
-    );
-
-    $form['agg']['records_with'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Filter base table records'),
-      '#description' => t('Filters %base_table to only those with the value in the aggregate array.', array('%base_table' => $this->view->base_table)),
-      '#default_value' => (isset($this->options['agg']['records_with'])) ? $this->options['agg']['records_with'] : TRUE,
-    );
-
-    $form['agg']['aggregates_with'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Filter aggregates displayed'),
-      '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of %base_table records.', array('%base_table' => $this->view->base_table)),
-      '#default_value' => (isset($this->options['agg']['aggregates_with'])) ? $this->options['agg']['aggregates_with'] : TRUE,
-    );
-
-  }
-
-  /**
-   * Called by query if the operator is between
-   */
-  function op_between($field) {
-
-    // Check whether we have a UNIX timestamp or an ISO Timestamp
-    // D7 TODO: Check DBTNG changes work
-    $check = db_query(
-      "SELECT :field as val FROM :table WHERE :field IS NOT NULL LIMIT 1",
-      array(':field' => $this->real_field, ':table' => $this->table)
-    );
-    $check = $check->fetchObject();
-    if (preg_match('/^\d+$/', $check->val)) {
-      // this is a unix timestamp
-      $is_unix = TRUE;
-    }
-    else {
-      // this is an ISO Timestamp
-      $is_unix = FALSE;
-    }
-
-    if ($this->operator == 'between') {
-      $a = intval(strtotime($this->value['min'], 0));
-      $b = intval(strtotime($this->value['max'], 0));
-    }
-    else {
-      $a = intval(strtotime($this->value['max'], 0));
-      $b = intval(strtotime($this->value['min'], 0));
-    }
-
-    if ($this->value['type'] == 'offset') {
-      $a = '***CURRENT_TIME***' . sprintf('%+d', $a); // keep sign
-      $b = '***CURRENT_TIME***' . sprintf('%+d', $b); // keep sign
-    }
-    // %s is safe here because strtotime scrubbed the input and we might
-    // have a string if using offset.
-    if ($is_unix) {
-      if ($this->operator == 'between') {
-        $this->query->add_where($this->options['group'], "$field >= %s", $a);
-        $this->query->add_where($this->options['group'], "$field <= %s", $b);
-      }
-      else {
-        $this->query->add_where($this->options['group'], "$field >= %s OR $field <= %s", array($a, $b));
-      }
-    }
-    else {
-      if ($this->operator == 'between') {
-        $this->query->add_where($this->options['group'], "CAST(EXTRACT(EPOCH FROM $field) as integer) >= %s", $a);
-        $this->query->add_where($this->options['group'], "CAST(EXTRACT(EPOCH FROM $field) as integer) <= %s", $b);
-      }
-      else {
-        $this->query->add_where($this->options['group'], "CAST(EXTRACT(EPOCH FROM $field) as integer) >= %s OR CAST(EXTRACT(EPOCH FROM $field) as integer) <= %s", array($a, $b));
-      }
-    }
-  }
-
-  /**
-   * Called by query if the operator is not between or empty
-   */
-  function op_simple($field) {
-    $value = intval(strtotime($this->value['value'], 0));
-
-    // Check whether we have a UNIX timestamp or an ISO Timestamp
-    // D7 TODO: Check DBTNG changes work
-    $check = db_query(
-      "SELECT :field as val FROM :table WHERE :field IS NOT NULL LIMIT 1",
-      array(':field' => $this->real_field, ':table' => $this->table)
-    );
-    $check = $check->fetchObject();
-    if (preg_match('/^\d+$/', $check->val)) {
-      // this is a unix timestamp
-      $is_unix = TRUE;
-    }
-    else {
-      // this is an ISO Timestamp
-      $is_unix = FALSE;
-    }
-
-    if ($is_unix) {
-      if (!empty($this->value['type']) && $this->value['type'] == 'offset') {
-        $value = '***CURRENT_TIME***' . sprintf('%+d', $value); // keep sign
-      }
-      $this->query->add_where($this->options['group'], "$field $this->operator %s", $value);
-    }
-    else {
-      if (!empty($this->value['type']) && $this->value['type'] == 'offset') {
-        $value = '***CURRENT_TIME***' . sprintf('%+d', $value); // keep sign
-      }
-      $this->query->add_where($this->options['group'], "CAST(EXTRACT(EPOCH FROM $field) as integer) $this->operator %s", $value);
-    }
-  }
-
-  /**
-   * Validate that the time values convert to something usable.
-   *
-   * We modify it to
-   * - fix a bug in the views handler for single values
-   *    $value['value'] didn't exist
-   * - fix a pass by reference error
-   *    changed form_error to form_set_error
-   */
-  function validate_valid_time(&$form, $operator, $value) {
-    $operators = $this->operators();
-
-    if ($operators[$operator]['values'] == 1) {
-      if (!empty($value['value'])) {
-        $convert = strtotime($value['value']);
-        if (!empty($form) && ($convert == -1 || $convert === FALSE)) {
-          form_set_error($form['value'], t('Invalid date format.'));
-        }
-      }
-    }
-    elseif ($operators[$operator]['values'] == 2) {
-      $min = strtotime($value['min']);
-      if ($min == -1 || $min === FALSE) {
-        form_set_error($form['min'], t('Invalid date format.'));
-      }
-      $max = strtotime($value['max']);
-      if ($max == -1 || $max === FALSE) {
-        form_set_error($form['max'], t('Invalid date format.'));
-      }
-    }
-  }
-
-}

+ 0 - 91
tripal_views/views/handlers/chado_views_handler_filter_equality.inc

@@ -1,91 +0,0 @@
-<?php
-
-/**
- * @file
- * A chado wrapper for the views_handler_filter_equality.
- *
- * Handles fields which may be aggregated during the chado join process. There are options
- * to filter the base table based on an aggregated table or just filter the aggregated
- * table (showing blank for that field if there are no records in the aggregated table).
- */
-class chado_views_handler_filter_equality extends views_handler_filter_equality {
-
-  /**
-   * Defines the options form (form available to admin when they add a field to a view)
-   */
-  function options_form(&$form, &$form_state) {
-    $form['msg'] = array(
-      '#type' => 'item',
-      '#value' => '<b>If this filter applies to a table that is aggregated, additionally options may be ignored.</b>'
-    );
-
-    parent::options_form($form, $form_state);
-
-    $form['agg'] = array(
-      '#type' => 'fieldset',
-      '#title' => 'Apply to fields that are aggregated'
-    );
-
-    $form['agg']['records_with'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Filter base table records'),
-      '#description' => t('Filters %base_table to only those with the value in the aggregate array.', array('%base_table' => $this->view->base_table)),
-      '#default_value' => (isset($this->options['agg']['records_with'])) ? $this->options['agg']['records_with'] : TRUE,
-    );
-
-    $form['agg']['aggregates_with'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Filter aggregates displayed'),
-      '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of %base_table records.', array('%base_table' => $this->view->base_table)),
-      '#default_value' => (isset($this->options['agg']['aggregates_with'])) ? $this->options['agg']['aggregates_with'] : TRUE,
-    );
-
-  }
-
-  /**
-   * If the table to be filtered is not aggregated uses the parent::query()
-   * However, if it is uses postgresql any() function to compare
-   */
-  function query() {
-
-    // make optional
-    // if it is not set or empty then don't restrict the query
-    if (!$this->value) {
-      return;
-    }
-
-    $this->ensure_my_table();
-
-    $table = $this->query->get_table_info($this->table);
-    if (preg_match('/aggregator/', $table['join']->definition['handler'])) {
-      $this->aggregated = TRUE;
-    }
-    else {
-      $this->aggregated = FALSE;
-    }
-
-    if (!$this->aggregated) {
-      parent::query();
-    }
-    else {
-
-      // Only base records with value in the aggregated field
-      // This doesn't restrict the items in the aggregate field
-      $this->ensure_my_table();
-      $field = "$this->table_alias.$this->real_field";
-      if ($this->options['agg']['records_with']) {
-        $where = "'%s' = ANY($field)";
-        $this->query->add_where($this->options['group'], $where, $this->value);
-      }
-
-      // To restrict the items in the aggregate...
-      // Tell the join handler about the filter
-      // so it can be done in the join query
-      if ($this->options['agg']['aggregates_with']) {
-        $table['join']->filter[] = $field . " = '" . $this->value . "'";
-      }
-    }
-
-  }
-
-}

+ 0 - 97
tripal_views/views/handlers/chado_views_handler_filter_float.inc

@@ -1,97 +0,0 @@
-<?php
-
-/**
- * @file
- * A chado wrapper for the views_handler_filter_float.
- *
- * Handles fields which may be aggregated during the chado join process. There are options
- * to filter the base table based on an aggregated table or just filter the aggregated
- * table (showing blank for that field if there are no records in the aggregated table).
- */
-class chado_views_handler_filter_float extends views_handler_filter_float {
-
-  /**
-   * Defines the options form (form available to admin when they add a field to a view)
-   */
-  function options_form(&$form, &$form_state) {
-    $form['msg'] = array(
-      '#type' => 'item',
-      '#value' => '<b>If this filter applies to a table that is aggregated, additionally options may be ignored.</b>'
-    );
-
-    parent::options_form($form, $form_state);
-
-    $form['agg'] = array(
-      '#type' => 'fieldset',
-      '#title' => 'Apply to fields that are aggregated'
-    );
-
-    $form['agg']['records_with'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Filter base table records'),
-      '#description' => t('Filters %base_table to only those with the value in the aggregate array.', array('%base_table' => $this->view->base_table)),
-      '#default_value' => (isset($this->options['agg']['records_with'])) ? $this->options['agg']['records_with'] : TRUE,
-    );
-
-    $form['agg']['aggregates_with'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Filter aggregates displayed'),
-      '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of %base_table records.', array('%base_table' => $this->view->base_table)),
-      '#default_value' => (isset($this->options['agg']['aggregates_with'])) ? $this->options['agg']['aggregates_with'] : TRUE,
-    );
-
-  }
-
-  /**
-   * If the table to be filtered is not aggregated uses the parent::query()
-   * However, if it is uses postgresql any() function to compare
-   */
-  function query() {
-
-    // make optional
-    // if it is not set or empty then don't restrict the query
-    if (!$this->value AND !is_array($this->value)) {
-      return;
-    }
-    elseif (is_array($this->value)) {
-      $tmp = array_filter($this->value);
-      if (!$tmp) {
-        return;
-      }
-    }
-
-    $this->ensure_my_table();
-
-    $table = $this->query->get_table_info($this->table);
-    if (preg_match('/aggregator/', $table['join']->definition['handler'])) {
-      $this->aggregated = TRUE;
-    }
-    else {
-      $this->aggregated = FALSE;
-    }
-
-    if (!$this->aggregated) {
-      parent::query();
-    }
-    else {
-
-      // Only base records with value in the aggregated field
-      // This doesn't restrict the items in the aggregate field
-      $this->ensure_my_table();
-      $field = "$this->table_alias.$this->real_field";
-      if ($this->options['agg']['records_with']) {
-        $where = "'%s' = ANY($field)";
-        $this->query->add_where($this->options['group'], $where, $this->value);
-      }
-
-      // To restrict the items in the aggregate...
-      // Tell the join handler about the filter
-      // so it can be done in the join query
-      if ($this->options['agg']['aggregates_with']) {
-        $table['join']->filter[] = $field . " = '" . $this->value . "'";
-      }
-    }
-
-  }
-
-}

+ 0 - 91
tripal_views/views/handlers/chado_views_handler_filter_numeric.inc

@@ -1,91 +0,0 @@
-<?php
-
-/**
- * @file
- * A chado wrapper for the views_handler_filter_numeric.
- *
- * Handles fields which may be aggregated during the chado join process. There are options
- * to filter the base table based on an aggregated table or just filter the aggregated
- * table (showing blank for that field if there are no records in the aggregated table).
- */
-class chado_views_handler_filter_numeric extends views_handler_filter_numeric {
-
-  /**
-   * Defines the options form (form available to admin when they add a field to a view)
-   */
-  function options_form(&$form, &$form_state) {
-    $form['msg'] = array(
-      '#type' => 'item',
-      '#value' => '<b>If this filter applies to a table that is aggregated, additionally options may be ignored.</b>'
-    );
-
-    parent::options_form($form, $form_state);
-
-    $form['agg'] = array(
-      '#type' => 'fieldset',
-      '#title' => 'Apply to fields that are aggregated'
-    );
-
-    $form['agg']['records_with'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Filter base table records'),
-      '#description' => t('Filters %base_table to only those with the value in the aggregate array.', array('%base_table' => $this->view->base_table)),
-      '#default_value' => (isset($this->options['agg']['records_with'])) ? $this->options['agg']['records_with'] : TRUE,
-    );
-
-    $form['agg']['aggregates_with'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Filter aggregates displayed'),
-      '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of %base_table records.', array('%base_table' => $this->view->base_table)),
-      '#default_value' => (isset($this->options['agg']['aggregates_with'])) ? $this->options['agg']['aggregates_with'] : TRUE,
-    );
-
-  }
-
-  /**
-   * If the table to be filtered is not aggregated uses the parent::query()
-   * However, if it is uses postgresql any() function to compare
-   */
-  function query() {
-
-    // make optional
-    // if it is not set or empty then don't restrict the query
-    if (!$this->value) {
-      return;
-    }
-
-    $this->ensure_my_table();
-
-    $table = $this->query->get_table_info($this->table);
-    if (preg_match('/aggregator/', $table['join']->definition['handler'])) {
-      $this->aggregated = TRUE;
-    }
-    else {
-      $this->aggregated = FALSE;
-    }
-
-    if (!$this->aggregated) {
-      parent::query();
-    }
-    else {
-
-      // Only base records with value in the aggregated field
-      // This doesn't restrict the items in the aggregate field
-      $this->ensure_my_table();
-      $field = "$this->table_alias.$this->real_field";
-      if ($this->options['agg']['records_with']) {
-        $where = "'%s' = ANY($field)";
-        $this->query->add_where($this->options['group'], $where, $this->value);
-      }
-
-      // To restrict the items in the aggregate...
-      // Tell the join handler about the filter
-      // so it can be done in the join query
-      if ($this->options['agg']['aggregates_with']) {
-        $table['join']->filter[] = $field . " = '" . $this->value . "'";
-      }
-    }
-
-  }
-
-}

+ 0 - 150
tripal_views/views/handlers/chado_views_handler_filter_string.inc

@@ -1,150 +0,0 @@
-<?php
-
-/**
- * @file
- * A chado wrapper for the views_handler_filter_string.
- *
- * Handles fields which may be aggregated during the chado join process. There are options
- * to filter the base table based on an aggregated table or just filter the aggregated
- * table (showing blank for that field if there are no records in the aggregated table).
- */
-class chado_views_handler_filter_string extends views_handler_filter_string {
-
-  /**
-   * Defines the options form (form available to admin when they add a field to a view)
-   */
-  function options_form(&$form, &$form_state) {
-    $form['msg'] = array(
-      '#type' => 'item',
-      '#value' => '<b>If this filter applies to a table that is aggregated, additionally options may be ignored.</b>'
-    );
-
-    parent::options_form($form, $form_state);
-
-    $form['agg'] = array(
-      '#type' => 'fieldset',
-      '#title' => 'Apply to fields that are aggregated'
-    );
-
-    $form['agg']['records_with'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Filter base table records'),
-      '#description' => t('Filters %base_table to only those with the value in the aggregate array.', array('%base_table' => $this->view->base_table)),
-      '#default_value' => (isset($this->options['agg']['records_with'])) ? $this->options['agg']['records_with'] : TRUE,
-    );
-
-    $form['agg']['aggregates_with'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Filter aggregates displayed'),
-      '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of %base_table records.', array('%base_table' => $this->view->base_table)),
-      '#default_value' => (isset($this->options['agg']['aggregates_with'])) ? $this->options['agg']['aggregates_with'] : TRUE,
-    );
-
-  }
-
-  /**
-   * If the table to be filtered is not aggregated uses the parent::query()
-   * However, if it is uses postgresql any() function to compare
-   */
-  function query() {
-
-    // make optional
-    // if it is not set or empty then don't restrict the query
-    if (!$this->value) {
-      return;
-    }
-
-    $this->ensure_my_table();
-
-    $table = $this->query->get_table_info($this->table);
-    if (preg_match('/aggregator/', $table['join']->definition['handler'])) {
-      $this->aggregated = TRUE;
-    }
-    else {
-      $this->aggregated = FALSE;
-    }
-
-    if (!$this->aggregated) {
-      parent::query();
-    }
-    else {
-
-      $this->ensure_my_table();
-      $field = "$this->table_alias.$this->real_field";
-
-      // Want to filter both the base table and the aggregated field
-      if ($this->options['agg']['records_with'] && $this->options['agg']['aggregates_with']) {
-        $where = "$field IS NOT NULL";
-        $this->query->add_where($this->options['group'], $where);
-        $table['join']->filter[] = $field . " " . $this->operator . " '" . $this->value . "'";
-      }
-      // Only base records with value in the aggregated field
-      // This doesn't restrict the items in the aggregate field
-      elseif ($this->options['agg']['records_with']) {
-        if ($this->operator == '~') {
-          // Currently postgresql doesn't support 'somevalue' ~ ANY(field) as a means of
-          // selecting all records where the field matches somevalue. Instead what this notation means
-          // is return TRUE if one of the values of field matches 'somevalue'
-          // Instead add in a subclause
-          $where = "array_to_string($field,'###') ~ '%s'";
-          $this->query->add_where($this->options['group'], $where, $this->value);
-        }
-        else {
-          $where = "'%s' " . $this->operator . " ANY($field)";
-          $this->query->add_where($this->options['group'], $where, $this->value);
-        }
-
-      }
-      // To restrict the items in the aggregate...
-      // Tell the join handler about the filter
-      // so it can be done in the join query
-      if ($this->options['agg']['aggregates_with']) {
-        $table['join']->filter[] = $field . " " . $this->operator . " '" . $this->value . "'";
-      }
-    }
-
-  }
-
-  /**
-   * This kind of construct makes it relatively easy for a child class
-   * to add or remove functionality by overriding this function and
-   * adding/removing items from this array.
-   */
-  function operators() {
-    $operators = array(
-      '=' => array(
-        'title' => t('Is equal to'),
-        'short' => t('='),
-        'method' => 'op_equal',
-        'values' => 1,
-      ),
-      '!=' => array(
-        'title' => t('Is not equal to'),
-        'short' => t('!='),
-        'method' => 'op_equal',
-        'values' => 1,
-      ),
-      '~' => array(
-        'title' => t('Contains'),
-        'short' => t('contains'),
-        'method' => 'op_contains',
-        'values' => 1,
-      ),
-      'starts' => array(
-        'title' => t('Starts with'),
-        'short' => t('begins'),
-        'method' => 'op_starts',
-        'values' => 1,
-      ),
-      'ends' => array(
-         'title' => t('Ends with'),
-         'short' => t('ends'),
-         'method' => 'op_ends',
-         'values' => 1,
-       ),
-    );
-
-    return $operators;
-  }
-
-}

+ 0 - 27
tripal_views/views/handlers/chado_views_handler_relationship.inc

@@ -1,27 +0,0 @@
-<?php
-
-/**
- * Simple relationship handler that allows a new version of the chado primary table
- * to be linked in.
- *
- * The base relationship handler can only handle a single join. Some relationships
- * are more complex and might require chains of joins; for those, you must
- * utilize a custom relationship handler.
- *
- * Definition items:
- * - base: The new base table this relationship will be adding. This does not
- *   have to be a declared base table, but if there are no tables that
- *   utilize this base table, it won't be very effective.
- * - base field: The field to use in the relationship; if left out this will be
- *   assumed to be the primary field.
- * - relationship table: The actual table this relationship operates against.
- *   This is analogous to using a 'table' override.
- * - relationship field: The actual field this relationship operates against.
- *   This is analogous to using a 'real field' override.
- * - label: The default label to provide for this relationship, which is
- *   shown in parentheses next to any field/sort/filter/argument that uses
- *   the relationship.
- */
-class chado_views_handler_relationship extends views_handler_relationship {
-
-}

+ 0 - 81
tripal_views/views/handlers/chado_views_handler_relationship_to_node.inc

@@ -1,81 +0,0 @@
-<?php
-/**
- * @file
- * TODO: add documentation
- */
-/**
- * Relationship handler that links a chado table to it's nodes by creating 2 joins.
- *
- * NOTE: This handler assumes if you are linking TABLEA to it's nodes that there is a
- *  table named chado_TABLEA in the drupal schema with at least the following two fields:
- *  nid and TABLEA_id.
- *
- * Definition items:
- * - base: The new base table this relationship will be adding. This does not
- *   have to be a declared base table, but if there are no tables that
- *   utilize this base table, it won't be very effective.
- * - base field: The field to use in the relationship; if left out this will be
- *   assumed to be the primary field.
- * - label: The default label to provide for this relationship, which is
- *   shown in parentheses next to any field/sort/filter/argument that uses
- *   the relationship.
- */
-class chado_views_handler_relationship_to_node extends views_handler_relationship {
-
-  function query() {
-
-    $this->ensure_my_table();
-
-    // The base table in chado
-    $base_table = $this->definition['base table'];
-    $base_field = $this->definition['base field'];
-
-    // The drupal linking table
-    $chado_table = 'chado_' . $base_table;
-
-    // Need to remove the incorrectly added node & chado_table join
-    unset($this->query->table_queue['node'],
-      $this->query->tables['stock']['node'],
-      $this->query->table_queue[$chado_table],
-      $this->query->tables['stock'][$chado_table]);
-
-    // First add base => chado_base join
-    $def = array();
-    $def['table'] = $chado_table;
-    $def['field'] = $base_field;
-    $def['left_table'] = $base_table;
-    $def['left_field'] = $base_field;
-    //$def['handler'] = 'views_handler_join_chado_aggregator';
-
-    $join = new views_join();
-
-    $join->definition = $def;
-    $join->construct();
-    $join->adjusted = TRUE;
-
-    $alias = $base_table . '_' . $chado_table;
-    $this->linker_alias = $this->query->add_relationship($alias, $join, $this->table);
-
-    // Now add chado_base => node join
-    $def = array();
-    $def['table'] = 'node';
-    $def['field'] = 'nid';
-    $def['left_table'] = $this->linker_alias;
-    $def['left_field'] = 'nid';
-    //$def['handler'] = 'views_handler_join_chado_aggregator';
-
-    $join = new views_join();
-
-    $join->definition = $def;
-    $join->construct();
-    $join->adjusted = TRUE;
-
-    if ($base_table == $this->view->base_table) {
-      $alias = 'node';
-    }
-    else {
-      $alias = $chado_table . '_node';
-    }
-    $this->alias = $this->query->add_relationship($alias, $join, 'node');
-  }
-}

+ 0 - 58
tripal_views/views/handlers/chado_views_handler_sort.inc

@@ -1,58 +0,0 @@
-<?php
-
-/**
- * @file
- * A chado wrapper for the views_handler_sort.
- *
- * Handles fields which may be aggregated during the chado join process. Sorting of
- * aggregated fields required PostgreSQL 9.0 due to postgresql limitations. Sorting of
- * non-aggregated fields works for all PostgreSQL versions.
- */
-class chado_views_handler_sort extends views_handler_sort {
-
-  /**
-   * Defines the options form (form available to admin when they add a field to a view)
-   */
-  function options_form(&$form, &$form_state) {
-
-    $form['msg'] = array(
-      '#type' => 'item',
-      '#value' => '<b>Sorting of aggregated fields only works for PostgreSQL 9.0+. This is due to lack of support at the database level. With lower postgreSQL versions, no sorting is applied.</b>'
-    );
-
-    parent::options_form($form, $form_state);
-  }
-
-  /**
-   * Adds the sort to the query only if the field isn't aggregated
-   * If the field is aggregated then the sort has to be applied at the join handler level
-   */
-  function query() {
-
-    // Determine if the current field is part of an aggregated table
-    $table = $this->query->get_table_info($this->table);
-    if (preg_match('/aggregator/', $table['join']->definition['handler'])) {
-      $this->aggregated = TRUE;
-    }
-    else {
-      $this->aggregated = FALSE;
-    }
-
-    // One day when the aggregated sort will work (ie: Postgresql 9.0+)
-    // it will need to be applied in join handler
-    // thus tell join handler about the sort
-    $table['join']->sort[] = array(
-      'table' => $table['alias'],
-      'field' => $this->options['field'],
-      'order' => $this->options['order']
-    );
-
-
-    // if not then add the sort
-    if (!$this->aggregated) {
-      parent::query();
-    }
-
-  }
-
-}

+ 0 - 116
tripal_views/views/handlers/chado_wrapper_functions.inc

@@ -1,116 +0,0 @@
-<?php
-
-/**
- * @file
- * TODO: add documentation
- */
-
-/**
- * Splits an SQL array of results in a single field
- * into a php array
- *
- * @param $field
- *   An SQL array (ie: {"",^(.*)$,646,tripal_analysis_blast} )
- * @return
- *   A PHP version of the SQL array (ie: array('','^(.*)$','646','tripal_analysis_blast') )
- */
-function chado_wrapper_split_array_agg_results($handler, &$values) {
-
-  if ($handler->aggregated) {
-    foreach ($values as $k => $v) {
-      // Some custom handlers re-use the same field
-      // This ensures that an already split value doesn't get re-split
-      if (!is_array($v->{$handler->field_alias})) {
-        if (preg_match('/^{(.*)}$/', $v->{$handler->field_alias}, $matches)) {
-          $values[$k]->{$handler->field_alias} = str_getcsv($matches[1]);
-        }
-        else {
-          $values[$k]->{$handler->field_alias} = array();
-        }
-      }
-    }
-  }
-
-  return $values;
-}
-
-/**
- * Determines if the current field is generated via the aggregated join handler
- *
- * @param $handler
- *   pass in $this from handler::query()
- *
- * @return
- *   TRUE/FALSE if or if not the field has the aggregated join handler
- */
-function chado_wrapper_is_aggregated_by_join($handler) {
-  $aggregated = FALSE;
-
-  $table = $handler->query->get_table_info($handler->table);
-  if (preg_match('/aggregator/', $table['join']->definition['handler'])) {
-    $aggregated = TRUE;
-  }
-
-  return $aggregated;
-}
-
-/**
- * Determines if the current field is generated via the result returned
- *
- * @param $handler
- *   pass in $this from handler::pre_render()
- * @param $values
- *   pass in $values from handler::pre_render()
- *
- * @return
- *   TRUE/FALSE if or if not the field is aggregated
- */
-function chado_wrapper_is_aggregated_by_result($handler, $values) {
-  $aggregated = FALSE;
-
-
-  $i = 0;
-  while (empty($values[$i]->{$handler->field_alias}) AND $i <= sizeof($values)) {
-    $i++;
-  }
-
-  if (is_array($values[$i]->{$handler->field_alias})) {
-    $aggregated = TRUE;
-  }
-  elseif (preg_match('/^{.*}$/', $values[$i]->{$handler->field_alias})) {
-    $aggregated = TRUE;
-  }
-
-  return $aggregated;
-}
-
-function chado_wrapper_render_items($handler, $values) {
-
-  // If it's aggregated (an array), then render each part
-  // using the parent render functionality
-  if ($handler->aggregated) {
-
-    $items = array();
-
-    $parts = $values->{$handler->field_alias};
-    foreach ($parts as $p) {
-      $v[ $handler->field_alias ] = $p;
-      $val = (object) $v;
-      $items[] = $handler->parent_render($val);
-      unset($v, $val);
-    }
-
-    if ($handler->options['type'] == 'separator') {
-      return implode(check_plain($handler->options['separator']), $items);
-    }
-    else {
-      return theme('item_list', $items, NULL, $handler->options['type']);
-    }
-
-  // Otherwise it is not aggragated
-  // Just render like the default handler would
-  }
-  else {
-    return $handler->parent_render($values);
-  }
-}

+ 0 - 67
tripal_views/views/handlers/deprecated/views_handler_field_chado_count.inc

@@ -1,67 +0,0 @@
-<?php
-
-/**
- * @file
- * Purpose: Provide a field that counts the number of records in the current table
- *   are connected to the base table. For example, this field could be used to count
- *   the number of features connected to a given organism -base table=organism,
- *   current table=feature: for each record in the organism view count feature records where
- *   feature.organism_id=organism_id of current organism record
- *
- * @ingroup views_field_handlers
- * @ingroup tripal_core
- */
-class views_handler_field_chado_count extends views_handler_field {
-
-  function init(&$view, $options) {
-    parent::init($view, $options);
-
-    // the table to query is required
-    // check that it was provided in the field definition and if not warn
-    if ($this->definition['table_to_query']) {
-      $this->aliases['current_table'] = $this->definition['table_to_query'];
-    }
-    else {
-      drupal_set_message(t("The field definition ( in hook_views_data() ) needs to specify the 'table_to_query' in order for this fields to work. Field:%field in the %table table definition"), array('%field' => $this->field, '%table' => $this->table), 'error');
-    }
-
-    // set aliases
-    $this->aliases['primary_id'] = $this->table . '_id';
-    $this->aliases['foreign_key'] = $this->table . '_id';
-  }
-
-  //Needed to ensure that the name of this field is not added to the query
-  function query() {
-    $this->add_additional_fields();
-  }
-
-  function pre_render(&$values) {
-    // Render nothing if the current table wasn't set in the field definition
-    if (!$this->aliases['current_table']) {
-      return '';
-    }
-
-    foreach ($values as $key => $record) {
-      $primary_id = $record->{$this->aliases['primary_id']};
-
-      //Select count from database
-      // D7 TODO: Check DBTNG changes work
-      $sql = 'SELECT count(*) as count FROM %s WHERE %s=%d';
-      $result = chado_query(
-        $sql,
-        $this->aliases['current_table'],
-        $this->aliases['foreign_key'],
-        $primary_id
-      );
-      $result = $result->fetchObject();
-
-      //Add to view results
-      $this->view->result[$key]->{$this->field} = $result->count;
-    }
-  }
-
-  function render($values) {
-    return $values->{$this->field};
-  }
-
-}

+ 0 - 48
tripal_views/views/handlers/deprecated/views_handler_field_dbxref_accession_link.inc

@@ -1,48 +0,0 @@
-<?php
-
-/**
- * @file
- * Used for a custom field so that field can render the database reference link
- *
- * @ingroup views_field_handlers
- * @ingroup tripal_core
- */
-class views_handler_field_dbxref_accession_link extends views_handler_field {
-  function construct() {
-    parent::construct();
-
-    $this->additional_fields['accession'] = 'accession';
-    $this->additional_fields['db_id'] = 'db_id';
-
-  }
-
-  function query() {
-    $this->ensure_my_table();
-    $this->add_additional_fields();
-  }
-
-  function render($values) {
-
-    $accession = $values->{$this->aliases['accession']};
-    $db_id = $values->{$this->aliases['db_id']};
-
-    if (!empty($db_id) AND !empty($accession)) {
-      // D7 TODO: Check DBTNG changes work
-      // @coder-ignore: non-drupal schema therefore table prefixing does not apply
-      $result = chado_query('SELECT urlprefix FROM {db} WHERE db_id=%d', $db_id);
-      $result = $result->fetchObject()
-      $urlprefix = $result->urlprefix;
-
-      if (!empty($urlprefix)) {
-        $accession_link = $urlprefix . $accession;
-        return $accession_link;
-      }
-      else {
-        return $accession;
-      }
-    }
-    else {
-      return $accession;
-    }
-  }
-}

+ 0 - 97
tripal_views/views/handlers/deprecated/views_handler_field_node_optional.inc

@@ -1,97 +0,0 @@
-<?php
-
-/**
- * @file
- * Field handler to provide simple renderer that allows linking to a node.
- *
- * @ingroup views_field_handlers
- * @ingroup tripal_core
- */
-class views_handler_field_node_optional extends views_handler_field_node {
-
-  function construct() {
-    parent::construct();
-    $this->additional_fields['nid'] = array('table' => 'node', 'field' => 'nid');
-    if (module_exists('translation')) {
-      $this->additional_fields['language'] = array('table' => 'node', 'field' => 'language');
-    }
-  }
-
-  /**
-   * Add chado_* and *_node alias'd left joins to the table
-   */
-  function query() {
-
-    // Check what we have (ie: current table? node table? )
-    $chado_table = 'chado_' . $this->table;
-    foreach ($this->query->table_queue as $table_def) {
-      //check is $this->table
-      if ($table_def['table'] == $this->table) {
-        $this_table_alias = $table_def['alias'];
-      }
-
-      // check is node joined to #this->table
-      if ($table_def['table'] == $chado_table) {
-        $node_table_alias = $table_def['alias'];
-      }
-    }
-
-    // First: Add the main field-----------------------------------------------
-    if (!$this_table_alias) {
-      $this_table_alias = $this->ensure_my_table();
-    }
-    $field_alias = $this->query->add_field($this_table_alias, $this->real_field);
-    $this->aliases[ $this->real_field ] = $field_alias;
-    $this->field_alias = $field_alias;
-
-    // Second: Add nid field and Joins if necessary----------------------------
-    // Add node join if needed
-    if (!$node_table_alias) {
-      $def['table'] = $chado_table;
-      $def['field'] = $this->table . '_id';
-      $def['left_table'] = $this_table_alias;
-      $def['left_field'] = $this->table . '_id';
-
-      $join = new views_join();
-      $join->definition = $def;
-      $join->construct();
-      $join->adjusted = TRUE;
-
-      $node_table_alias = $this->query->add_relationship($def['table'], $join, $def['table']);
-    }
-
-    // Finally Add Field
-    $field_alias = $this->query->add_field($node_table_alias, 'nid');
-    $this->aliases['nid'] = $field_alias;
-
-  }
-
-  /**
-   * Render whatever the data is as a link to the node.
-   *
-   * Data should be made XSS safe prior to calling this function.
-   */
-  function render_link($data, $values) {
-    if (!empty($this->options['link_to_node']) && $data !== NULL && $data !== '') {
-      if (!empty($values->{$this->aliases['nid']})) {
-        $this->options['alter']['make_link'] = TRUE;
-        $this->options['alter']['path'] = "node/" . $values->{$this->aliases['nid']};
-        if (isset($this->aliases['language'])) {
-          $languages = language_list();
-          if (isset($languages[$values->{$this->aliases['language']}])) {
-            $this->options['alter']['language'] = $languages[$values->{$this->aliases['language']}];
-          }
-          else {
-            unset($this->options['alter']['language']);
-          }
-        }
-      }
-      else {
-        $this->options['alter']['make_link'] = FALSE;
-        $this->options['alter']['path'] = "";
-      }
-    }
-
-    return $data;
-  }
-}

+ 0 - 82
tripal_views/views/handlers/deprecated/views_handler_field_readable_date.inc

@@ -1,82 +0,0 @@
-<?php
-
-/**
- * @file
- * A handler to provide proper displays for dates.
- *
- * @ingroup views_field_handlers
- * @ingroup tripal_core
- */
-class views_handler_field_readable_date extends views_handler_field {
-  function option_definition() {
-    $options = parent::option_definition();
-
-    $options['date_format'] = array('default' => 'small');
-    $options['custom_date_format'] = array('default' => '');
-
-    return $options;
-  }
-
-  function options_form(&$form, &$form_state) {
-    parent::options_form($form, $form_state);
-    $time = $REQUEST_TIME;
-
-    $form['date_format'] = array(
-      '#type' => 'select',
-      '#title' => t('Date format'),
-      '#options' => array(
-        'small' => format_date($time, 'small'),
-        'medium' => format_date($time, 'medium'),
-        'large' => format_date($time, 'large'),
-        'custom' => t('Custom'),
-        'raw time ago' => t('Time ago'),
-        'time ago' => t('Time ago (with "ago" appended)'),
-        'raw time span' => t('Time span (future dates start with - )'),
-        'time span' => t('Time span (with "ago/hence" appended)'),
-      ),
-      '#default_value' => isset($this->options['date_format']) ? $this->options['date_format'] : 'small',
-    );
-    $form['custom_date_format'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Custom date format'),
-      '#description' => t('If "Custom", see <a href="http://us.php.net/manual/en/function.date.php" target="_blank">the PHP docs</a> for date formats. If "Time ago" this is the the number of different units to display, which defaults to two.'),
-      '#default_value' => isset($this->options['custom_date_format']) ? $this->options['custom_date_format'] : '',
-      '#process' => array('views_process_dependency'),
-      '#dependency' => array('edit-options-date-format' => array('custom', 'raw time ago', 'time ago', 'raw time span', 'time span')),
-    );
-  }
-
-  function render($values) {
-    $value = $values->{$this->field_alias};
-
-    // value is currently a CCYY:MM:DD HH:MM:SS format
-    // change it to unix timestamp so rest works
-    $value = strtotime($value);
-
-    $format = $this->options['date_format'];
-    if (in_array($format, array('custom', 'raw time ago', 'time ago', 'raw time span', 'time span'))) {
-      $custom_format = $this->options['custom_date_format'];
-    }
-
-    if (!$value) {
-      return theme('views_nodate');
-    }
-    else {
-      $time_diff = $REQUEST_TIME - $value; // will be positive for a datetime in the past (ago), and negative for a datetime in the future (hence)
-      switch ($format) {
-        case 'raw time ago':
-          return format_interval($time_diff, is_numeric($custom_format) ? $custom_format : 2);
-        case 'time ago':
-          return t('%time ago', array('%time' => format_interval($time_diff, is_numeric($custom_format) ? $custom_format : 2)));
-        case 'raw time span':
-          return ($time_diff < 0 ? '-' : '') . format_interval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2);
-        case 'time span':
-          return t(($time_diff < 0 ? '%time hence' : '%time ago'), array('%time' => format_interval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2)));
-        case 'custom':
-          return format_date($value, $format, $custom_format);
-        default:
-          return format_date($value, $format);
-      }
-    }
-  }
-}

+ 0 - 93
tripal_views/views/handlers/deprecated/views_handler_filter_chado_boolean.inc

@@ -1,93 +0,0 @@
-<?php
-
-/**
- * @file
- * Purpose: This handler provides a TRUE/FALSE or YES/NO select for chado fields
- *  of type boolean (includes both 0/1 and t/f booleans)
- *
- * @ingroup views_filter_handlers
- * @ingroup tripal_core
- */
-class views_handler_filter_chado_boolean extends views_handler_filter_boolean_operator {
- /**
-  * Checks if this field uses 0/1 or t/f
-  * @todo Implement LIMIT 1 functionality for tripal_core_chado_select().
-  */
-  function init(&$view, $options) {
-    parent::init($view, $options);
-
-    $results = tripal_core_chado_select($this->table, array($this->field), array());
-    $this->boolean_type_tf = FALSE;
-    if (preg_match('/[tf]/', $results[0]->{$this->field})) {
-      $this->boolean_type_tf = TRUE;
-    }
-
-  }
-
- /**
-  * This function sets the options array for the select.
-  * If we are using a t/f boolean then the options need to evaluate to either t or f
-  * Otherwise, (0/1 boolean) the options evaluate to 0 or 1
-  */
-  function get_value_options() {
-
-    if ($this->boolean_type_tf) {
-      if (isset($this->definition['type'])) {
-        if ($this->definition['type'] == 'yes-no') {
-          $this->value_options = array('t' => t('Yes'), 'f' => t('No'));
-        }
-        if ($this->definition['type'] == 'on-off') {
-          $this->value_options = array('t' => t('On'), 'f' => t('Off'));
-        }
-      }
-
-      // Provide a fallback if the above didn't set anything.
-      if (!isset($this->value_options)) {
-        $this->value_options = array('t' => t('True'), 'f' => t('False'));
-      }
-    }
-    else { //end of t/f boolean
-      if (isset($this->definition['type'])) {
-        if ($this->definition['type'] == 'yes-no') {
-          $this->value_options = array(1 => t('Yes'), 0 => t('No'));
-        }
-        if ($this->definition['type'] == 'on-off') {
-          $this->value_options = array(1 => t('On'), 0 => t('Off'));
-        }
-      }
-
-      // Provide a fallback if the above didn't set anything.
-      if (!isset($this->value_options)) {
-        $this->value_options = array(1 => t('True'), 0 => t('False'));
-      }
-    } //end of 0/1 boolean
-  }
-
-  function query() {
-    $this->ensure_my_table();
-
-    $where = "$this->table_alias.$this->real_field ";
-
-    if ($this->boolean_type_tf) {
-      if (preg_match('/f/', $this->value)) {
-        $where .= "= 'f'";
-      }
-      else {
-        $where .= "= 't'";
-      }
-      $this->query->add_where($this->options['group'], $where);
-    }
-    else {
-      if (empty($this->value)) {
-        $where .= '= 0';
-        if ($this->accept_null) {
-          $where = '(' . $where . " OR $this->table_alias.$this->real_field IS NULL)";
-        }
-      }
-      else {
-        $where .= '<> 0';
-      }
-      $this->query->add_where($this->options['group'], $where);
-    }
-  }
-}

+ 0 - 260
tripal_views/views/handlers/deprecated/views_handler_filter_chado_select_cvterm_name.inc

@@ -1,260 +0,0 @@
-<?php
-
-/**
- * @file
- * Purpose: This Handler provides a select list for the type field
- *
- *  NOTE: This handler only works when applied to the type_id field in the base_table of
- *  this view.
- *
- * @ingroup views_filter_handlers
- * @ingroup tripal_core
- */
-class views_handler_filter_chado_select_cvterm_name extends views_handler_filter_string {
-
- /**
-  * Executed when the field is added
-  * Determine which cv to limit the cvterms to
-  */
-  function init(&$view, $options) {
-    parent::init($view, $options);
-
-    if ($this->options['show_all']) {
-      $cv_id = variable_get('chado_' . $this->view->base_table . '_cv', NULL);
-      if ($cv_id) {
-        $results = tripal_core_chado_select('cvterm', array('cvterm_id', 'name'), array('cv_id' => $cv_id));
-        if (empty($results)) {
-          $results = array();
-        }
-        foreach ($results as $c) {
-          $cvterms[$c->cvterm_id] = $c->name;
-        }
-      }
-      else {
-        //get a list of cvs currently used
-        if ($this->view->base_table == 'cvterm') {
-          $sql = 'SELECT distinct(cv.cv_id) FROM {' . $this->view->base_table . '}'
-            .' LEFT JOIN {cv} cv ON cv.cv_id=cvterm.cv_id';
-        }
-        else {
-          $sql = 'SELECT distinct(cv.cv_id) FROM {' . $this->view->base_table . '}'
-            .' LEFT JOIN {cvterm} cvterm ON cvterm.cvterm_id=' . $this->view->base_table . '.type_id '
-            .'LEFT JOIN {cv} cv ON cv.cv_id=cvterm.cv_id';
-        }
-        // D7 TODO: Check DBTNG changes work
-        $resource = chado_query($sql);
-        $cvterms = array();
-        foreach ($resource as $r) {
-          $results = tripal_core_chado_select('cvterm', array('cvterm_id', 'name'), array('cv_id' => $r->cv_id));
-          if (empty($results)) {
-            $results = array();
-          }
-          foreach ($results as $c) {
-            $cvterms[$c->cvterm_id] = $c->name;
-          }
-        }
-      }// end of if variable not defined
-
-    }
-    else {
-      // D7 TODO: Check DBTNG changes work
-      // @coder-ignore: non-drupal schema therefore table prefixing does not apply
-      $sql = "SELECT cvterm_id, name FROM {cvterm} WHERE cvterm_id IN (SELECT distinct(type_id) FROM {%s})";
-      $resource = chado_query($sql, $this->table);
-      $cvterms = array();
-      foreach ($resource as $r) {
-        $cvterms[$r->cvterm_id] = $r->name;
-      }
-    }
-    //sort cvterms by name (case insensitive)
-    natcasesort($cvterms);
-
-    //add to this handler
-    $this->cvterm_options = $cvterms;
-  }
-
- /**
-  * Defines options for the option forms
-  */
-  function options_form(&$form, &$form_state) {
-    parent::options_form($form, $form_state);
-
-    $form['values_form_type'] = array(
-      '#type' => 'radios',
-      '#title' => t('Filter Type'),
-      '#options' => array(
-        'textfield' => 'Text Field',
-        'select' => 'Drop-Down Box',
-      ),
-      '#default_value' => ($this->options['values_form_type']) ? $this->options['values_form_type'] : 'select',
-    );
-
-    $form['multiple'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Select Multiple'),
-      '#description' => t('Allows more then one option to be selected.'),
-      '#default_value' => (isset($this->options['multiple'])) ? $this->options['multiple'] : FALSE,
-    );
-
-    $form['optional'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Optional'),
-      '#description' => t('Adds --Any-- to the available options.'),
-      '#default_value' => (isset($this->options['optional'])) ? $this->options['optional'] : TRUE,
-    );
-
-    $form['show_all'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Show All Terms'),
-      '#description' => 'Otherwise only cvterms used in the base table will be used'
-    );
-  }
-
- /**
-  * Alters the query so that WHERE cvterm.cvterm_id=212 is used
-  */
-  function query() {
-    $this->ensure_table;
-
-    if ($this->options['multiple']) {
-      // Remove any if it's there
-      unset($this->value['All']);
-
-      if (sizeof($this->value)) {
-        $holders = array();
-        foreach ($this->value as $v) {
-          if (preg_match('/^[\d\.]+$/', $v)) {
-            $holders[] = '%d';
-          }
-          else {
-            $holders[] = "'%s'";
-          }
-        }
-        $where = "cvterm.cvterm_id IN (" . implode(", ", $holders) . ")";
-      }
-    }
-    elseif ($this->value != 'All') {
-      if (preg_match('/^\d+$/', $this->value)) {
-        $where = 'cvterm.cvterm_id=%d';
-      }
-      else {
-        $where = "cvterm.name" . $this->operator . "'%s'";
-      }
-    }
-
-    if ($where) {
-      $this->query->add_where($this->options['group'], $where, $this->value);
-    }
-  }
-
- /**
-  * Defines the value field in both the views filter options form
-  *   and the exposed form
-  */
-  function value_form(&$form, &$form_state) {
-    parent::value_form($form, $form_state);
-
-    if (preg_match('/select/', $this->options['values_form_type'])) {
-      // Get Options
-      if ($this->options['optional']) {
-        $options['<select ' . $this->table . '>'] = '--None--';
-        $options['All'] = '--Any--';
-      }
-      $max_length = 40;
-      foreach ($this->cvterm_options as $cvterm_id => $cvterm_name) {
-        if (drupal_strlen($cvterm_name) > $max_length) {
-          $options[$cvterm_id] = drupal_substr($cvterm_name, 0, $max_length) . '...';
-        }
-        else {
-          $options[$cvterm_id] = $cvterm_name;
-        }
-      }
-
-      if (empty($options)) {
-        $options[0] = '';
-      }
-
-      //Select List
-      $form['value'] = array(
-          '#type' => 'select',
-          '#title' => t('%label', array('%label' => $this->options['label'])),
-          '#options' => $options,
-          '#default_value' => $this->value,
-      );
-
-      if ($this->options['multiple']) {
-        $form['value']['#multiple'] = TRUE;
-      }
-
-    }
-    else {
-      $form['value'] = array(
-        '#type' => 'textfield',
-        '#title' => t('%label', array('%label' => $this->options['label'])),
-        '#default_value' => $this->value,
-      );
-    }
-  }
-
- /**
-  * Ensures the select list gets rendered when the filter is exposed
-  */
-  function exposed_form(&$form, &$form_state) {
-    if (empty($this->options['exposed'])) {
-      return;
-    }
-
-    $value = $this->options['expose']['identifier'];
-    $this->value_form($form, $form_state);
-    $form[$value] = $form['value'];
-
-    if (isset($form[$value]['#title']) && !empty($form[$value]['#type']) && $form[$value]['#type'] != 'checkbox') {
-      unset($form[$value]['#title']);
-    }
-
-    $this->exposed_translate($form[$value], 'value');
-
-    if (!empty($form['#type']) && ($form['#type'] == 'checkboxes' || ($form['#type'] == 'select' && !empty($form['#multiple'])))) {
-      unset($form[$value]['#default_value']);
-    }
-
-    if (!empty($form['#type']) && $form['#type'] == 'select' && empty($form['#multiple'])) {
-      $form[$value]['#default_value'] = 'All';
-    }
-
-    if ($value != 'value') {
-      unset($form['value']);
-    }
-
-  }
-
-  /**
-   * This kind of construct makes it relatively easy for a child class
-   * to add or remove functionality by overriding this function and
-   * adding/removing items from this array.
-   */
-  function operators() {
-    $operators = array(
-      '=' => array(
-        'title' => t('Is equal to'),
-        'short' => t('='),
-        'method' => 'op_equal',
-        'values' => 1,
-      ),
-      '!=' => array(
-        'title' => t('Is not equal to'),
-        'short' => t('!='),
-        'method' => 'op_equal',
-        'values' => 1,
-      ),
-      '~' => array(
-        'title' => t('Contains'),
-        'short' => t('contains'),
-        'method' => 'op_contains',
-        'values' => 1,
-      ),
-    );
-
-    return $operators;
-  }
-}

+ 0 - 205
tripal_views/views/handlers/deprecated/views_handler_filter_chado_select_string.inc

@@ -1,205 +0,0 @@
-<?php
-
-/**
- * @file
- * Purpose: This Handler provides a generic select list for any chado field that is a string
- *  The select list includes all distinct values for that field.
- *
- * @ingroup views_filter_handlers
- * @ingroup tripal_core
- */
-class views_handler_filter_chado_select_string extends views_handler_filter_string {
-
-  function options_form(&$form, &$form_state) {
-    parent::options_form($form, $form_state);
-
-    $form['values_form_type'] = array(
-      '#type' => 'radios',
-      '#title' => t('Filter Type'),
-      '#options' => array(
-        'textfield' => 'Text Field',
-        'select' => 'Drop-Down Box',
-      ),
-      '#default_value' => ($this->options['values_form_type']) ? $this->options['values_form_type'] : 'select',
-    );
-
-    $form['multiple'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Select Multiple'),
-      '#description' => t('Allows more then one option to be selected.'),
-      '#default_value' => (isset($this->options['multiple'])) ? $this->options['multiple'] : FALSE,
-    );
-
-    $form['optional'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Optional'),
-      '#description' => t('Adds --Any-- to the available options.'),
-      '#default_value' => (isset($this->options['optional'])) ? $this->options['optional'] : TRUE,
-    );
-
-    $form['max_length'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Max Width'),
-      '#description' => t('Specify the maximum width of the select box'),
-      '#default_value' => (isset($this->options['max_length'])) ? $this->options['max_length'] : 40,
-
-    );
-    $form['max_length'] = array(
-      '#type' => 'markup',
-      '#value' => t('<strong><font color="red">Note:</font></strong> If another filter exists for the same table then '.
-                    'the values shown in the drop box will only include those from rows that are not filtered.'),
-
-    );
-
-  }
-
- /**
-  * Defines the value field in both the views filter options form
-  *   and the exposed form
-  */
-  function value_form(&$form, &$form_state) {
-    parent::value_form($form, $form_state);
-
-    if (preg_match('/textfield/', $this->options['values_form_type'])) {
-      $form['value'] = array(
-        '#type' => 'textfield',
-        '#title' => t('%label', array('%label' => $this->options['label'])),
-        '#default_value' => $this->value,
-      );
-
-    }
-    else {
-
-      // build a where clause that will filter the list in the drop box
-      // using fields that are not exposed and that are for the table
-      // from whcih the values in the drop box will be slected and
-      // we only want to use non-exposed fields because these are not
-      // available to the user to edit--their fixed.
-      $where = '';
-      $filters = $this->view->filter;
-      foreach ($filters as $filter_name => $details) {
-         // we only want to inclue non-exposed filters
-         if ($details->options['exposed'] == FALSE) {
-            // we only want to filter on the table we're getting the list from
-            if (strcmp($details->table, $this->table)==0) {
-              $where .= "$details->field $details->operator ". $details->value['value'];
-              $where .= ' AND ';
-            }
-         }
-      }
-      if ($where) {
-         $where = "WHERE $where";
-         $where = substr($where, 0, -5); # remove the final ' AND '
-      }
-
-      // get the values from the table
-      $sql = "SELECT $this->real_field FROM $this->table $where ORDER BY $this->field ASC";
-      $results = chado_query($sql);
-
-      // Build the select box options
-      $max_length = $this->options['max_length'];
-      if (!$max_length) {
-        $max_length = 40;
-      }
-      if ($this->options['optional']) {
-        //$options['<select '.$this->table.'>'] = '--None--';
-        $options['All'] = '--Any--';
-      }
-      // D7 TODO: Check DBTNG changes work
-      foreach ($results as $r) {
-        if (drupal_strlen($r->{$this->field}) > $max_length) {
-          $options[$r->{$this->field}] = drupal_substr($r->{$this->field}, 0, $max_length) . '...';
-        }
-        else {
-          $options[$r->{$this->field}] = $r->{$this->field};
-        }
-      }
-
-      //Select List
-      $form['value'] = array(
-          '#type' => 'select',
-          '#title' => t('%label', array('%label' => $this->options['label'])),
-          '#options' => $options,
-          '#default_value' => $this->value,
-      );
-
-      if ($this->options['multiple']) {
-        $form['value']['#multiple'] = TRUE;
-      }
-    }
-  }
-
- /**
-  * Ensures the select list gets rendered when the filter is exposed
-  */
-  function exposed_form(&$form, &$form_state) {
-    if (empty($this->options['exposed'])) {
-      return;
-    }
-
-    $value = $this->options['expose']['identifier'];
-    $this->value_form($form, $form_state);
-    $form[$value] = $form['value'];
-
-    if (isset($form[$value]['#title']) && !empty($form[$value]['#type']) && $form[$value]['#type'] != 'checkbox') {
-      unset($form[$value]['#title']);
-    }
-
-    $this->exposed_translate($form[$value], 'value');
-
-    if (!empty($form['#type']) && ($form['#type'] == 'checkboxes' || ($form['#type'] == 'select' && !empty($form['#multiple'])))) {
-      unset($form[$value]['#default_value']);
-    }
-
-    if (!empty($form['#type']) && $form['#type'] == 'select' && empty($form['#multiple'])) {
-      $form[$value]['#default_value'] = 'All';
-    }
-
-    if ($value != 'value') {
-      unset($form['value']);
-    }
-
-  }
-
- /**
-  *
-  */
-  function query() {
-
-    $this->ensure_my_table();
-    $field = "$this->table_alias.$this->real_field";
-    $upper = $this->case_transform();
-
-    if ($this->options['multiple']) {
-      // Remove any if it's there
-      unset($this->value['All']);
-
-      if (sizeof($this->value)) {
-        $holders = array();
-        foreach ($this->value as $v) {
-          if (preg_match('/^[\d\.]+$/', $v)) {
-            $holders[] = '%d';
-          }
-          else {
-            $holders[] = "'%s'";
-          }
-        }
-        $where = "$field IN (" . implode(", ", $holders) . ")";
-        $this->query->add_where($this->options['group'], $where, $this->value);
-      }
-    }
-    else {
-
-      // Deal with All/Any as value
-      if (preg_match('/All/', $this->value)) {
-        // Don't do anything
-      }
-      else {
-        $info = $this->operators();
-        if (!empty($info[$this->operator]['method'])) {
-          $this->{$info[$this->operator]['method']}($field, $upper);
-        }
-      }
-    }
-  }
-}

+ 0 - 340
tripal_views/views/handlers/views_handler_join_chado_aggregator.inc

@@ -1,340 +0,0 @@
-<?php
-
-module_load_include('inc', 'views', 'includes/base');
-module_load_include('inc', 'views', 'includes/handlers');
-
-/**
- * @file
- * Handler to allow joins between records via a linking table
- *
- * Example Usage:
- *   To join the analysisprop table to the analysis table,
- *   Use the following code in the analysisprop hook_views_data:
- *   @code
-        $data['analysisprop']['table']['join']['analysis'] = array(
-          'left_field' => 'analysis_id',
-          'field' => 'analysis_id',
-          'handler' => 'views_handler_join_chado_aggregator',
-          'pre-aggregated' => TRUE | FALSE //whether the table is already aggregated (contains arrays)
-          'table_aggregated' => CURRENT | LEFT //the table which has many records for each record in the other
-        );
- *   @endcode
- */
-class views_handler_join_chado_aggregator extends views_join {
-
-  // PHP 4 doesn't call constructors of the base class automatically from a
-  // constructor of a derived class. It is your responsibility to propagate
-  // the call to constructors upstream where appropriate.
-  function construct($table = NULL, $left_table = NULL, $left_field = NULL, $field = NULL, $extra = array(), $type = 'LEFT', $added = NULL) {
-    parent::construct($table, $left_table, $left_field, $field, $extra, $type);
-
-    // Determine the postgresql version
-    $postgresql_version = pg_version();
-    $this->postgresql_version = $postgresql_version['client'];
-
-    // If version is 9.0+ then indicate
-    // Needed to apply sorting for aggregated fields
-    if (intval($postgresql_version['client']) >= 9) {
-      $this->postgresql_9up = TRUE;
-    }
-
-  }
-
-  /**
-   * Creates SQL including aggregation query used in join
-   */
-  function join($table, &$query) {
-
-    $opt = array(
-      'table' => $this->definition['table'],
-      'field' => $this->definition['field'],
-      'left_table' => $this->definition['left_table'],
-      'left_field' => $this->definition['left_field'],
-      'table_aggregated' => $this->definition['table_aggregated'],
-      'sort' => $this->sort,
-      'filter' => $this->filter,
-      'additional_joins' => $this->additional_joins,
-      'postgresql_9up' => $this->postgresql_9up,
-    );
-
-    $output = $this->aggregate_join($query, $opt);
-    return implode("\n", $output);
-
-  }
-
-  function aggregate_join(&$query, $opt) {
-    // Create the table SQL (used in join) -------
-    // query creating one-to-one table using array_agg
-
-    // Only aggregate each field if it the join table hadn't been pre-aggregated
-    // Example where it might be pre-aggregated: Materialized view
-    if (!$this->definition['pre-aggregated']) {
-
-      $sql = $this->get_aggregate_sql_for_table_field($opt);
-
-      // Create the join (full SQL) ----------------
-      $output[] = $this->create_single_join(
-        $query,
-        array(
-          'table' => $opt['table'],
-          'field' => $opt['field'],
-          'table_sql' => $sql,
-          'is_drupal' => FALSE,
-        ),
-        array(
-          'table' => $opt['left_table'],
-          'field' => $opt['left_field'],
-        ),
-        'LEFT'
-      );
-
-    // Otherwise the table has been pre-aggregated
-    // Then only need to do a regular join with any in where
-    }
-    else {
-
-      // Create the join
-
-      $current_table_spec = array(
-        'table' => $opt['table'],
-        'field' => $opt['field'],
-        'is_drupal' => FALSE,
-      );
-      $left_table_spec = array(
-        'table' => $opt['left_table'],
-        'field' => $opt['left_field'],
-      );
-
-      switch ($opt['table_aggregated']) {
-        default:
-        case 'CURRENT':
-          $current_table_spec['pre-aggregated'] = TRUE;
-        break;
-        case 'LEFT':
-          $left_table_spec['pre-aggregated'] = TRUE;
-        break;
-      }
-
-      $output[] = $this->create_single_join(
-        $query,
-        $current_table_spec,
-        $left_table_spec,
-        'LEFT'
-      );
-    }
-
-    return $output;
-  }
-
-  /**
-   * Create the SQL needed to aggregate a table
-   */
-  function get_aggregate_sql_for_table_field($opt) {
-
-    // Determine Order BY's for aggregates
-    $order_by = array();
-    if (!is_array($opt['sort'])) {
-      $opt['sort'] = array();
-    }
-    foreach ($opt['sort'] as $s) {
-      $order_by[] = $s['table'] . '.' . $s['field'] . ' ' . $s['order'];
-    }
-
-    // get table description (if defined via schema api)
-    $table_desc = tripal_core_get_chado_table_schema($opt['table']);
-    $select_fields[ $opt['table'] ] = $table_desc['fields'];
-
-
-    $joins = array();
-    if (!empty($table_desc)) {
-      // Add joins to tables with a foreign key in this table
-      // (ie: add join to cvterm if this table has a type_id
-      foreach ($table_desc['foreign keys'] as $defn) {
-        if ($defn['table'] != $opt['left_table']) {
-          foreach ( $defn['columns'] as $left => $right) {
-            $table_alias = 'fk_' . $defn['table']  . '_' . $left;
-            $left = $opt['table'] . '.' . $left;
-            $right = $table_alias . '.' . $right;
-            $joins[] = "LEFT JOIN $defn[table] $table_alias ON $left=$right";
-
-            // Fields to be selected from joined table
-            $join_table = tripal_core_get_chado_table_schema($defn['table']);
-            $select_fields[ $table_alias ] = $join_table['fields'];
-          }
-        }
-      }
-
-      // Fields to be selected
-      foreach ($select_fields as $table => $table_fields) {
-        foreach ($table_fields as $fname => $f) {
-          $alias = '';
-          if ($table != $opt['table']) {
-            $alias = $table . '_';
-          }
-
-          if ($fname != $opt['field']) {
-            // Add sort to aggregate field if postgreSQL 9.0+
-            if ($opt['postgresql_9up'] && !empty($order_by)) {
-              $fields[] = 'array_agg(' . $table . '.' . $fname . ' ORDER BY ' . implode(',', $order_by) . ') as ' . $alias . $fname;
-            }
-            else {
-              $fields[] = 'array_agg(' . $table . '.' . $fname . ') as '. $alias . $fname;
-            }
-            $composite_field_parts[] = "'" . $alias . $fname . "::' || COALESCE(CAST(" . $table . '.' . $fname . " as text), '')";
-          }
-          else {
-            $fields[] = $fname;
-            $composite_field_parts[] = "'" . $alias . $fname . "::' || COALESCE(CAST(" . $table . '.' . $fname . " as text), '')";
-          }
-        }
-      }
-
-    // There is no definition in schema api
-    // then use postgresql select
-    }
-    else {
-
-      // No known foreign key relationships
-      // so don't add to $joins
-
-      // Fields to be selected
-      $sql = "SELECT
-                attname as column,
-                format_type(atttypid, atttypmod) as datatype
-              FROM pg_attribute, pg_type
-              WHERE typname='nd_genotype_experiment'
-                AND attrelid=typrelid
-                AND attname NOT IN ('cmin','cmax','ctid','oid','tableoid','xmin','xmax')";
-      // D7 TODO: Check DBTNG changes work
-      $resource = chado_query($sql);
-      foreach ($resource as $r) {
-        $table = $opt['table'];
-        $alias = ''; //no alias needed if table is current table (only option if no schema api definition)
-        $fname = $r->column;
-
-        if ($fname != $opt['field']) {
-          // Add sort to aggregate field if postgreSQL 9.0+
-          if ($opt['postgresql_9up'] && !empty($order_by)) {
-            $fields[] = 'array_agg(' . $table . '.' . $fname . ' ORDER BY ' . implode(',', $order_by) . ') as ' . $alias . $fname;
-          }
-          else {
-            $fields[] = 'array_agg(' . $table . '.' . $fname . ') as ' . $alias . $fname;
-          }
-          $composite_field_parts[] = "'" . $alias . $fname . "::' || COALESCE(CAST(" . $table . '.' . $fname . " as text), '')";
-        }
-        else {
-          $fields[] = $fname;
-          $composite_field_parts[] = "'" . $alias . $fname . "::' || COALESCE(CAST(" . $table . '.' . $fname . " as text), '')";
-        }
-      }
-
-    }
-
-    // Add in any additional joins specified by handlers
-    if (!empty($opt['additional_joins'])) {
-      foreach ($opt['additional_joins'] as $join_defn) {
-
-        // Add the join SQL in
-        $table = ($join_defn['table_alias']) ? $join_defn['table_alias'] : 'adt_' . $join_defn['table'] . '_' . $join_defn['left_field'];
-        $left = $join_defn['left_table'] . '.' . $join_defn['left_field'];
-        $right = $table . '.' . $join_defn['field'];
-        $joins[] = "LEFT JOIN $join_defn[table] $table ON $left=$right";
-
-        // Add to the fields and composite field
-        $join_table_desc = tripal_core_get_chado_table_schema($join_defn['table']);
-        $alias = $table . '_';
-        foreach ($join_table_desc['fields'] as $fname => $fdesc) {
-          // Add sort to aggregate field if postgreSQL 9.0+
-          if ($opt['postgresql_9up'] && !empty($order_by)) {
-            $fields[] = 'array_agg(' . $table . '.' . $fname . ' ORDER BY ' . implode(',', $order_by) . ') as ' . $alias . $fname;
-          }
-          else {
-            $fields[] = 'array_agg(' . $table . '.' . $fname . ') as ' . $alias . $fname;
-          }
-          $composite_field_parts[] = "'" . $alias . $fname . "::' || COALESCE(CAST(" . $table . '.' . $fname . " as text), '')";
-        }
-      }
-    }
-
-    // composite field
-    // (combines all other fields before aggregating)
-    // Add sort to aggregate field if postgreSQL 9.0+
-    if ($opt['postgresql_9up'] && !empty($order_by)) {
-      $composite_field = "array_agg('{'||" . implode(" || ',' || ", $composite_field_parts) . "||'}' ORDER BY " . implode(',', $order_by) . ") as all";
-    }
-    else {
-      $composite_field = "array_agg('{'||" . implode(" || ',' || ", $composite_field_parts) . "||'}') as all";
-    }
-    $fields[] = $composite_field;
-
-    // SQL to use in the join
-    $sql = 'SELECT ' . implode(', ', $fields)
-      .' FROM ' . $opt['table']
-      .' ' . implode(' ', $joins);
-
-    if (!empty($opt['filter'])) {
-      $sql .= ' WHERE ' . implode(' AND ', $opt['filter']);
-    }
-
-    $sql .= ' GROUP BY ' . $opt['field'];
-
-    return $sql;
-  }
-
-  /**
-   * Creates SQL for a single join based on parameters
-   * Join will be: <type> JOIN (<query creating one-to-one table using array_agg>) <table alias>
-   *                  ON <qualified left field>=<qualified right field>
-   */
-  function create_single_join(&$query, $right_spec, $left_spec, $join_type) {
-
-    if ($right_spec['table']) {
-      $right = $query->get_table_info($right_spec['table']);
-      if (!$right['alias']) {
-        $right['alias'] = $right_spec['table'];
-      }
-      $right_field = "$right[alias].$right_spec[field]";
-
-      // Add any() around field if already aggregated
-      if ($right_spec['pre-aggregated']) {
-        $right_field = "any(" . $right_field . ")";
-      }
-
-      // Add drupal { } around table
-      if ($right_spec['is_drupal']) {
-        $right_table = '{' . $right_spec['table'] . '}';
-      }
-      else {
-        $right_table = $right_spec['table'];
-      }
-    }
-
-    if ($left_spec['table']) {
-      $left = $query->get_table_info($left_spec['table']);
-      if (!$left['alias']) {
-        $left['alias'] = $left_spec['table'];
-      }
-      $left_field = "$left[alias].$left_spec[field]";
-    }
-    else {
-      // This can be used if left_field is a formula or something. It should be used only *very* rarely.
-      $left_field = $this->left_spec['field'];
-    }
-
-    // Add any() around field if already aggregated
-    if ($left_spec['pre-aggregated']) {
-      $left_field = "any(" . $left_field . ")";
-    }
-
-    // Concatenate parts together to form join sql
-    if (!empty($right_spec['table_sql'])) {
-      $output = " $join_type JOIN ($right_spec[table_sql]) $right[alias] ON $left_field = $right_field";
-    }
-    else {
-      $output = " $join_type JOIN $right_spec[table] $right[alias] ON $left_field = $right_field";
-    }
-
-    return $output;
-  }
-
-}

+ 0 - 122
tripal_views/views/handlers/views_handler_join_chado_through_linking.inc

@@ -1,122 +0,0 @@
-<?php
-
-module_load_include('inc', 'views', 'includes/base');
-module_load_include('inc', 'views', 'includes/handlers');
-
-/**
- * @file
- * Handler to allow joins between records via a linking table
- *
- * Example Usage:
- *   To join the analysis table to the feature table through the analysisfeature table,
- *   (ie: get analysis fields to show up in a feature view)
- *   Use the following code in the analysis hook_views_data:
- *   @code
-        $data['analysis']['table']['join']['feature'] = array(
-          'linking' => array(
-            'table' => 'analysisfeature',
-            'left_field' => 'feature_id',
-            'field' => 'analysis_id',
-          ),
-          'left_field' => 'feature_id',
-          'field' => 'analysis_id',
-          'handler' => 'views_handler_join_chado_through_linking'
-        );
- *   @endcode
- *
- * NOTE: If the right table is in the drupal schema rather then the chado schema
- *  (ie: node, chado_feature) then add the following to the above join description:
- *  @code
-    'table_is_drupal' => TRUE
- *  @endcode
- *  This will ensure the drupal table is surrounded by { } and as such any database
- *  prefixes are added correctly. If the left table is in the drupal schema it should already
- *  be defined by a previous join (or the From clause).
- */
-class views_handler_join_chado_through_linking extends views_join {
-
-  // PHP 4 doesn't call constructors of the base class automatically from a
-  // constructor of a derived class. It is your responsibility to propagate
-  // the call to constructors upstream where appropriate.
-  function construct($table = NULL, $left_table = NULL, $left_field = NULL, $field = NULL, $extra = array(), $type = 'LEFT', $added = NULL) {
-    parent::construct($table, $left_table, $left_field, $field, $extra, $type);
-  }
-
-  /**
-   * Creates SQL for both joins table => linking_table and linking_table => left_table
-   * NOTE: Uses fields in definition as passed in from hook_views_data join definition
-   */
-  function join($table, &$query) {
-    $output = '';
-    $joins = array();
-
-    $joins[] = $this->create_single_join(
-      $query,
-      array(
-        'table' => $this->definition['linking']['table'],
-        'field' => $this->definition['linking']['left_field'],
-        'is_drupal' => FALSE,
-      ),
-      array(
-        'table' => $this->definition['left_table'],
-        'field' => $this->definition['left_field'],
-      ),
-      'LEFT'
-    );
-
-    $joins[] = $this->create_single_join(
-      $query,
-      array(
-        'table' => $this->definition['table'],
-        'field' => $this->definition['field'],
-        'is_drupal' => $this->definition['table_is_drupal'],
-      ),
-      array(
-        'table' => $this->definition['linking']['table'],
-        'field' => $this->definition['linking']['field'],
-      ),
-      'LEFT'
-    );
-
-    $output .= implode("\n", $joins);
-    return $output;
-  }
-
-  /**
-   * Creates SQL for a single join based on parameters
-   */
-  function create_single_join(&$query, $right_spec, $left_spec, $join_type) {
-
-    if ($right_spec['table']) {
-      $right = $query->get_table_info($right_spec['table']);
-      if (!$right['alias']) {
-        $right['alias'] = $right_spec['table'];
-      }
-      $right_field = "$right[alias].$right_spec[field]";
-
-      if ($right_spec['is_drupal']) {
-        $right_table = '{' . $right_spec['table'] . '}';
-      }
-      else {
-        $right_table = $right_spec['table'];
-      }
-    }
-
-    if ($left_spec['table']) {
-      $left = $query->get_table_info($left_spec['table']);
-      if (!$left['alias']) {
-        $left['alias'] = $left_spec['table'];
-        }
-      $left_field = "$left[alias].$left_spec[field]";
-    }
-    else {
-      // This can be used if left_field is a formula or something. It should be used only *very* rarely.
-      $left_field = $this->left_spec['field'];
-    }
-
-    $output = " $join_type JOIN $right_table $right[alias] ON $left_field = $right_field";
-
-    return $output;
-  }
-
-}