Skip to content
Snippets Groups Projects
Commit 12c70470 authored by boobaa's avatar boobaa Committed by podarok
Browse files

Issue #901596 by Ambidex, Boobaa | Rob_Feature: Use libraries api module for storing markers.

parent 31d6aaf9
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,7 @@ function gmap_uninstall() {
variable_del('gmap_mm_type');
variable_del('gmap_load_zoom_plugin');
variable_del('gmap_markermanager');
variable_del('gmap_marker_custom_dir');
variable_del('gmap_markerfiles');
variable_del('gmap_node_markers');
variable_del('gmap_private_markerfile');
......
......@@ -497,7 +497,6 @@ function gmap_regenerate_markers() {
$contents .= "// GMap marker image data.\n";
$contents .= "Drupal.gmap = Drupal.gmap || {};\n";
$contents .= "Drupal.gmap.iconpath = " . drupal_json_encode(base_path() . variable_get('gmap_markerfiles', drupal_get_path('module', 'gmap') . '/markers')) . ";\n";
$contents .= "Drupal.gmap.icondata = " . drupal_json_encode(gmap_get_icondata(TRUE)) . ";\n";
$dir = "public://js/";
......
......@@ -22,64 +22,78 @@ function _gmap_get_icondata() {
'transparent',
);
$markerdir = variable_get('gmap_markerfiles', drupal_get_path('module', 'gmap') . '/markers');
$markerdirs = variable_get('gmap_markerfiles', array(drupal_get_path('module', 'gmap') . '/markers'));
$markercustomdir = variable_get('gmap_marker_custom_dir', NULL);
if ($markercustomdir) {
$markerdirs[] = $markercustomdir;
}
if (module_exists('libraries')) {
$markercustomdir = libraries_get_path('gmap_markers');
if ($markercustomdir) {
$markerdirs[] = $markercustomdir;
}
}
// The following routines are designed to be easy to comprehend, not fast.
// This whole process gets cached.
// Get the ini files.
$inifiles = file_scan_directory($markerdir, '/.*\.ini$/');
// Parse the ini files and store by path
$inis = array();
foreach ($inifiles as $file) {
$path = substr($file->uri, strlen($markerdir), -strlen($file->filename));
if (!isset($inis[$path])) {
$inis[$path] = array();
}
$inis[$path][] = parse_ini_file($file->uri, TRUE);
}
unset($inifiles);
// Per directory..
foreach ($inis as $path => $path_inis) {
$icons[$path] = array(
'tempf' => array(),
'f' => array(),
'w' => array(),
'h' => array(),
'i' => array(), // Sets of sets
);
// Part 1: Collect image names
$filenames = array();
foreach ($path_inis as $ini) {
foreach ($ini as $k => $v) {
// Is this definition for an icon? (anything with a dot is a file)
if (strpos($k, '.') !== FALSE) {
// Add the icon name.
$filenames[$k] = TRUE;
if (is_array($markerdirs)) {
foreach ($markerdirs as $markerdir) {
$inifiles = file_scan_directory($markerdir, '/.*\.ini$/');
// Parse the ini files and store by path.
$inis = array();
foreach ($inifiles as $file) {
$path = substr($file->uri, 0, -strlen($file->filename));
if (!isset($inis[$path])) {
$inis[$path] = array();
}
else {
// Shadow / alternate search
foreach ($imagetypes as $check) {
if (isset($v[$check])) {
$filenames[$v[$check]] = TRUE;
$inis[$path][] = parse_ini_file($file->uri, TRUE);
}
unset($inifiles);
// Per directory.
foreach ($inis as $path => $path_inis) {
$icons[$path] = array(
'tempf' => array(),
'f' => array(),
'w' => array(),
'h' => array(),
'i' => array(), // Sets of sets.
);
// Part 1: Collect image names.
$filenames = array();
foreach ($path_inis as $ini) {
foreach ($ini as $k => $v) {
// Is this definition for an icon? (Anything with a dot is a file.)
if (strpos($k, '.') !== FALSE) {
// Add the icon name.
$filenames[$k] = TRUE;
}
}
// A sequence is a list of image names.
if (isset($v['sequence'])) {
foreach (explode(',', $v['sequence']) as $f) {
$filenames[trim($f)] = TRUE;
else {
// Shadow / alternate search.
foreach ($imagetypes as $check) {
if (isset($v[$check])) {
$filenames[$v[$check]] = TRUE;
}
}
// A sequence is a list of image names.
if (isset($v['sequence'])) {
foreach (explode(',', $v['sequence']) as $f) {
$filenames[trim($f)] = TRUE;
}
}
}
}
}
$icons[$path]['tempf'] = $filenames;
}
unset($filenames);
}
$icons[$path]['tempf'] = $filenames;
}
unset($filenames);
// Part 2: Assign ids, get width and height
// Part 2: Assign ids, get width and height.
foreach ($icons as $path => $v) {
$counter = 0;
foreach ($icons[$path]['tempf'] as $filename => $fv) {
......@@ -87,7 +101,7 @@ function _gmap_get_icondata() {
if (empty($filename)) {
continue;
}
$size = getimagesize($markerdir . $path . $filename);
$size = getimagesize($path . $filename);
$icons[$path]['f'][$counter] = $filename;
$icons[$path]['w'][$counter] = $size[0];
$icons[$path]['h'][$counter] = $size[1];
......@@ -120,7 +134,7 @@ function _gmap_get_icondata() {
$ini[$k][$t] = $icons[$path]['tempf'][$ini[$k][$t]];
}
}
// Setup key for compression
// Setup key for compression.
$ini[$k]['key'] = $k;
}
......@@ -215,35 +229,49 @@ function _gmap_compress_array(&$arr) {
}
function _gmap_get_marker_titles() {
$markerdir = variable_get('gmap_markerfiles', drupal_get_path('module', 'gmap') . '/markers');
$markerdirs = variable_get('gmap_markerfiles', array(drupal_get_path('module', 'gmap') . '/markers'));
$markercustomdir = variable_get('gmap_marker_custom_dir', NULL);
if ($markercustomdir) {
$markerdirs[] = $markercustomdir;
}
if (module_exists('libraries')) {
$markercustomdir = libraries_get_path('gmap_markers');
if ($markercustomdir) {
$markerdirs[] = $markercustomdir;
}
}
// The following routines are designed to be easy to comprehend, not fast.
// This whole process gets cached.
// Get the ini files.
$inifiles = file_scan_directory($markerdir, '/.*\.ini$/');
// Parse the ini files and store by path
$inis = array();
foreach ($inifiles as $file) {
$data = parse_ini_file($file->uri, TRUE);
if (isset($data['defaults'])) {
// Ignore defaults
unset($data['defaults']);
}
foreach ($data as $k => $v) {
if (strpos($k, '.') !== FALSE) {
// Ignore files
unset($data[$k]);
if (is_array($markerdirs)) {
foreach ($markerdirs as $markerdir) {
$inifiles = file_scan_directory($markerdir, '/.*\.ini$/');
// Parse the ini files and store by path.
$inis = array();
foreach ($inifiles as $file) {
$data = parse_ini_file($file->uri, TRUE);
if (isset($data['defaults'])) {
// Ignore defaults.
unset($data['defaults']);
}
foreach ($data as $k => $v) {
if (strpos($k, '.') !== FALSE) {
// Ignore files.
unset($data[$k]);
}
}
$inis[] = $data;
}
}
$inis[] = $data;
}
unset($inifiles);
unset($inifiles);
$titles = array();
foreach ($inis as $ini => $inidata) {
foreach ($inidata as $k => $v) {
$titles[$k] = t($inis[$ini][$k]['name']);
$titles = array();
foreach ($inis as $ini => $inidata) {
foreach ($inidata as $k => $v) {
$titles[$k] = t($inis[$ini][$k]['name']);
}
}
}
}
return $titles;
......
......@@ -580,6 +580,12 @@ if (file_default_scheme() != 'public') {
'#size' => 4,
'#maxlength' => 4,
);
$form['gmap_marker_custom_dir'] = array(
'#type' => 'textfield',
'#title' => t('Custom markers path'),
'#description' => t('Fill in your custom markers folder (absolute path).'),
'#default_value' => variable_get('gmap_marker_custom_dir', 'no value'),
);
// @@@ Convert to element level validation.
$form['#validate'][] = 'gmap_admin_settings_validate';
......
......@@ -49,7 +49,7 @@ Drupal.gmap.getIcon = function (setname, sequence) {
for (var i = 0; i < q.sequence.length; i++) {
/*
t = new GIcon();
p = Drupal.gmap.iconpath + q.path;
p = q.path;
t.image = p + q.sequence[i].f;
if (q.shadow.f !== '') {
t.shadow = p + q.shadow.f;
......@@ -59,7 +59,7 @@ Drupal.gmap.getIcon = function (setname, sequence) {
t.iconAnchor = new GPoint(q.anchorX, q.anchorY);
t.infoWindowAnchor = new GPoint(q.infoX, q.infoY);
*/
p = Drupal.gmap.iconpath + q.path;
p = q.path;
t = new google.maps.MarkerImage(p + q.sequence[i].f,
new google.maps.Size(q.sequence[i].w, q.sequence[i].h),
null,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment