cis_connector_views_plugin_display_extender.inc

  1. cis7 sites/all/modules/elmsln_contrib/cis_connector/cis_connector_views_plugin_display_extender.inc
  2. cle7 sites/all/modules/elmsln_contrib/cis_connector/cis_connector_views_plugin_display_extender.inc
  3. ecd7 sites/all/modules/elmsln_contrib/cis_connector/cis_connector_views_plugin_display_extender.inc
  4. elmsmedia7 sites/all/modules/elmsln_contrib/cis_connector/cis_connector_views_plugin_display_extender.inc
  5. harmony7 sites/all/modules/elmsln_contrib/cis_connector/cis_connector_views_plugin_display_extender.inc
  6. icor7 sites/all/modules/elmsln_contrib/cis_connector/cis_connector_views_plugin_display_extender.inc
  7. meedjum_blog7 sites/all/modules/elmsln_contrib/cis_connector/cis_connector_views_plugin_display_extender.inc
  8. mooc7 sites/all/modules/elmsln_contrib/cis_connector/cis_connector_views_plugin_display_extender.inc

Definition of cis_connector_views_plugin_display_extender.

Classes

Namesort descending Description
cis_connector_views_plugin_display_extender Adds the CIS connector options to the display

File

sites/all/modules/elmsln_contrib/cis_connector/cis_connector_views_plugin_display_extender.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of cis_connector_views_plugin_display_extender.
  5. */
  6. /**
  7. * Adds the CIS connector options to the display
  8. *
  9. * @ingroup views_display_plugins
  10. * @ignore style_class_names*/
  11. class cis_connector_views_plugin_display_extender extends views_plugin_display_extender {
  12. function add_signature(&$view) {}
  13. /**
  14. * Provide a form to edit options for this plugin.
  15. */
  16. function option_definition() {
  17. $options = parent::option_definition();
  18. $options['cis_bucket'] = array('default' => '-none-');
  19. $options['cis_instance'] = array('default' => TRUE);
  20. return $options;
  21. }
  22. /**
  23. * Alter the options to allow for defaults.
  24. */
  25. function options_definition_alter(&$options) {
  26. $options['cis_bucket'] = array('default' => '-none-');
  27. $options['cis_instance'] = array('default' => TRUE);
  28. }
  29. /**
  30. * Provide a form to edit options for this plugin.
  31. */
  32. function options_form(&$form, &$form_state) {
  33. if ($form['#section'] == 'page-cis_connector') {
  34. $registry = _cis_connector_build_registry();
  35. $options = array('-none-' => '-none-');
  36. foreach ($registry as $key => $option) {
  37. // only display things we can connect to via backend calls
  38. if (isset($option['service_address'])) {
  39. $options[$key] = $key . ' (' . $option['address'] . ')';
  40. }
  41. }
  42. // allow for selection of the bucket to connect to
  43. $form['cis_bucket'] = array(
  44. '#type' => 'select',
  45. '#options' => $options,
  46. '#title' => t('Connector bucket'),
  47. '#description' => t('Which service instance should this view connect to'),
  48. '#weight' => 0,
  49. '#default_value' => $this->display->get_option('cis_bucket'),
  50. );
  51. // allow for designation of a related instance or if this is a single service
  52. $form['cis_instance'] = array(
  53. '#type' => 'checkbox',
  54. '#title' => t('Instance'),
  55. '#description' => t('Is this an instance of a service or a central service?'),
  56. '#weight' => 1,
  57. '#default_value' => $this->display->get_option('cis_instance'),
  58. );
  59. }
  60. }
  61. /**
  62. * Handle any special handling on the validate form.
  63. */
  64. function options_submit(&$form, &$form_state) {
  65. if (isset($form_state['values']['cis_bucket'])) {
  66. $this->display->set_option('cis_bucket', $form_state['values']['cis_bucket']);
  67. $this->display->set_option('cis_instance', $form_state['values']['cis_instance']);
  68. }
  69. }
  70. /**
  71. * Provide the default summary for options in the views UI.
  72. *
  73. * This output is returned as an array.
  74. */
  75. function options_summary(&$categories, &$options) {
  76. if ($this->view->base_table == 'xml') {
  77. $bucket = check_plain(trim($this->display->get_option('cis_bucket')));
  78. $options['cis_connector'] = array(
  79. 'category' => 'other',
  80. 'title' => t('CIS connector'),
  81. 'value' => $bucket,
  82. 'desc' => t('CIS connector settings to modify request address dynamically.'),
  83. );
  84. }
  85. }
  86. /**
  87. * Inject anything into the query that the display_extender handler needs.
  88. */
  89. function query() {
  90. if ($this->view->base_table == 'xml') {
  91. $options = $this->view->display_handler->options;
  92. $this->view->query->options['cis_bucket'] = $options['cis_bucket'];
  93. $this->view->query->options['cis_instance'] = $options['cis_instance'];
  94. }
  95. }
  96. }