/**
  * 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;
 }
 /**
  * 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;
 }
 /**
  * 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;
 }