chado_views_handler_field.inc 2.3 KB

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