generate maps for naked geo: urls

This commit is contained in:
Mike Macgirvin 2023-02-12 10:23:14 +11:00
parent da33c88f0f
commit e7ade6df3a

View file

@ -756,6 +756,15 @@ function rpost_callback($match)
}
}
fun($match)
{
return str_replace($match[0], '<div class="map">'
. generate_map(floatval($match[1]),floatval($match[2]))
. '</div>',
$match[0]);
}
function bb_map_coords($match)
{
$x = str_replace(['/', ','], [' ', ' '], $match[1]);
@ -1846,8 +1855,15 @@ function bbcode($Text, $options = [])
$Text = preg_replace("/\[map\/\]/", '<div class="map"></div>', $Text);
$Text = preg_replace("/\[map\]/", '<div class="map"></div>', $Text);
}
// provide a map for naked geo: links
$Text = preg_replace_callback(
'/geo:([-+]?(?:[1-8]?\d(?:\.\d+)?|90(?:\.0+)?)),\s*([-+]?(?:180(?:\.0+)?|(?:(?:1[0-7]\d)|(?:[1-9]?\d))(?:\.\d+)?))(?!\d)/',
'bb_map_latlon', $Text);
}
// Check for bold text
if (str_contains($Text, '[b]')) {
$Text = preg_replace("(\[b\](.*?)\[\/b\])ism", '<strong>$1</strong>', $Text);