first import

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-08 11:40:19 +02:00
commit 1bc61b12ad
8435 changed files with 1582817 additions and 0 deletions

View File

@@ -0,0 +1,152 @@
<?php
/**
* @file
*
* OpenLayers default packaged layers
*/
function _openlayers_test_openlayers_layers() {
$layers = array();
// KML example with URL
$layer = new stdClass();
$layer->api_version = 1;
$layer->name = 'test_kml_url';
$layer->title = t('KML Test URL');
$layer->description = t('Testing KML layer via an URL.');
$layer->data = array(
'layer_type' => 'openlayers_layer_type_kml',
'layer_handler' => 'kml',
'projection' => array('4326'),
'isBaseLayer' => FALSE,
'vector' => TRUE,
'url' => url(drupal_get_path('module', 'openlayers_test') . '/data/openlayers_test.kml'),
);
$layers[$layer->name] = $layer;
// GeoJSON example with URL
$layer = new stdClass();
$layer->api_version = 1;
$layer->name = 'test_geojson_url';
$layer->title = t('GeoJSON Test URL');
$layer->description = t('Testing GeoJSON layer via an URL.');
$layer->data = array(
'layer_type' => 'openlayers_layer_type_geojson',
'layer_handler' => 'geojson',
'projection' => array('4326'),
'isBaseLayer' => FALSE,
'vector' => TRUE,
'url' => url(drupal_get_path('module', 'openlayers_test') . '/data/openlayers_test.json'),
);
$layers[$layer->name] = $layer;
// GeoJSON example with direct data
$layer = new stdClass();
$layer->api_version = 1;
$layer->name = 'test_geojson_direct_data';
$layer->title = t('GeoJSON Test Direct Data');
$layer->description = t('Testing putting GeoJSON directly in layer.');
$layer->data = array(
'layer_type' => 'openlayers_layer_type_geojson',
'layer_handler' => 'geojson',
'projection' => array('4326'),
'isBaseLayer' => FALSE,
'vector' => TRUE,
'geojson_data' => '
{
"type": "Feature",
"properties": {
"name": "Hello, World",
"description": "This is a GeoJSON test with data directly in the layer."
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-17.578125,
-1.0546875
],
[
-37.265625,
3.1640625
],
[
-54.140625,
-3.8671875
],
[
-48.515625,
-20.0390625
],
[
-30.9375,
-24.9609375
],
[
-21.796875,
-29.1796875
],
[
-23.90625,
-36.9140625
],
[
-39.375,
-42.5390625
],
[
-51.328125,
-44.6484375
],
[
-50.625,
-52.3828125
],
[
-28.125,
-48.8671875
],
[
-13.359375,
-41.1328125
],
[
-11.953125,
-24.9609375
],
[
-28.125,
-15.8203125
],
[
-44.296875,
-11.6015625
],
[
-35.859375,
-1.7578125
],
[
-23.203125,
-9.4921875
],
[
-17.578125,
-1.0546875
]
]
]
},
"crs": {
"type": "name",
"properties": {
"name": "urn:ogc:def:crs:OGC:1.3:CRS84"
}
}
}
',
);
$layers[$layer->name] = $layer;
return $layers;
}

View File

@@ -0,0 +1,250 @@
<?php
/**
* @file
* Holds testing maps
*/
/**
* Separated implementation of hook_openlayers_maps().
*/
function _openlayers_test_openlayers_maps() {
$items = array();
// Map with some behaviors
$behaviors_test = new stdClass();
$behaviors_test->api_version = 1;
$behaviors_test->name = 'behaviors_test';
$behaviors_test->title = t('Test: Behaviors');
$behaviors_test->description = t('This is a test map.');
$behaviors_test->data = array(
'projection' => '900913',
'width' => 'auto',
'default_layer' => 'osm_mapnik',
'height' => '400px',
'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/',
'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css',
'center' => array(
'initial' => array(
'centerpoint' => '0,0',
'zoom' => '2'
)
),
'options' => array(
'displayProjection' => '4326',
'maxExtent' => openlayers_get_extent('4326'),
),
'behaviors' => array(
'openlayers_behavior_panzoombar' => array(),
'openlayers_behavior_layerswitcher' => array(),
'openlayers_behavior_attribution' => array(),
'openlayers_behavior_keyboarddefaults' => array(),
'openlayers_behavior_navigation' => array(),
'openlayers_behavior_fullscreen' => array(),
'openlayers_behavior_mouseposition' => array(),
'openlayers_behavior_dragpan' => array(),
'openlayers_behavior_boxselect' => array(),
'openlayers_behavior_permalink' => array(),
'openlayers_behavior_scaleline' => array(),
'openlayers_behavior_zoombox' => array(),
'openlayers_behavior_zoomtomaxextent' => array(),
),
'layers' => array(
'osm_mapnik' => 'osm_mapnik',
)
);
$items['behaviors_test'] = $behaviors_test;
// Map integrating a Views overlay
$openlayers_maps_cck_views = new stdClass;
$openlayers_maps_cck_views->api_version = 1;
$openlayers_maps_cck_views->name = 'openlayers_test_map_cck_views';
$openlayers_maps_cck_views->title = 'Test: OpenLayers Test Views';
$openlayers_maps_cck_views->description = 'This map tests a custom content type with a WKT field and a views layer.';
$openlayers_maps_cck_views->data = array(
'width' => 'auto',
'height' => '400px',
'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/',
'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css',
'center' => array(
'initial' => array(
'centerpoint' => '0,0',
'zoom' => '2',
),
'restrict' => array(
'restrictextent' => 0,
'restrictedExtent' => '',
),
),
'behaviors' => array(
'openlayers_behavior_attribution' => array(),
'openlayers_behavior_keyboarddefaults' => array(),
'openlayers_behavior_layerswitcher' => array(),
'openlayers_behavior_navigation' => array(),
'openlayers_behavior_panzoombar' => array(),
'openlayers_behavior_popup' => array(),
),
'default_layer' => 'osm_mapnik',
'layers' => array(
'osm_mapnik' => 'osm_mapnik',
'openlayers_test_view_openlayers_1' => 'openlayers_test_view_openlayers_1',
),
'layer_styles' => array(),
'layer_activated' => array(
'openlayers_test_view_openlayers_1' => 'openlayers_test_view_openlayers_1',
),
'layer_switcher' => array(
'openlayers_test_view_openlayers_1' => 'openlayers_test_view_openlayers_1',
),
'projection' => '900913',
'displayProjection' => '4326',
'styles' => array(
'default' => 'default',
'select' => 'default',
'temporary' => 'default',
),
'options' => NULL,
);
// GeoJSON example
$openlayers_maps = new stdClass;
$openlayers_maps->disabled = FALSE;
$openlayers_maps->api_version = 1;
$openlayers_maps->name = 'geojson';
$openlayers_maps->title = 'Test: Using GeoJSON';
$openlayers_maps->description = 'This map uses direct data in a GeoJSON layer, as well as a URL based GeoJSON layer.';
$openlayers_maps->data = array(
'width' => 'auto',
'height' => '400px',
'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/',
'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css',
'center' => array(
'initial' => array(
'centerpoint' => '0,0',
'zoom' => '2',
),
'restrict' => array(
'restrictextent' => 0,
'restrictedExtent' => '',
),
),
'behaviors' => array(
'openlayers_behavior_attribution' => array(),
'openlayers_behavior_keyboarddefaults' => array(),
'openlayers_behavior_layerswitcher' => array(
'ascending' => 1,
'roundedCorner' => 1,
'roundedCornerColor' => '#222222',
),
'openlayers_behavior_navigation' => array(
'zoomWheelEnabled' => 1,
'documentDrag' => 0,
),
'openlayers_behavior_panzoombar' => array(),
'openlayers_behavior_popup' => array(
'layers' => array(
'test_geojson_direct_data' => 'test_geojson_direct_data',
'test_geojson_url' => 'test_geojson_url',
),
),
),
'default_layer' => 'mapquest_osm',
'layers' => array(
'mapquest_osm' => 'mapquest_osm',
'mapquest_openaerial' => 'mapquest_openaerial',
'test_geojson_direct_data' => 'test_geojson_direct_data',
'test_geojson_url' => 'test_geojson_url',
),
'layer_styles' => array(
'test_geojson_direct_data' => 'default',
'test_geojson_url' => 'default_marker_blue',
),
'layer_styles_select' => array(
'test_geojson_direct_data' => 'default_select',
'test_geojson_url' => 'default_marker_green',
),
'projection' => '900913',
'displayProjection' => '4326',
'styles' => array(
'default' => 'default',
'select' => 'default_select',
'temporary' => 'default',
),
);
$items[$openlayers_maps->name] = $openlayers_maps;
// GeoJSON example
$openlayers_maps = new stdClass;
$openlayers_maps->disabled = FALSE;
$openlayers_maps->api_version = 1;
$openlayers_maps->name = 'kml';
$openlayers_maps->title = 'Test: Using KML';
$openlayers_maps->description = 'This map uses a KML feed.';
$openlayers_maps->data = array(
'width' => 'auto',
'height' => '400px',
'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/',
'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css',
'center' => array(
'initial' => array(
'centerpoint' => '-122.08452530529, 37.421872987049',
'zoom' => '17',
),
'restrict' => array(
'restrictextent' => 0,
'restrictedExtent' => '',
),
),
'behaviors' => array(
'openlayers_behavior_attribution' => array(),
'openlayers_behavior_keyboarddefaults' => array(),
'openlayers_behavior_layerswitcher' => array(
'ascending' => 1,
'roundedCorner' => 1,
'roundedCornerColor' => '#222222',
),
'openlayers_behavior_navigation' => array(
'zoomWheelEnabled' => 1,
'documentDrag' => 0,
),
'openlayers_behavior_panzoombar' => array(),
'openlayers_behavior_popup' => array(
'layers' => array(
'test_geojson_direct_data' => 'test_kml_url',
),
),
),
'default_layer' => 'mapquest_osm',
'layers' => array(
'mapquest_osm' => 'mapquest_osm',
'mapquest_openaerial' => 'mapquest_openaerial',
'test_kml_url' => 'test_kml_url',
),
'layer_styles' => array(
'test_kml_url' => 'default',
),
'layer_styles_select' => array(
'test_kml_url' => 'default_select',
),
'projection' => '900913',
'displayProjection' => '4326',
'styles' => array(
'default' => 'default',
'select' => 'default_select',
'temporary' => 'default',
),
);
$items[$openlayers_maps->name] = $openlayers_maps;
// We only want to provide the Views/CCK map if the
// modules are installed and the view is provide
if (module_exists('content') && module_exists('views') && module_exists('content_copy')) {
$layers = openlayers_layers_load();
if (!empty($layers['openlayers_test_view_openlayers_1'])) {
$items['openlayers_test_map_cck_views'] = $openlayers_maps_cck_views;
}
}
// Return maps
return $items;
}

View File

@@ -0,0 +1,64 @@
<?php
/**
* @file
* Pages for test module
*/
/**
* Callback for OpenLayers Test Show Maps Page
*/
function openlayers_test_show_maps() {
$output = '';
// Render all maps
$maps = openlayers_maps();
foreach ($maps as $name => $map) {
$output .= '
<h3>' . $map->title . '</h3>
' . openlayers_render_map($map) . '
';
}
/*
// Create collapsed fieldset
//$render_fieldset = openlayers_render_map();
$element = array(
'#value' => $render_fieldset['themed'],
'#title' => t('Fieldset Example'),
'#collapsed' => TRUE,
'#collapsible' => TRUE,
);
$fieldset = theme_fieldset($element);
*/
return $output;
}
/**
* Callback for OpenLayers Test JS Page
*/
function openlayers_test_js() {
drupal_add_js(drupal_get_path('module', 'openlayers_test') . '/js/qunit/qunit.js');
drupal_add_css(drupal_get_path('module', 'openlayers_test') . '/js/qunit/qunit.css');
drupal_add_js(drupal_get_path('module', 'openlayers_test') . '/js/openlayers_test.js');
$output = '';
// Display QUnit stuff
$output .= '
<h1 id="qunit-header">OpenLayers QUnit Tests</h1>
<h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
';
// Render only specific maps
$maps = array('default', 'behaviors_test');
foreach ($maps as $name => $map) {
$output .= '
' . openlayers_render_map($map) . '
';
}
return $output;
}

View File

@@ -0,0 +1,178 @@
<?php
/**
* @file
* Holds Openlayers test views
*/
/**
* Implements hook_views_default_views().
*/
function _openlayers_test_views_default_views() {
// Only provide view if everything is already setup properly
if (module_exists('content') && module_exists('content_copy')) {
$field = content_fields('field_openlayers_test_wkt', 'openlayers_test_type');
if (!empty($field)) {
$view = new view;
$view->name = 'openlayers_test_view';
$view->description = 'OpenLayers Test View';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'OpenLayers Test View Default Display', 'default');
$handler->override_option('fields', array(
'field_openlayers_test_wkt_openlayers_wkt' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 0,
'label_type' => 'none',
'format' => 'openlayers_wkt',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 0,
'id' => 'field_openlayers_test_wkt_openlayers_wkt',
'table' => 'node_data_field_openlayers_test_wkt',
'field' => 'field_openlayers_test_wkt_openlayers_wkt',
'relationship' => 'none',
),
'teaser' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'exclude' => 0,
'id' => 'teaser',
'table' => 'node_revisions',
'field' => 'teaser',
'relationship' => 'none',
),
'title' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 1,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
));
$handler->override_option('filters', array(
'type' => array(
'operator' => 'in',
'value' => array(
'openlayers_test_type' => 'openlayers_test_type',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('title', 'OpenLayers Test View Layer');
$handler->override_option('items_per_page', 200);
$handler->override_option('style_plugin', 'openlayers_data');
$handler->override_option('style_options', array(
'grouping' => '',
'data_source' => array(
'value' => array(
'openlayers_wkt' => 'openlayers_wkt',
),
'other_lat' => 'field_openlayers_test_wkt_openlayers_wkt',
'other_lon' => 'field_openlayers_test_wkt_openlayers_wkt',
'openlayers_wkt' => 'field_openlayers_test_wkt_openlayers_wkt',
'other_top' => 'field_openlayers_test_wkt_openlayers_wkt',
'other_right' => 'field_openlayers_test_wkt_openlayers_wkt',
'other_bottom' => 'field_openlayers_test_wkt_openlayers_wkt',
'other_left' => 'field_openlayers_test_wkt_openlayers_wkt',
'name_field' => 'title',
'description_field' => 'teaser',
),
));
$handler = $view->new_display('openlayers', 'OpenLayers Test View OpenLayers Display', 'openlayers_1');
$handler->override_option('row_plugin', '');
$handler->override_option('displays', array());
// Return
$views['openlayers_test_view'] = $view;
return $views;
}
}
}