openlayers.theme.inc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * @file
  4. * This file holds the theme and preprocess functions for openlayers module
  5. *
  6. * @ingroup openlayers
  7. */
  8. /**
  9. * Preprocess function for openlayers_map
  10. */
  11. function openlayers_preprocess_openlayers_map(&$variables, $hook) {
  12. $map = $variables['map'];
  13. $map['map_name'] = isset($map['map_name']) ? $map['map_name'] : '';
  14. $css_map_name = drupal_clean_css_identifier($map['map_name']);
  15. $links = array();
  16. if (!empty($map['map_name'])) {
  17. $links = array(
  18. '#type' => 'contextual_links',
  19. '#contextual_links' => array(
  20. 'openlayers' => array(
  21. 'admin/structure/openlayers/maps/list', array($map['map_name']),
  22. ),
  23. )
  24. );
  25. }
  26. $variables['links'] = render($links);
  27. $variables['container']['classes'] = implode(" ", array(
  28. 'contextual-links-region',
  29. 'openlayers-container',
  30. 'openlayers-container-map-' . $css_map_name
  31. ));
  32. $variables['container']['width'] = $map['width'];
  33. $variables['container']['height'] = $map['height'];
  34. $variables['container']['id'] = 'openlayers-container-' . $map['id'];
  35. $variables['classes_array'][] = 'openlayers-map-' . $css_map_name;
  36. }
  37. /**
  38. * Theme function to be able to override styles
  39. */
  40. function theme_openlayers_styles($args) {
  41. return $args['styles'];
  42. }