]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/details-html.php
details.php now also responsive
[nominatim.git] / lib / template / details-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/details.css" rel="stylesheet" type="text/css" />
6 </head>
7
8
9
10 <?php
11
12         function headline($sTitle)
13         {
14                 echo "<h2>".$sTitle."</h2>\n";
15         }
16
17         function osm_link($aFeature)
18         {
19                 $sOSMType = ($aFeature['osm_type'] == 'N'?'node':($aFeature['osm_type'] == 'W'?'way':($aFeature['osm_type'] == 'R'?'relation':'')));
20                 if ($sOSMType) {
21                         return '<a href="http://www.openstreetmap.org/browse/'.$sOSMType.'/'.$aFeature['osm_id'].'">'.$sOSMType.' '.$aFeature['osm_id'].'</a>';
22                 }
23                 return '';
24         }
25
26         function wikipedia_link($aFeature)
27         {
28                 if ($aFeature['wikipedia'])
29                 {
30                         list($sWikipediaLanguage,$sWikipediaArticle) = explode(':',$aFeature['wikipedia']);
31                         return '<a href="http://'.$sWikipediaLanguage.'.wikipedia.org/wiki/'.urlencode($sWikipediaArticle).'">'.$aFeature['wikipedia'].'</a>';
32                 }
33                 return '';
34         }
35
36         function nominatim_link($aFeature, $sTitle)
37         {
38                 return '<a href="details.php?place_id='.$aFeature['place_id'].'">'.$sTitle.'</a>';
39         }
40
41         function format_distance($fDistance)
42         {
43                 return'<abbr class="distance" title="'.$fDistance.'">~'.(round($fDistance,1)).' km</abbr>';
44         }
45
46         function kv($sKey,$sValue)
47         {
48                 echo ' <tr><td>' . $sKey . '</td><td>'.$sValue.'</td></tr>'. "\n";
49         }
50
51
52         function hash_to_subtable($aAssociatedList)
53         {
54                 $sHTML = '';
55                 foreach($aAssociatedList as $sKey => $sValue)
56                 {
57                         $sHTML = $sHTML.' <div class="line"><span class="name">'.$sValue.'</span> ('.$sKey.')</div>'."\n";
58                 }
59                 return $sHTML;
60         }
61
62         // function hash_to_subtable($aAssociatedList)
63         // {
64         //      $sHTML = '<table class="table">';
65         //      foreach($aAssociatedList as $sKey => $sValue)
66         //      {
67         //              $sHTML = $sHTML . '<tr><td>'.$sKey.'</td><td class="name">'.$sValue.'</td></tr>'."\n";
68         //      }
69         //      $sHTML = $sHTML . '</table>';
70         //      return $sHTML;
71         // }
72
73
74         function map_icon($sIcon)
75         {
76                 if ($sIcon){
77                         echo '<img id="mapicon" src="'.CONST_Website_BaseURL.'images/mapicons/'.$sIcon.'.n.32.png'.'" alt="'.$sIcon.'" />';
78                 }
79         }
80
81
82         function _one_row($aAddressLine){
83                 $bNotUsed = (isset($aAddressLine['isaddress']) && $aAddressLine['isaddress'] == 'f');
84
85                 echo '<tr class="' . ($bNotUsed?'notused':'') . '">';
86                 echo '  <td class="name">'.(trim($aAddressLine['localname'])?$aAddressLine['localname']:'<span class="noname">No Name</span>').'</td>';
87                 echo '  <td>' . $aAddressLine['class'].':'.$aAddressLine['type'] . '</td>';
88                 echo '  <td>' . osm_link($aAddressLine) . '</td>';
89                 echo '  <td>' . (isset($aAddressLine['admin_level']) ? $aAddressLine['admin_level'] : '') . '</td>';
90                 // echo '<td>' . (isset($aAddressLine['rank_search_label']) ? $aAddressLine['rank_search_label'] : '') .'</td>';
91                 // echo ', <span class="area">'.($aAddressLine['fromarea']=='t'?'Polygon':'Point').'</span>';
92                 echo '  <td>' . format_distance($aAddressLine['distance']).'</td>';;
93                 echo '  <td>' . nominatim_link($aAddressLine,'details &gt;') . '</td>';;
94                 echo "</tr>\n";
95         }
96
97 ?>
98
99
100
101 <body id="details-page">
102         <div class="container">
103                 <div class="row">
104                         <div class="col-sm-10">
105                                 <h1><?php echo $aPointDetails['localname'] ?></h1>
106                         </div>
107                         <div class="col-sm-2 text-right">
108                                 <?php map_icon($aPointDetails['icon']) ?>
109                         </div>
110                 </div>
111                 <div class="row">
112                         <div class="col-md-6">
113                                 <table id="locationdetails" class="table table-striped">
114
115                                 <?php
116
117                                         kv('Name'            , hash_to_subtable($aPointDetails['aNames']) );
118                                         kv('Type'            , $aPointDetails['class'].':'.$aPointDetails['type'] );
119                                         kv('Last Updated'    , $aPointDetails['indexed_date'] );
120                                         kv('Admin Level'     , $aPointDetails['admin_level'] );
121                                         kv('Rank'            , $aPointDetails['rank_search_label'] );
122                                         if ($aPointDetails['calculated_importance']) {
123                                                 kv('Importance'    , $aPointDetails['calculated_importance'].($aPointDetails['importance']?'':' (estimated)') );
124                                         }
125                                         kv('Coverage'        , ($aPointDetails['isarea']=='t'?'Polygon':'Point') );
126                                         kv('Centre Point'    , $aPointDetails['lat'].','.$aPointDetails['lon'] );
127                                         kv('OSM'             , osm_link($aPointDetails) );
128                                         if ($aPointDetails['wikipedia'])
129                                         {
130                                                 kv('Wikipedia Calculated' , wikipedia_link($aPointDetails) );
131                                         }
132
133                                         kv('Extra Tags'      , hash_to_subtable($aPointDetails['aExtraTags']) );
134
135                                 ?>
136
137                                 </table>
138                         </div>
139
140                         <div class="col-md-6">
141                                 <div id="map"></div>
142                         </div>
143
144                 </div>
145                 <div class="row">
146                         <div class="col-md-12">
147
148                         <h2>Address</h2>
149
150                         <table id="address" class="table table-striped table-responsive">
151                                 <thead>
152                                         <tr>
153                                           <td>Local name</td>
154                                           <td>Type</td>
155                                           <td>OSM</td>
156                                           <td>Admin level</td>
157                                           <!-- <td>Search rank</td> -->
158                                           <td>Distance</td>
159                                           <td></td>
160                                         </tr>
161                                 </thead>
162                                 <tbody>
163
164                                 <?php
165
166                                         foreach($aAddressLines as $aAddressLine)
167                                         {       
168                                                 _one_row($aAddressLine);
169                                         }
170                                 ?>
171         
172                                 </tbody>
173                         </table>
174
175
176 <?php
177
178         if ($aLinkedLines)
179         {
180                 headline('Linked Places');
181                 echo '<table id="linked" class="table table-striped table-responsive">';
182                 foreach($aLinkedLines as $aAddressLine)
183                 {       
184                         _one_row($aAddressLine);
185                 }
186                 echo '</table>';
187         }
188
189
190
191         if ($aPlaceSearchNameKeywords)
192         {
193                 headline('Name Keywords');
194                 foreach($aPlaceSearchNameKeywords as $aRow)
195                 {
196                         echo '<div>'.$aRow['word_token']."</div>\n";
197                 }
198         }
199
200         if ($aPlaceSearchAddressKeywords)
201         {
202                 headline('Address Keywords');
203                 foreach($aPlaceSearchAddressKeywords as $aRow)
204                 {
205                         echo '<div>'.($aRow['word_token'][0]==' '?'*':'').$aRow['word_token'].'('.$aRow['word_id'].')'."</div>\n";
206                 }
207         }
208
209         if (sizeof($aParentOfLines))
210         {
211                 headline('Parent Of');
212
213                 $aGroupedAddressLines = array();
214                 foreach($aParentOfLines as $aAddressLine)
215                 {
216                         if ($aAddressLine['type'] == 'yes') $sType = $aAddressLine['class'];
217                         else $sType = $aAddressLine['type'];
218
219                         if (!isset($aGroupedAddressLines[$sType]))
220                                 $aGroupedAddressLines[$sType] = array();
221                         $aGroupedAddressLines[$sType][] = $aAddressLine;
222                 }
223                 foreach($aGroupedAddressLines as $sGroupHeading => $aParentOfLines)
224                 {
225                         $sGroupHeading = ucwords($sGroupHeading);
226                         echo "<h3>$sGroupHeading</h3>\n";
227
228                         echo '<table id="linked" class="table table-striped table-responsive">';
229                         foreach($aParentOfLines as $aAddressLine)
230                         {
231                                 _one_row($aAddressLine);
232                         }
233                         echo '</table>';
234                 }
235                 if (sizeof($aParentOfLines) >= 500) {
236                         echo '<p>There are more child objects which are not shown.</p>';
237                 }
238         }
239
240         // headline('Other Parts');
241         // headline('Linked To');
242 ?>
243
244                         </div>
245                 </div>
246         </div>
247
248         <footer>
249                 <p class="copyright">
250                         &copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors
251                 </p>
252         </footer>
253
254
255         <script type="text/javascript">
256
257                 var nominatim_result = {
258                         outlinestring: '<?php echo $aPointDetails['outlinestring'];?>',
259                         lon: <?php echo $aPointDetails['lon'];?>,
260                         lat: <?php echo $aPointDetails['lat'];?>,
261                 };
262
263         </script>
264
265
266
267         <?php include(CONST_BasePath.'/lib/template/includes/html-footer.php'); ?>
268   </body>
269 </html>