Пример #1
0
 public function saveNewIcon()
 {
     $data = reqGmp::get('post');
     $res = new responseGmp();
     $result = $this->getModel()->saveNewIcon($data['icon']);
     if ($result) {
         $data['icon']['id'] = $result;
         $res->addData($data['icon']);
     } else {
         outGmp($this->getModel()->getErrors());
     }
     frameGmp::_()->getModule("promo_ready")->getModel()->saveUsageStat("icon.add");
     return $res->ajaxExec();
 }
Пример #2
0
 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);
 }