/** * * @param array $lista_elementos */ public function guardar($lista_elementos) { $guardados = array(); if (count($lista_elementos) > 0) { foreach ($lista_elementos as $elemento_json) { $elemento = json_decode($elemento_json); if (is_object($elemento)) { $emergencia_elemento = $this->_emergencia_elemento_model->getById($elemento->id); $icono = ""; $color = ""; if (isset($elemento->icono)) { if (isset($elemento->hash)) { $this->_ci->archivo_save->saveFromCache($elemento->hash, array("emergencia", $this->_id_emergencia, "mapa")); $icono = $this->_ci->archivo_save->getPath(); if (!is_null($emergencia_elemento)) { $existe = strpos($emergencia_elemento->icono, "spotlight-poi-black.png"); if ($existe === false) { @unlink(FCPATH . $emergencia_elemento->icono); } } } else { $icono = $elemento->icono; } } if (isset($elemento->color)) { $color = $elemento->color; } $data = array("id_emergencia" => $this->_id_emergencia, "tipo" => $elemento->tipo, "color" => $color, "icono" => $icono, "propiedades" => json_encode($elemento->propiedades), "coordenadas" => json_encode($elemento->coordenadas)); if (!is_null($emergencia_elemento)) { $this->_emergencia_elemento_model->update($data, $emergencia_elemento->id); $id = $emergencia_elemento->id; $guardados[$elemento->clave] = $id; } else { $id = $this->_emergencia_elemento_model->insert($data); $guardados[$elemento->clave] = $id; } } } } $this->_emergencia_elemento_model->deleteNotIn($this->_id_emergencia, $guardados); return $guardados; }
/** * */ public function popup_marcador_editar() { $this->load->library(array("cache", "core/string/random")); $params = $this->input->post(null, true); $params_url = $this->uri->uri_to_assoc(); if (TRIM($params["html"]) == "") { $bo_editor_texto = false; } else { $bo_editor_texto = true; } $id = null; $marcador = $this->_emergencia_elementos_model->getById($params["id"]); if (!is_null($marcador)) { $id = $marcador->id; } $imagen = array(); $es_cache = strpos($params["icono"], "hash"); if ($es_cache === false) { $relative_path = str_replace(base_url(), "", $params["icono"]); if (is_file(FCPATH . $relative_path)) { $imagen["name"] = basename(FCPATH . $relative_path); $imagen["file"] = $params["icono"]; $finfo = finfo_open(FILEINFO_MIME_TYPE); $imagen["type"] = finfo_file($finfo, FCPATH . $relative_path); finfo_close($finfo); $imagen["size"] = filesize(FCPATH . $relative_path); } } else { $cache = $this->cache->iniciar(); $separado = explode("/", $params["icono"]); if ($imagen_cache = $cache->load($separado[count($separado) - 1])) { $imagen["name"] = $imagen_cache["archivo_nombre"]; $imagen["file"] = $params["icono"]; $imagen["type"] = $imagen_cache["mime"]; $imagen["size"] = $imagen_cache["size"]; } } $this->load->view("pages/mapa/popup-marcador-editar", array("id" => $id, "clave" => $params["clave"], "icono" => $params["icono"], "imagen" => $imagen, "bo_editor_texto" => $bo_editor_texto, "propiedades" => $params["propiedades"], "html" => $params["html"])); }