Ejemplo n.º 1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exists
     if ($this->id !== null && BackendLocationModel::exists($this->id)) {
         $this->header->addJS(FrontendLocationModel::getPathToMapStyles());
         parent::execute();
         // define Google Maps API key
         $apikey = $this->get('fork.settings')->get('Core', 'google_maps_key');
         // check Google Maps API key, otherwise redirect to settings
         if ($apikey === null) {
             $this->redirect(BackendModel::createURLForAction('Index', 'Settings'));
         }
         // add js
         $this->header->addJS('https://maps.googleapis.com/maps/api/js?key=' . $apikey, null, false, true, false);
         $this->loadData();
         $this->loadForm();
         $this->validateForm();
         $this->loadSettingsForm();
         $this->parse();
         $this->display();
     } else {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
 }
Ejemplo n.º 2
0
 /**
  * Load the data
  */
 protected function loadData()
 {
     $this->items = FrontendLocationModel::getAll();
     $this->settings = FrontendLocationModel::getMapSettings(0);
     $firstMarker = current($this->items);
     if (empty($this->settings)) {
         $this->settings = $this->get('fork.settings')->getForModule('Location');
         $this->settings['center']['lat'] = $firstMarker['lat'];
         $this->settings['center']['lng'] = $firstMarker['lng'];
     }
     // no center point given yet, use the first occurrence
     if (!isset($this->settings['center'])) {
         $this->settings['center']['lat'] = $firstMarker['lat'];
         $this->settings['center']['lng'] = $firstMarker['lng'];
     }
 }
Ejemplo n.º 3
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->header->addJS(FrontendLocationModel::getPathToMapStyles());
     parent::execute();
     // define Google Maps API key
     $apikey = $this->get('fork.settings')->get('Core', 'google_maps_key');
     // check Google Maps API key, otherwise redirect to settings
     if ($apikey === null) {
         $this->redirect(BackendModel::createURLForAction('Index', 'Settings'));
     }
     // add js
     $this->header->addJS('https://maps.googleapis.com/maps/api/js?key=' . $apikey, null, false, true, false);
     $this->loadData();
     $this->loadDataGrid();
     $this->loadSettingsForm();
     $this->parse();
     $this->display();
 }
Ejemplo n.º 4
0
 /**
  * Load the data
  */
 protected function loadData()
 {
     $this->item = FrontendLocationModel::get($this->data['id']);
     $this->settings = FrontendLocationModel::getMapSettings($this->data['id']);
     if (empty($this->settings)) {
         $settings = $this->get('fork.settings')->getForModule('Location');
         $this->settings['width'] = $settings['width_widget'];
         $this->settings['height'] = $settings['height_widget'];
         $this->settings['map_type'] = $settings['map_type_widget'];
         $this->settings['zoom_level'] = $settings['zoom_level_widget'];
         $this->settings['center']['lat'] = $this->item['lat'];
         $this->settings['center']['lng'] = $this->item['lng'];
     }
     // no center point given yet, use the first occurrence
     if (!isset($this->settings['center'])) {
         $this->settings['center']['lat'] = $this->item['lat'];
         $this->settings['center']['lng'] = $this->item['lng'];
     }
     $this->settings['maps_url'] = FrontendLocationModel::buildUrl($this->settings, array($this->item));
 }