Commit d37f4130 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge "Handle more Google Maps URLs. Bug 1378645"

parents 8d7fa0b1 4b1ce677
......@@ -262,10 +262,10 @@ class PluginBlocktypeGoogleApps extends SystemBlocktype {
'url' => $httpstr . '://www.google.com/calendar/embed?src=$1',
'type' => 'iframe',
),
// maps.google.com - Google My Maps (IMPORTANT: this is ONLY for My Maps)
// (maps|www).google.com - Google My Maps (IMPORTANT: this is ONLY for My Maps)
array(
'match' => '#.*maps.google.[^/]*/maps/ms\?([a-zA-Z0-9\.\,\;\_\-\&\%\=\+/]+).*#',
'url' => $httpstr . '://maps.google.com/maps/ms?$1',
'match' => '#.*google.[^/]*/maps/ms\?([a-zA-Z0-9\.\,\;\_\-\&\%\=\+/]+).*#',
'url' => $httpstr . '://maps.google.com/maps/ms?$1&output=embed',
'type' => 'iframe',
),
// maps.google.com - Other maps.google.map URLs.
......@@ -274,6 +274,16 @@ class PluginBlocktypeGoogleApps extends SystemBlocktype {
'url' => $httpstr . '://maps.google.com/maps?$2&output=embed',
'type' => 'iframe',
),
// (maps|www).google.com/maps/place - Google Map for a place URLs.
array(
'match' => '#.*google.[^/]*/maps/place/([^/]+)/@([0-9\-\.]+),([0-9\-\.]+),([0-9]+)z/data=.+!1s([0-9xa-f]+):([0-9xa-f]+).*#',
'url' => function ($m) {
$zoomlevel = min(max($m[4], 3), 21);
$height = 188 * pow(2, (21 - $zoomlevel));
return "https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d${height}!2d${m[3]}!3d${m[2]}!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s${m[5]}%3A${m[6]}!2s${m[1]}!5e0";
},
'type' => 'iframe',
),
// mapsengine.google.com/map/embed URLs.
array(
'match' => '#.*mapsengine.google.com[^/]*/map/[^?]*\?([a-zA-Z0-9\.\,\;\_\-\&\%\=\+\?/]+).*#',
......@@ -316,7 +326,12 @@ class PluginBlocktypeGoogleApps extends SystemBlocktype {
foreach ($embedsources as $source) {
$url = htmlspecialchars_decode($url); // convert & back to &, etc.
if (preg_match($source['match'], $url)) {
$apps_url = preg_replace($source['match'], $source['url'], $url);
if (is_string($source['url'])) {
$apps_url = preg_replace($source['match'], $source['url'], $url);
}
else if (is_callable($source['url'])) {
$apps_url = preg_replace_callback($source['match'], $source['url'], $url);
}
// For correctly embed Google maps...
$apps_url = str_replace('source=embed', 'output=embed', $apps_url);
$apps_type = $source['type'];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment