]> git.openstreetmap.org Git - nominatim.git/commitdiff
use detailsPermaLink function on main website as well
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 9 Feb 2020 15:05:22 +0000 (16:05 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Sun, 9 Feb 2020 15:05:22 +0000 (16:05 +0100)
lib/output.php
lib/template/address-html.php
lib/template/search-html.php
test/php/Nominatim/OutputTest.php

index 8715efbc49b61d5fa83aa7d37c9f4d27955634dc..4a15ecde462298c06b19199f03c3d1fe0c182543 100644 (file)
@@ -33,20 +33,39 @@ function wikipediaLink($aFeature)
     return '';
 }
 
     return '';
 }
 
-function detailsLink($aFeature, $sTitle = false)
+function detailsLink($aFeature, $sTitle = false, $sExtraProperties = false)
 {
     if (!$aFeature['place_id']) return '';
 
 {
     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) {
 {
     $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);
 }
 }
index 9b0984289c021060ce48389956e8d4dd9b53c2ef..5be714d3c3bb2453ca4c2a2665b632adeb3a1ffd 100644 (file)
@@ -85,7 +85,7 @@
             else
                 echo ' <span class="type">('.ucwords(str_replace('_',' ',$aResult['type'])).')</span>';
             echo '<p>'.$aResult['lat'].','.$aResult['lon'].'</p>';
             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 '</div>';
         ?>
         </div>
index c42476bff905467e1134e1565af83967e0aa4f4b..2b8c14951551b0f359d72518cd51e78484fb514e 100644 (file)
@@ -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 ' <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;
             }
                 echo '</div>';
                 $i = $i+1;
             }
index ce9bfa35983400a09278065fd69417d328654085..486448456c10292bc1df6713a3197c6e6f5fd612 100644 (file)
@@ -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>'
+                );
+    }
+
+