]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/template/search-xml.php
Merge pull request #378 from mtmail/spaces-to-tabs
[nominatim.git] / lib / template / search-xml.php
index dfcf1375e95231e7f7252ec9d373a040106ec5d8..b61ff22f55fe2eed589466c682a8f650ac14b52b 100644 (file)
@@ -5,7 +5,8 @@
        echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?";
        echo ">\n";
 
-       echo "<searchresults";
+       echo "<";
+       echo (isset($sXmlRootTag)?$sXmlRootTag:'searchresults');
        echo " timestamp='".date(DATE_RFC822)."'";
        echo " attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright'";
        echo " querystring='".htmlspecialchars($sQuery, ENT_QUOTES)."'";
                echo " display_name='".htmlspecialchars($aResult['name'], ENT_QUOTES)."'";
 
                echo " class='".htmlspecialchars($aResult['class'])."'";
-               echo " type='".htmlspecialchars($aResult['type'])."'";
+               echo " type='".htmlspecialchars($aResult['type'], ENT_QUOTES)."'";
                echo " importance='".htmlspecialchars($aResult['importance'])."'";
                if (isset($aResult['icon']) && $aResult['icon'])
                {
                        echo " icon='".htmlspecialchars($aResult['icon'], ENT_QUOTES)."'";
                }
 
-               if (isset($aResult['address']) || isset($aResult['askml']))
-               {
-                       echo ">";
-               }
+               $bHasDelim = false;
 
                if (isset($aResult['askml']))
                {
+                       if (!$bHasDelim)
+                       {
+                               $bHasDelim = true;
+                               echo ">";
+                       }
                        echo "\n<geokml>";
                        echo $aResult['askml'];
                        echo "</geokml>";
                }
 
+               if (isset($aResult['sExtraTags']))
+               {
+                       if (!$bHasDelim)
+                       {
+                               $bHasDelim = true;
+                               echo ">";
+                       }
+                       echo "\n<extratags>";
+                       foreach ($aResult['sExtraTags'] as $sKey => $sValue)
+                       {
+                               echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
+                       }
+                       echo "</extratags>";
+               }
+
+               if (isset($aResult['sNameDetails']))
+               {
+                       if (!$bHasDelim)
+                       {
+                               $bHasDelim = true;
+                               echo ">";
+                       }
+                       echo "\n<namedetails>";
+                       foreach ($aResult['sNameDetails'] as $sKey => $sValue)
+                       {
+                               echo '<name desc="'.htmlspecialchars($sKey).'">';
+                               echo htmlspecialchars($sValue);
+                               echo "</name>";
+                       }
+                       echo "</namedetails>";
+               }
+
                if (isset($aResult['address']))
                {
+                       if (!$bHasDelim)
+                       {
+                               $bHasDelim = true;
+                               echo ">";
+                       }
                        echo "\n";
                        foreach($aResult['address'] as $sKey => $sValue)
                        {
                        }
                }
 
-               if (isset($aResult['address']) || isset($aResult['askml']))
+               if ($bHasDelim)
                {
                        echo "</place>";
                }
                }
        }
        
-       echo "</searchresults>";
+       echo "</" . (isset($sXmlRootTag)?$sXmlRootTag:'searchresults') . ">";