? 710908-variable-styling-context-37.patch
? includes/layer_types/vector.inc
? modules/openlayers_views/views/openlayers-views-data.tpl.php
? tests/js/openlayers_test.context.js
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	31 May 2010 00:06:38 -0000
@@ -90,6 +90,11 @@ function _openlayers_styles_process($sty
         !empty($styles_info[$style]) && 
         $info = $styles_info[$style]->data) {
       $processed[$style] = $info;
+      
+      // Include context files if needed
+      if ($styles_info[$style]->data['context_enable'] == TRUE) {
+        drupal_add_js($styles_info[$style]->data['context_include']);
+      }
     }
   }
 
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	31 May 2010 00:06:38 -0000
@@ -278,8 +278,20 @@ 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_enable != 'undefined' 
+          && map.styles[style].context_enable === true) {
+          stylesAdded['default'] = new OpenLayers.Style(
+            map.styles[style],
+            { context: Drupal.openlayers.context[map.styles[style].context_object] }
+          );
+        }
+        else {
+          stylesAdded['default'] = new OpenLayers.Style(map.styles[style]);
+        }
       }
+
       return new OpenLayers.StyleMap(stylesAdded);
     }
     // Default styles
@@ -310,3 +322,4 @@ Drupal.openlayers = {
 };
 
 Drupal.openlayers.layer = {};
+Drupal.openlayers.context = {};
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	31 May 2010 00:06:38 -0000
@@ -147,7 +147,7 @@ function openlayers_ui_styles_form(&$for
       ),
     ),
   );
-
+  
   // Style object basics
   $form['info'] = array(
     '#type' => 'fieldset',
@@ -171,9 +171,39 @@ function openlayers_ui_styles_form(&$for
     '#default_value' => !empty($style->description) ? $style->description : '',
   );
 
-  // OpenLayers style properties
+  // OpenLayers style properties data set
   $form['data'] = array('#type' => 'fieldset', '#tree' => TRUE);
 
+  // Style Context callback
+  $form['data']['context_enable'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Enable Context'),
+    '#description' => t('Use this to enable style contexts.
+      These are used to provide more detailed styling for
+      Style properties.  Once set up, then use ${callbackName}
+      for the style you want to use the context.'),
+    '#default_value' => isset($style->data['context_enable']) ?
+      $style->data['context_enable'] : FALSE,
+  );
+  // TODO: Use CTools dependency to hide this.
+  $form['data']['context_include'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Context Include Path'),
+    '#description' => t('The Drupal path to the JS
+      to include for this context callback.'),
+    '#default_value' => isset($style->data['context_include']) ?
+      $style->data['context_include'] : '',
+  );
+  $form['data']['context_object'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Context Object'),
+    '#description' => t('The name of the object that
+      defines the style context.'),
+    '#default_value' => isset($style->data['context_object']) ?
+      $style->data['context_object'] : '',
+  );
+
+  // Interface style properties
   foreach ($properties as $key => $prop) {
     $form['data'][$key] = array(
       '#type' => !isset($prop['options']) ? 'textfield' : 'select',
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	31 May 2010 00:06:38 -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,33 @@ function openlayers_test_views_api() {
 }
 
 /**
+ * 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',
+    'fillOpacity' => '${getFillOpacity}',
+    'strokeOpacity' => '0.8',
+    'context_enable' => TRUE,
+    'context_include' => drupal_get_path('module', 'openlayers_test') . '/js/openlayers_test.context.js',
+    'context_object' => 'openlayers_test_context_object',
+  );
+  $styles[$style->name] = $style;
+
+  return $styles;
+}
+
+/**
  * Implementation of hook_openlayers_presets().
  */
 function openlayers_test_openlayers_presets() {
