You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
132 lines
4.0 KiB
HTML
132 lines
4.0 KiB
HTML
#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}|supprimer_timestamp|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|sinon{''}|extraire_attribut{src}|supprimer_timestamp|texte_script)';] //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 = '[(#VAL{articlepdf:copyright}|_T|pdf_first_clean|sinon{''}|texte_script)][(#NOM_SITE_SPIP|pdf_first_clean|supprimer_tags|sinon{''}|texte_script)][(#VAL{articlepdf:tous_droits_reserves}|_T|pdf_first_clean|sinon{''}|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_FPDF_LIB.'font');
|
|
include_spip(_DIR_FPDF_LIB.'fpdf');
|
|
include_spip('pdf/lib_pdf_global');
|
|
include_spip('pdf/lib_pdf_spip');
|
|
|
|
//--------------------------------
|
|
// Debut génération du PDF
|
|
//--------------------------------
|
|
$pdf=new PDF_SPIP();
|
|
$pdf->debug=$debug;
|
|
|
|
$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);
|
|
|
|
$lier_pdf = pipeline('build_pdf',array(
|
|
'args'=>array(
|
|
'objet' => 'article',
|
|
'id_objet' => $id_article,
|
|
'file_name' => $files_pdf
|
|
),
|
|
'data'=> $file_out,
|
|
));
|
|
|
|
}
|
|
|
|
$id_document = isset($lier_pdf['data'][$file_out]) ? $lier_pdf['data'][$file_out] : 0;
|
|
if($id_document > 0){
|
|
$file_out = '#URL_DOCUMENT{$id_document}';
|
|
}
|
|
|
|
// Vous voulez afficher un pdf
|
|
header("Content-type: application/pdf");
|
|
//Si on est en mutualisé avec masquages des vraies urls d'images
|
|
if (stripos($GLOBALS['spip_pipeline']['affichage_final'],'mutualisation_url_img_courtes')){
|
|
$file_out = str_replace(_DIR_IMG,_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES,$file_out);
|
|
}
|
|
// Affiche le PDF directement dans l'onglet de Firefox
|
|
header("location: ". url_de_base() . $file_out);
|
|
|
|
exit;
|