function submit() { $this->load->library('form_validation'); $this->form_validation->set_rules('title', 'titre', 'required|max_length[255]'); $this->form_validation->set_rules('type', 'type du contenu', 'required|is_natural'); $this->form_validation->set_rules('categorie', 'champ de la catégorie', 'required|is_natural'); $this->form_validation->set_rules('idCreation', 'id', 'required|is_natural'); $type = $this->input->post('type'); if ($type == 3) { // article => image obligatoire $this->form_validation->set_rules('image', 'champ de l\'image', 'required'); } // $this->form_validation->set_rules('description', 'champ de la description', 'required'); $formValid = $this->form_validation->run(); $errors = $this->form_validation->error_array(); if ($formValid) { $errors['redirectTo'] = site_url('monCompte/contributions'); if ($type == 2) { $categorie = null; $parent = $this->input->post('categorie'); if ($parent == 0) { $parent = null; } } else { $parent = null; $categorie = $this->input->post('categorie'); } $data['user'] = $this->session->userdata('id'); $data['title'] = $this->input->post('title'); $data['redirect'] = $this->input->post('redirect'); $data['type'] = $type; $data['parent'] = $parent; $data['categorie'] = $categorie; $data['site'] = $this->contents->getIdSite(); $data['description'] = $this->input->post('description'); $data['content'] = $this->input->post('contentTxt'); $data['editDate'] = date('Y-m-d H:i:s'); $urlImage = $this->input->post('image'); // si on fourni une url d'image if (trim($urlImage) != '' && in_array($type, array(1, 3))) { $image = @ImageCreateFromString(@file_get_contents($urlImage)); if (is_resource($image) === true) { $width = imagesx($image); $height = imagesy($image); // on cherche le bon format en fonction du type de contenu if ($type == 1) { $goodSize = $this->size_slider; } else { if ($type == 3) { $goodSize = $this->size_article; } } // la taille d'image fourni n'est pas aux proportions correctes, on la recadre if ($width != $goodSize[0] || $height != $goodSize[1]) { $dest = 'public/images_upload/crop/' . str_replace('.', '', microtime(true)) . '.png'; imagepng($image, $dest, 0); $config['quality'] = '100%'; $config['width'] = intval($this->input->post('w')); $config['height'] = intval($this->input->post('h')); $config['x_axis'] = intval($this->input->post('x')); $config['y_axis'] = intval($this->input->post('y')); $config['source_image'] = $dest; $config['maintain_ratio'] = false; // on recadre $this->load->library('image_lib', $config); $this->image_lib->crop(); // et on redimensionne proprement $config['width'] = $goodSize[0]; $config['height'] = $goodSize[1]; $this->image_lib->initialize($config); $this->image_lib->resize(); $data['image'] = $dest; } else { //sinon, on garde la meme $data['image'] = str_replace(base_url(), '', $urlImage); } } else { // l'url n'est pas une image, on la vide $data['image'] = ''; } } $id = $this->input->post('id'); $idCreation = $this->input->post('idCreation'); $editFromVersion = $this->input->post('editFromVersion'); if ($idCreation == 0) { $data['version'] = 1; if ($type == 2) { $data['order'] = $this->contents->getLastOrder($parent); } else { $data['order'] = 0; } $data['editFromVersion'] = 1; $data['idCreation'] = 0; $data['date'] = date('Y-m-d H:i:s'); } else { // on recupere l'ancien contenu pour calculer combien de lignes/caracteres on a modifié $resContent = $this->db->select('content')->where('id', $id)->get('contents')->row_array(); $oldContent = $resContent['content']; $data['linesModified'] = nbLines($data['content']) - nbLines($oldContent); $data['sizeModified'] = mb_strlen($data['content']) - mb_strlen($oldContent); $data['version'] = $this->contents->getLastVersion($idCreation) + 1; $data['editFromVersion'] = $this->input->post('editFromVersion'); $data['idCreation'] = $idCreation; $infos = $this->contents->getInfosForNewVersion($idCreation); $data['inSlider'] = $infos['inSlider']; $data['order'] = $infos['order']; $data['date'] = $infos['date']; $data['nbComment'] = $infos['nbComment']; } $lastId = $this->contents->create($data); // $this->contents->setCurrent($lastId); } $this->users->gils(150); echo json_encode($errors); }
$pdf->SetFillColor(222, 222, 222); $pdf->cell($table_col_width[0], 6, $LANG['label'], 1, 0, "C", 1); $pdf->cell($table_col_width[1], 6, $LANG['login'], 1, 0, "C", 1); $pdf->cell($table_col_width[2], 6, $LANG['pw'], 1, 0, "C", 1); $pdf->cell($table_col_width[3], 6, $LANG['description'], 1, 1, "C", 1); } $prev_path = $record['path']; if (!isutf8($record['pw'])) { $record['pw'] = ""; } $record['description'] = html_entity_decode(htmlspecialchars_decode(str_replace("<br />", "\n", $record['description']), ENT_QUOTES)); //row height calculation $nb = 0; $nb = max($nb, nbLines($table_col_width[0], $record['label'])); $nb = max($nb, nbLines($table_col_width[3], $record['description'])); $nb = max($nb, nbLines($table_col_width[2], $record['pw'])); $h = 5 * $nb; //Page break needed? checkPageBreak($h); //Draw cells $pdf->SetFont('DejaVu', '', 9); for ($i = 0; $i < count($table); $i++) { $w = $table_col_width[$i]; $a = 'L'; //actual position $x = $pdf->GetX(); $y = $pdf->GetY(); //Draw $pdf->Rect($x, $y, $w, $h); //Write $pdf->MultiCell($w, 5, stripslashes($record[$table[$i]]), 0, $a);
$pdf->SetFillColor(192, 192, 192); error_log('key: ' . $key . ' - paths: ' . $paths[$key]); $pdf->cell(0, 6, $paths[$key], 1, 1, "L", 1); $pdf->SetFillColor(222, 222, 222); $pdf->cell(45, 6, $LANG['label'], 1, 0, "C", 1); $pdf->cell(40, 6, $LANG['login'], 1, 0, "C", 1); $pdf->cell(45, 6, $LANG['pw'], 1, 0, "C", 1); $pdf->cell(60, 6, $LANG['description'], 1, 1, "C", 1); foreach ($val as $item) { //row height calculus $nb = 0; for ($i = 0; $i < count($item); $i++) { if ($i == 3) { $item[$i] = html_entity_decode(htmlspecialchars_decode(str_replace("<br />", "\n", $item[$i]), ENT_QUOTES)); } $nb = max($nb, nbLines($table_col_width[$i], $item[$i])); } $h = 5 * $nb; //Page break needed? checkPageBreak($h); //Draw cells $pdf->SetFont('DejaVu', '', 9); for ($i = 0; $i < count($item); $i++) { $w = $table_col_width[$i]; $a = 'L'; //actual position $x = $pdf->GetX(); $y = $pdf->GetY(); //Draw $pdf->Rect($x, $y, $w, $h); //Write