GPS Track BBCode mod

Mods, snippets and styles postet and supported by the users
Forum rules
As the forum title says this is for User Contributions
Post a support request in this forum and you will be banned!
Locked
stef775
BBCoder I
BBCoder I
Posts: 2
Joined: 07 Mar 2010, 22:13

GPS Track BBCode mod

Post by stef775 »

Well don't know if this is a mod or just a custom bbcode. It's easy to do, you only need a api key at h t t p : / / g p s i e s . c o m and it will embed your track in your forum by using bbcode [gpsies=your trackcode]Your tracktitle[/gpsies]
It looks like this:
Naamloos-2.jpg
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>';
                }
            }   
On line 346 in functiion bbcode_cache_init add:

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;   
In function bbcode_tpl on line 425 add:

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>',   
In functions.php add to the end:

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;    
}
   
In message_parser.php about line 128 add:

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 . ']';
    }   
Please remove spaces out url from g p s i e s . c o m
Happy tracking
desheikh
BBCoder I
BBCoder I
Posts: 1
Joined: 22 Jan 2015, 07:59
BBCodes: 3

Re: GPS Track BBCode mod

Post by desheikh »

THANKS, this is helpful..





________________
http://www.pass-guide.com/
www.kuleuven.be
www.ugent.be
Locked