]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/search-html.php
Merge pull request #1898 from lonvia/show-housenumber-with-housename
[nominatim.git] / lib / template / search-html.php
1 <?php
2     header("content-type: text/html; charset=UTF-8");
3 ?>
4 <?php include(CONST_BasePath.'/lib/template/includes/html-header.php'); ?>
5     <link href="css/common.css" rel="stylesheet" type="text/css" />
6     <link href="css/search.css" rel="stylesheet" type="text/css" />
7 </head>
8
9 <body id="search-page">
10
11     <?php include(CONST_BasePath.'/lib/template/includes/html-top-navigation.php'); ?>
12
13         <div class="top-bar" id="structured-query-selector">
14             <div class="search-type-link">
15                 <a id="switch-to-reverse" href="<?php echo CONST_Website_BaseURL; ?>reverse.php?format=html">reverse search</a>
16             </div>
17
18         <div class="radio-inline">
19           <input type="radio" name="query-selector" id="simple" value="simple">
20           <label for="simple">simple</label>
21         </div>
22         <div class="radio-inline">
23           <input type="radio" name="query-selector" id="structured" value="structured">
24           <label for="structured">structured</label>
25         </div>
26
27     <form role="search" accept-charset="UTF-8" action="<?php echo CONST_Website_BaseURL; ?>search.php">
28         <div class="form-group-simple">
29             <input id="q" name="q" type="text" class="form-control input-sm" placeholder="Search" value="<?php echo htmlspecialchars($aMoreParams['q'] ?? ''); ?>" >
30         </div>
31         <div class="form-group-structured">
32 <div class="form-inline">
33             <input id="street" name="street" type="text" class="form-control input-sm" placeholder="House number/Street" value="<?php echo htmlspecialchars($aMoreParams['street'] ?? ''); ?>" >
34             <input id="city" name="city" type="text" class="form-control input-sm" placeholder="City" value="<?php echo htmlspecialchars($aMoreParams['city'] ?? ''); ?>" >
35             <input id="county" name="county" type="text" class="form-control input-sm" placeholder="County" value="<?php echo htmlspecialchars($aMoreParams['county'] ?? ''); ?>" >
36             <input id="state" name="state" type="text" class="form-control input-sm" placeholder="State" value="<?php echo htmlspecialchars($aMoreParams['state'] ?? ''); ?>" >
37             <input id="country" name="country" type="text" class="form-control input-sm" placeholder="Country" value="<?php echo htmlspecialchars($aMoreParams['country'] ?? ''); ?>" >
38             <input id="postalcode" name="postalcode" type="text" class="form-control input-sm" placeholder="Postal Code" value="<?php echo htmlspecialchars($aMoreParams['postalcode'] ?? ''); ?>" >
39         </div></div>
40         <div class="form-group search-button-group">
41             <button type="submit" class="btn btn-primary btn-sm">Search</button>
42             <?php if (CONST_Search_AreaPolygons) { ?>
43                 <input type="hidden" value="1" name="polygon_geojson" />
44             <?php } ?>
45             <input type="hidden" name="viewbox" value="<?php echo htmlspecialchars($aMoreParams['viewbox'] ?? ''); ?>" />
46             <div class="checkbox-inline">
47                 <input type="checkbox" id="use_viewbox" <?php if (!empty($aMoreParams['viewbox'])) echo "checked='checked'"; ?>>
48                 <label for="use_viewbox">apply viewbox</label>
49             </div>
50         </div>
51     </form>
52 </div>
53
54     <div id="content">
55
56 <?php if ($sQuery) { ?>
57
58         <div id="searchresults" class="sidebar">
59         <?php
60             $i = 0;
61             foreach($aSearchResults as $iResNum => $aResult)
62             {
63
64                 echo '<div class="result" data-position=' . $i . '>';
65
66                 echo (isset($aResult['icon'])?'<img alt="icon" src="'.$aResult['icon'].'"/>':'');
67                 echo ' <span class="name">'.htmlspecialchars($aResult['name']).'</span>';
68                 // echo ' <span class="latlon">'.round($aResult['lat'],3).','.round($aResult['lon'],3).'</span>';
69                 // echo ' <span class="place_id">'.$aResult['place_id'].'</span>';
70                 if (isset($aResult['label']))
71                     echo ' <span class="type">('.$aResult['label'].')</span>';
72                 else if ($aResult['type'] == 'yes')
73                     echo ' <span class="type">('.ucwords(str_replace('_',' ',$aResult['class'])).')</span>';
74                 else
75                     echo ' <span class="type">('.ucwords(str_replace('_',' ',$aResult['type'])).')</span>';
76                 echo detailsPermaLink($aResult, 'details', 'class="btn btn-default btn-xs details"');
77                 echo '</div>';
78                 $i = $i+1;
79             }
80             if (!empty($aSearchResults) && $sMoreURL)
81             {
82                 echo '<div class="more"><a class="btn btn-primary" href="'.htmlentities($sMoreURL).'">Search for more results</a></div>';
83             }
84             else
85             {
86                 echo '<div class="noresults">No search results found</div>';
87             }
88
89         ?>
90         </div>
91
92 <?php } else { ?>
93
94         <div id="intro" class="sidebar">
95             <?php include(CONST_BasePath.'/lib/template/includes/introduction.php'); ?>
96         </div>
97
98 <?php } ?>
99
100         <div id="map-wrapper">
101             <div id="map-position">
102                 <div id="map-position-inner"></div>
103                 <div id="map-position-close"><a href="#">hide</a></div>
104             </div>
105             <div id="map"></div>
106         </div>
107
108     </div> <!-- /content -->
109
110
111
112     <script type="text/javascript">
113     <?php
114
115         $aNominatimMapInit = array(
116             'zoom' => CONST_Default_Zoom,
117             'lat' => CONST_Default_Lat,
118             'lon' => CONST_Default_Lon,
119             'tile_url' => CONST_Map_Tile_URL,
120             'tile_attribution' => CONST_Map_Tile_Attribution
121         );
122         echo 'var nominatim_map_init = ' . json_encode($aNominatimMapInit, JSON_PRETTY_PRINT) . ';';
123
124         echo 'var nominatim_results = ' . json_encode($aSearchResults, JSON_PRETTY_PRINT) . ';';
125         $sStructuredQuery = (empty($aMoreParams['q'])
126                              && !(empty($aMoreParams['street'])
127                                   && empty($aMoreParams['city'])
128                                   && empty($aMoreParams['county'])
129                                   && empty($aMoreParams['state'])
130                                   && empty($aMoreParams['country'])
131                                   && empty($aMoreParams['postalcode'])))
132                             ? 'true' : 'false';
133         echo 'var nominatim_structured_query = '.$sStructuredQuery.';';
134     ?>
135     </script>
136     <?php include(CONST_BasePath.'/lib/template/includes/html-footer.php'); ?>
137
138 </body>
139 </html>