phpcs fixes. Mostly spacing and single quotes

This commit is contained in:
Marc Tobias Metten
2018-02-23 01:16:01 +01:00
parent eaaa4a7b31
commit 8a615ad969
10 changed files with 143 additions and 236 deletions

View File

@@ -2,20 +2,15 @@
$aFilteredPlaces = array();
if (!sizeof($aPlace))
{
if (!sizeof($aPlace)) {
if (isset($sError))
$aFilteredPlaces['error'] = $sError;
else
$aFilteredPlaces['error'] = 'Unable to geocode';
}
else
{
else $aFilteredPlaces['error'] = 'Unable to geocode';
} else {
if (isset($aPlace['place_id'])) $aFilteredPlaces['place_id'] = $aPlace['place_id'];
$aFilteredPlaces['licence'] = "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright";
$aFilteredPlaces['licence'] = 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright';
$sOSMType = formatOSMType($aPlace['osm_type']);
if ($sOSMType)
{
if ($sOSMType) {
$aFilteredPlaces['osm_type'] = $sOSMType;
$aFilteredPlaces['osm_id'] = $aPlace['osm_id'];
}
@@ -26,31 +21,25 @@ else
if (isset($aPlace['sExtraTags'])) $aFilteredPlaces['extratags'] = $aPlace['sExtraTags'];
if (isset($aPlace['sNameDetails'])) $aFilteredPlaces['namedetails'] = $aPlace['sNameDetails'];
if (isset($aPlace['aBoundingBox']))
{
if (isset($aPlace['aBoundingBox'])) {
$aFilteredPlaces['boundingbox'] = $aPlace['aBoundingBox'];
}
if (isset($aPlace['asgeojson']))
{
if (isset($aPlace['asgeojson'])) {
$aFilteredPlaces['geojson'] = json_decode($aPlace['asgeojson']);
}
if (isset($aPlace['assvg']))
{
if (isset($aPlace['assvg'])) {
$aFilteredPlaces['svg'] = $aPlace['assvg'];
}
if (isset($aPlace['astext']))
{
if (isset($aPlace['astext'])) {
$aFilteredPlaces['geotext'] = $aPlace['astext'];
}
if (isset($aPlace['askml']))
{
if (isset($aPlace['askml'])) {
$aFilteredPlaces['geokml'] = $aPlace['askml'];
}
}
javascript_renderData($aFilteredPlaces);

View File

@@ -2,20 +2,15 @@
$aFilteredPlaces = array();
if (!sizeof($aPlace))
{
if (!sizeof($aPlace)) {
if (isset($sError))
$aFilteredPlaces['error'] = $sError;
else
$aFilteredPlaces['error'] = 'Unable to geocode';
}
else
{
else $aFilteredPlaces['error'] = 'Unable to geocode';
} else {
if ($aPlace['place_id']) $aFilteredPlaces['place_id'] = $aPlace['place_id'];
$aFilteredPlaces['licence'] = "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright";
$aFilteredPlaces['licence'] = 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright';
$sOSMType = formatOSMType($aPlace['osm_type']);
if ($sOSMType)
{
if ($sOSMType) {
$aFilteredPlaces['osm_type'] = $sOSMType;
$aFilteredPlaces['osm_id'] = $aPlace['osm_id'];
}
@@ -38,31 +33,25 @@ else
if (isset($aPlace['sExtraTags'])) $aFilteredPlaces['extratags'] = $aPlace['sExtraTags'];
if (isset($aPlace['sNameDetails'])) $aFilteredPlaces['namedetails'] = $aPlace['sNameDetails'];
if (isset($aPlace['aBoundingBox']))
{
if (isset($aPlace['aBoundingBox'])) {
$aFilteredPlaces['boundingbox'] = $aPlace['aBoundingBox'];
}
if (isset($aPlace['asgeojson']))
{
if (isset($aPlace['asgeojson'])) {
$aFilteredPlaces['geojson'] = json_decode($aPlace['asgeojson']);
}
if (isset($aPlace['assvg']))
{
if (isset($aPlace['assvg'])) {
$aFilteredPlaces['svg'] = $aPlace['assvg'];
}
if (isset($aPlace['astext']))
{
if (isset($aPlace['astext'])) {
$aFilteredPlaces['geotext'] = $aPlace['astext'];
}
if (isset($aPlace['askml']))
{
if (isset($aPlace['askml'])) {
$aFilteredPlaces['geokml'] = $aPlace['askml'];
}
}
javascript_renderData($aFilteredPlaces);

View File

@@ -1,103 +1,87 @@
<?php
header("content-type: text/xml; charset=UTF-8");
header('content-type: text/xml; charset=UTF-8');
echo "<";
echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?";
echo '<';
echo '?xml version="1.0" encoding="UTF-8" ?';
echo ">\n";
echo "<reversegeocode";
echo '<reversegeocode';
echo " timestamp='".date(DATE_RFC822)."'";
echo " attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright'";
echo " querystring='".htmlspecialchars($_SERVER['QUERY_STRING'], ENT_QUOTES)."'";
echo ">\n";
if (!sizeof($aPlace))
{
if (!sizeof($aPlace)) {
if (isset($sError))
echo "<error>$sError</error>";
else
echo "<error>Unable to geocode</error>";
}
else
{
echo "<result";
else echo '<error>Unable to geocode</error>';
} else {
echo '<result';
if ($aPlace['place_id']) echo ' place_id="'.$aPlace['place_id'].'"';
$sOSMType = formatOSMType($aPlace['osm_type']);
if ($sOSMType) echo ' osm_type="'.$sOSMType.'"'.' osm_id="'.$aPlace['osm_id'].'"';
if ($aPlace['ref']) echo ' ref="'.htmlspecialchars($aPlace['ref']).'"';
if (isset($aPlace['lat'])) echo ' lat="'.htmlspecialchars($aPlace['lat']).'"';
if (isset($aPlace['lon'])) echo ' lon="'.htmlspecialchars($aPlace['lon']).'"';
if (isset($aPlace['aBoundingBox']))
{
if (isset($aPlace['aBoundingBox'])) {
echo ' boundingbox="';
echo join(',', $aPlace['aBoundingBox']);
echo '"';
}
if (isset($aPlace['asgeojson']))
{
if (isset($aPlace['asgeojson'])) {
echo ' geojson=\'';
echo $aPlace['asgeojson'];
echo '\'';
}
if (isset($aPlace['assvg']))
{
if (isset($aPlace['assvg'])) {
echo ' geosvg=\'';
echo $aPlace['assvg'];
echo '\'';
}
if (isset($aPlace['astext']))
{
if (isset($aPlace['astext'])) {
echo ' geotext=\'';
echo $aPlace['astext'];
echo '\'';
}
echo ">".htmlspecialchars($aPlace['langaddress'])."</result>";
echo '>'.htmlspecialchars($aPlace['langaddress']).'</result>';
if (isset($aPlace['aAddress']))
{
echo "<addressparts>";
foreach($aPlace['aAddress'] as $sKey => $sValue)
{
$sKey = str_replace(' ','_',$sKey);
if (isset($aPlace['aAddress'])) {
echo '<addressparts>';
foreach ($aPlace['aAddress'] as $sKey => $sValue) {
$sKey = str_replace(' ', '_', $sKey);
echo "<$sKey>";
echo htmlspecialchars($sValue);
echo "</$sKey>";
}
echo "</addressparts>";
echo '</addressparts>';
}
if (isset($aPlace['sExtraTags']))
{
echo "<extratags>";
foreach ($aPlace['sExtraTags'] as $sKey => $sValue)
{
if (isset($aPlace['sExtraTags'])) {
echo '<extratags>';
foreach ($aPlace['sExtraTags'] as $sKey => $sValue) {
echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
}
echo "</extratags>";
echo '</extratags>';
}
if (isset($aPlace['sNameDetails']))
{
echo "<namedetails>";
foreach ($aPlace['sNameDetails'] as $sKey => $sValue)
{
if (isset($aPlace['sNameDetails'])) {
echo '<namedetails>';
foreach ($aPlace['sNameDetails'] as $sKey => $sValue) {
echo '<name desc="'.htmlspecialchars($sKey).'">';
echo htmlspecialchars($sValue);
echo "</name>";
echo '</name>';
}
echo "</namedetails>";
echo '</namedetails>';
}
if (isset($aPlace['askml']))
{
if (isset($aPlace['askml'])) {
echo "\n<geokml>";
echo $aPlace['askml'];
echo "</geokml>";
echo '</geokml>';
}
}
echo "</reversegeocode>";
echo '</reversegeocode>';

View File

@@ -1,42 +1,37 @@
<?php
$aOutput = array();
$aOutput['licence'] = "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright";
$aOutput['licence'] = 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright';
$aOutput['batch'] = array();
foreach($aBatchResults as $aSearchResults)
{
foreach ($aBatchResults as $aSearchResults) {
if (!$aSearchResults) $aSearchResults = array();
$aFilteredPlaces = array();
foreach($aSearchResults as $iResNum => $aPointDetails)
{
foreach ($aSearchResults as $iResNum => $aPointDetails) {
$aPlace = array(
'place_id'=>$aPointDetails['place_id'],
);
'place_id'=>$aPointDetails['place_id'],
);
$sOSMType = formatOSMType($aPointDetails['osm_type']);
if ($sOSMType)
{
if ($sOSMType) {
$aPlace['osm_type'] = $sOSMType;
$aPlace['osm_id'] = $aPointDetails['osm_id'];
}
if (isset($aPointDetails['aBoundingBox']))
{
if (isset($aPointDetails['aBoundingBox'])) {
$aPlace['boundingbox'] = array(
$aPointDetails['aBoundingBox'][0],
$aPointDetails['aBoundingBox'][1],
$aPointDetails['aBoundingBox'][2],
$aPointDetails['aBoundingBox'][3]);
$aPointDetails['aBoundingBox'][0],
$aPointDetails['aBoundingBox'][1],
$aPointDetails['aBoundingBox'][2],
$aPointDetails['aBoundingBox'][3]
);
if (isset($aPointDetails['aPolyPoints']) && $bShowPolygons)
{
if (isset($aPointDetails['aPolyPoints']) && $bShowPolygons) {
$aPlace['polygonpoints'] = $aPointDetails['aPolyPoints'];
}
}
if (isset($aPointDetails['zoom']))
{
if (isset($aPointDetails['zoom'])) {
$aPlace['zoom'] = $aPointDetails['zoom'];
}
@@ -50,33 +45,27 @@ foreach($aBatchResults as $aSearchResults)
$aPlace['importance'] = $aPointDetails['importance'];
if (isset($aPointDetails['icon']))
{
if (isset($aPointDetails['icon'])) {
$aPlace['icon'] = $aPointDetails['icon'];
}
if (isset($aPointDetails['address']) && sizeof($aPointDetails['address'])>0)
{
if (isset($aPointDetails['address']) && sizeof($aPointDetails['address'])>0) {
$aPlace['address'] = $aPointDetails['address'];
}
if (isset($aPointDetails['asgeojson']))
{
if (isset($aPointDetails['asgeojson'])) {
$aPlace['geojson'] = json_decode($aPointDetails['asgeojson']);
}
if (isset($aPointDetails['assvg']))
{
if (isset($aPointDetails['assvg'])) {
$aPlace['svg'] = $aPointDetails['assvg'];
}
if (isset($aPointDetails['astext']))
{
if (isset($aPointDetails['astext'])) {
$aPlace['geotext'] = $aPointDetails['astext'];
}
if (isset($aPointDetails['askml']))
{
if (isset($aPointDetails['askml'])) {
$aPlace['geokml'] = $aPointDetails['askml'];
}

View File

@@ -1,33 +1,28 @@
<?php
header("content-type: application/json; charset=UTF-8");
header('content-type: application/json; charset=UTF-8');
$aFilteredPlaces = array();
foreach($aSearchResults as $iResNum => $aPointDetails)
{
foreach ($aSearchResults as $iResNum => $aPointDetails) {
$aPlace = array(
'place_id'=>$aPointDetails['place_id'],
'licence'=>"Data © OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright",
);
'place_id'=>$aPointDetails['place_id'],
'licence'=>'Data © OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright',
);
$sOSMType = formatOSMType($aPointDetails['osm_type']);
if ($sOSMType)
{
if ($sOSMType) {
$aPlace['osm_type'] = $sOSMType;
$aPlace['osm_id'] = $aPointDetails['osm_id'];
}
if (isset($aPointDetails['aBoundingBox']))
{
if (isset($aPointDetails['aBoundingBox'])) {
$aPlace['boundingbox'] = $aPointDetails['aBoundingBox'];
if (isset($aPointDetails['aPolyPoints']))
{
if (isset($aPointDetails['aPolyPoints'])) {
$aPlace['polygonpoints'] = $aPointDetails['aPolyPoints'];
}
}
if (isset($aPointDetails['zoom']))
{
if (isset($aPointDetails['zoom'])) {
$aPlace['zoom'] = $aPointDetails['zoom'];
}
@@ -40,33 +35,27 @@ foreach($aSearchResults as $iResNum => $aPointDetails)
$aPlace['importance'] = $aPointDetails['importance'];
if (isset($aPointDetails['icon']) && $aPointDetails['icon'])
{
if (isset($aPointDetails['icon']) && $aPointDetails['icon']) {
$aPlace['icon'] = $aPointDetails['icon'];
}
if (isset($aPointDetails['address']))
{
if (isset($aPointDetails['address'])) {
$aPlace['address'] = $aPointDetails['address'];
}
if (isset($aPointDetails['asgeojson']))
{
if (isset($aPointDetails['asgeojson'])) {
$aPlace['geojson'] = json_decode($aPointDetails['asgeojson']);
}
if (isset($aPointDetails['assvg']))
{
if (isset($aPointDetails['assvg'])) {
$aPlace['svg'] = $aPointDetails['assvg'];
}
if (isset($aPointDetails['astext']))
{
if (isset($aPointDetails['astext'])) {
$aPlace['geotext'] = $aPointDetails['astext'];
}
if (isset($aPointDetails['askml']))
{
if (isset($aPointDetails['askml'])) {
$aPlace['geokml'] = $aPointDetails['askml'];
}

View File

@@ -1,32 +1,27 @@
<?php
$aFilteredPlaces = array();
foreach($aSearchResults as $iResNum => $aPointDetails)
{
foreach ($aSearchResults as $iResNum => $aPointDetails) {
$aPlace = array(
'place_id'=>$aPointDetails['place_id'],
'licence'=>"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
);
'place_id'=>$aPointDetails['place_id'],
'licence'=>'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright',
);
$sOSMType = formatOSMType($aPointDetails['osm_type']);
if ($sOSMType)
{
if ($sOSMType) {
$aPlace['osm_type'] = $sOSMType;
$aPlace['osm_id'] = $aPointDetails['osm_id'];
}
if (isset($aPointDetails['aBoundingBox']))
{
if (isset($aPointDetails['aBoundingBox'])) {
$aPlace['boundingbox'] = $aPointDetails['aBoundingBox'];
if (isset($aPointDetails['aPolyPoints']))
{
if (isset($aPointDetails['aPolyPoints'])) {
$aPlace['polygonpoints'] = $aPointDetails['aPolyPoints'];
}
}
if (isset($aPointDetails['zoom']))
{
if (isset($aPointDetails['zoom'])) {
$aPlace['zoom'] = $aPointDetails['zoom'];
}
@@ -40,33 +35,27 @@ foreach($aSearchResults as $iResNum => $aPointDetails)
$aPlace['importance'] = $aPointDetails['importance'];
if (isset($aPointDetails['icon']))
{
if (isset($aPointDetails['icon'])) {
$aPlace['icon'] = $aPointDetails['icon'];
}
if (isset($aPointDetails['address']) && sizeof($aPointDetails['address'])>0)
{
if (isset($aPointDetails['address']) && sizeof($aPointDetails['address'])>0) {
$aPlace['address'] = $aPointDetails['address'];
}
if (isset($aPointDetails['asgeojson']))
{
if (isset($aPointDetails['asgeojson'])) {
$aPlace['geojson'] = json_decode($aPointDetails['asgeojson']);
}
if (isset($aPointDetails['assvg']))
{
if (isset($aPointDetails['assvg'])) {
$aPlace['svg'] = $aPointDetails['assvg'];
}
if (isset($aPointDetails['astext']))
{
if (isset($aPointDetails['astext'])) {
$aPlace['geotext'] = $aPointDetails['astext'];
}
if (isset($aPointDetails['askml']))
{
if (isset($aPointDetails['askml'])) {
$aPlace['geokml'] = $aPointDetails['askml'];
}

View File

@@ -1,72 +1,63 @@
<?php
header("content-type: text/xml; charset=UTF-8");
header('content-type: text/xml; charset=UTF-8');
echo "<";
echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?";
echo '<';
echo '?xml version="1.0" encoding="UTF-8" ?';
echo ">\n";
echo "<";
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)."'";
if (isset($aMoreParams['viewbox'])) echo " viewbox='".htmlspecialchars($aMoreParams['viewbox'], ENT_QUOTES)."'";
echo " polygon='".(isset($aMoreParams['polygon'])?'true':'false')."'";
if (isset($aMoreParams['exclude_place_ids']))
{
if (isset($aMoreParams['exclude_place_ids'])) {
echo " exclude_place_ids='".htmlspecialchars($aMoreParams['exclude_place_ids'])."'";
}
echo " more_url='".htmlspecialchars($sMoreURL)."'";
echo ">\n";
foreach($aSearchResults as $iResNum => $aResult)
{
foreach ($aSearchResults as $iResNum => $aResult) {
echo "<place place_id='".$aResult['place_id']."'";
$sOSMType = formatOSMType($aResult['osm_type']);
if ($sOSMType)
{
if ($sOSMType) {
echo " osm_type='$sOSMType'";
echo " osm_id='".$aResult['osm_id']."'";
}
echo " place_rank='".$aResult['rank_search']."'";
if (isset($aResult['aBoundingBox']))
{
if (isset($aResult['aBoundingBox'])) {
echo ' boundingbox="';
echo join(',',$aResult['aBoundingBox']);
echo join(',', $aResult['aBoundingBox']);
echo '"';
if (isset($aResult['aPolyPoints']))
{
if (isset($aResult['aPolyPoints'])) {
echo ' polygonpoints=\'';
echo json_encode($aResult['aPolyPoints']);
echo '\'';
}
}
if (isset($aResult['asgeojson']))
{
if (isset($aResult['asgeojson'])) {
echo ' geojson=\'';
echo $aResult['asgeojson'];
echo '\'';
}
if (isset($aResult['assvg']))
{
if (isset($aResult['assvg'])) {
echo ' geosvg=\'';
echo $aResult['assvg'];
echo '\'';
}
if (isset($aResult['astext']))
{
if (isset($aResult['astext'])) {
echo ' geotext=\'';
echo $aResult['astext'];
echo '\'';
}
if (isset($aResult['zoom']))
{
if (isset($aResult['zoom'])) {
echo " zoom='".$aResult['zoom']."'";
}
@@ -77,82 +68,67 @@ foreach($aSearchResults as $iResNum => $aResult)
echo " class='".htmlspecialchars($aResult['class'])."'";
echo " type='".htmlspecialchars($aResult['type'], ENT_QUOTES)."'";
echo " importance='".htmlspecialchars($aResult['importance'])."'";
if (isset($aResult['icon']) && $aResult['icon'])
{
if (isset($aResult['icon']) && $aResult['icon']) {
echo " icon='".htmlspecialchars($aResult['icon'], ENT_QUOTES)."'";
}
$bHasDelim = false;
if (isset($aResult['askml']))
{
if (!$bHasDelim)
{
if (isset($aResult['askml'])) {
if (!$bHasDelim) {
$bHasDelim = true;
echo ">";
echo '>';
}
echo "\n<geokml>";
echo $aResult['askml'];
echo "</geokml>";
echo '</geokml>';
}
if (isset($aResult['sExtraTags']))
{
if (!$bHasDelim)
{
if (isset($aResult['sExtraTags'])) {
if (!$bHasDelim) {
$bHasDelim = true;
echo ">";
echo '>';
}
echo "\n<extratags>";
foreach ($aResult['sExtraTags'] as $sKey => $sValue)
{
foreach ($aResult['sExtraTags'] as $sKey => $sValue) {
echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
}
echo "</extratags>";
echo '</extratags>';
}
if (isset($aResult['sNameDetails']))
{
if (!$bHasDelim)
{
if (isset($aResult['sNameDetails'])) {
if (!$bHasDelim) {
$bHasDelim = true;
echo ">";
echo '>';
}
echo "\n<namedetails>";
foreach ($aResult['sNameDetails'] as $sKey => $sValue)
{
foreach ($aResult['sNameDetails'] as $sKey => $sValue) {
echo '<name desc="'.htmlspecialchars($sKey).'">';
echo htmlspecialchars($sValue);
echo "</name>";
echo '</name>';
}
echo "</namedetails>";
echo '</namedetails>';
}
if (isset($aResult['address']))
{
if (!$bHasDelim)
{
if (isset($aResult['address'])) {
if (!$bHasDelim) {
$bHasDelim = true;
echo ">";
echo '>';
}
echo "\n";
foreach($aResult['address'] as $sKey => $sValue)
{
$sKey = str_replace(' ','_',$sKey);
foreach ($aResult['address'] as $sKey => $sValue) {
$sKey = str_replace(' ', '_', $sKey);
echo "<$sKey>";
echo htmlspecialchars($sValue);
echo "</$sKey>";
}
}
if ($bHasDelim)
{
echo "</place>";
}
else
{
echo "/>";
if ($bHasDelim) {
echo '</place>';
} else {
echo '/>';
}
}
echo "</" . (isset($sXmlRootTag)?$sXmlRootTag:'searchresults') . ">";
echo '</' . (isset($sXmlRootTag)?$sXmlRootTag:'searchresults') . '>';