It looks like this: Here it comes:
In constants.php change NUM_CORE_BBCODES in 13.
In bbcode.php in function bbcode_second_pass on line 116 add:
Code: Select all
if ($bbcode_id == 13)
{
if (preg_match("/fileId=([a-z]{12,19})/", $message, $matches))
{
$track = '</iframe>' . gpsies_properties($matches[1]) . '</div><br style="clear:both;" />';
$message = preg_replace("~</iframe>~", $track, $message);
}else
{
$message .= '</div>';
}
}
Code: Select all
case 13:
$this->bbcode_cache[$bbcode_id] = array(
'preg' => array(
'!\[gpsies=(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z\-]+):$uid\](.*?)\[/gpsies:$uid\]!is' => $this->bbcode_tpl('gpsies', $bbcode_id),
)
);
break;
Code: Select all
'gpsies' => '<div><iframe src="h t t p : / / w w w . g p s i e s . c o m / m a p O n l y . d o ?fileId=$1" style="float:left; width:400px; height:400px; border:none;" scrolling="no" title="$2"></iframe>',
Code: Select all
function gpsies_properties($gpsies='')
{
$gpsies_api_key = 'Your Api key';
$gpsies_url_api = 'h t t p : / / w w w . g p s i e s . c o m / a p i . d o ? key=';
$gpsies_url_api .= $gpsies_api_key;
$gpsies = 'fileId=' . $gpsies . ' show=details';
$defaults = array(
CURLOPT_URL => $gpsies_url_api . (strpos($gpsies_url_api, '?') === FALSE ? '?' : '&') . $gpsies,
CURLOPT_HEADER => 0,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_TIMEOUT => 4
);
$ch = curl_init();
curl_setopt_array($ch, ($defaults));
if (!$result = curl_exec($ch))
{
trigger_error(curl_error($ch));
}
curl_close($ch);
$xmlresp = $result;
$xmlgpsies = new SimpleXMLElement($xmlresp);
$tracksrev = array_reverse($xmlgpsies->tracks->xpath('track'));
$trackinfo = 'No data available!';
foreach ($tracksrev as $track)
{
$trackinfo ='<div style="float:left; width:250px; font-size:11px; margin-left:10px;">
<strong>Track title:</strong> ' . $track->title . '
<strong>Track length:</strong> ' . round((real)$track->trackLengthM/1000, 1) . ' km
<strong>Altitudes:</strong> ' . $track->altitudeDifferenceM . ' m
<strong>Min. height:</strong> ' . $track->altitudeMinHeightM . ' m
<strong>Max. height:</strong> ' . $track->altitudeMaxHeightM . ' m
<strong>Climb:</strong> ' . $track->totalAscentM . ' m | '.
'<strong>Descents:</strong> ' . $track->totalDescentM . ' m
<strong>Address:</strong> ' . $track->startPointAddress . '
<strong>Latitude:</strong> ' . $track->startPointLat . '
<strong>Longitude:</strong> ' . $track->startPointLon . '</div>';
}
return $trackinfo;
}
Code: Select all
'gpsies' => array('bbcode_id' => 13, 'regexp' => array('!\[gpsies=(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z\-]+)\](.*?)\[/gpsies\]!uise' => "\$this->bbcode_gpsies('\$1', '\$2')")),
and about line 281:
Code: Select all
/**
* Parse gpsies tag
*/
function bbcode_gpsies($stx, $in)
{
if (!$this->check_bbcode('gpsies', $in))
{
return $in;
}
return '[gpsies=' . $stx . ':' . $this->bbcode_uid . ']' . $in . '[/gpsies:' . $this->bbcode_uid . ']';
}
Happy tracking