static function geocode($address = null) { $result = array('status' => 'FAIL', 'lat' => null, 'lng' => null); if (!MValidate::address($address)) { return $result; } global $geocoder; try { $geocode = $geocoder->geocode($address); $result['status'] = 'OK'; $result['lat'] = $geocode->getLatitude(); $result['lng'] = $geocode->getLongitude(); } catch (Exception $e) { return $result; } return $result; }
public function __construct() { MMessaging::init(); $SysConf = new MSettings(); if (is_array($SysConf::$coords)) { global $coords; $coords['lat'] = $SysConf::$coords['lat']; $coords['lng'] = $SysConf::$coords['lng']; } elseif (isset($SysConf::$location)) { if (MValidate::address($SysConf::$location)) { global $geocoder; global $coords; try { $geocode = $geocoder->geocode($SysConf::$location); $coords['lat'] = $geocode->getLatitude(); $coords['lng'] = $geocode->getLongitude(); } catch (Exception $e) { } } } else { if (MValidate::address(MSettings::$location)) { global $geocoder; global $coords; try { $geocode = $geocoder->geocode(MSettings::$location); $coords['lat'] = $geocode->getLatitude(); $coords['lng'] = $geocode->getLongitude(); } catch (Exception $e) { } } } $routing = new M_Route(); $module = new M_Module(); $module_instance = $module->instance($routing->get_module(), $routing->get_task(), $routing->get_object()); $template = new M_Template(); $template_instance = $template->instance($module_instance); }
private function setup_object($record, $new = false) { if (!$record || !is_object($record)) { return null; } if ($this->title && MValidate::title($this->title)) { $record->title = $this->title; } else { return mapi_report_message('Not a valid content title: ' . $this->title); } if ($this->license && MValidate::id($this->license) && in_array($this->license, mapi_available_ids('licenses'))) { $record->license = $this->license; } else { return mapi_report_message('Not a valid content license: ' . $this->license); } $record->name = $this->name; if ($new) { if (!mapi_check_double('contents', 'name', $this->name)) { return mapi_report_message('Content with that name already exists: ' . $this->name); } } if ($this->address && MValidate::address($this->address)) { $record->address = $this->address; } else { return mapi_report_message('Not a valid content address: ' . $this->address); } if (isset($this->meta_name)) { if ($this->meta_name && MValidate::meta_name($this->meta_name)) { $record->meta_name = $this->meta_name; } else { return mapi_report_message('Not a valid meta name: ' . $this->meta_name); } } if (isset($this->meta_value)) { if ($this->meta_value && MValidate::meta_value($this->meta_value)) { $record->meta_value = $this->meta_value; } else { return mapi_report_message('Not a valid meta value: ' . $this->meta_value); } } if ($this->lat && MValidate::coord($this->lat)) { $record->lat = $this->lat; } else { return mapi_report_message('Not a valid latitude.'); } if ($this->lng && MValidate::coord($this->lng)) { $record->lng = $this->lng; } else { return mapi_report_message('Not a valid longitude.'); } if ($this->hits && $this->hits > 0) { $record->hits = intval($this->hits); } if ($this->parent) { $record->parent = intval($this->parent); } if ($this->language) { $record->language = strval($this->language); } if ($this->translation && 1 == $this->translation) { $record->translation = 1; } if ($this->enabled && 1 == $this->enabled) { $record->enabled = 1; } else { $record->enabled = 0; } return true; }