From 72eed58b05a6409759fab3261b26eecdd1ef041b Mon Sep 17 00:00:00 2001
From: Pol Dell'Aiera <Pol@47194.no-reply.drupal.org>
Date: Fri, 3 Aug 2012 17:02:45 +0200
Subject: [PATCH] Miscellaneous fix.

---
 includes/boxes/openlayers_simple.inc               |    2 +-
 includes/openlayers.maps.inc                       |    2 +-
 .../includes/openlayers_ui.layers.inc              |    8 ++++----
 .../openlayers_ui/includes/openlayers_ui.maps.inc  |    6 +++---
 modules/openlayers_ui/openlayers_ui.module         |   19 +++++++++++++------
 .../themes/openlayers-ui-styles-preview.tpl.php    |    1 +
 .../plugins/layer_types/openlayers_views_vector.js |    2 +-
 openlayers.module                                  |    4 +++-
 tests/includes/openlayers_test.maps.inc            |    3 +--
 9 files changed, 28 insertions(+), 19 deletions(-)
 create mode 100644 modules/openlayers_ui/themes/openlayers-ui-styles-preview.tpl.php

diff --git a/includes/boxes/openlayers_simple.inc b/includes/boxes/openlayers_simple.inc
index 9c93763..5126f63 100644
--- a/includes/boxes/openlayers_simple.inc
+++ b/includes/boxes/openlayers_simple.inc
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * OpenLayers Boxk
+ * OpenLayers Box
  */
 class openlayers_simple extends boxes_box {
   /**
diff --git a/includes/openlayers.maps.inc b/includes/openlayers.maps.inc
index aa63d58..1f17e3a 100644
--- a/includes/openlayers.maps.inc
+++ b/includes/openlayers.maps.inc
@@ -18,7 +18,7 @@
 function _openlayers_openlayers_maps() {
   $items = array();
 
-  // Defualt map with MapQuest
+  // Default map with MapQuest
   $default = new stdClass();
   $default->api_version = 1;
   $default->name = 'default';
diff --git a/modules/openlayers_ui/includes/openlayers_ui.layers.inc b/modules/openlayers_ui/includes/openlayers_ui.layers.inc
index 7a55f2b..2255bc0 100644
--- a/modules/openlayers_ui/includes/openlayers_ui.layers.inc
+++ b/modules/openlayers_ui/includes/openlayers_ui.layers.inc
@@ -117,11 +117,10 @@ function openlayers_ui_get_layer_form($args, $layer = FALSE) {
 
 
   $form['basics'] = array(
-    '#tree' => TRUE,
+    '#tree' => FALSE,
     '#type' => 'fieldset',
     '#title' => t('Layer Basics'),
     '#description' => t('The following settings are for all layers.'),
-    '#tree' => FALSE,
   );
   $form['basics']['name'] = array(
     '#type' => 'textfield',
@@ -171,7 +170,7 @@ function openlayers_ui_get_layer_type_options($type) {
     if (in_array($key, array('openlayers_views_vector', 'openlayers_layer_type_raw'))) {
       continue;
     }
-  
+
     $class = ctools_plugin_get_class($plugin, 'layer_type');
     if ($class) {
       // Build form.
@@ -221,7 +220,8 @@ function openlayers_ui_layers_import_validate($form, &$form_state) {
   ob_end_clean();
 
   if (!is_array($items)) {
-    return form_error($form['layer'], t('Unable to interpret layer code.'));
+    form_error($form['layer'], t('Unable to interpret layer code.'));
+    return;
   }
 
   // View name must be alphanumeric or underscores, no other punctuation.
diff --git a/modules/openlayers_ui/includes/openlayers_ui.maps.inc b/modules/openlayers_ui/includes/openlayers_ui.maps.inc
index 731b446..5879c1d 100644
--- a/modules/openlayers_ui/includes/openlayers_ui.maps.inc
+++ b/modules/openlayers_ui/includes/openlayers_ui.maps.inc
@@ -785,9 +785,9 @@ function openlayers_ui_maps_form_process($values = array()) {
         if (isset($values['layer_weight'])) {
           $overlays = array();
           asort($values['layer_weight']);
-          foreach (array_keys($values['layer_weight']) as $key) {
-            if ($values['layers']['overlays'][$key]) {
-               $overlays[$key] = $key;
+          foreach (array_keys($values['layer_weight']) as $layer_key) {
+            if ($values['layers']['overlays'][$layer_key]) {
+               $overlays[$layer_key] = $layer_key;
             }
           }
           // TODO: Above code is terrrrrrrrible. rewrite when I have the time
diff --git a/modules/openlayers_ui/openlayers_ui.module b/modules/openlayers_ui/openlayers_ui.module
index c2ffc1c..36ecba2 100644
--- a/modules/openlayers_ui/openlayers_ui.module
+++ b/modules/openlayers_ui/openlayers_ui.module
@@ -9,7 +9,7 @@
 /**
  * Implements hook_init
  */
-function openlayers_init() {
+function openlayers_ui_init() {
   // For backwards compability for the change from maps to presets
   // in the 7.x-2.x version, we want to make it really obvious that
   // administrators and developers should be updating their maps
@@ -394,6 +394,13 @@ function openlayers_ui_theme($existing, $type, $theme, $path) {
       'render element' => 'elements',
       'file' => 'includes/openlayers_ui.theme.inc',
     ),
+    'openlayers_ui_styles_preview' => array(
+      'arguments' => array(
+        'style' => NULL,
+      ),
+      'template' => 'openlayers-ui-styles-preview',
+      'path' => drupal_get_path('module', 'openlayers_ui') .  '/themes',
+    ),
   );
 }
 
@@ -445,9 +452,9 @@ function openlayers_ui_object_list($type) {
 
     // Check map type and create links accordingly.
     $links[] = l(t('Export'), "admin/structure/openlayers/{$type}/{$object->name}/export");
-    
+
     // Do not allow for cloning of Views based layers or specifically unclonable
-    if (!($type == 'layers' && isset($object->data['views'])) || 
+    if (!($type == 'layers' && isset($object->data['views'])) ||
       (isset($object->data['clonable']) && $object->data['clonable'] === FALSE)) {
       $links[] = l(t('Clone'), "admin/structure/openlayers/{$type}/clone/{$object->name}");
     }
@@ -634,6 +641,7 @@ function openlayers_ui_import_page(&$form_state) {
  */
 function openlayers_ui_import_validate($form, &$form_state) {
   $view = '';
+  $map = '';
   ob_start();
   eval($form_state['values']['map']);
   ob_end_clean();
@@ -788,6 +796,5 @@ function openlayers_ui_style_preview($style, $crosshairs = FALSE) {
     ),
   ), 'setting');
 
-  // TODO: This should probably be in a theme function.
-  return '<div id="' . $style->name . '"class="openlayers-ui-style-preview"></div>';
-}
\ No newline at end of file
+  return theme('openlayers_ui_styles_preview', array('style' => $style));
+}
diff --git a/modules/openlayers_ui/themes/openlayers-ui-styles-preview.tpl.php b/modules/openlayers_ui/themes/openlayers-ui-styles-preview.tpl.php
new file mode 100644
index 0000000..c1f4f86
--- /dev/null
+++ b/modules/openlayers_ui/themes/openlayers-ui-styles-preview.tpl.php
@@ -0,0 +1 @@
+<div id="<?php print $style->name; ?>" class="openlayers-ui-style-preview"></div>
diff --git a/modules/openlayers_views/plugins/layer_types/openlayers_views_vector.js b/modules/openlayers_views/plugins/layer_types/openlayers_views_vector.js
index e6d2a51..6a8dcf0 100644
--- a/modules/openlayers_views/plugins/layer_types/openlayers_views_vector.js
+++ b/modules/openlayers_views/plugins/layer_types/openlayers_views_vector.js
@@ -14,7 +14,7 @@ Drupal.openlayers.layer.openlayers_views_vector = function(title, map, options)
   // Create layer object
   var layer = new OpenLayers.Layer.Vector(title, options.options);
 
-  // Add fetures if there are any
+  // Add features if there are any
   if (options.features) {
     Drupal.openlayers.addFeatures(map, layer, options.features);
   }
diff --git a/openlayers.module b/openlayers.module
index a94b880..95d5ddf 100644
--- a/openlayers.module
+++ b/openlayers.module
@@ -37,7 +37,7 @@ define('OPENLAYERS_HOSTED_API_LIBRARY', 2.11);
 function openlayers_help($path, $arg) {
   switch ($path) {
     case 'admin/help#openlayers':
-      $output = '<p>' . t('The OpenLayers module is the base module for the
+      return '<p>' . t('The OpenLayers module is the base module for the
         OpenLayers suite of modules, and provides the main API.') . '</p>';
   }
   return '';
@@ -199,6 +199,7 @@ function openlayers_build_map($map = array()) {
 function openlayers_render_map_data($map = array(), $map_name = '') {
   // Run map through build process
   $map = openlayers_build_map($map);
+  $output = '';
 
   // Given hide_empty_map flag, check if the map has any features
   // defined. If not, assume it is an empty map and shouldn't be displayed.
@@ -426,6 +427,7 @@ function openlayers_layer_sanity_check($layer, $projection = FALSE, $strict = FA
       'The layer %layer_name cannot be reprojected to the map projection: EPSG: %map_proj',
       array(
         '%layer_name' => $layer->name,
+        // TODO: $map is not defined.
         '%map_proj' => $map['projection'],
       )
     );
diff --git a/tests/includes/openlayers_test.maps.inc b/tests/includes/openlayers_test.maps.inc
index 569a4e5..1edfc44 100644
--- a/tests/includes/openlayers_test.maps.inc
+++ b/tests/includes/openlayers_test.maps.inc
@@ -18,7 +18,6 @@ function _openlayers_test_openlayers_maps() {
   $behaviors_test->title = t('Test: Behaviors');
   $behaviors_test->description = t('This is a test map.');
   $behaviors_test->data = array(
-    'projection' => '4326',
     'projection' => '900913',
     'width' => 'auto',
     'default_layer' => 'osm_mapnik',
@@ -248,4 +247,4 @@ function _openlayers_test_openlayers_maps() {
 
   // Return maps
   return $items;
-}
\ No newline at end of file
+}
-- 
1.7.3.4

