return '';
}
-function detailsLink($aFeature, $sTitle = false)
+function detailsLink($aFeature, $sTitle = false, $sExtraProperties = false)
{
if (!$aFeature['place_id']) return '';
- return '<a href="details.php?place_id='.$aFeature['place_id'].'">'.($sTitle?$sTitle:$aFeature['place_id']).'</a>';
+ $sHtml = '<a ';
+ if ($sExtraProperties) {
+ $sHtml .= $sExtraProperties.' ';
+ }
+
+ $sHtml .= 'href="details.php?place_id='.$aFeature['place_id'].'">'.($sTitle?$sTitle:$aFeature['place_id']).'</a>';
+
+ return $sHtml;
}
-function detailsPermaLink($aFeature, $sRefText = false)
+function detailsPermaLink($aFeature, $sRefText = false, $sExtraProperties = false)
{
$sOSMType = formatOSMType($aFeature['osm_type'], false);
if ($sOSMType) {
- $sLabel = $sRefText ? $sRefText : $sOSMType.' '.$aFeature['osm_id'];
- return '<a href="details.php?osmtype='.$aFeature['osm_type'].'&osmid='.$aFeature['osm_id'].'&class='.$aFeature['class'].'">'.$sLabel.'</a>';
+ $sHtml = '<a ';
+ if ($sExtraProperties) {
+ $sHtml .= $sExtraProperties.' ';
+ }
+ $sHtml .= 'href="details.php?osmtype='.$aFeature['osm_type']
+ .'&osmid='.$aFeature['osm_id'].'&class='.$aFeature['class'].'">';
+
+ if ($sRefText) {
+ $sHtml .= $sRefText.'</a>';
+ } else {
+ $sHtml .= $sOSMType.' '.$aFeature['osm_id'].'</a>';
+ }
+
+ return $sHtml;
}
- return detailsLink($aFeature, $sRefText);
+ return detailsLink($aFeature, $sRefText, $sExtraProperties);
}
else
echo ' <span class="type">('.ucwords(str_replace('_',' ',$aResult['type'])).')</span>';
echo '<p>'.$aResult['lat'].','.$aResult['lon'].'</p>';
- echo ' <a class="btn btn-default btn-xs details" href="details.php?osmtype='.$aResult['osm_type'].'&osmid='.$aResult['osm_id'].'&class='.$aResult['class'].'">details</a>';
+ echo detailsPermaLink($aResult, 'details', 'class="btn btn-default btn-xs details"');
echo '</div>';
?>
</div>
echo ' <span class="type">('.ucwords(str_replace('_',' ',$aResult['class'])).')</span>';
else
echo ' <span class="type">('.ucwords(str_replace('_',' ',$aResult['type'])).')</span>';
- echo ' <a class="btn btn-default btn-xs details" href="details.php?osmtype='.$aResult['osm_type'].'&osmid='.$aResult['osm_id'].'&class='.$aResult['class'].'">details</a>';
+ echo detailsPermaLink($aResult, 'details', 'class="btn btn-default btn-xs details"');
echo '</div>';
$i = $i+1;
}
);
}
+ public function testDetailsPermaLinkWithExtraPropertiesNode()
+ {
+ $aFeature = array('osm_type' => 'N', 'osm_id'=> 2, 'class' => 'amenity');
+ $this->assertSame(
+ detailsPermaLink($aFeature, 'something', 'class="xtype"'),
+ '<a class="xtype" href="details.php?osmtype=N&osmid=2&class=amenity">something</a>'
+ );
+ }
+
+ public function testDetailsPermaLinkWithExtraPropertiesTiger()
+ {
+ $aFeature = array('osm_type' => 'T', 'osm_id'=> 5, 'place_id' => 46);
+ $this->assertSame(
+ detailsPermaLink($aFeature, 'something', 'class="xtype"'),
+ '<a class="xtype" href="details.php?place_id=46">something</a>'
+ );
+ }
+
+