chado_views_handler_field_numeric.inc

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.

File

tripal_views/views/handlers/chado_views_handler_field_numeric.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * A chado wrapper for the views_handler_field_numeric.
  5. *
  6. * Handles fields which may be aggregated during the chado join process. This field
  7. * will render an aggregated field as a pre_rendered list and will dynamically detect
  8. * whether the field is aggregated or not.
  9. */
  10. class chado_views_handler_field_numeric extends views_handler_field_numeric {
  11. function init(&$view, $options) {
  12. include_once('chado_wrapper_functions.inc');
  13. parent::init($view, $options);
  14. }
  15. /**
  16. * Defines the defaults for the options form
  17. */
  18. function option_definition() {
  19. $options = parent::option_definition();
  20. $options['type'] = array('default' => 'separator');
  21. $options['separator'] = array('default' => ', ');
  22. return $options;
  23. }
  24. /**
  25. * Defines the options form (form available to admin when they add a field to a view)
  26. */
  27. function options_form(&$form, &$form_state) {
  28. parent::options_form($form, $form_state);
  29. $form['type'] = array(
  30. '#type' => 'radios',
  31. '#title' => t('Display type'),
  32. '#options' => array(
  33. 'ul' => t('Unordered list'),
  34. 'ol' => t('Ordered list'),
  35. 'separator' => t('Simple separator'),
  36. ),
  37. '#default_value' => $this->options['type'],
  38. );
  39. $form['separator'] = array(
  40. '#type' => 'textfield',
  41. '#title' => t('Separator'),
  42. '#default_value' => $this->options['separator'],
  43. '#process' => array('views_process_dependency'),
  44. '#dependency' => array('radio:options[type]' => array('separator')),
  45. );
  46. }
  47. /**
  48. * Determines whether the current field is aggregated or not
  49. * Note: The parent::query() takes care of adding the field to the query, etc.
  50. */
  51. function query() {
  52. parent::query();
  53. $this->aggregated = chado_wrapper_is_aggregated_by_join($this);
  54. }
  55. /**
  56. * Splits the aggregated values up for use in rendering
  57. */
  58. function pre_render(&$values) {
  59. // further check the results to see if this field is a postgresql array
  60. $this->aggregated = chado_wrapper_is_aggregated_by_result($this, $values);
  61. // Split Aggregated Results
  62. chado_wrapper_split_array_agg_results($this, $values);
  63. }
  64. /**
  65. * Render the field.
  66. *
  67. * Note: Checks to see if we have an array or simple field. If we have an array, then
  68. * split it up and render each part using the parent render functionality.
  69. *
  70. * @param $values
  71. * The values retrieved from the database.
  72. */
  73. function render($values) {
  74. return chado_wrapper_render_items($this, $values);
  75. }
  76. function parent_render($val) {
  77. return parent::render($val);
  78. }
  79. }