mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-14 10:27:57 +00:00
use detailsPermaLink function on main website as well
This commit is contained in:
@@ -33,20 +33,39 @@ function wikipediaLink($aFeature)
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
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>
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,25 @@ class OutputTest extends \PHPUnit\Framework\TestCase
|
||||
);
|
||||
}
|
||||
|
||||
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>'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user