You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
129 lines
4.0 KiB
129 lines
4.0 KiB
#CACHE{0} |
|
<?php |
|
|
|
//au choix, selon le cas (voir les avantages et les inconvéniants de chaque selon le site): |
|
$path_pdf = sous_repertoire(_DIR_IMG, "article_PDF"); //stockage sous le dossier IMG |
|
|
|
// Mode release => $debug=0 |
|
// Mode debug => $debug=1 (ne fonctionne pas sous Internet Explorer)=> ??? si, ça fonctionne ! |
|
$debug=1; |
|
|
|
<B_principale> |
|
<BOUCLE_principale(RUBRIQUES){id_rubrique}> |
|
|
|
$conf_url_site = '[(#URL_SITE_SPIP|texte_script)]' ; |
|
$conf_nom_site = '[(#NOM_SITE_SPIP|pdf_first_clean|texte_script)]' ; |
|
|
|
// Recuperation et definition des differents elements |
|
|
|
$site='[(#NOM_SITE_SPIP|pdf_first_clean|texte_script)]'; |
|
$rubrique='[(#NOM_SITE_SPIP|pdf_first_clean|texte_script)]'; |
|
$DateParution='[(#DATE_REDAC|affdate|pdf_first_clean|texte_script)]'; |
|
$DateMiseEnLigne='[(#DATE|nom_jour|texte_script)] [(#DATE|affdate|pdf_first_clean|texte_script)]'; |
|
|
|
$yahoo='-<BOUCLE_yahoo(HIERARCHIE){id_rubrique}> [(#TITRE|pdf_first_clean|texte_script)] - </BOUCLE_yahoo>'; |
|
|
|
$logo_site='[(#LOGO_SITE_SPIP|extraire_attribut{src}|texte_script)]'; |
|
// attention à l'ordre des filtres SPIP |
|
// [$logo_fichier='(#LOGO_ARTICLE_RUBRIQUE|extraire_attribut{src}|texte_script)';] ne fonctionne pas |
|
[$logo_fichier='(#LOGO_ARTICLE_RUBRIQUE|texte_script|extraire_attribut{src})';] //fonctionne correctement |
|
// [$logo_lien="(#URL_ARTICLE)";] |
|
|
|
[$titre='(#TITRE|pdf_first_clean|texte_script)';] |
|
[$descriptif='(#DESCRIPTIF|pdf_first_clean|texte_script)';] |
|
$texte= texte_script( |
|
pdf_first_clean( |
|
recuperer_fond('noisettes/aff_rub_complet_texte',array('id_rubrique' => '#ID_RUBRIQUE')) |
|
) |
|
); |
|
|
|
$copyright = '[(#REM|texte{'Copyright (c) '}|pdf_first_clean|texte_script)][(#NOM_SITE_SPIP|pdf_first_clean|texte_script)][(#REM|texte{'\nTous droits réservés'}|pdf_first_clean|texte_script)]'; |
|
|
|
$id_rubrique = "#ID_RUBRIQUE"; |
|
|
|
|
|
$url_rubrique = generer_url_entite($id_rubrique,'rubrique'); |
|
if (strpos($url_rubrique,'?')===FALSE){ |
|
$p = strrpos($url_rubrique,'.'); |
|
if ($p!==FALSE) |
|
$url_rubrique = substr($url_rubrique,0,$p); |
|
$files_pdf = $url_rubrique.".pdf"; |
|
} |
|
else |
|
$files_pdf = "rubrique_".$id_rubrique.".pdf" ; |
|
$file_out = $path_pdf . $files_pdf ; |
|
|
|
if (file_exists($file_out)) |
|
{ |
|
clearstatcache; |
|
$damo = date(YmdHi , strtotime("#DATE_MODIF")) ; |
|
$dage = date(YmdHi , filemtime($file_out)) ; |
|
if ($damo > $dage) |
|
{ |
|
unlink($file_out); |
|
} |
|
} |
|
|
|
</BOUCLE_principale> |
|
</B_principale> |
|
header("Location: index.php"); |
|
exit; |
|
<//B_principale> |
|
|
|
if ($debug == 1 && file_exists($file_out)) |
|
{ |
|
unlink($file_out); |
|
} |
|
|
|
if (!file_exists($file_out)) |
|
{ |
|
|
|
//define('FPDF_FONTPATH',_DIR_PLUGIN_ARTICLE_PDF.'/font/'); |
|
include_spip('pdf/fpdf'); |
|
include_spip('pdf/lib_pdf_global'); |
|
include_spip('pdf/lib_pdf_spip'); |
|
|
|
//-------------------------------- |
|
// Debut génération du PDF |
|
//-------------------------------- |
|
$pdf->debug=$debug; |
|
$pdf=new PDF_SPIP(); |
|
|
|
$pdf->SetCompression(false); |
|
$pdf->SetDisplayMode(fullpage, single ); |
|
|
|
// haut, gauche, bas, droite |
|
$pdf->SetAllMargins(12,15,12,10); |
|
|
|
$pdf->SetTitle($titre); |
|
$pdf->SetCreator($site); |
|
$pdf->SetCopyright($copyright); |
|
$pdf->SetSubject($rubrique); |
|
$pdf->SetKeywords($motsclef); |
|
|
|
$pdf->Build($file_out); |
|
|
|
} |
|
|
|
// Vous voulez afficher un pdf |
|
header("Content-type: application/pdf"); |
|
if ($debug==1) |
|
{ |
|
// Affiche le PDF directement dans l'onglet de Firefox |
|
// Ne fonctionne pas sous IE 6 SP2 : le pdf n'est pas reconnu (pris pour un fichier texte) |
|
header("location: ". url_de_base() . $file_out); |
|
} |
|
else |
|
{ |
|
// Il sera nommé $files_pdf |
|
// ATTENTION : pour "filename", mettre un nom de fichier court (<nom>.<extension>) |
|
// sinon IE 6 SP2 ne reconnaîtra pas le type de fichier |
|
// Semble poser problème sous IE6 SP1 |
|
// Ah, Microsoft, je vous jure ! |
|
header('Content-Disposition: attachment; filename=' . $files_pdf); |
|
|
|
// Le source du PDF original.pdf |
|
readfile($file_out); |
|
} |
|
|
|
exit;
|
|
|