コード例 #1
0
ファイル: options.php プロジェクト: Roman921/Step-21
 /**
  * Load all options data into protected array
  */
 protected function _loadOptions()
 {
     if (empty($this->_allOptions)) {
         $options = frameGmp::_()->getTable('options');
         $htmltype = frameGmp::_()->getTable('htmltype');
         $optionsCategories = frameGmp::_()->getTable('options_categories');
         $this->_allOptions = $options->innerJoin($htmltype, 'htmltype_id')->leftJoin($optionsCategories, 'cat_id')->orderBy(array('cat_id', 'sort_order'))->getAll($options->alias() . '.*, ' . $htmltype->alias() . '.label AS htmltype, ' . $optionsCategories->alias() . '.label AS cat_label');
         foreach ($this->_allOptions as $i => $opt) {
             if (!empty($this->_allOptions[$i]['params'])) {
                 $this->_allOptions[$i]['params'] = utilsGmp::unserialize($this->_allOptions[$i]['params']);
             }
             if ($this->_allOptions[$i]['value_type'] == 'array') {
                 $this->_allOptions[$i]['value'] = utilsGmp::unserialize($this->_allOptions[$i]['value']);
                 if (!is_array($this->_allOptions[$i]['value'])) {
                     $this->_allOptions[$i]['value'] = array();
                 }
             }
             if (empty($this->_allOptions[$i]['cat_id'])) {
                 // Move all options that have no category - to Other
                 $this->_allOptions[$i]['cat_id'] = 6;
                 $this->_allOptions[$i]['cat_label'] = 'Other';
             }
         }
     }
 }
コード例 #2
0
ファイル: marker.php プロジェクト: spokencode/bophillips
 public function _afterGet($marker, $widthMapData = false, $withoutIcons = false)
 {
     if (!empty($marker)) {
         if (!$withoutIcons) {
             $marker['icon_data'] = frameGmp::_()->getModule('icons')->getModel()->getIconFromId($marker['icon']);
         }
         $marker['params'] = utilsGmp::unserialize($marker['params']);
         /*$marker['position'] = array(
         			'coord_x' => $marker['coord_x'],
         			'coord_y' => $marker['coord_y'],
         		);*/
         if (isset($marker['params']['marker_title_link']) && !empty($marker['params']['marker_title_link']) && strpos($marker['params']['marker_title_link'], 'http') !== 0) {
             $marker['params']['marker_title_link'] = 'http://' . $marker['params']['marker_title_link'];
         }
         if (!isset($marker['params']['title_is_link'])) {
             $marker['params']['title_is_link'] = false;
         }
         // Go to absolute path as "../wp-content/" will not work on frontend
         $marker['description'] = str_replace('../wp-content/', GMP_SITE_URL . 'wp-content/', $marker['description']);
         if (uriGmp::isHttps()) {
             $marker['description'] = uriGmp::makeHttps($marker['description']);
         }
         if ($widthMapData && !empty($marker['map_id'])) {
             $marker['map'] = frameGmp::_()->getModule('gmap')->getModel()->getMapById($marker['map_id'], false);
         }
     }
     return $marker;
 }
コード例 #3
0
ファイル: options.php プロジェクト: Roman921/Step-21
 public function getPluginSettingsTab()
 {
     $saveStatistic = $this->getModel('options')->getStatisticStatus();
     $indoWindowSize = utilsGmp::unserialize($this->getModel('options')->get('infowindow_size'));
     $this->assign('saveStatistic', $saveStatistic);
     $this->assign('indoWindowSize', $indoWindowSize);
     $this->assign('additionalGlobalSettings', dispatcherGmp::applyFilters('additionalGlobalSettings', array()));
     return parent::getContent('settingsTab');
 }
コード例 #4
0
ファイル: controller.php プロジェクト: Roman921/Step-21
 public function importData()
 {
     $res = new responseGmp();
     if (!isset($_FILES['BackupFileCsv'])) {
         $res->addError(langGmp::_("Cannot Upload File"));
         return $res->ajaxExec();
     }
     $fileData = $_FILES['BackupFileCsv'];
     $uplDir = wp_upload_dir();
     $filePath = $uplDir['path'];
     $source = $fileData['tmp_name'];
     $dest = $filePath . DS . $fileData['name'];
     if (!copy($source, $dest)) {
         $res->addError(langRpw::_("Cannot Copy File"));
         return $res->ajaxExec();
     }
     $backupInfoCsv = file_get_contents($dest);
     $backupInfo = utilsGmp::unserialize($backupInfoCsv);
     if (empty($backupInfo)) {
         $res->addError(langRpw::_("Wrong Format"));
         return $res->ajaxExec();
     }
     $mapsKeys = array();
     $mapModel = frameGmp::_()->getModule("gmap")->getModel();
     $groupModule = frameGmp::_()->getModule("marker_groups");
     $markerModule = FrameGmp::_()->getModule("marker");
     $group_params = array();
     $groupKeys = array();
     $markersArr = array();
     foreach ($backupInfo as $map) {
         $map_params = array("title" => $map["title"], "description" => $map["description"], "params" => utilsGmp::serialize($map["params"]), "html_options" => utilsGmp::serialize($map["html_options"]), "create_date" => $map["create_date"]);
         //outeGmp($map_params);
         $map_new_id = frameGmp::_()->getTable("maps")->store($map_params);
         $mapsKeys[$map['id']] = $map_new_id;
         foreach ($map['markers'] as $marker) {
             if (isset($marker['groupObj']) && !empty($marker['groupObj'])) {
                 $group_params[$marker['groupObj']['id']] = $marker['groupObj'];
             }
             $markersArr[] = $marker;
         }
     }
     foreach ($group_params as $oldId => $groupInfo) {
         $gParams = array("title" => $groupInfo['title'], "description" => $groupInfo['description'], "mode" => "insert");
         $groupKeys[$oldId] = $groupModule->getModel()->saveGroup($gParams);
     }
     foreach ($markersArr as $marker) {
         $mParams = array("title" => $marker['title'], "description" => $marker['description'], "coord_x" => $marker['coord_x'], "coord_y" => $marker['coord_y'], "map_id" => $mapsKeys[$marker['map_id']], "marker_group_id" => $groupKeys[$marker['marker_group_id']], "address" => $marker['address'], "animation" => (int) $marker['animation'], "create_date" => $marker['create_date'], "params" => $marker['params'], "titleLink" => utilsGmp::serialize($marker['titleLink']));
         if (is_array($marker['icon'])) {
             $mParams['icon'] = $marker['icon']['id'];
         } elseif (is_string($marker['icon'])) {
             $mParams['icon'] = $marker['icon'];
         }
         $markerModule->getModel()->saveMarker($mParams);
     }
     outGmp($mapsKeys);
     outeGmp($groupKeys);
 }
コード例 #5
0
ファイル: gmap.php プロジェクト: Roman921/Step-21
 public function getMapById($id = false, $withMarkers = true, $withGroups = false)
 {
     if (!$id) {
         return false;
     }
     $map = frameGmp::_()->getTable('maps')->get('*', array('id' => (int) $id));
     if (!empty($map)) {
         $markerModule = frameGmp::_()->getModule('marker');
         if ($withMarkers) {
             $map[0]['markers'] = $markerModule->getModel()->getMapMarkers($map[0]['id'], $withGroups);
         }
         $map[0]['html_options'] = utilsGmp::unserialize($map[0]['html_options']);
         $map[0]['params'] = utilsGmp::unserialize($map[0]['params']);
         return $map[0];
     }
     return false;
 }
コード例 #6
0
ファイル: gmap.php プロジェクト: Roman921/Step-21
 public function drawMap($params)
 {
     $ajaxurl = admin_url('admin-ajax.php');
     if (frameGmp::_()->getModule('options')->get('ssl_on_ajax')) {
         $ajaxurl = uriGmp::makeHttps($ajaxurl);
     }
     $jsData = array('siteUrl' => GMP_SITE_URL, 'imgPath' => GMP_IMG_PATH, 'loader' => GMP_LOADER_IMG, 'close' => GMP_IMG_PATH . 'cross.gif', 'ajaxurl' => $ajaxurl, 'animationSpeed' => frameGmp::_()->getModule('options')->get('js_animation_speed'), 'siteLang' => langGmp::getData(), 'options' => frameGmp::_()->getModule('options')->getAllowedPublicOptions(), 'GMP_CODE' => GMP_CODE, 'ball_loader' => GMP_IMG_PATH . 'ajax-loader-ball.gif', 'ok_icon' => GMP_IMG_PATH . 'ok-icon.png', 'isHttps' => uriGmp::isHttps());
     frameGmp::_()->addScript('coreGmp', GMP_JS_PATH . 'core.js');
     $jsData = dispatcherGmp::applyFilters('jsInitVariables', $jsData);
     frameGmp::_()->addJSVar('coreGmp', 'GMP_DATA', $jsData);
     frameGmp::_()->addScript('jquery', '', array('jquery'));
     $mapObj = frameGmp::_()->getModule('gmap')->getModel()->getMapById($params['id']);
     if (isset($params['map_center']) && is_string($params['map_center'])) {
         if (strpos($params['map_center'], ';')) {
             $centerXY = array_map('trim', explode(';', $params['map_center']));
             $params['map_center'] = array('coord_x' => $centerXY[0], 'coord_y' => $centerXY[1]);
         } elseif (is_numeric($params['map_center'])) {
             // Map center - is coords of one of it's marker
             $params['map_center'] = (int) trim($params['map_center']);
             $found = false;
             if (!empty($mapObj['markers'])) {
                 foreach ($mapObj['markers'] as $marker) {
                     if ($marker['id'] == $params['map_center']) {
                         $params['map_center'] = array('coord_x' => $marker['coord_x'], 'coord_y' => $marker['coord_y']);
                         $found = true;
                         break;
                     }
                 }
             }
             // If no marker with such ID were found - just unset it to prevent map broke
             if (!$found) {
                 unset($params['map_center']);
             }
         } else {
             // If it is set, but not valid - just unset it to not break user map
             unset($params['map_center']);
         }
     }
     $shortCodeHtmlParams = array('width', 'height', 'align');
     $paramsCanNotBeEmpty = array('width', 'height');
     foreach ($shortCodeHtmlParams as $code) {
         if (isset($params[$code])) {
             if (in_array($code, $paramsCanNotBeEmpty) && empty($params[$code])) {
                 continue;
             }
             $mapObj['html_options'][$code] = $params[$code];
         }
     }
     $shortCodeMapParams = $this->getModel()->getParamsList();
     //array('map_display_mode', 'language', 'type', 'zoom', 'enable_zoom', 'enable_mouse_zoom');
     foreach ($shortCodeMapParams as $code) {
         if (isset($params[$code])) {
             if (in_array($code, $paramsCanNotBeEmpty) && empty($params[$code])) {
                 continue;
             }
             $mapObj['params'][$code] = $params[$code];
         }
     }
     if (isset($params['display_as_img']) && $params['display_as_img']) {
         $mapObj['params']['map_display_mode'] = 'popup';
     }
     if ($mapObj['params']['map_display_mode'] == 'popup') {
         frameGmp::_()->addScript('bpopup', GMP_JS_PATH . '/bpopup.js');
     }
     frameGmp::_()->addScript('google_maps_api_' . $mapObj['params']['language'], $this->getApiUrl() . $mapObj['params']['language']);
     frameGmp::_()->addScript('map.options', $this->getModule()->getModPath() . 'js/map.options.js', array('jquery'));
     frameGmp::_()->addStyle('map_params', $this->getModule()->getModPath() . 'css/map.css');
     frameGmp::_()->getModule('marker')->connectAssets();
     if (empty($mapObj['params']['map_display_mode'])) {
         $mapObj['params']['map_display_mode'] = 'map';
     }
     // This is for posibility to show multy maps with same ID on one page
     $mapObj['original_id'] = $mapObj['id'];
     if (isset($this->_idToRandId[$mapObj['original_id']])) {
         $mapObj['id'] = $this->_idToRandId[$mapObj['original_id']];
     } else {
         $this->_idToRandId[$mapObj['original_id']] = $mapObj['id'] = mt_rand(1, 99999) . $mapObj['id'];
     }
     $indoWindowSize = utilsGmp::unserialize(frameGmp::_()->getModule('options')->getModel('options')->get('infowindow_size'));
     $this->assign('indoWindowSize', $indoWindowSize);
     $this->assign('currentMap', $mapObj);
     $markersDisplayType = '';
     if (isset($params['display_type'])) {
         $markersDisplayType = $params['display_type'];
     } else {
         if (isset($params['markers_list_type'])) {
             $markersDisplayType = $params['markers_list_type'];
         } else {
             if (isset($mapObj['params']['markers_list_type']) && !empty($mapObj['params']['markers_list_type'])) {
                 $markersDisplayType = $mapObj['params']['markers_list_type'];
             }
         }
     }
     $mapObj['params']['markers_list_type'] = $markersDisplayType;
     $this->addMapData($mapObj);
     $this->assign('markersDisplayType', $markersDisplayType);
     // This will require only in PRO, but we will make it here - to avoid code doubling
     $this->assign('mapCategories', frameGmp::_()->getModule('marker_groups')->getModel()->getListForMarkers(isset($mapObj['markers']) ? $mapObj['markers'] : false));
     return parent::getContent('mapPreview');
 }
コード例 #7
0
ファイル: marker.php プロジェクト: Roman921/Step-21
 public function updateMapMarkers($params, $mapId = null)
 {
     foreach ($params as $id => $data) {
         //self::$tableObj->delete($id);
         $newId = $id;
         $exists = self::$tableObj->exists($id);
         unset($data['id']);
         if ($mapId) {
             $data['map_id'] = $mapId;
         }
         $data['marker_group_id'] = $data['groupId'];
         $data['params'] = utilsGmp::serialize(array('titleLink' => $data['titleLink']));
         unset($data['titleLink']);
         if ($exists) {
             self::$tableObj->update($data, array('id' => $id));
         } else {
             $params[$id]['tmp_id'] = $id;
             $newId = self::$tableObj->insert($data);
         }
         $params[$id]['id'] = $newId;
         $params[$id]['params'] = utilsGmp::unserialize($data['params']);
     }
     return $params;
 }