Skip to content

Commit 73e53bb

Browse files
Add option to show track information in plugin
1 parent fe9f4fe commit 73e53bb

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

docs/plugin.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ The plugin accepts the following optional parameters (comma-separated):
1616
| `map_width` | Width of map (default is set in plugin options) |
1717
| `map_height` | Height of map (default is set in plugin options) |
1818
| `show_graph` | (0 or 1): show graph with elevation and speed below the map. Default is no graph (0). |
19+
| `show_info` | (0 or 1): display track information: length, altitude, level, category, and terrain information. Default is no information (0). |
1920
| `show_link` | (0, 1, or 2): show link to J!TrackGallery page with track details. Use '2' to get a link that opens in a new tab. Default is no link (0). |

plugins/content/jtrackgallery_maps/jtrackgallery_maps.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ private function rendermap($plgParams, $plg_call_params, $imap)
209209
$trackImages = $model->getImages($plg_call_params['id']);
210210
$document = JFactory::getDocument();
211211
require_once JPATH_SITE . '/components/com_jtg/helpers/gpsClass.php';
212+
require_once JPATH_SITE . '/components/com_jtg/models/jtg.php';
212213
$document->addScript( JUri::root(true) . '/media/com_jtg/js/openlayers/ol.js');
213214
$document->addScript( JUri::root(true) . '/components/com_jtg/assets/js/jtg.js');
214215
$document->addScript( JUri::root(true) . '/components/com_jtg/assets/js/animatedCursor.js');
@@ -274,6 +275,75 @@ private function rendermap($plgParams, $plg_call_params, $imap)
274275
$map .= $graphJS;
275276
}
276277
}
278+
if (isset($plg_call_params['show_info']) && $plg_call_params['show_info'] != '0') {
279+
$map .= ' <div class="gps-info-cont" style="width: '.$map_width.'";>'."\n".
280+
' <div class="block-header">'.JText::_('COM_JTG_DETAILS')."</div>\n".
281+
' <div class="gps-info"><table class="gps-info-tab">'."\n";
282+
283+
if ( ($track->distance != "") AND ((float) $track->distance != 0) )
284+
{
285+
$map .= " <tr>\n".
286+
" <td>".JText::_('COM_JTG_DISTANCE')."</td>\n".
287+
" <td>".JtgHelper::getFormattedDistance($track->distance, '', $cfg->unit)."</td>\n".
288+
" </tr>\n";
289+
}
290+
291+
if ($track->ele_asc)
292+
{
293+
$map .= " <tr>\n".
294+
" <td>".JText::_('COM_JTG_ELEVATION_UP')."</td>\n".
295+
" <td>$track->ele_asc ".JText::_('COM_JTG_UNIT_METER')."</td>\n".
296+
" </tr>\n";
297+
}
298+
299+
if ($track->ele_desc)
300+
{
301+
$map .= " <tr>\n".
302+
" <td>".JText::_('COM_JTG_ELEVATION_DOWN')."</td>\n".
303+
" <td>$track->ele_desc ".JText::_('COM_JTG_UNIT_METER')."</td>\n".
304+
" </tr>\n";
305+
}
306+
$map .= " </table> </div>\n".
307+
' <div class="gps-info"><table class="gps-info-tab">'."\n";
308+
if ( $track->level != "0" )
309+
{
310+
$map .= " <tr>\n".
311+
" <td>".JText::_('COM_JTG_LEVEL')."</td>\n".
312+
" <td>".$model->getLevel($track->level)."</td>\n".
313+
" </tr>\n";
314+
}
315+
$sortedcats = JtgModeljtg::getCatsData(true);
316+
$map .= " <tr>\n".
317+
" <td>".JText::_('COM_JTG_CATS')."</td>\n".
318+
' <td colspan="2">'.
319+
JtgHelper::parseMoreCats($sortedcats, $track->catid, "TrackDetails", true).
320+
" </td>\n".
321+
" </tr>\n";
322+
if (! $this->params->get("jtg_param_disable_terrains"))
323+
{
324+
// Terrain description is enabled
325+
if ($track->terrain)
326+
{
327+
$terrain = $track->terrain;
328+
$terrain = explode(',', $terrain);
329+
$newterrain = array();
330+
331+
foreach ($terrain as $t)
332+
{
333+
$t = $model->getTerrain(' WHERE id=' . $t);
334+
335+
if ( ( isset($t[0])) AND ( $t[0]->published == 1 ) )
336+
{
337+
$newterrain[] = $t[0]->title;
338+
}
339+
}
340+
341+
$terrain = implode(', ', $newterrain);
342+
$map .= "<tr><td>".JText::_('COM_JTG_TERRAIN')."</td><td>".$terrain."</td></tr>";
343+
}
344+
}
345+
$map .= "</table>\n</div>";
346+
}
277347
}
278348

279349
return $map;

0 commit comments

Comments
 (0)