Пример #1
0
 public function save()
 {
     $saveRes = false;
     $data = reqGmp::get('post');
     $res = new responseGmp();
     $markerGroupId = 0;
     $edit = true;
     if (!isset($data['marker_group'])) {
         $res->pushError(__('Marker Category data not found', GMP_LANG_CODE));
         return $res->ajaxExec();
     }
     if (isset($data['marker_group']['id']) && !empty($data['marker_group']['id'])) {
         $saveRes = $this->getModel()->updateMarkerGroup($data['marker_group']);
         $markerGroupId = $data['marker_group']['id'];
     } else {
         $saveRes = $this->getModel()->saveNewMarkerGroup($data['marker_group']);
         $markerGroupId = $saveRes;
         $edit = false;
     }
     if ($saveRes) {
         $res->addData('marker_group_id', $markerGroupId);
         $res->addData('marker_group', $this->getModel()->getMarkerGroupById($markerGroupId));
         if (!$edit) {
             // For new marker category
             $fullEditUrl = $this->getModule()->getEditMarkerGroupLink($markerGroupId);
             $editUrlParts = explode('/', $fullEditUrl);
             $res->addData('edit_url', $editUrlParts[count($editUrlParts) - 1]);
         }
     } else {
         $res->pushError($this->getModel()->getErrors());
     }
     return $res->ajaxExec();
 }
Пример #2
0
 public function exportData()
 {
     $data = reqGmp::get('post');
     $exportItem = $data['to_export'];
     $res = new responseGmp();
     //$exportModule = frameGmp::_()->getModule($exportItem);
     switch ($data["gmpActionMode"]) {
         case "export":
             $maps = $data['map'];
             $mapsArr = array();
             $mapsModule = frameGmp::_()->getModule("gmap");
             foreach ($maps as $k => $map_id) {
                 $mapsArr[] = $mapsModule->getModel()->getMapById($map_id, $withMarkers = true, $withGroups = true);
             }
             $uplDir = wp_upload_dir();
             $filePath = $uplDir['basedir'];
             $filename = "export" . date("Y_M_D") . "_" . rand(10, 100) . ".csv";
             $dest = $filePath . DS . $filename;
             $handle = fopen($dest, "a+");
             if ($handle) {
                 file_put_contents($dest, utilsGmp::serialize($mapsArr));
             }
             fclose($handle);
             $data = array("file" => $uplDir['baseurl'] . DS . $filename);
             break;
     }
     $res->addData($data);
     return $res->ajaxExec();
 }
Пример #3
0
 public function save()
 {
     $saveRes = false;
     $data = reqGmp::get('post');
     $res = new responseGmp();
     $mapId = 0;
     $edit = true;
     if (!isset($data['map_opts'])) {
         $res->pushError(__('Map data not found', GMP_LANG_CODE));
         return $res->ajaxExec();
     }
     if (isset($data['map_opts']['id']) && !empty($data['map_opts']['id'])) {
         $saveRes = $this->getModel()->updateMap($data['map_opts']);
         $mapId = $data['map_opts']['id'];
     } else {
         $saveRes = $this->getModel()->saveNewMap($data['map_opts']);
         $mapId = $saveRes;
         $edit = false;
     }
     if ($saveRes) {
         $addMarkerIds = reqGmp::getVar('add_marker_ids');
         if ($addMarkerIds && !empty($addMarkerIds)) {
             frameGmp::_()->getModule('marker')->getModel()->setMarkersToMap($addMarkerIds, $mapId);
             $this->getModel()->resortMarkers(array('map_id' => $mapId));
         }
         $res->addMessage(__('Done', GMP_LANG_CODE));
         $res->addData('map_id', $mapId);
         $res->addData('map', $this->getModel()->getMapById($mapId));
         if (!$edit) {
             // For new maps
             $fullEditUrl = $this->getModule()->getEditMapLink($mapId);
             $editUrlParts = explode('/', $fullEditUrl);
             $res->addData('edit_url', $editUrlParts[count($editUrlParts) - 1]);
         }
     } else {
         $res->pushError($this->getModel()->getErrors());
     }
     //frameGmp::_()->getModule('supsystic_promo')->getModel()->saveUsageStat('map.edit');
     return $res->ajaxExec();
 }
Пример #4
0
 function saveGoup()
 {
     $data = reqGmp::get('post');
     $res = new responseGmp();
     if (!isset($data['goupInfo'])) {
         $res->pushError(langGmp::_('Nothing To Save'));
         return $res->ajaxExec();
     }
     if ($id = $this->getModel()->saveGroup($data['goupInfo'])) {
         $res->addMessage(langGmp::_('Done'));
         $res->addData('group', $this->getModel()->getGroupById($id));
     } else {
         $res->pushError(langGmp::_('Cannot Save Group'));
     }
     return $res->ajaxExec();
 }
Пример #5
0
 public function downloadIconFromUrl()
 {
     $data = reqGmp::get('post');
     $res = new responseGmp();
     if (!isset($data['icon_url']) || empty($data['icon_url'])) {
         $res->pushError(__('Empty url', GMP_LANG_CODE));
         return $res->ajaxExec();
     }
     $result = $this->getModel()->downloadIconFromUrl($data['icon_url']);
     if ($result) {
         $res->addData($result);
     } else {
         $res->pushError($this->getModel()->getErrors());
     }
     return $res->ajaxExec();
 }
Пример #6
0
 public function getMarker()
 {
     $res = new responseGmp();
     $id = (int) reqGmp::getVar('id');
     if ($id) {
         $marker = $this->getModel()->getById($id);
         if (!empty($marker)) {
             $res->addData('marker', $marker);
         } else {
             $res->pushError($this->getModel()->getErrors());
         }
     } else {
         $res->pushError(langGmp::_('Empty or invalid marker ID'));
     }
     return $res->ajaxExec();
 }
Пример #7
0
 /**
  * Common method for list table data
  */
 public function getListForTbl()
 {
     $res = new responseGmp();
     $res->ignoreShellData();
     $model = $this->getModel();
     $page = (int) reqGmp::getVar('page');
     $rowsLimit = (int) reqGmp::getVar('rows');
     $orderBy = reqGmp::getVar('sidx');
     $sortOrder = reqGmp::getVar('sord');
     // Our custom search
     $search = reqGmp::getVar('search');
     if ($search && !empty($search) && is_array($search)) {
         foreach ($search as $k => $v) {
             $v = trim($v);
             if (empty($v)) {
                 continue;
             }
             if ($k == 'text_like') {
                 $v = $this->_prepareTextLikeSearch($v);
                 if (!empty($v)) {
                     $model->addWhere(array('additionalCondition' => $v));
                 }
             } else {
                 $model->addWhere(array($k => $v));
             }
         }
     }
     // jqGrid search
     $isSearch = reqGmp::getVar('_search');
     if ($isSearch) {
         $searchField = trim(reqGmp::getVar('searchField'));
         $searchString = trim(reqGmp::getVar('searchString'));
         if (!empty($searchField) && !empty($searchString)) {
             // For some cases - we will need to modify search keys and/or values before put it to the model
             $model->addWhere(array($this->_prepareSearchField($searchField) => $this->_prepareSearchString($searchString)));
         }
     }
     $model = $this->_prepareModelBeforeListSelect($model);
     // Get total pages count for current request
     $totalCount = $model->getCount(array('clear' => array('selectFields')));
     $totalPages = 0;
     if ($totalCount > 0) {
         $totalPages = ceil($totalCount / $rowsLimit);
     }
     if ($page > $totalPages) {
         $page = $totalPages;
     }
     // Calc limits - to get data only for current set
     $limitStart = $rowsLimit * $page - $rowsLimit;
     // do not put $limit*($page - 1)
     if ($limitStart < 0) {
         $limitStart = 0;
     }
     $data = $model->setLimit($limitStart . ', ' . $rowsLimit)->setOrderBy($this->_prepareSortOrder($orderBy))->setSortOrder($sortOrder)->getFromTbl();
     $data = $this->_prepareListForTbl($data);
     $res->addData('page', $page);
     $res->addData('total', $totalPages);
     $res->addData('rows', $data);
     $res->addData('records', $model->getLastGetCount());
     $res = dispatcherGmp::applyFilters($this->getCode() . '_getListForTblResults', $res);
     $res->ajaxExec();
 }
Пример #8
0
 public function getListForTable()
 {
     $res = new responseGmp();
     $res->ignoreShellData();
     $count = $this->getModel()->getCount();
     $listReqData = array('limitFrom' => reqGmp::getVar('iDisplayStart'), 'limitTo' => reqGmp::getVar('iDisplayLength'));
     $displayColumns = $this->getView()->getDisplayColumns();
     $displayColumnsKeys = array_keys($displayColumns);
     $iSortCol = reqGmp::getVar('iSortCol_0');
     if (!is_null($iSortCol) && is_numeric($iSortCol)) {
         $listReqData['orderBy'] = $displayColumns[$displayColumnsKeys[$iSortCol]]['db'];
         $iSortDir = reqGmp::getVar('sSortDir_0');
         if (!is_null($iSortDir)) {
             $listReqData['orderBy'] .= ' ' . strtoupper($iSortDir);
         }
     }
     $search = reqGmp::getVar('sSearch');
     if (!is_null($search) && !empty($search)) {
         $dbSearch = dbGmp::escape($search);
         $listReqData['additionalCondition'] = 'title LIKE "%' . $dbSearch . '%" OR description LIKE "%' . $dbSearch . '%"';
     }
     $list = $this->getModel()->getAllMaps($listReqData, true);
     $res->addData('aaData', $this->_convertDataForDatatable($list));
     $res->addData('iTotalRecords', $count);
     $res->addData('iTotalDisplayRecords', $count);
     $res->addData('sEcho', reqGmp::getVar('sEcho'));
     $res->addMessage(__('Done'));
     return $res->ajaxExec();
 }