getJournalResume(); $this->pdf->SetTitle($journal['titre']); $this->pdf->SetAuthor(utils::getJournalURL($this->id)); $this->pdf->AliasNbPages(); $this->pdf->SetCustomFooter('Helvetica', '', 9, $journal['titre'] . ' - ' . utils::getJournalURL($this->id) . ' - Page {current}'); $this->pdf->AddPage(); $this->pdf->SetY(120); $this->pdf->SetFont('Helvetica', 'B', 36); $this->pdf->MultiCell(0, 15, $journal['titre'], 0, 'C'); $this->pdf->Ln(); $this->pdf->SetFont('Courier', 'B', 12); $this->pdf->Cell(0, 6, utils::getJournalURL($this->id), 'T', 1, 'C', false, utils::getJournalURL($this->id)); $this->pdf->SetY(-30); $this->pdf->SetFont('Helvetica', '', 10); $this->pdf->Cell(0, 5, "Archive du journal au " . $this->dateFormat(time(), false), 0, 1, 'C'); $this->pdf->Ln(); $this->pdf->AddPage(); } protected function pdf_Ecrit() { $ecrit = $this->getEcrit(); if (!$ecrit) return false; // Sommaire par mois $m = date('Ym', $ecrit['date']); if ($m != $this->month) { $this->month = $m; $this->pdf->AddSummary(utils::frenchDateFormat('F Y', $ecrit['date']), 0); } $this->pdf->BeginBlock(); $this->pdf->SetFont('Helvetica', 'B', 20); $this->pdf->MultiCell(0, 10, $ecrit['titre'], 0, 'C'); $this->pdf->Ln(0); $this->pdf->SetFont('Helvetica', '', 11); $this->pdf->Cell(0, 6, $this->dateFormat($ecrit['date']), 'T', 1, 'C'); $this->pdf->Ln(5); $this->pdf->EndBlock(); // Ajoute l'écrit au sommaire $this->pdf->AddSummary(utils::frenchDateFormat('l j', $ecrit['date']) . ': ' . $ecrit['titre'], 1); preg_match_all('!]+src="([^"]+)"[^>]*>!', $ecrit['texte_html'], $match, PREG_SET_ORDER); foreach ($match as $img) { // Pas de gestion des images pour le moment c'est compliqué /* $src = $img[1]; // Pour les images distantes on charge pas n'importe quoi if (preg_match('!^https?://!', $src)) { $headers = @get_headers($src, true); if (!empty($headers['Content-Type']) && is_array($headers['Content-Type'])) { $headers['Content-Type'] = end($headers['Content-Type']); } if (!empty($headers['Content-Type']) && preg_match('!^image/(?:jpe?g|gif|png)$!i', $headers['Content-Type']) && !empty($headers['Content-Length']) && (int) $headers['Content-Length'] < 1000000) { continue; } unset($headers); } elseif (preg_match('!^/datas/documents/!', $src)) { $src = LENCRIER_DATA_ROOT . substr($src, 6); if (file_exists($src)) { $ecrit['texte_html'] = str_replace($img[0], '', $ecrit['texte_html']); continue; } } */ // Remplacement $ecrit['texte_html'] = str_replace($img[0], '', $ecrit['texte_html']); } $this->pdf->SetFont('Times', '', 12); $this->pdf->WriteHTML($ecrit['texte_html']); $this->pdf->Ln(16); return true; } public function export() { $path = LENCRIER_DATA_ROOT . '/documents/'.$this->id.'/export-journal-'.$this->id.'.pdf'; $this->pdf = new FPDF_Extended; $this->pdf->setCompression(true); $this->pdf_Header(); $this->pdf->StartPageNums(); $this->resetEcrits(); while ($this->pdf_Ecrit()) { continue; } $this->pdf->StopPageNums(); $this->pdf->RenderSummary(array( 'on_page' => 2, 'font' => 'Helvetica', 'title_label' => 'Sommaire des écrits', 'title_size' => 20, 'text_size' => 10, ) ); $this->pdf->Output($path); return true; } } ?>