/** * Determines the request method and selects the appropriate data result. * * @param array $arrInput Fragments from request uri * @return mixed JSON data */ public function generate(array $arrInput) { // Only allow GET requests if (strtoupper($_SERVER['REQUEST_METHOD']) != 'GET') { \HttpResultHelper::MethodNotAllowed(); } // A map id is required if (count($arrInput) < 1 && !is_numeric($arrInput[0])) { \HttpResultHelper::BadRequest(); } $intProfileId = intval($arrInput[0]); $arrParams = array(); $strParams = ""; foreach ($_GET as $key => $value) { if (\Input::get($key)) { $arrParams[$key] = \Input::get($key); if (strlen($strParams) > 0) { $strParams .= "&"; } if ($key == "loc_to" || $key == "loc_from") { $strParams .= "loc=" . \Input::get($key); } else { $strParams .= $key . "=" . \Input::get($key); } } } return $this->getRoutingResponse($intProfileId, $strParams); }
/** * Returns the layer data. * * @param int $id */ protected function getStyleData($arrIds) { $arrLocationsStyles = array(); $objLocationStyles = C4gMapLocstylesModel::findMultipleByIds($arrIds); if ($objLocationStyles == null) { \HttpResultHelper::NotFound(); } while ($objLocationStyles->next()) { $arrLocationsStyles[] = $this->prepareStyleData($objLocationStyles->row()); } return $arrLocationsStyles; }
public function generate(array $arrInput) { // Only allow GET requests if (strtoupper($_SERVER['REQUEST_METHOD']) != 'GET') { \HttpResultHelper::MethodNotAllowed(); } // A map id is required if (count($arrInput) < 1 && !is_numeric($arrInput[0])) { \HttpResultHelper::BadRequest(); } return json_encode($this->getLayerData(intval($arrInput[0]), true)); }
/** * Returns the editor configuration from a given profile. * * @param int $id The profile-ID */ protected function getEditorConfigForProfile($intId) { $arrEditorConfig = array(); // Find the requested profile $objProfile = \C4gMapProfilesModel::findById($intId); if ($objProfile == null) { \HttpResultHelper::NotFound(); } // Get editor config from profile $arrEditorConfig['styles_point'] = unserialize($objProfile->editor_styles_point); $arrEditorConfig['styles_line'] = unserialize($objProfile->editor_styles_line); $arrEditorConfig['styles_polygon'] = unserialize($objProfile->editor_styles_polygon); $arrEditorConfig['vars'] = $objProfile->editor_vars; $arrEditorConfig['show_items'] = $objProfile->editor_show_items; $arrEditorConfig['helpurl'] = $objProfile->editor_helpurl; return $arrEditorConfig; }
/** * Determines the request method and selects the appropriate data result. * * @param array $arrInput Fragments from request uri * @return mixed JSON data */ public function generate(array $arrInput) { // Only allow GET requests if (strtoupper($_SERVER['REQUEST_METHOD']) != 'GET') { \HttpResultHelper::MethodNotAllowed(); } // A profile id is required if (count($arrInput) < 1 && !is_numeric($arrInput[0])) { \HttpResultHelper::BadRequest(); } $intProfileId = intval($arrInput[0]); $arrParams = array(); foreach ($_GET as $key => $value) { if (\Input::get($key)) { $arrParams[$key] = \Input::get($key); } } return $this->getNominatimResponse($intProfileId, $arrParams); }
public function generate(array $arrInput) { // Only allow GET requests if (strtoupper($_SERVER['REQUEST_METHOD']) != 'GET') { \HttpResultHelper::MethodNotAllowed(); } // A map id is required if (count($arrInput) < 1 && !is_numeric($arrInput[0])) { \HttpResultHelper::BadRequest(); } $intProfileId = intval($arrInput[0]); $blnProfileBaselayerFilter = false; $mapsProfileModel = \C4gMapProfilesModel::findById($intProfileId); if ($mapsProfileModel !== null) { if ($mapsProfileModel->baselayers) { $blnProfileBaselayerFilter = true; $arrProfileBaselayerFilter = deserialize($mapsProfileModel->baselayers, true); } } $arrLayers = $this->getBaseLayerList($blnProfileBaselayerFilter ? $arrProfileBaselayerFilter : false); $this->arrConfig['countAll'] = sizeof($arrLayers); return json_encode(array('config' => $this->arrConfig, 'baselayer' => $arrLayers)); }
/** * Determines the request method and selects the appropriate data result. * * @param array $arrInput Fragments from request uri * @return mixed JSON data */ public function generate(array $arrInput) { // Only allow GET requests if (strtoupper($_SERVER['REQUEST_METHOD']) != 'GET') { \HttpResultHelper::MethodNotAllowed(); } // A map id is required if (count($arrInput) < 1) { \HttpResultHelper::BadRequest(); } //$arrIds = \Input::get('ids'); /*if (count($arrIds) < 1) { \HttpResultHelper::BadRequest(); }*/ if (strpos($arrInput[0], ":") !== false) { $arrInputExploded = explode(':', $arrInput[0]); $strTable = $arrInputExploded[0]; $intId = $arrInputExploded[1]; } else { \HttpResultHelper::BadRequest(); } return json_encode($this->getInfoWindowContent($strTable, $intId)); }
/** * Returns the layer structure for the map. * * @param int $id */ protected function getLayerList($intId, $blnIsSubLayer = false) { $arrLayer = array(); $arrLinkData = array(); if (!$blnIsSubLayer) { // Find the requested map $objMap = C4gMapsModel::findById($intId); // Only return map entries if ($objMap == null || !$objMap->is_map) { \HttpResultHelper::NotFound(); } } // Get all layers on the map $objLayers = C4gMapsModel::findPublishedByPid($intId); if ($objMap) { // append map itself as structure element if ($objMap->location_type != "none") { $mapLayer = $this->parseLayer($objMap); unset($mapLayer['raw']); $arrLayer[] = $mapLayer; } } if ($objLayers != null) { while ($objLayers->next()) { // workaround for incorrect model function if (!$objLayers->published) { continue; } // do not return protected layers, to users without permission if ($objLayers->protect_element) { if (FE_USER_LOGGED_IN && !empty($objLayers->permitted_groups)) { if (sizeof(array_intersect($this->User->groups, deserialize($objLayers->permitted_groups))) <= 0) { continue; } } else { continue; } } //if ($objLayers->forum_reassign_layer) if ($arrGetLayerData = $this->parseLayer($objLayers)) { $arrLayerData = $arrGetLayerData; //$this->parseLayer($objLayers); if ($childLayerList = $this->getLayerList($arrLayerData['id'], true)) { $arrLayerData['hasChilds'] = true; $arrLayerData['childsCount'] = sizeof($childLayerList); $arrLayerData['childs'] = $childLayerList; } else { if ($objLayers->location_type == 'link') { // link handling if ($childLayerList = $this->getLayerList($arrLayerData['link_id'], true)) { // duplicate children for the link foreach ($childLayerList as $key => $child) { // generate new unique ids $childId = $childLayerList[$key]['id']; $childLayerList[$key]['link_id'] = $childId; $childLayerList[$key]['id'] = uniqid(); $childLayerList[$key]['pid'] = $arrLayerData['id']; $childLayerList[$key]['childs'] = $this->getLinkedChilds($childLayerList[$key]); if ($childLayerList[$key]['childs'] && sizeof($childLayerList[$key]['childs']) > 0) { $childLayerList[$key]['hasChilds'] = true; $childLayerList[$key]['childCount'] = sizeof($childLayerList[$key]['childs']); foreach ($childLayerList[$key]['childs'] as $index => $item) { $childLayerList[$key]['childs'][$index]['hide'] = $objLayers->data_hidelayer; } } } $arrLayerData['hasChilds'] = true; $arrLayerData['childsCount'] = sizeof($childLayerList); $arrLayerData['childs'] = $childLayerList; } } } $arrLayerData['childs'] = $this->setChildHide($arrLayerData['childs'], $objLayers); // HOOK: add custom logic if (isset($GLOBALS['TL_HOOKS']['c4gAddLocationsParent']) && is_array($GLOBALS['TL_HOOKS']['c4gAddLocationsParent'])) { foreach ($GLOBALS['TL_HOOKS']['c4gAddLocationsParent'] as $callback) { $str_class = $callback[0]; $str_function = $callback[1]; if ($str_class && $str_function) { $this->import($str_class); $arrData = $this->{$str_class}->{$str_function}($arrLayerData['pid'], $arrLayerData, $this); if ($arrData && is_array($arrData) && sizeof($arrData) > 0) { $arrLayerData = $arrData; } } } } unset($arrLayerData['raw']); $arrLayer[] = $arrLayerData; } } } return $arrLayer; }