Query(" SELECT * FROM " . PREFIX . "_module_gmap WHERE id = '" . $gmap_id . "' "); $row_gs = $sql->FetchAssocArray(); $sql = $AVE_DB->Query(" SELECT * FROM " . PREFIX . "_module_gmap_markers WHERE gmap_id = '" . $gmap_id . "' "); $markers = array(); while ($row = $sql->FetchAssocArray()) { array_push($markers, $row); } $AVE_Template->assign('gmap', $row_gs); $AVE_Template->assign('markers', json_encode($markers)); $AVE_Template->assign('api_key', GOOGLE_MAP_API_KEY); $AVE_Template->display($tpl_dir . 'map.tpl'); } /** * ФУНКЦИИ АДМИНИСТРАТИВНОЙ ЧАСТИ */ /** * КАТЕГОРИИ - СОЗДАНИЕ - ДОБАВЛЕНИЕ - РЕДАКТИРОВАНИЕ */ // Просмотр существующих категорий в админ панели function gmapCategoryShow($tpl_dir) { global $AVE_DB, $AVE_Template; $gcats = array(); $sql = $AVE_DB->Query(" SELECT * FROM " . PREFIX . "_module_gmap_category "); //$row_gcat = $sql->FetchRow(); while($row = $sql->FetchAssocArray()) { array_push($gcats, $row); } $AVE_Template->assign('gcats', $gcats); $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_gmap_category.tpl')); } // Редактирование маркеров function gmapMarkerEdit($tpl_dir, $id) { global $AVE_DB, $AVE_Template; $gmarkers = array(); $sql = $AVE_DB->Query(" SELECT * FROM " . PREFIX . "_module_gmap_markers WHERE id = '" . (int)$id. "' "); while($row = $sql->FetchAssocArray()) { array_push($gmarkers, $row); } $gcats = array(); $sql = $AVE_DB->Query(" SELECT * FROM " . PREFIX . "_module_gmap_category "); //$row_gcat = $sql->FetchRow(); while($row = $sql->FetchAssocArray()) { array_push($gcats, $row); } $AVE_Template->assign('gcats', $gcats); $AVE_Template->assign('gmarkers', $gmarkers); $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_gmap_edit_marker.tpl')); } // Сохранение отредактированного маркера function gmapMarkerEditSave($id){ if (isset($_POST['e_marker'])) { global $AVE_DB; $markerDataE = $_POST['e_marker']; $sql = "UPDATE " . PREFIX . "_module_gmap_markers SET id = '" . $markerDataE['id'] . "', gmap_id = '" . $markerDataE['gmap_id'] . "', latitude = '" . $markerDataE['latitude'] . "', longitude = '" . $markerDataE['longitude'] . "', title = '" . $markerDataE['title'] . "', title_link = '" . $markerDataE['title_link'] . "', marker_cat_id = '" . $markerDataE['marker_cat_id'] . "', marker_cat_title = '" . $markerDataE['marker_cat_title'] . "', marker_cat_link = '" . $markerDataE['marker_cat_link'] . "', img_title = '" . $markerDataE['img_title'] . "', marker_city = '" . $markerDataE['marker_city'] . "', marker_street = '" . $markerDataE['marker_street'] . "', marker_building = '" . $markerDataE['marker_building'] . "', marker_dopfield = '" . $markerDataE['marker_dopfield'] . "', marker_phone = '" . $markerDataE['marker_phone'] . "', marker_www = '" . $markerDataE['marker_www'] . "', image = '" . $markerDataE['image']. "' WHERE id = '" . (int)$id. "' "; $AVE_DB->Query($sql); //$markerDataE['id'] = $AVE_DB->InsertId(); echo json_encode($markerDataE); exit; } } // Добавление и сохранение новых категорий в админ панели модуля и вывод категории при создании function gmapCategoryNewAdd(){ if (isset($_POST['category'])) { global $AVE_DB; $categoryData = $_POST['category']; $sql = " INSERT INTO " . PREFIX . "_module_gmap_category SET id = '', gcat_title = '" . $categoryData['gcatnewadd'] . "', gcat_link = '" . $categoryData['gct_link'] . "' "; $AVE_DB->Query($sql); $categoryData['id'] = $AVE_DB->InsertId(); $sql = $AVE_DB->Query(" SELECT gcat_title FROM " . PREFIX . "_module_gmap_category ORDER BY id DESC LIMIT 1 "); $row_gcat = $sql->FetchRow(); $categoryData['gcat_title'] = $row_gcat->gcat_title; echo json_encode($categoryData); exit; } } /** * Удаление категории * * @param int $id - идентификатор категории */ function gmapCategoryDel($id){ global $AVE_DB; $sql = "DELETE FROM " . PREFIX . "_module_gmap_category WHERE id = '" . (int)$id. "'"; $AVE_DB->Query("DELETE FROM " . PREFIX . "_module_gmap_markers WHERE marker_cat_id = '" . (int)$id . "'"); $AVE_DB->Query($sql); echo $id; exit; } /** * Просмотр маркеров карты и добавление новых в админке * * @param string $tpl_dir - путь к папке с шаблонами модуля * @param int $gmap_id - идентификатор карты */ function gmapMarkersShow($tpl_dir, $gmap_id) { global $AVE_DB, $AVE_Template; $pin_dir = BASE_DIR.'/modules/gmap/images'; $pin_base_dir = ABS_PATH.'modules/gmap/images'; $pins = array(); if ($handle = opendir($pin_dir . '/')) { while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') { $image_title = substr($file, 0, -4); $upload_file_ext = strtolower(substr($file, -4)); $upload_filename = prepare_fname($image_title) . $upload_file_ext; if (!empty($upload_filename) && $upload_file_ext == '.png') { $pins[] = array('name' => $image_title, 'path' => $pin_base_dir . '/' . $upload_filename); } } } closedir($handle); } $sql = $AVE_DB->Query(" SELECT * FROM " . PREFIX . "_module_gmap WHERE id = '" . $gmap_id . "' "); $row_gs = $sql->FetchAssocArray(); $sql = $AVE_DB->Query(" SELECT * FROM " . PREFIX . "_module_gmap_markers WHERE gmap_id = '" . $gmap_id . "' "); $load_markers = array(); while ($row = $sql->FetchAssocArray()) { array_push($load_markers, $row); } $limit = 5; $start = get_current_page() * $limit - $limit; $sql = $AVE_DB->Query(" SELECT SQL_CALC_FOUND_ROWS * FROM " . PREFIX . "_module_gmap_markers WHERE gmap_id = '" . $gmap_id . "' ORDER BY id ASC LIMIT " . $start . "," . $limit . " "); $sql_num = $AVE_DB->Query("SELECT FOUND_ROWS()"); $num = $sql_num->GetCell(); $markers = array(); while ($row = $sql->FetchAssocArray()) { array_push($markers, $row); } if ($num > $limit) { $page_nav = ' {t} '; $page_nav = get_pagination(ceil($num / $limit), 'page', $page_nav); } else { $page_nav = ''; } $gcats = array(); $sql = $AVE_DB->Query(" SELECT * FROM " . PREFIX . "_module_gmap_category "); //$row_gcat = $sql->FetchRow(); while($row = $sql->FetchAssocArray()) { array_push($gcats, $row); } $AVE_Template->assign('gcats', $gcats); $AVE_Template->assign('gcats_id', $row['id']); $AVE_Template->assign('api_key', GOOGLE_MAP_API_KEY); $AVE_Template->assign('page_nav', $page_nav); $AVE_Template->assign('gmap', $row_gs); $AVE_Template->assign('gmap_id', $row_gs['id']); $AVE_Template->assign('gmap_title', $row_gs['gmap_title']); $AVE_Template->assign('markers', $markers); $AVE_Template->assign('load_markers', json_encode($load_markers)); $AVE_Template->assign('pins', $pins); $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_gmap_markers.tpl')); } /** * Вывод списка карт * * @param string $tpl_dir - путь к папке с шаблонами модуля */ function gmapListShow($tpl_dir) { global $AVE_DB, $AVE_Template; $gmaps = array(); $limit = 20; $start = get_current_page() * $limit - $limit; $sql = $AVE_DB->Query(" SELECT SQL_CALC_FOUND_ROWS g.*, COUNT(m.id) AS marker_count FROM " . PREFIX . "_module_gmap AS g LEFT JOIN " . PREFIX . "_module_gmap_markers AS m ON m.gmap_id = g.id GROUP BY g.id ORDER BY g.id ASC LIMIT " . $start . "," . $limit . " "); $sql_num = $AVE_DB->Query("SELECT FOUND_ROWS()"); $num = $sql_num->GetCell(); while($row = $sql->FetchAssocArray()) { array_push($gmaps, $row); } if ($num > $limit) { $page_nav = "