Esempio n. 1
0
 function afterEventCrate(OW_Event $e)
 {
     $params = $e->getParams();
     if (!empty($params['eventDto']) && $params['eventDto'] instanceof EVENT_BOL_Event) {
         /* @var $eventDto EVENT_BOL_Event */
         $eventDto = $params['eventDto'];
         $locationValue = OW::getSession()->get('googlelocation_tmp_event_data');
         OW::getSession()->delete('googlelocation_tmp_event_data');
         $locationFormElement = new GOOGLELOCATION_CLASS_Location('location');
         $locationFormElement->setValue($locationValue);
         $value = $locationFormElement->getValue();
         if (!empty($value)) {
             $json = !empty($value['json']) ? json_decode($value['json'], true) : array();
             $countryCode = "";
             if (!empty($json['address_components'])) {
                 foreach ($json['address_components'] as $component) {
                     if (!empty($component['types']) && is_array($component['types']) && in_array('country', $component['types'])) {
                         $countryCode = !empty($component['short_name']) ? $component['short_name'] : "";
                     }
                 }
             }
             $location = new GOOGLELOCATION_BOL_Location();
             $location->entityId = $eventDto->id;
             $location->countryCode = $countryCode;
             $location->address = !empty($value['address']) ? $value['address'] : "";
             $location->lat = (double) $value['latitude'];
             $location->lng = (double) $value['longitude'];
             $location->northEastLat = (double) $value['northEastLat'];
             $location->northEastLng = (double) $value['northEastLng'];
             $location->southWestLat = (double) $value['southWestLat'];
             $location->southWestLng = (double) $value['southWestLng'];
             $location->json = !empty($value['json']) ? $value['json'] : "";
             $location->entityType = GOOGLELOCATION_BOL_LocationDao::ENTITY_TYPE_EVENT;
             GOOGLELOCATION_BOL_LocationService::getInstance()->save($location);
         }
     }
     OW::getSession()->delete('googlelocation_tmp_event_data');
 }
Esempio n. 2
0
 public function __construct($name)
 {
     parent::__construct($name);
     $this->addAttribute('class', 'ow_googlelocation_search_location');
     OW::getEventManager()->trigger(new OW_Event('googlelocation.add_js_lib'));
 }