Browse Source

Add more checks on h-geo

Now it checks that:
1. h-geo exists
2. it's a microformat
3. it's of type "h-geo"
4. that it has properties
5. that it has latitude
6. that it has longitude

If all checks are true, lat and lon get replaced with values of h-geo object.
pull/93/head
Vika 5 years ago
committed by GitHub
parent
commit
611696099f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions
  1. +8
    -3
      lib/XRay/Formats/Mf2.php

+ 8
- 3
lib/XRay/Formats/Mf2.php View File

@ -341,9 +341,14 @@ class Mf2 extends Format {
}
}
// If we have a geo property, it overrides p-latitude and p-longitude
if(array_key_exists('geo', $mf2) && in_array('h-geo', $mf2['geo']['type'])) {
$hcard['latitude'] = $mf2['geo']['latitude'][0];
$hcard['longitude'] = $mf2['geo']['longitude'][0];
if(array_key_exists('geo', $mf2) &&
self::isMicroformat($mf2['geo'][0]) &&
in_array('h-geo', $mf2['geo'][0]['type']) &&
array_key_exists($mf2['geo'][0]['properties']) &&
$lat=self::getPlaintext($mf2['geo'][0], 'latitude') &&
$lon=self::getPlaintext($mf2['geo'][0], 'longitude')) {
$hcard['latitude'] = $lat;
$hcard['longitude'] = $lon;
}
return $hcard;
}

Loading…
Cancel
Save