public function modificar($id) { $this->permisos('admin'); $this->form_validation->set_error_delimiters('<div class="alert alert-error"> <button type="button" class="close" data-dismiss="alert">×</button> <h4>Error</h4>', '</div>'); $this->pagina = 'crear noticia'; $this->carpeta = 'administrador'; $this->titulo = 'Editar noticia'; $this->estilo = array('jquery-te-1.3.3', 'crear noticia', 'jquery-ui'); $this->javascript = array('jquery.validate.min', 'validarNoticia', 'editor', 'jquery-te-1.3.3.min', 'sincroEditor'); $this->menu = 'menu_admin_noticias'; $datos['boton'] = array('class' => 'btn btn-info', 'name' => 'button', 'id' => 'boton_cliente'); $datos['actualizar'] = TRUE; $datos['id'] = $id; $noticia = new Noticias_model(); $noticia->datos($id); $datos['formulario'] = array('titulo' => array('class' => 'input-xlarge', 'id' => 'titulo', 'name' => 'titulo', 'label' => 'titulo', 'maxlength' => '150', 'type' => 'text', 'value' => $noticia->titulo(), 'autofocus' => 'autofocus'), 'contenido' => array('class' => 'editor', 'id' => "contenido-noticia-{$id}", 'name' => 'contenido', 'label' => 'contenido', 'value' => $noticia->contenido())); $this->form_validation->set_rules('titulo', 'Titulo', 'trim|required|min_length[3]|xss_clean'); $this->form_validation->set_rules('contenido', 'Contenido', 'trim|required|min_length[3]'); $this->form_validation->set_message('required', 'El campo %s no puede estar vacio'); $this->form_validation->set_message('min_legth', 'El campo %s debe tener mínmo 3 caracteres'); $this->form_validation->set_message('xss_clean', 'El campo %s no es válido'); if ($this->form_validation->run() == TRUE) { $noticia = new Noticias_model(); if ($noticia->actualizar($id)) { $this->exito = 'La noticia se actualizado satisfactoriamente.'; $datos['formulario']['titulo']['value'] = $this->input->post('titulo'); $datos['formulario']['contenido']['value'] = $this->input->post('contenido'); } else { $this->error = array('nivel' => '2', 'mensaje' => 'No se ha podido actualizar la noticia, por favor inténtelo de nuevo más tarde'); } } $this->mostrar($datos); }