entity_views_handler_field_numeric.inc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * @file
  4. * Contains the entity_views_handler_field_numeric class.
  5. */
  6. /**
  7. * Render a field as a numeric value.
  8. *
  9. * Overrides the default Views handler to retrieve the data from an entity via
  10. * data selection.
  11. *
  12. * This handler may only be used in conjunction with data selection based Views
  13. * tables or other base tables using a query plugin that supports data
  14. * selection.
  15. *
  16. * @see entity_views_field_definition()
  17. * @ingroup views_field_handlers
  18. */
  19. class entity_views_handler_field_numeric extends views_handler_field_numeric {
  20. /**
  21. * Stores the entity type of the result entities.
  22. */
  23. public $entity_type;
  24. /**
  25. * Stores the result entities' metadata wrappers.
  26. */
  27. public $wrappers = array();
  28. /**
  29. * Stores the current value when rendering list fields.
  30. */
  31. public $current_value;
  32. /**
  33. * Overridden to add the field for the entity ID (if necessary).
  34. */
  35. public function query() {
  36. EntityFieldHandlerHelper::query($this);
  37. }
  38. /**
  39. * Adds a click-sort to the query.
  40. */
  41. public function click_sort($order) {
  42. EntityFieldHandlerHelper::click_sort($this, $order);
  43. }
  44. /**
  45. * Load the entities for all rows that are about to be displayed.
  46. */
  47. public function pre_render(&$values) {
  48. parent::pre_render($values);
  49. EntityFieldHandlerHelper::pre_render($this, $values);
  50. }
  51. /**
  52. * Overridden to use a metadata wrapper.
  53. */
  54. public function get_value($values, $field = NULL) {
  55. return EntityFieldHandlerHelper::get_value($this, $values, $field);
  56. }
  57. /**
  58. * Provide options for this handler.
  59. */
  60. public function option_definition() {
  61. return parent::option_definition() + EntityFieldHandlerHelper::option_definition($this);
  62. }
  63. /**
  64. * Provide a options form for this handler.
  65. */
  66. public function options_form(&$form, &$form_state) {
  67. parent::options_form($form, $form_state);
  68. EntityFieldHandlerHelper::options_form($this, $form, $form_state);
  69. }
  70. /**
  71. * Render the field.
  72. *
  73. * @param $values
  74. * The values retrieved from the database.
  75. */
  76. public function render($values) {
  77. return EntityFieldHandlerHelper::render($this, $values);
  78. }
  79. /**
  80. * Render a single field value.
  81. */
  82. public function render_single_value($value, $values) {
  83. return parent::render($values);
  84. }
  85. }