Beispiel #1
0
    /**
     * The main dispatcher for ajax based editing of maps
     *
     * @param int $p_mapId
     * @param int $p_languageId
     * @param int $p_articleNumber
     * @param mixed $p_map
     * @param mixed $p_remove
     * @param mixed $p_insert
     * @param mixed $p_locations
     * @param mixed $p_contents
     * @param mixed $p_order
     *
     * @return array
     */
	public static function StoreMapData($p_mapId, $p_languageId, $p_articleNumber, $p_map = "", $p_remove = "", $p_insert = "", $p_locations = "", $p_contents = "", $p_order = "")
	{
        $security_problem = array("status" => "403", "description" => "Invalid security token!");
        $unknown_request = array("status" => "404", "description" => "Unknown request!");
        $data_wrong = array("status" => "404", "description" => "Wrong data.");


        $status = true;

        if ("" != $p_map)
        {
            $map_data = array();
            try
            {
                $p_map = str_replace("%2B", "+", $p_map);
                $p_map = str_replace("%2F", "/", $p_map);
                $map_json = base64_decode($p_map);

                $map_data = json_decode($map_json);
            }
            catch (Exception $exc)
            {
                $status = false;
            }
            if ($status)
            {
                $status = Geo_Map::UpdateMap($p_mapId, $p_articleNumber, $map_data);
            }
        }

        if (!$status)
        {
            return $data_wrong;
        }

        if ("" != $p_remove)
        {
            $remove_data = array();
            try
            {
                $p_remove = str_replace("%2B", "+", $p_remove);
                $p_remove = str_replace("%2F", "/", $p_remove);
                $remove_json = base64_decode($p_remove);
                $remove_data = json_decode($remove_json);
            }
            catch (Exception $exc)
            {
                $status = false;
            }
            if ($status)
            {
                $status = Geo_Map::RemovePoints($p_mapId, $remove_data);
            }
        }

        if (!$status)
        {
            return $data_wrong;
        }

        $new_ids = array();
        if ("" != $p_insert)
        {
            $insert_data = array();
            try
            {
                $p_insert = str_replace("%2B", "+", $p_insert);
                $p_insert = str_replace("%2F", "/", $p_insert);
                $insert_json = base64_decode($p_insert);

                $insert_data = json_decode($insert_json);
            }
            catch (Exception $exc)
            {
                $status = false;
            }
            if ($status)
            {
                $status = Geo_Map::InsertPoints($p_mapId, $p_languageId, $p_articleNumber, $insert_data, $new_ids);

            }
        }


        if (!$status)
        {
            return $data_wrong;
        }


        if ("" != $p_locations)
        {
            $locations_data = array();
            try
            {
                $p_locations = str_replace("%2B", "+", $p_locations);
                $p_locations = str_replace("%2F", "/", $p_locations);
                $locations_json = base64_decode($p_locations);
                $locations_data = json_decode($locations_json);
            }
            catch (Exception $exc)
            {
                $status = false;
            }
            if ($status)
            {

                $status = Geo_Location::UpdateLocations($p_mapId, $locations_data);
            }
        }

        if (!$status)
        {
            return $data_wrong;
        }


        if ("" != $p_contents)
        {
            $contents_data = array();
            try
            {

                $p_contents = str_replace("%2B", "+", $p_contents);
                $p_contents = str_replace("%2F", "/", $p_contents);
                $contents_json = base64_decode($p_contents);

                $contents_data = json_decode($contents_json);
            }
            catch (Exception $exc)
            {
                $status = false;
            }
            if ($status)
            {
                $status = Geo_Location::UpdateContents($p_mapId, $contents_data);
            }
        }

        if (!$status)
        {
            return $data_wrong;
        }

        if ("" != $p_order)
        {
            $order_data = array();
            try
            {
                $p_order = str_replace("%2B", "+", $p_order);
                $p_order = str_replace("%2F", "/", $p_order);
                $order_json = base64_decode($p_order);
                $order_data = json_decode($order_json);
            }
            catch (Exception $exc)
            {
                $status = false;
            }
            if ($status)
            {
                $status = Geo_Location::UpdateOrder($p_mapId, $order_data, $new_ids);
            }
        }

        if (!$status)
        {
            return $data_wrong;
        }

        $geo_map_usage = Geo_Map::ReadMapInfo("map", $p_mapId);


        $found_list = Geo_Map::ReadMapPoints($p_mapId, $p_languageId);

        $res_array = array("status" => "200", "pois" => $found_list, "map" => $geo_map_usage);

        return $res_array;
    } // fn StoreMapData