openlayers_simple.inc 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * OpenLayers Box
  4. */
  5. class openlayers_simple extends boxes_box {
  6. /**
  7. * Implementation of boxes_content::options_defaults().
  8. */
  9. public function options_defaults() {
  10. return array(
  11. 'map' => ''
  12. );
  13. }
  14. /**
  15. * Implementation of boxes_content::options_form().
  16. */
  17. public function options_form(&$form_state) {
  18. $form = array();
  19. // Map objects
  20. $form['map'] = array(
  21. '#type' => 'select',
  22. '#title' => t('Map'),
  23. '#description' => t('This is map that will be used to render the view.'),
  24. '#options' => openlayers_map_options(),
  25. '#default_value' => $this->options['map'] ?
  26. $this->options['map'] : variable_get('openlayers_default_map', 'default'),
  27. );
  28. return $form;
  29. }
  30. /**
  31. * Implementation of boxes_content::options_form().
  32. */
  33. public function render() {
  34. $title = isset($this->title) ? check_plain($this->title) : NULL;
  35. $map = openlayers_map_load($this->options['map']);
  36. return array(
  37. 'delta' => $this->delta, // Crucial.
  38. 'title' => $title,
  39. 'subject' => $title,
  40. 'content' => openlayers_render_map($map, $map->name)
  41. );
  42. }
  43. }