views_handler_area.inc

  1. cis7 sites/all/modules/ulmus/views/handlers/views_handler_area.inc
  2. cle7 sites/all/modules/ulmus/views/handlers/views_handler_area.inc
  3. ecd7 sites/all/modules/ulmus/views/handlers/views_handler_area.inc
  4. elmsmedia7 sites/all/modules/ulmus/views/handlers/views_handler_area.inc
  5. harmony7 sites/all/modules/ulmus/views/handlers/views_handler_area.inc
  6. icor7 sites/all/modules/ulmus/views/handlers/views_handler_area.inc
  7. meedjum_blog7 sites/all/modules/ulmus/views/handlers/views_handler_area.inc
  8. mooc7 sites/all/modules/ulmus/views/handlers/views_handler_area.inc

Views area handlers.

Classes

Namesort descending Description
views_handler_area Base class for area handlers.
views_handler_area_broken A special handler to take the place of missing or broken handlers.

File

sites/all/modules/ulmus/views/handlers/views_handler_area.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Views area handlers.
  5. */
  6. /**
  7. * @defgroup views_area_handlers Views area handlers
  8. * @{
  9. * Handlers to tell Views what can display in header, footer
  10. * and empty text in a view.
  11. */
  12. /**
  13. * Base class for area handlers.
  14. *
  15. * @ingroup views_area_handlers
  16. */
  17. class views_handler_area extends views_handler {
  18. /**
  19. * Overrides views_handler::init().
  20. *
  21. * Make sure that no result area handlers are set to be shown when the result
  22. * is empty.
  23. */
  24. function init(&$view, &$options) {
  25. parent::init($view, $options);
  26. if ($this->handler_type == 'empty') {
  27. $this->options['empty'] = TRUE;
  28. }
  29. }
  30. /**
  31. * Get this field's label.
  32. */
  33. function label() {
  34. if (!isset($this->options['label'])) {
  35. return $this->ui_name();
  36. }
  37. return $this->options['label'];
  38. }
  39. function option_definition() {
  40. $options = parent::option_definition();
  41. $this->definition['field'] = !empty($this->definition['field']) ? $this->definition['field'] : '';
  42. $label = !empty($this->definition['label']) ? $this->definition['label'] : $this->definition['field'];
  43. $options['label'] = array('default' => $label, 'translatable' => TRUE);
  44. $options['empty'] = array('default' => FALSE, 'bool' => TRUE);
  45. return $options;
  46. }
  47. /**
  48. * Provide extra data to the administration form
  49. */
  50. function admin_summary() {
  51. return $this->label();
  52. }
  53. /**
  54. * Default options form that provides the label widget that all fields
  55. * should have.
  56. */
  57. function options_form(&$form, &$form_state) {
  58. parent::options_form($form, $form_state);
  59. $form['label'] = array(
  60. '#type' => 'textfield',
  61. '#title' => t('Label'),
  62. '#default_value' => isset($this->options['label']) ? $this->options['label'] : '',
  63. '#description' => t('The label for this area that will be displayed only administratively.'),
  64. );
  65. if ($form_state['type'] != 'empty') {
  66. $form['empty'] = array(
  67. '#type' => 'checkbox',
  68. '#title' => t('Display even if view has no result'),
  69. '#default_value' => isset($this->options['empty']) ? $this->options['empty'] : 0,
  70. );
  71. }
  72. }
  73. /**
  74. * Don't run a query
  75. */
  76. function query() { }
  77. /**
  78. * Render the area
  79. */
  80. function render($empty = FALSE) {
  81. return '';
  82. }
  83. /**
  84. * Area handlers shouldn't have groupby.
  85. */
  86. function use_group_by() {
  87. return FALSE;
  88. }
  89. }
  90. /**
  91. * A special handler to take the place of missing or broken handlers.
  92. *
  93. * @ingroup views_area_handlers
  94. */
  95. class views_handler_area_broken extends views_handler_area {
  96. function ui_name($short = FALSE) {
  97. return t('Broken/missing handler');
  98. }
  99. function ensure_my_table() { /* No table to ensure! */ }
  100. function query($group_by = FALSE) { /* No query to run */ }
  101. function render($empty = FALSE) { return ''; }
  102. function options_form(&$form, &$form_state) {
  103. $form['markup'] = array(
  104. '#prefix' => '<div class="form-item description">',
  105. '#value' => t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.'),
  106. );
  107. }
  108. /**
  109. * Determine if the handler is considered 'broken'
  110. */
  111. function broken() { return TRUE; }
  112. }
  113. /**
  114. * @}
  115. */