openlayers_blocks.inc 955 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * @file
  4. * Openlayers Blocks bean plugin.
  5. */
  6. class OpenlayersBlocksBean extends BeanPlugin {
  7. /**
  8. * Declares default block settings.
  9. */
  10. public function values() {
  11. return array(
  12. 'openlayers_map' => array(),
  13. );
  14. }
  15. /**
  16. * Builds extra settings for the block edit form.
  17. */
  18. public function form($bean, $form, &$form_state) {
  19. $form['openlayers_map'] = array(
  20. '#type' => 'select',
  21. '#title' => t('Map'),
  22. '#description' => t('This is the map that will be rendered in the block.'),
  23. '#options' => openlayers_map_options(),
  24. '#default_value' => $bean->openlayers_map
  25. );
  26. return $form;
  27. }
  28. /**
  29. * Displays the bean.
  30. */
  31. public function view($bean, $content, $view_mode = 'default', $langcode = NULL) {
  32. $preset = openlayers_preset_load($bean->openlayers_map);
  33. $content['openlayers_map']['#markup'] = openlayers_render_map($preset->data);
  34. return $content;
  35. }
  36. }