]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/template/search-html.php
show simple query field when no parameters are given
[nominatim.git] / lib / template / search-html.php
index 37a6ce4a8b8e85916f9a0a3fa375e3a9fb89c013..5090a6faaa755b2a23d49cf545c6d5c39b0c4ee6 100644 (file)
 
     <?php include(CONST_BasePath.'/lib/template/includes/html-top-navigation.php'); ?>
 
-    <form class="form-inline" role="search" accept-charset="UTF-8" action="<?php echo CONST_Website_BaseURL; ?>search.php">
-        <div class="form-group">
-            <input id="q" name="q" type="text" class="form-control input-sm" placeholder="Search" value="<?php echo htmlspecialchars($sQuery); ?>" >
+        <div class="top-bar" id="structured-query-selector">
+            <div class="search-type-link">
+                <a id="switch-to-reverse" href="<?php echo CONST_Website_BaseURL; ?>reverse.php?format=html">reverse search</a>
+            </div>
+        <?php
+        $bSimpleQuery = !empty($aMoreParams['q']);
+        $bStructuredQuery = !$bSimpleQuery
+                            && !(empty($aMoreParams['street'])
+                                 && empty($aMoreParams['city'])
+                                 && empty($aMoreParams['county'])
+                                 && empty($aMoreParams['state'])
+                                 && empty($aMoreParams['country'])
+                                 && empty($aMoreParams['postalcode']));
+        ?>
+        <div class="radio-inline">
+          <input type="radio" name="query-selector" id="simple" value="simple" <?php if ($bSimpleQuery) { echo 'checked="checked"'; } ?> >
+          <label for="simple">simple</label>
+        </div>
+        <div class="radio-inline">
+          <input type="radio" name="query-selector" id="structured" value="structured" <?php if ($bStructuredQuery) { echo 'checked="checked"'; } ?> >
+          <label for="structured">structured</label>
+        </div>
+
+    <form role="search" accept-charset="UTF-8" action="<?php echo CONST_Website_BaseURL; ?>search.php">
+        <div class="form-group-simple"
+        <?php
+        if ($bStructuredQuery) {
+            echo 'style="display:none;"';
+        }
+        ?>>
+            <input id="q" name="q" type="text" class="form-control input-sm" placeholder="Search" value="<?php echo htmlspecialchars($aMoreParams['q'] ?? ''); ?>" >
         </div>
+        <div class="form-group-structured"
+        <?php
+        if (!$bStructuredQuery) {
+            echo "style='display:none;'";
+        }
+        ?>>
+<div class="form-inline">
+            <input id="street" name="street" type="text" class="form-control input-sm" placeholder="House number/Street" value="<?php echo htmlspecialchars($aMoreParams['street'] ?? ''); ?>" >
+            <input id="city" name="city" type="text" class="form-control input-sm" placeholder="City" value="<?php echo htmlspecialchars($aMoreParams['city'] ?? ''); ?>" >
+            <input id="county" name="county" type="text" class="form-control input-sm" placeholder="County" value="<?php echo htmlspecialchars($aMoreParams['county'] ?? ''); ?>" >
+            <input id="state" name="state" type="text" class="form-control input-sm" placeholder="State" value="<?php echo htmlspecialchars($aMoreParams['state'] ?? ''); ?>" >
+            <input id="country" name="country" type="text" class="form-control input-sm" placeholder="Country" value="<?php echo htmlspecialchars($aMoreParams['country'] ?? ''); ?>" >
+            <input id="postalcode" name="postalcode" type="text" class="form-control input-sm" placeholder="Postal Code" value="<?php echo htmlspecialchars($aMoreParams['postalcode'] ?? ''); ?>" >
+        </div></div>
         <div class="form-group search-button-group">
             <button type="submit" class="btn btn-primary btn-sm">Search</button>
             <?php if (CONST_Search_AreaPolygons) { ?>
                 <input type="hidden" value="1" name="polygon_geojson" />
             <?php } ?>
-            <input type="hidden" name="viewbox" value="<?php if (isset($aMoreParams['viewbox'])) echo ($aMoreParams['viewbox']); ?>" />
+            <input type="hidden" name="viewbox" value="<?php echo htmlspecialchars($aMoreParams['viewbox'] ?? ''); ?>" />
             <div class="checkbox-inline">
-                <input type="checkbox" id="use_viewbox" <?php if (isset($aMoreParams['viewbox'])) echo "checked='checked'"; ?>>
+                <input type="checkbox" id="use_viewbox" <?php if (!empty($aMoreParams['viewbox'])) echo "checked='checked'"; ?>>
                 <label for="use_viewbox">apply viewbox</label>
             </div>
         </div>
-        <div class="search-type-link">
-            <a id="switch-to-reverse" href="<?php echo CONST_Website_BaseURL; ?>reverse.php?format=html">reverse search</a>
-        </div>
     </form>
-
+</div>
 
     <div id="content">
 
                     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?place_id='.$aResult['place_id'].'">details</a>';
+                echo detailsPermaLink($aResult, 'details', 'class="btn btn-default btn-xs details"');
                 echo '</div>';
                 $i = $i+1;
             }
-            if (sizeof($aSearchResults) && $sMoreURL)
+            if (!empty($aSearchResults) && $sMoreURL)
             {
                 echo '<div class="more"><a class="btn btn-primary" href="'.htmlentities($sMoreURL).'">Search for more results</a></div>';
             }
 
 
 
-
-
-
-
     <script type="text/javascript">
     <?php