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