1 | <?php |
---|
2 | |
---|
3 | /******************************************************************************************/ |
---|
4 | /* SPIP-listes est un système de gestion de listes d'information par email pour SPIP */ |
---|
5 | /* Copyright (C) 2004 Vincent CARON v.caron<at>laposte.net , http://bloog.net */ |
---|
6 | /* */ |
---|
7 | /* Ce programme est libre, vous pouvez le redistribuer et/ou le modifier selon les termes */ |
---|
8 | /* de la Licence Publique Générale GNU publiée par la Free Software Foundation */ |
---|
9 | /* (version 2). */ |
---|
10 | /* */ |
---|
11 | /* Ce programme est distribué car potentiellement utile, mais SANS AUCUNE GARANTIE, */ |
---|
12 | /* ni explicite ni implicite, y compris les garanties de commercialisation ou */ |
---|
13 | /* d'adaptation dans un but spécifique. Reportez-vous à la Licence Publique Générale GNU */ |
---|
14 | /* pour plus de détails. */ |
---|
15 | /* */ |
---|
16 | /* Vous devez avoir reçu une copie de la Licence Publique Générale GNU */ |
---|
17 | /* en même temps que ce programme ; si ce n'est pas le cas, écrivez à la */ |
---|
18 | /* Free Software Foundation, */ |
---|
19 | /* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, États-Unis. */ |
---|
20 | /******************************************************************************************/ |
---|
21 | |
---|
22 | if (!defined("_ECRIRE_INC_VERSION")) return; |
---|
23 | |
---|
24 | include_spip('inc/presentation'); |
---|
25 | include_spip('inc/distant'); |
---|
26 | include_spip('inc/affichage'); |
---|
27 | include_spip('inc/meta'); |
---|
28 | include_spip('inc/filtres'); |
---|
29 | include_spip('inc/lang'); |
---|
30 | |
---|
31 | function exec_import_patron(){ |
---|
32 | |
---|
33 | $id_message = _request('id_message'); |
---|
34 | $patron = _request('patron'); |
---|
35 | $date = _request('date'); |
---|
36 | $changer_lang = _request('changer_lang'); |
---|
37 | |
---|
38 | $lang = (isset($changer_lang)) ? $changer_lang : $GLOBALS['spip_lang'] ; |
---|
39 | |
---|
40 | $nomsite=lire_meta("nom_site"); |
---|
41 | $message_texte =''; |
---|
42 | $texte_patron = ''; |
---|
43 | |
---|
44 | # ATENTION : une image erronnee dans le patron sous la forme <img src='' /> |
---|
45 | # provoque un deuxieme hit sur cet exec, mais sans argument patron |
---|
46 | # il ne faut pas ecraser la nl avec la page 404 dans ce cas ! |
---|
47 | if ($patron) { |
---|
48 | include_spip('public/assembler'); |
---|
49 | $contexte_patron = array('date' => $date,'patron'=>$patron,'lang'=>$lang); |
---|
50 | |
---|
51 | if (find_in_path('patrons/'.$patron.'_texte.html')){ |
---|
52 | $patron_version_texte = true ; |
---|
53 | $message_texte = recuperer_fond('patrons/'.$patron.'_texte', $contexte_patron); |
---|
54 | } |
---|
55 | // Il faut utiliser recuperer_page et non recuperer_fond car sinon les url des articles |
---|
56 | // sont sous forme privee : spip.php?action=redirect&.... horrible ! |
---|
57 | // pour utiliser recuperer_fond,il faudrait etre ici dans un script action |
---|
58 | //$texte_patron = recuperer_fond('patrons/'.$patron, $contexte_patron); |
---|
59 | $url = generer_url_public('patron_switch','',true); |
---|
60 | foreach ($contexte_patron as $k=>$v) |
---|
61 | $url = parametre_url($url,$k,$v,'&'); |
---|
62 | $texte_patron = recuperer_page($url) ; |
---|
63 | |
---|
64 | // passer tout ca en unicode pour eviter certains problemes |
---|
65 | include_spip('inc/charsets'); |
---|
66 | $texte_patron = charset2unicode($texte_patron); |
---|
67 | } |
---|
68 | |
---|
69 | $titre_patron = _T('spiplistes:lettre_info')." ".$nomsite; |
---|
70 | |
---|
71 | $titre = $titre_patron; |
---|
72 | $texte = $texte_patron; |
---|
73 | $message_texte = $message_texte; |
---|
74 | |
---|
75 | if((strlen($texte) > 10)) |
---|
76 | spip_query("UPDATE spip_courriers SET titre="._q($titre).", texte="._q($texte).", message_texte="._q($message_texte)." WHERE id_courrier="._q($id_message)); |
---|
77 | else |
---|
78 | $message_erreur = _T('spiplistes:patron_erreur'); |
---|
79 | |
---|
80 | $nomsite=lire_meta("nom_site"); |
---|
81 | $charset = lire_meta('charset'); |
---|
82 | |
---|
83 | echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"; |
---|
84 | echo "<html lang='$lang' dir='ltr'>"; |
---|
85 | echo "<head><meta http_equiv='Content-Type' content='text/html; charset=".$charset."'></head><body>\n"; |
---|
86 | |
---|
87 | echo "<div style='float:right;width:200px;text-align:left;border:1px solid #000;background: yellow;color: #000;margin-bottom: 10px;padding:10px;'>"; |
---|
88 | echo "<p><strong>$patron</strong><p>\n"; |
---|
89 | if($patron_version_texte) echo _T('spiplistes:patron_detecte'); |
---|
90 | echo _T('spiplistes:date_ref').": $date<br />"; |
---|
91 | |
---|
92 | echo menu_langues('changer_lang', $lang , _T('spiplistes:langue') ,'', generer_url_ecrire('import_patron','id_message='.$id_message.'&patron='.$patron.'&date='.$date ) ); |
---|
93 | |
---|
94 | echo "<br /><form action='?exec=courrier_edit&id_message=$id_message' method='post'>\n"; |
---|
95 | echo "<input type='submit' name='Valider' value='"._T('spiplistes:confirmer')."' class='fondo'>\n"; |
---|
96 | echo "<a href='?exec=courrier_edit&id_message=$id_message'>"._T('spiplistes:retour_link')."</a><br />\n"; |
---|
97 | echo "</form>"; |
---|
98 | echo "</div>"; |
---|
99 | |
---|
100 | echo "<div style='text-align:left;margin-right:250px;border-right:2px outset #000000'>"; |
---|
101 | echo spiplistes_propre($texte_patron).$message_erreur; |
---|
102 | |
---|
103 | $contexte_pied = array('lang'=>$lang); |
---|
104 | $texte_pied = recuperer_fond('modeles/piedmail', $contexte_pied); |
---|
105 | |
---|
106 | echo $texte_pied; |
---|
107 | echo "</div>"; |
---|
108 | |
---|
109 | echo "</body></html>"; |
---|
110 | } |
---|
111 | |
---|
112 | ?> |
---|