function google_map_field_filter_process in Google Map Field 7
Process callback for hook_filter_info().
1 string reference to 'google_map_field_filter_process'
- google_map_field_filter_info in ./
google_map_field.module - Implements hook_filter_info().
File
- ./
google_map_field.module, line 284 - This file defines all the necessary hooks and functions to create a Google Map Field field type and also a WYSIWYG editor plugin for inserting maps directly into filtered content.
Code
function google_map_field_filter_process($text, $filter, $format) {
$out = $text;
$matches = array();
preg_match_all('/\\[gmf\\:([^\\]]*)\\]/', $text, $matches);
$i = 0;
while (isset($matches[0][$i])) {
$old = '/' . str_replace(']', '\\]', str_replace('[', '\\[', $matches[0][$i])) . '/';
$new = $matches[1][$i] . ';';
$out = preg_replace($old, $new, $out, 1);
$i++;
}
preg_match_all('/lat([^\\]]*)\\;/', $out, $matches);
$i = 0;
$delta = 1000;
//google_map_field_add_maps_api();
$maps = array();
while (isset($matches[1][$i])) {
$match = str_replace(';', '', $matches[0][$i]);
$settings = explode(',', $match);
$map_settings = array();
foreach ($settings as $setting) {
$offset = strpos($setting, '=');
if ($offset !== FALSE) {
$key = trim(substr($setting, 0, $offset));
$val = trim(substr($setting, $offset + 1));
$map_settings[$key] = $val;
}
}
$maps[$i] = $map_settings;
//$replace = str_replace(']', '\]/', str_replace('[', '/\\[', $matches[0][$i]));
$replace = $matches[0][$i];
$settings = array(
'delta' => $delta,
'width' => $map_settings['width'],
'height' => $map_settings['height'],
);
$replacement = theme('google_map_field_map_token', $settings);
$out = preg_replace('/' . $matches[0][$i] . '/', $replacement, $out, 1);
$delta++;
$i++;
}
$map_collection = array(
'gmf_token_maps' => $maps,
);
drupal_add_js(drupal_get_path('module', 'google_map_field') . '/js/google_map_field_token_maps.js');
drupal_add_js($map_collection, 'setting');
return $out;
}