Backend\Modules\Location\Engine\Model::getMapSettings PHP Method

getMapSettings() public static method

Fetch all the settings for a specific map
public static getMapSettings ( integer $mapId ) : array
$mapId integer
return array
    public static function getMapSettings($mapId)
    {
        $mapSettings = (array) BackendModel::getContainer()->get('database')->getPairs('SELECT s.name, s.value
             FROM location_settings AS s
             WHERE s.map_id = ?', array((int) $mapId));
        foreach ($mapSettings as $key => $value) {
            $mapSettings[$key] = unserialize($value);
        }
        return $mapSettings;
    }

Usage Example

Example #1
0
 /**
  * Get the data
  */
 private function loadData()
 {
     $this->record = (array) BackendLocationModel::get($this->id);
     // no item found, throw an exceptions, because somebody is f*****g with our URL
     if (empty($this->record)) {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
     $this->settings = BackendLocationModel::getMapSettings($this->id);
     // load the settings from the general settings
     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['map_style'] = isset($settings['map_style_widget']) ? $settings['map_style_widget'] : 'standard';
         $this->settings['zoom_level'] = $settings['zoom_level_widget'];
         $this->settings['center']['lat'] = $this->record['lat'];
         $this->settings['center']['lng'] = $this->record['lng'];
     }
     // no center point given yet, use the first occurrence
     if (!isset($this->settings['center'])) {
         $this->settings['center']['lat'] = $this->record['lat'];
         $this->settings['center']['lng'] = $this->record['lng'];
     }
     $this->settings['full_url'] = isset($this->settings['full_url']) ? $this->settings['full_url'] : false;
     $this->settings['directions'] = isset($this->settings['directions']) ? $this->settings['directions'] : false;
 }
All Usage Examples Of Backend\Modules\Location\Engine\Model::getMapSettings