Example #1
0
 public static function getInfosVideo($videoId, $returnObject = true)
 {
     $xml = dwn(repl('##videoId##', $videoId, static::VIDEO_INFOS_URI));
     $xml = simplexml_load_string($xml);
     $json = json_encode($xml);
     $array = json_decode($json, true);
     if (true === $returnObject) {
         $obj = new Container($array);
         return $obj;
     }
     return $array;
 }
Example #2
0
 public function getAd($id = null)
 {
     $id = empty($id) ? $this->id : $id;
     $this->property = array();
     $this->seg = dwn('http://m.duproprio.com/habitation/' . $id);
     $methods = array('getDescription', 'getLongitude', 'getLatitude', 'getAddress', 'getCity', 'getProvince', 'getNumBedroom', 'getType', 'getPriceCategory', 'getPrice', 'getPics', 'getCaracteristics', 'getHomePhone', 'getWorkPhone', 'getFax', 'getCellPhone', 'getTaxes', 'getPics');
     $this->property['partner_id'] = $id;
     $this->property['partner'] = 'duproprio';
     foreach ($methods as $method) {
         $this->{$method}();
     }
     return $this;
 }
Example #3
0
 public function getSource($first = true, $page = 1)
 {
     $string = urlencode($this->q);
     $link = 'http://www.google.fr/search?q=';
     if ($first) {
         $link .= $string . '&hl=fr-FR&newwindow=1&prmd=imvns&filter=0&biw=1366&bih=667';
     } else {
         $link .= $string;
         $link .= '&hl=fr-FR&newwindow=1&prmd=imvns&ei=9NtQULzRD-r00gGpnYD4CQ&start=';
         $link .= ($page - 1) * 10;
         $link .= '&sa=N&filter=0&biw=1366&bih=667';
     }
     $this->source = dwn($link);
 }
Example #4
0
 public static function getInfosMovie($id)
 {
     $html = dwn('http://vod.canalplay.com/films/cinema/holiday,297,308,' . $id . '.aspx');
     if (strstr($html, 'Object moved to')) {
         $url = 'http://vod.canalplay.com' . urldecode(Utils::cut('<h2>Object moved to <a href="', '"', $html));
         $html = dwn($url);
     }
     $story = Utils::cut('alt="L\'histoire" title="L\'histoire" /></h2><p>', '</p>', $html);
     $title = Utils::cut('var title="', '"', $html);
     $image = 'http://canalplay-publishing.canal-plus.com/movies/' . $id . '/pictures/' . $id . '_pivot.jpg';
     $purpose = Utils::cut('title="A propos du film" /></h2><p>', '</p></div></div>', $html);
     $distribution = array();
     $tab = explode("title=\"Voir tous les films de/avec '", $html);
     if (count($tab)) {
         for ($i = 1; $i < count($tab) - 1; $i++) {
             $seg = trim($tab[$i]);
             if (strstr($seg, "</a>") && strstr($seg, "underline")) {
                 $person = Utils::cut('\'">', '</a>', $seg);
                 if (!Arrays::inArray($person, $distribution)) {
                     $distribution[] = $person;
                 }
             }
         }
     }
     $director = null;
     $actors = array();
     if (count($distribution)) {
         $director = current($distribution);
         $actors = array();
         if (1 < count($distribution)) {
             for ($j = 1; $j < count($distribution); $j++) {
                 $actors[] = $distribution[$j];
             }
         }
     }
     $other = Utils::cut('<li style="clear:left;"><strong><br />', '</li>', $html);
     list($first, $second) = explode('</strong>- ', $other, 2);
     list($country, $year) = explode("-", $first, 2);
     $country = substr($country, 0, -1);
     $year = repl("\n", '', $year);
     $year = repl("\r", '', $year);
     $year = repl("\n", '', $year);
     list($duration, $dummy) = @explode("\n", $second, 2);
     $infos = array('title' => $title, 'story' => $story, 'image' => $image, 'purpose' => $purpose, 'director' => $director, 'actors' => $actors, 'country' => $country, 'year' => $year, 'duration' => $duration);
     return $infos;
 }
Example #5
0
 public static function auto($sentence, $source = 'fr', $target = 'en')
 {
     $key = sha1(serialize(func_get_args()));
     $res = Data::query('translation', 'key = ' . $key);
     if (count($res)) {
         $obj = current($res);
         return $obj->getSentence();
     }
     $source = Inflector::lower($source);
     $target = Inflector::lower($target);
     $url = "http://api.mymemory.translated.net/get?q=" . urlencode($sentence) . "&langpair=" . urlencode($source) . "|" . urlencode($target);
     $res = dwn($url);
     $tab = json_decode($res, true);
     if (Arrays::exists('responseData', $tab)) {
         if (Arrays::exists('translatedText', $tab['responseData'])) {
             $translation = $tab['responseData']['translatedText'];
             $data = array('source' => $source, 'target' => $target, 'key' => $key, 'sentence' => $translation);
             Data::add('translation', $data);
             return $translation;
         }
     }
     return $sentence;
 }
Example #6
0
 function infosIP($array = false, $localhost = false)
 {
     $session = session('web');
     $infosIP = $session->getInfosIp();
     if (empty($infosIP)) {
         $ip = $_SERVER["REMOTE_ADDR"];
         if (true === $localhost) {
             $url = "http://ip-api.com/json";
         } else {
             $url = "http://ip-api.com/json/{$ip}";
         }
         $json = dwn($url);
         $json = str_replace(array('query', 'countryCode', 'regionName'), array('ip', 'country_code', 'region_name'), $json);
         $infos = json_decode($json, true);
         if (Arrays::is($infos)) {
             if (Arrays::exists('status', $infos)) {
                 if ($infos['status'] == 'fail') {
                     return infosIP($array, true);
                 }
             }
             $InfosIp = o("IP");
             $InfosIp->populate($infos);
             $session->setInfosIp($InfosIp);
         }
     }
     return false === $array ? $infosIP : $infos;
 }
Example #7
0
 public function contrat(array $data, $disposition = null, $test = false)
 {
     $disposition = is_null($disposition) ? 'attachment' : $disposition;
     $tpl = File::read(APPLICATION_PATH . DS . 'templates/contrat_zechallenge.html');
     $bucket = new Bucket(SITE_NAME, 'http://zelift.com/bucket');
     $affiliation = isAke($data, 'affiliation', 'resto');
     $univers = isAke($data, 'univers', 'resto');
     $zechallenge_id = isAke($data, 'compte_zechallenge', 1);
     $contrat = Model::FacturationContrat()->reset()->where(['platform', '=', 'ZeChallenge'])->where(['affiliation', '=', $affiliation])->where(['univers', '=', $univers])->where(['zechallenge_id', '=', (int) $zechallenge_id])->first(true);
     if ($contrat && !$test) {
         $return = true;
         if ($disposition == 'attachment') {
             if (!fnmatch('http://*', $contrat->url)) {
                 $contrat->delete();
                 $return = false;
             }
             if ($return) {
                 return ['url' => $contrat->url, 'error' => false];
             }
         }
         if ($return) {
             $pdf = dwn($contrat->url);
             header('Content-Type: application/pdf');
             header('Content-Length: ' . strlen($pdf));
             header('Content-Disposition: ' . $disposition . '; filename="Contrat-ZeChallenge.pdf"');
             header('Cache-Control: private, max-age=0, must-revalidate');
             header('Pragma: public');
             ini_set('zlib.output_compression', '0');
             die($pdf);
         }
     }
     $contract = lib('contrat')->store($univers, 'ZeChallenge', $affiliation, $zechallenge_id);
     if ($univers == 'resto') {
         $code_contrat = 'RES';
     } elseif ($univers == 'services') {
         $code_contrat = 'SER';
     }
     $code_contrat .= '-C-' . $contract->id;
     $data['code_contrat'] = $code_contrat;
     foreach ($data as $k => $v) {
         if ($k == 'univers') {
             $tpl = str_replace("##Univers##", ucfirst($v), $tpl);
             $tpl = str_replace("##univers##", $v, $tpl);
         } else {
             $tpl = str_replace("##{$k}##", $v, $tpl);
         }
     }
     $disposition = is_null($disposition) ? 'attachment' : $disposition;
     // $keep = lib('keep')->instance();
     // $keep['url'] = 'http://zelift.com/';
     $pdf = pdfFile($tpl, 'Contrat-ZeChallenge', 'portrait');
     $url = $bucket->data($pdf, 'pdf');
     $contract->url = $url;
     if (!fnmatch('http://*', $url)) {
         return ['url' => false, 'error' => $contract->url];
     }
     if (!$test) {
         $contract->save();
     }
     if ($disposition == 'attachment') {
         return ['url' => $url, 'error' => false];
     }
     header('Content-Type: application/pdf');
     header('Content-Length: ' . strlen($pdf));
     header('Content-Disposition: ' . $disposition . '; filename="Contrat-ZeChallenge.pdf"');
     header('Cache-Control: private, max-age=0, must-revalidate');
     header('Pragma: public');
     ini_set('zlib.output_compression', '0');
     die($pdf);
 }
Example #8
0
 public function searchNearByAddress($address, $query)
 {
     $collection = lib('collection');
     $coords = lib('geo')->getCoords($address);
     $url = 'http://search.mappy.net/search/1.0/find?extend_bbox=1&bbox=' . $coords['lat1'] . ',' . $coords['lng1'] . ',' . $coords['lat2'] . ',' . $coords['lng2'] . '&q=' . urlencode($query) . '&favorite_country=' . $coords['country_id'] . '&language=FRE&&max_results=199';
     dd($url);
     $key = 'serach.near.' . sha1($url);
     $json = redis()->get($key);
     if (!$json) {
         $json = dwn($url);
         redis()->set($key, $json);
     }
     $data = json_decode($json, true);
     $pois = isAke($data, 'pois', []);
     foreach ($pois as $service) {
         $dbService = rdb('geo', 'service')->where(['code', '=', $service['rubricId']])->first(true);
         if ($dbService) {
             $id = $dbService->id;
         } else {
             if (isset($service['allRubrics'])) {
                 if (count($service['allRubrics'])) {
                     foreach ($service['allRubrics'] as $rubrikA) {
                         $idr = isAke($rubrikA, 'id');
                         $lr = isAke($rubrikA, 'label');
                         $pr = isAke($rubrikA, 'rubricParentId');
                         if ($idr == $service['rubricId']) {
                             $spi = rdb('geo', 'service')->firstOrCreate(['code' => $idr])->setLabel($lr)->setFamily($pr)->save();
                             $id = $spi->id;
                         }
                     }
                 }
             }
         }
         $serviceproxIds = $supplements = [];
         $serviceproxIds[] = $id;
         $poi = $service['id'];
         $checkEtab = rdb('geo', 'etablissement')->where(['poi', '=', (string) $poi])->first(true);
         $add = $checkEtab ? false : true;
         unset($service['id']);
         if (false === $add) {
             $service['id'] = $checkEtab->id;
         }
         unset($service['offer']);
         unset($service['prov']);
         unset($service['pjBlocId']);
         unset($service['thematicId']);
         if (isset($service['tabs'])) {
             if (count($service['tabs'])) {
                 foreach ($service['tabs'] as $tmp) {
                     $tmpUrl = isAke($tmp, 'url', false);
                     $tmpId = isAke($tmp, 'appId', false);
                     if (false !== $tmpUrl && false !== $tmpId) {
                         $key = 'inf.' . $poi . '.' . $tmpId;
                         if ($tmpId == 'pj') {
                             $inf = redis()->get($key);
                             if (empty($inf)) {
                                 $infHtml = dwn($tmpUrl);
                                 $inf = substr($infHtml, strlen('callback('), -1);
                                 redis()->set($key, $inf);
                             }
                             $inf = json_decode($inf, true);
                             $t = isAke($inf, 'tabs', []);
                             if (!empty($t)) {
                                 foreach ($t as $tmpT) {
                                     $b = isAke($tmpT, 'blocks', []);
                                     $t = isAke($tmpT, 'tags', []);
                                     if (!empty($b)) {
                                         for ($ti = 0; $ti < count($b); $ti += 2) {
                                             $seg = $b[$ti];
                                             $seg2 = $b[$ti + 1];
                                             if (is_array($seg) && is_array($seg2)) {
                                                 $title = isAke($seg, 'title', false);
                                                 $kv = isAke($seg2, 'keyValue', false);
                                                 if (false !== $title && false !== $kv) {
                                                     $title = Inflector::urlize($title);
                                                     foreach ($kv as $tmpRow) {
                                                         $supplements[$title][] = [$tmpRow['key'] => $tmpRow['value']];
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         } elseif ($tmpId == 'indoor') {
                         } elseif ($tmpId == 'localbusinesspremium') {
                         } elseif ($tmpId == 'total') {
                         } elseif ($tmpId == 'totalaccess') {
                         } elseif ($tmpId == 'darty') {
                         } elseif ($tmpId == 'eleclerc') {
                         } elseif ($tmpId == 'moteurproduitpromo') {
                         } elseif ($tmpId == 'mappyshopping') {
                         } elseif ($tmpId == 'booking') {
                             $inf = redis()->get($key);
                             if (empty($inf)) {
                                 $infHtml = dwn($tmpUrl);
                                 $inf = substr($infHtml, strlen('callback('), -1);
                                 redis()->set($key, $inf);
                             }
                             $inf = json_decode($inf, true);
                             /* TODO */
                         } elseif ($tmpId == 'localbusinessdiscovery') {
                             $inf = redis()->get($key);
                             if (empty($inf)) {
                                 $infHtml = dwn($tmpUrl);
                                 $inf = substr($infHtml, strlen('callback('), -1);
                                 redis()->set($key, $inf);
                             }
                             $inf = json_decode($inf, true);
                             $t = isAke($inf, 'tabs', []);
                             if (!empty($t)) {
                                 foreach ($t as $tmpT) {
                                     $b = isAke($tmpT, 'blocks', []);
                                     if (!empty($b)) {
                                         foreach ($b as $tmpB) {
                                             $kv = isAke($tmpB, 'keyValue', false);
                                             if (false !== $kv) {
                                                 foreach ($kv as $tmpRow) {
                                                     $tmpK = Inflector::urlize($tmpRow['key']);
                                                     $supplements['infos'][$tmpK] = $tmpRow['value'];
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         } else {
                             $inf = redis()->get($key);
                             if (empty($inf)) {
                                 $infHtml = dwn($tmpUrl);
                                 $inf = substr($infHtml, strlen('callback('), -1);
                                 redis()->set($key, $inf);
                             }
                             $inf = json_decode($inf, true);
                         }
                     }
                 }
             }
         }
         unset($service['tabs']);
         unset($service['contextualPoiUrl']);
         unset($service['providerIds']);
         unset($service['pjRatingId']);
         unset($service['hasUnclaimableProvider']);
         unset($service['additionalInfos']);
         unset($service['additionalInfo']);
         unset($service['coordinateProvider']);
         unset($service['coordinateProvider3D']);
         unset($service['offerType']);
         unset($service['rubricId']);
         unset($service['closestPanoramicId']);
         if (isset($service['allRubrics'])) {
             if (count($service['allRubrics'])) {
                 foreach ($service['allRubrics'] as $rubrikA) {
                     $idr = isAke($rubrikA, 'id');
                     $lr = isAke($rubrikA, 'label');
                     $pr = isAke($rubrikA, 'rubricParentId');
                     $spi = rdb('geo', 'service')->firstOrCreate(['code' => $idr])->setLabel($lr)->setFamily($pr)->save();
                 }
             }
             unset($service['allRubrics']);
         }
         if (isset($service['additionalRubricIds'])) {
             if (count($service['additionalRubricIds'])) {
                 foreach ($service['additionalRubricIds'] as $newRubrique) {
                     $spi = rdb('geo', 'service')->firstOrCreate(['code' => $newRubrique]);
                     $serviceproxIds[] = $spi->id;
                 }
             }
         }
         unset($service['additionalRubricIds']);
         unset($service['brandIconUrl']);
         unset($service['slat']);
         unset($service['slng']);
         unset($service['salt']);
         unset($service['brand']);
         unset($service['indoors']);
         unset($service['visibleIn3D']);
         unset($service['townCode']);
         if (isset($service['town'])) {
             $service['city'] = $service['town'];
             unset($service['town']);
         }
         if (isset($service['positions3D'])) {
             if (isset($service['positions3D']['origin'])) {
                 if (isset($service['positions3D']['origin']['alt'])) {
                     $service['altitude'] = $service['positions3D']['origin']['alt'];
                     unset($service['positions3D']);
                 }
             }
         }
         if (isset($service['way'])) {
             $service['address'] = $service['way'];
             unset($service['way']);
         }
         if (isset($service['pCode'])) {
             $service['zip'] = $service['pCode'];
             unset($service['pCode']);
             unset($service['positions3D']);
         }
         if (isset($service['lat']) && isset($service['lng'])) {
             $distances = distanceKmMiles($coords['lng1'], $coords['lat1'], $service['lng'], $service['lat']);
             $service['distance'] = (double) $distances['km'];
         }
         ksort($service);
         $service['poi'] = $poi;
         if (false === $add) {
             $collection[] = $service;
         }
         if (true === $add) {
             $distance = $service['distance'];
             unset($service['distance']);
             $etab = rdb('geo', 'etablissement')->firstOrCreate($service)->setPoi($poi)->save();
             setLocation($etab, $etab->lng, $etab->lat);
             if (!empty($supplements)) {
                 foreach ($supplements as $supK => $supV) {
                     $setter = setter($supK);
                     $etab->{$setter}($supV);
                 }
                 $etab->save();
             }
             $fields = $etab->_keys();
             $sFields = array_merge(array_keys($service), array_keys($supplements));
             $except = ['id', 'poi', 'created_at', 'updated_at'];
             $resave = false;
             $expurge = [];
             foreach ($fields as $field) {
                 if (!in_array($field, $except)) {
                     if (!in_array($field, $sFields)) {
                         $expurge[] = $field;
                         $etab = $etab->expurge($field);
                         $resave = true;
                     }
                 }
             }
             if (true === $resave) {
                 $etab = $etab->save();
             }
             foreach ($serviceproxIds as $serviceproxId) {
                 $spTmp = rdb('geo', 'service')->find((int) $serviceproxId);
                 $spTmp->attach($etab);
             }
             $zone = rdb('geo', 'zone')->find(1);
             $zone->attach($etab);
             $service['new'] = true;
             $service['id'] = $etab->id;
             $service['distance'] = $distance;
         }
         $collection[] = $service;
     }
     if (!empty($collection)) {
         $tuples = $new = [];
         $collection->sortBy('distance');
         foreach ($collection as $row) {
             $hasPoi = isAke($row, 'poi', false);
             if (false === $hasPoi) {
                 $new[] = $row;
             } else {
                 $poi = sha1($hasPoi);
                 if (!in_array($poi, $tuples)) {
                     $tuples[] = $poi;
                     $new[] = $row;
                 }
             }
         }
         $collection = lib('collection', [$new]);
     }
     return $collection->toArray();
 }
Example #9
0
 public function weather($lat, $lng)
 {
     $url = "http://vmrest.viamichelin.com/apir/1/weather.json2?center={$lng}:{$lat}&todayForecast=true&fullForecast=true&nbDays=1&atLeastOne=true&obfuscation=false&ie=UTF-8&charset=UTF-8&authKey=JSBS20110216111214120400892678&lg=fra";
     // $json = $this->dwn($url);
     $json = getCached('geoweather.' . sha1(serialize(func_get_args())), function () use($url) {
         return dwn($url);
     }, strtotime('+1 hour'));
     $tab = json_decode($json, true);
     if (isset($tab['weatherStationList'])) {
         if (is_array($tab['weatherStationList'])) {
             return $tab['weatherStationList'][0]['observation'];
         }
     }
 }
Example #10
0
 public function mic($zip = 21000, $city = 'dijon')
 {
     $db = rdb('michelin', 'resto');
     $page = 1;
     $url = "http://restaurant.michelin.fr/ajaxSearchRestaurant/france/{$zip}-{$city}/page-##page##";
     $urlTo = str_replace('##page##', $page, $url);
     $etabs = redis()->get("resto.mic.{$zip}.{$city}");
     if (!$etabs) {
         $restos = [];
         $json = dwn($urlTo);
         $etabs = json_decode($json, true);
         $asyncPoiList = isAke($etabs, 'asyncPoiList', []);
         $stats = isAke($asyncPoiList, 'stats', []);
         $nbresults = (int) isAke($stats, 'tag_vm_nbresults_total', 0);
         $Oj = isAke($asyncPoiList, 'Oj', []);
         $restos = array_merge($restos, $Oj);
         $nbPages = ceil($nbresults / 18);
         for ($i = 2; $i <= $nbPages; $i++) {
             $urlTo = str_replace('##page##', $i, $url);
             $json = dwn($urlTo);
             $etabs = json_decode($json, true);
             $asyncPoiList = isAke($etabs, 'asyncPoiList', []);
             $Oj = isAke($asyncPoiList, 'Oj', []);
             $restos = array_merge($restos, $Oj);
         }
         redis()->set("resto.mic.{$zip}.{$city}", serialize($restos));
     } else {
         $etabs = unserialize($etabs);
         foreach ($etabs as $etab) {
             $id = isAke($etab, 'id', false);
             if (false !== $id) {
                 $infoUrl = "http://vmrest.viamichelin.com/apir/2/FindPOIByCriteria.json/RESTAURANT/fra?&filter=poi_id%20in%20%5B{$id}%5D&obfuscation=true&ie=UTF-8&charset=UTF-8&callback=JSE.cr.pv[0].cv&authKey=JSBS20111110142911566673070414&lg=fra&nocache=1433580926785";
                 $data = redis()->get("restos.mic.{$id}");
                 if (!$data) {
                     $html = dwn($infoUrl);
                     $json = Utils::cut('cv(', '}]}]})', $html) . '}]}]}';
                     $data = json_decode($json, true);
                     $resto = isAke($data, 'Oj', []);
                     if (!empty($resto)) {
                         $resto = current($resto);
                         $datasheets = isAke($resto, 'datasheets', []);
                         if (!empty($datasheets)) {
                             $numFound = false;
                             foreach ($datasheets as $ds) {
                                 $ds['poi_id'] = $id;
                                 $dts_id = isAke($ds, 'dts_id', 'a');
                                 if (is_numeric($dts_id)) {
                                     $numFound = true;
                                 }
                                 $resto = $ds;
                             }
                             redis()->set("restos.mic.{$id}", serialize($resto));
                         }
                     }
                 } else {
                     $data = unserialize($data);
                     $data['phone'] = (string) $data['phone'];
                     $data['local_phone'] = (string) $data['local_phone'];
                     $row = $db->firstOrCreate(['poi_id' => $data['poi_id']]);
                     foreach ($data as $k => $v) {
                         if (fnmatch('*phone*', $k)) {
                             $v = str_replace('+', '', $v);
                         }
                         $row->{$k} = $v;
                     }
                     $row->save();
                 }
             }
         }
         dd($row);
     }
 }
Example #11
0
 /**
  * [cors description]
  *
  * @method cors
  *
  * @param  [type] $url [description]
  * @return [type]      [description]
  */
 public function cors($url)
 {
     return dwn('http://crossorigin.me/' . $url);
 }
Example #12
0
 function getCoords($address, $country = 250)
 {
     return lib("geo")->getCoordsMap($address);
     $components = [];
     $components['lat'] = $components['lng'] = 0;
     $keyJsonLocal = 'pois.' . sha1($address);
     $urlLocalisation = "http://search.mappy.net/search/1.0/find?q=" . urlencode($address) . "&favorite_country={$country}&language=FRE&loc_format=geojson";
     $json = redis()->get($keyJsonLocal);
     if (!$json) {
         $json = dwn($urlLocalisation);
         redis()->set($keyJsonLocal, $json);
     }
     $tab = json_decode($json, true);
     if (isset($tab['addresses'])) {
         if (isset($tab['addresses']['features'])) {
             if (!empty($tab['addresses']['features'])) {
                 $coords = current($tab['addresses']['features']);
                 $bbox = isAke($coords, 'bbox', []);
                 $components['bbox'] = $bbox;
                 if (isset($coords['geometry'])) {
                     if (isset($coords['geometry']['geometries'])) {
                         if (!empty($coords['geometry']['geometries'])) {
                             $geometries = current($coords['geometry']['geometries']);
                             if (isset($geometries['coordinates'])) {
                                 list($lng, $lat) = $geometries['coordinates'];
                                 $components['lng'] = (double) $lng;
                                 $components['lat'] = (double) $lat;
                             }
                         }
                     }
                 }
                 if (isset($coords['properties']['address_components'])) {
                     if (!empty($coords['properties']['address_components'])) {
                         foreach ($coords['properties']['address_components'] as $k => $v) {
                             $components[$k] = $v;
                         }
                     }
                 }
                 if (isset($components['way'])) {
                     $components['street'] = $components['way'];
                     unset($components['way']);
                 }
                 if (isset($components['way_number'])) {
                     $components['street_number'] = $components['way_number'];
                     unset($components['way_number']);
                 }
                 if (isset($components['town'])) {
                     $components['city'] = $components['town'];
                     unset($components['town']);
                 }
                 if (isset($components['admin_1'])) {
                     $components['region'] = $components['admin_1'];
                     unset($components['admin_1']);
                 }
                 if (isset($components['bbox'])) {
                     $components['limits'] = [];
                     $components['limits']['lng1'] = $components['bbox'][0];
                     $components['limits']['lat1'] = $components['bbox'][1];
                     $components['limits']['lng2'] = $components['bbox'][2];
                     $components['limits']['lat2'] = $components['bbox'][3];
                     unset($components['bbox']);
                 }
                 if (isset($components['postcode'])) {
                     $components['zip'] = $components['postcode'];
                     unset($components['postcode']);
                 }
                 ksort($components);
             }
         }
     }
     return $components;
 }
Example #13
0
 public static function store($type, $flat, $key = null)
 {
     $object = new $type();
     $object->populate($flat);
     $serialize = serialize($object);
     if (is_null($key)) {
         $key = json_decode(dwn(static::$_urlAPI . 'makeKey/' . $type));
     }
     $store = json_decode(dwn(static::$_urlAPI . 'store/' . $type . '/' . $key . '/' . base64_encode($serialize)));
     return $object;
 }