? 710908-style_handler-41.patch
? 750810-export-translation-30.patch
? includes/layer_types/vector.inc
? modules/openlayers_views/views/openlayers-views-data.tpl.php
? tests/js/openlayers_test.context.js
Index: openlayers.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openlayers/openlayers.module,v
retrieving revision 1.69.2.74
diff -u -p -r1.69.2.74 openlayers.module
--- openlayers.module	3 Jun 2010 21:30:46 -0000	1.69.2.74
+++ openlayers.module	4 Jun 2010 16:17:19 -0000
@@ -432,6 +432,21 @@ function openlayers_behaviors($reset = F
 }
 
 /**
+ * Get all style handlers.
+ *
+ * @ingroup openlayers_api
+ *
+ * @param $reset
+ *   Boolean whether to reset cache or not.
+ * @return
+ *   Array of style handler info.
+ */
+function openlayers_style_handlers($reset = FALSE) {
+  ctools_include('plugins');
+  return ctools_get_plugins('openlayers', 'style_handlers');
+}
+
+/**
  * Get all openlayers styles.
  *
  * @ingroup openlayers_api
@@ -885,6 +900,26 @@ class openlayers_layer_type {
 }
 
 /**
+ * Base class for style handlers
+ *
+ * We define base classes in the core module.
+ * All other parent classes can be autoloaded through ctools.
+ */
+class openlayers_style_handler {
+  var $options;
+
+  function __construct($options = array()) {
+    $this->options = $options + $this->options_init();
+  }
+
+  function options_init() {
+    return array();
+  }
+
+  function render(&$style) {}
+}
+
+/**
  * Implementation of hook_ctools_plugin
  */
 function openlayers_ctools_plugin_behaviors() {
@@ -903,6 +938,15 @@ function openlayers_ctools_plugin_layer_
 }
 
 /**
+ * Implementation of hook_ctools_plugin
+ */
+function openlayers_ctools_plugin_style_handlers() {
+  return array(
+    'use hooks' => TRUE,
+  );
+}
+
+/**
  * Implementation of hook_ctools_plugin_api().
  */
 function openlayers_ctools_plugin_api($module, $api) {
Index: includes/openlayers.render.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openlayers/includes/openlayers.render.inc,v
retrieving revision 1.3.2.16
diff -u -p -r1.3.2.16 openlayers.render.inc
--- includes/openlayers.render.inc	27 Apr 2010 15:50:15 -0000	1.3.2.16
+++ includes/openlayers.render.inc	4 Jun 2010 16:17:19 -0000
@@ -68,9 +68,24 @@ function _openlayers_behaviors_render($b
  */
 function _openlayers_styles_process($styles = array(), 
   $layer_styles = array(), &$map = array()) {
+  ctools_include('plugins');
 
   // Get styles info array
   $styles_info = openlayers_styles();
+  
+  // Process with handler if available
+  $style_handlers = openlayers_style_handlers();
+  foreach ($styles_info as $i => $style) {
+    if (isset($style->data['handler']) && 
+      isset($style_handlers[$style->data['handler']])) {
+      $handler_class = ctools_plugin_get_class(
+        $style_handlers[$style->data['handler']], 'style_handler');
+      if (isset($handler_class)) {
+        $handler = new $handler_class;
+        $handler->render($styles_info[$i]);
+      }
+    }
+  }
 
   // Go through styles
   $processed = array();
Index: js/openlayers.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openlayers/js/openlayers.js,v
retrieving revision 1.47.2.31
diff -u -p -r1.47.2.31 openlayers.js
--- js/openlayers.js	17 May 2010 12:31:20 -0000	1.47.2.31
+++ js/openlayers.js	4 Jun 2010 16:17:19 -0000
@@ -278,8 +278,19 @@ Drupal.openlayers = {
       // Implement layer-specific styles.
       if (map.layer_styles !== undefined && map.layer_styles[layername]) {
         var style = map.layer_styles[layername];
-        stylesAdded['default'] = new OpenLayers.Style(map.styles[style]);
+        // Check for context
+        if (typeof map.styles[style].context_object != 'undefined' &&
+          typeof Drupal.openlayers.styleContext[map.styles[style].context_object] != 'undefined') {
+          stylesAdded['default'] = new OpenLayers.Style(
+            map.styles[style],
+            { context: Drupal.openlayers.styleContext[map.styles[style].context_object] }
+          );
+        }
+        else {
+          stylesAdded['default'] = new OpenLayers.Style(map.styles[style]);
+        }        
       }
+      
       return new OpenLayers.StyleMap(stylesAdded);
     }
     // Default styles
@@ -310,3 +321,4 @@ Drupal.openlayers = {
 };
 
 Drupal.openlayers.layer = {};
+Drupal.openlayers.styleContext = {};
Index: modules/openlayers_ui/includes/openlayers_ui.styles.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openlayers/modules/openlayers_ui/includes/Attic/openlayers_ui.styles.inc,v
retrieving revision 1.1.2.6
diff -u -p -r1.1.2.6 openlayers_ui.styles.inc
--- modules/openlayers_ui/includes/openlayers_ui.styles.inc	30 May 2010 22:33:21 -0000	1.1.2.6
+++ modules/openlayers_ui/includes/openlayers_ui.styles.inc	4 Jun 2010 16:17:19 -0000
@@ -15,6 +15,16 @@
 function openlayers_ui_styles_form(&$form_state, $style = NULL, $edit = FALSE) {
   $form = array();
   
+  // Get style handlers
+  $handlers = array(
+    'none' => t('None'),
+  );
+  $style_handlers = openlayers_style_handlers();
+  foreach ($style_handlers as $key => $plugin) {
+    $handler_class = ctools_plugin_get_class($plugin, 'style_handler');
+    $handlers[$handler_class] = $plugin['title'];
+  }
+  
   // Available styling properies.  Defaults and descriptions are taken
   // from OpenLayers.
   // @see http://docs.openlayers.org/library/feature_styling.html
@@ -146,6 +156,11 @@ function openlayers_ui_styles_form(&$for
         'none' => t('None (off)'),
       ),
     ),
+    'handler' => array(
+      'default' => 'none',
+      'desc' => t('Style handlers allow processing to happen on styles.'),
+      'options' => $handlers,
+    )
   );
 
   // Style object basics
Index: tests/openlayers_test.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openlayers/tests/Attic/openlayers_test.module,v
retrieving revision 1.2.2.13
diff -u -p -r1.2.2.13 openlayers_test.module
--- tests/openlayers_test.module	2 May 2010 10:27:31 -0000	1.2.2.13
+++ tests/openlayers_test.module	4 Jun 2010 16:17:20 -0000
@@ -38,6 +38,9 @@ function openlayers_test_ctools_plugin_a
     switch ($api) {
       case 'openlayers_presets':
         return array('version' => 1);
+        
+      case 'openlayers_styles':
+        return array('version' => 1);
 
     }
   }
@@ -53,6 +56,83 @@ function openlayers_test_views_api() {
 }
 
 /**
+ * Implementation of hook_openlayers_style_handlers().
+ */
+function openlayers_test_openlayers_style_handlers() {
+  // Note that this should be point to outside file
+  // but for patch just points here.
+  return array(
+    'openlayers_style_handler_example_context' => array(
+      'title' => t('Example Context'),
+      'description' => t('Example context styling.'),
+      'path' => drupal_get_path('module', 'openlayers_test'),
+      'file' => 'openlayers_test.module',
+      'style_handler' => array(
+        'class' => 'openlayers_style_handler_example_context',
+        'parent' => 'openlayers_style_handler',
+      ),
+    ),
+  );
+}
+
+/**
+ * Attribution Behavior
+ */
+class openlayers_style_handler_example_context extends 
+  openlayers_style_handler {
+  /**
+   * Provide initial values for options.
+   */
+  function options_init() {
+    return array(
+      'context_properties' => array(
+        'fillOpacity' => 'getFillOpacity',
+      ),
+      'context_object' => 'openlayersExampleContext',
+    );
+  }
+
+  function render(&$style) {
+    // For context sstyling, we want to replace the
+    // style properties with their context value
+    foreach ($this->options['context_properties'] as $prop => $callback) {
+      $style->data[$prop] = '${' . $callback . '}';
+    }
+    
+    // Enable context
+    $style->data['context_object'] = $this->options['context_object'];
+    
+    // Add JS
+    drupal_add_js(drupal_get_path('module', 'openlayers_test') .
+      '/js/openlayers_test.context.js');
+  }
+}
+
+/**
+ * Implementation of hook_openlayers_styles()
+ */
+function openlayers_test_openlayers_styles() {
+  $styles = array();
+
+  $style = new stdClass();
+  $style->api_version = 1;
+  $style->name = 'test_context';
+  $style->title = t('Test: Context style');
+  $style->description = t('A style to test context styling.');
+  $style->data = array(
+    'pointRadius' => '6',
+    'fillColor' => '#77777',
+    'strokeColor' => '#222222',
+    'strokeWidth' => '2',
+    'strokeOpacity' => '0.8',
+    'handler' => 'openlayers_style_handler_example_context',
+  );
+  $styles[$style->name] = $style;
+
+  return $styles;
+}
+
+/**
  * Implementation of hook_openlayers_presets().
  */
 function openlayers_test_openlayers_presets() {
