1 | <?php |
---|
2 | include_spip("inc/charsets") ; |
---|
3 | function spip_thelia_supprimer_balises_thelia($texte) { |
---|
4 | //suppression des boucles th�lia |
---|
5 | $texte = str_replace("THELIA_", "DUMMY_", $texte); |
---|
6 | //suppression des balises thelia |
---|
7 | $texte = str_replace("THELIA-", "DUMMY-", $texte); |
---|
8 | return $texte; |
---|
9 | } |
---|
10 | |
---|
11 | function spip_thelia_demarrer_session_thelia () { |
---|
12 | global $page; |
---|
13 | |
---|
14 | //sauvegarde des variables qui vont �tre modifi�es pour th�lia |
---|
15 | $sav_page = $page; |
---|
16 | $sav_session_navig_lang = $_SESSION['navig']->lang; |
---|
17 | |
---|
18 | //conflit sur la variable $page. |
---|
19 | $page = new stdclass; |
---|
20 | $page = ""; |
---|
21 | |
---|
22 | include_once("../classes/Navigation.class.php"); |
---|
23 | |
---|
24 | ini_set('arg_separator.output', '&'); |
---|
25 | ini_set("url_rewriter.tags","a=href,area=href,frame=src,iframe=src,input=src"); |
---|
26 | session_start(); |
---|
27 | } |
---|
28 | |
---|
29 | function spip_thelia_header_prive($flux) { |
---|
30 | //si une boite de s�lection spip/th�lia sera affich�e sur la page, il faut d�marrer pr�alablement une session th�lia |
---|
31 | $exec = $_REQUEST['exec']; |
---|
32 | $id_article= $_REQUEST['id_article']; |
---|
33 | $id_rubrique= $_REQUEST['id_rubrique']; |
---|
34 | if (function_exists('lire_config')) { |
---|
35 | if ($exec=='articles'){ |
---|
36 | if((lire_config("spip_thelia/produits_articles_spip_thelia", "non") == "oui")||(lire_config("spip_thelia/rubriques_articles_spip_thelia", "non") == "oui")) |
---|
37 | spip_thelia_demarrer_session_thelia(); |
---|
38 | } |
---|
39 | else if (($exec=='naviguer')&&($id_rubrique)){ |
---|
40 | if((lire_config("spip_thelia/produits_rubriques_spip_thelia", "non") == "oui")||(lire_config("spip_thelia/rubriques_rubriques_spip_thelia", "non") == "oui")) |
---|
41 | spip_thelia_demarrer_session_thelia(); |
---|
42 | } |
---|
43 | } |
---|
44 | |
---|
45 | |
---|
46 | //on restaure les variables session et request modifi�es pour les plugins suivants sur affichage final |
---|
47 | $page = $sav_page; |
---|
48 | $_SESSION['navig']->lang = $sav_session_navig_lang; |
---|
49 | |
---|
50 | if (function_exists('chemin')&&($_REQUEST['exec']!="articles")&&($_REQUEST['exec']!="naviguer")) { |
---|
51 | echo ("erreur : la fonction chemin() dans ecrire/inc/utils.php doit être mise en commentaire !"); |
---|
52 | } |
---|
53 | if (!file_exists("../fonctions/moteur.php")&&($_REQUEST['exec']!="")) |
---|
54 | echo ("erreur : thélia introuvable, vérifiez que les sous-répertoires de thélia et spip sont dans le même répertoire."); |
---|
55 | if (!function_exists('lire_config')) |
---|
56 | echo ("erreur : le plugin CFG est n'est pas installé."); |
---|
57 | return $flux; |
---|
58 | } |
---|
59 | |
---|
60 | function spip_thelia_insert_head($flux) { |
---|
61 | $flux.="<link rel=\"stylesheet\" href=\""._DIR_PLUGIN_SPIP_THELIA."spipthelia.css\" type=\"text/css\" media=\"projection, screen, tv\" />"; |
---|
62 | return $flux; |
---|
63 | } |
---|
64 | |
---|
65 | function spip_thelia_appeler_moteur_thelia($texte) { |
---|
66 | |
---|
67 | //si pas de boucle ou de balise th�lia dans la page on sort |
---|
68 | if ((strpos($texte, "THELIA-") === FALSE) && (strpos($texte, "<THELIA") == FALSE)) |
---|
69 | return $texte; |
---|
70 | |
---|
71 | //convertion utf-8 vers ISO des variables $_REQUEST |
---|
72 | $sauvegarde_request = array(); |
---|
73 | foreach ($_REQUEST as $clef => $valeur) { |
---|
74 | $sauvegarde_request[$clef] = $valeur; |
---|
75 | $_REQUEST[$clef]=unicode2charset(charset2unicode($valeur, 'utf-8'),'iso-8859-1'); |
---|
76 | } |
---|
77 | |
---|
78 | //parsonnalisation des variables th�lia |
---|
79 | switch($_REQUEST['page']){ |
---|
80 | case 'merci' : $securise=0; $pageret=0; $reset=1; break; |
---|
81 | case 'panier' : $securise=0; $pageret=1; break; |
---|
82 | case 'adresse' : $securise=1; $pageret=1; break; |
---|
83 | case 'cheque' : $securise=1; $pageret=1;$reset=1; break; |
---|
84 | case 'commande' : $securise=1; $pageret=1; $panier=1; $transport=1; break; |
---|
85 | case 'commande_detail' : $securise=1; break; |
---|
86 | case 'commande_visualiser' : $securise=1; break; |
---|
87 | case 'compte_modifier' : $formulaire=1; $securise=1; $obligetelfixe=1; break; |
---|
88 | case 'compte_modifiererr' : $formulaire=1; $securise=1; $obligetelfixe=1; break; |
---|
89 | case 'connexion' : $pageret=0; break; |
---|
90 | case 'livraison_adresse' : $securise=1; break; |
---|
91 | case 'livraison_modifier' : $securise=1; break; |
---|
92 | case 'moncompte' : $pageret=1; $securise=1; break; |
---|
93 | case 'nouveau' : $securise=1; break; |
---|
94 | case 'regret' : $pageret=1; break; |
---|
95 | case 'virement' : $securise=1; $pageret=1; $reset=1; break; |
---|
96 | } |
---|
97 | |
---|
98 | global $page, $res, $id_rubrique; |
---|
99 | |
---|
100 | //sauvegarde des variables qui vont �tre modifi�es pour th�lia |
---|
101 | $sav_page = $page; |
---|
102 | $sav_session_navig_lang = $_SESSION['navig']->lang; |
---|
103 | |
---|
104 | //conflit sur la variable $page. |
---|
105 | |
---|
106 | $page = new stdclass; |
---|
107 | $page = ""; |
---|
108 | |
---|
109 | |
---|
110 | include_once("classes/Navigation.class.php"); |
---|
111 | |
---|
112 | ini_set('arg_separator.output', '&'); |
---|
113 | ini_set("url_rewriter.tags","a=href,area=href,frame=src,iframe=src,input=src"); |
---|
114 | session_start(); |
---|
115 | |
---|
116 | //conflit entre spip et th�lia sur la langue en session. |
---|
117 | if ($_SESSION['navig']->lang != '') { |
---|
118 | $_SESSION['navig']->lang=0; |
---|
119 | } |
---|
120 | |
---|
121 | //concordance des langues entre spip et th�lia |
---|
122 | //modifiez �ventuellement la liste si vous avez ajout� de nouvelles langues dans Th�lia |
---|
123 | |
---|
124 | switch($_REQUEST['lang']) { |
---|
125 | case 'fr' : $_REQUEST['lang'] = 1; break; |
---|
126 | case 'en' : $_REQUEST['lang'] = 2; break; |
---|
127 | case 'es' : $_REQUEST['lang'] = 3; break; |
---|
128 | default: $_REQUEST['lang'] = 1; break; |
---|
129 | } |
---|
130 | |
---|
131 | //r�affectation des variables de th�lia qui ont �t�es renomm�es dans les squelettes pour �viter les conflits avec spip |
---|
132 | $_REQUEST['action'] = $_REQUEST['thelia_action']; |
---|
133 | $_REQUEST['page'] = $_REQUEST['page_thelia']; |
---|
134 | |
---|
135 | if (isset($_REQUEST['thelia_article'])) |
---|
136 | $_REQUEST['article'] = $_REQUEST['thelia_article']; |
---|
137 | |
---|
138 | //on pr�pare le flux � envoyer au moteur th�lia |
---|
139 | $res = $texte; |
---|
140 | $res = str_replace("THELIA-", "#", $res); |
---|
141 | |
---|
142 | //avant d'envoyer � th�lia, on convertie en iso pour th�lia |
---|
143 | if(lire_config("spip_thelia/encodage_spip_thelia", "non") == "oui") |
---|
144 | $res = unicode2charset(charset2unicode($res, 'utf-8'),'iso-8859-1'); |
---|
145 | |
---|
146 | //on bloque la sortie vers le navigateur le temps d'y faire quelques substitutions |
---|
147 | ob_start(); |
---|
148 | |
---|
149 | //si version >= 1.3.4 : plus de surcharge dans le plugin, on appelle directement le moteur de Th�lia |
---|
150 | include_once("fonctions/moteur.php"); |
---|
151 | |
---|
152 | //Connexion à SPIP à la création du compte Thelia |
---|
153 | if ($_GET['page'] == 'nouveau' || $_GET['page_thelia'] == 'nouveau') { |
---|
154 | if ($_SESSION['navig']->connecte == 1 && lire_config("spip_thelia/auth_unique_spip_thelia","non")=="oui") { |
---|
155 | include_spip('auth/thelia'); |
---|
156 | $auteur = creer_auteur_thelia( |
---|
157 | array( |
---|
158 | 'login'=>'', |
---|
159 | 'pass'=>'', |
---|
160 | 'client'=>$_SESSION['navig']->client |
---|
161 | ) |
---|
162 | ); |
---|
163 | $session = charger_fonction('session','inc'); |
---|
164 | $session($auteur); |
---|
165 | } |
---|
166 | } |
---|
167 | |
---|
168 | |
---|
169 | $texte = ob_get_contents(); |
---|
170 | ob_end_clean(); |
---|
171 | $texte = remplacement_sortie_thelia($texte); |
---|
172 | |
---|
173 | //au retour de th�lia, on convertie en utf8 pour SPIP |
---|
174 | if(lire_config("spip_thelia/encodage_spip_thelia", "non") == "oui") |
---|
175 | $texte = unicode2charset(charset2unicode($texte, 'iso-8859-1'),'utf-8'); |
---|
176 | |
---|
177 | //on restaure les variables session et request modifi�es pour les plugins suivants sur affichage final |
---|
178 | $page = $sav_page; |
---|
179 | $_SESSION['navig']->lang = $sav_session_navig_lang; |
---|
180 | |
---|
181 | //restauration des variables $_REQUEST en utf-8 pour SPIP |
---|
182 | foreach ($sauvegarde_request as $clef => $valeur) { |
---|
183 | $_REQUEST[$clef]=$valeur; |
---|
184 | } |
---|
185 | |
---|
186 | return ($texte); |
---|
187 | } |
---|
188 | |
---|
189 | function remplacement_sortie_thelia($in_thelia) { |
---|
190 | //renommage action en thelia_action. m�thode provisoire � revoir. |
---|
191 | $in_thelia = str_replace("adresse.php?action", "adresse.php?thelia_action", $in_thelia); |
---|
192 | $in_thelia = str_replace("cheque.php?action", "cheque.php?thelia_action", $in_thelia); |
---|
193 | $in_thelia = str_replace("commande.php?action", "commande.php?thelia_action", $in_thelia); |
---|
194 | $in_thelia = str_replace("commande_detail.php?action", "commande_detail.php?thelia_action", $in_thelia); |
---|
195 | $in_thelia = str_replace("commande_visualiser.php?action", "commande_visualiser.php?thelia_action", $in_thelia); |
---|
196 | $in_thelia = str_replace("compte_modifier.php?action", "compte_modifier.php?thelia_action", $in_thelia); |
---|
197 | $in_thelia = str_replace("compte_modifiererr.php?action", "compte_modifiererr.php?thelia_action", $in_thelia); |
---|
198 | $in_thelia = str_replace("connexion.php?action", "connexion.php?thelia_action", $in_thelia); |
---|
199 | $in_thelia = str_replace("creercompte.php?action", "creercompte.php?thelia_action", $in_thelia); |
---|
200 | $in_thelia = str_replace("formulerr.php?action", "formulerr.php?thelia_action", $in_thelia); |
---|
201 | $in_thelia = str_replace("imgpop?action", "imgpop?thelia_action", $in_thelia); |
---|
202 | $in_thelia = str_replace("livraison_adresse.php?action", "livraison_adresse.php?thelia_action", $in_thelia); |
---|
203 | $in_thelia = str_replace("mdpoublie.php?action", "mdpoublie.php?thelia_action", $in_thelia); |
---|
204 | $in_thelia = str_replace("merci.php?action", "merci.php?thelia_action", $in_thelia); |
---|
205 | $in_thelia = str_replace("moncompte.php?action", "moncompte.php?thelia_action", $in_thelia); |
---|
206 | $in_thelia = str_replace("nouveau.php?action", "nouveau.php?thelia_action", $in_thelia); |
---|
207 | $in_thelia = str_replace("panier.php?action", "panier.php?thelia_action", $in_thelia); |
---|
208 | $in_thelia = str_replace("produit.php?action", "produit.php?thelia_action", $in_thelia); |
---|
209 | $in_thelia = str_replace("regret.php?action", "regret.php?thelia_action", $in_thelia); |
---|
210 | $in_thelia = str_replace("virement.php?action", "virement.php?thelia_action", $in_thelia); |
---|
211 | |
---|
212 | return $in_thelia; |
---|
213 | } |
---|
214 | |
---|
215 | function spip_thelia_ajouter_boutons($boutons_admin) { |
---|
216 | // si on est admin |
---|
217 | if ($GLOBALS['connect_statut'] == "0minirezo") { |
---|
218 | // on voit le bouton dans la barre "naviguer" |
---|
219 | $boutons_admin['naviguer']->sousmenu['spip_thelia_catalogue']= new Bouton( |
---|
220 | _DIR_PLUGIN_SPIP_THELIA.'img_pack/logo_thelia_petit.png', 'Catalogue Thélia'); |
---|
221 | } |
---|
222 | return $boutons_admin; |
---|
223 | } |
---|
224 | |
---|
225 | function spip_thelia_affiche_milieu($flux) { |
---|
226 | $exec = $flux['args']['exec']; |
---|
227 | $id_article= $_REQUEST['id_article']; |
---|
228 | $id_rubrique= $_REQUEST['id_rubrique']; |
---|
229 | if (function_exists('lire_config')) { |
---|
230 | if ($exec=='articles'){ |
---|
231 | if((lire_config("spip_thelia/produits_articles_spip_thelia", "non") == "oui")||(lire_config("spip_thelia/rubriques_articles_spip_thelia", "non") == "oui")) |
---|
232 | $flux['data'] .= spip_thelia_formulaire_article($id_article, spip_thelia_article_editable($id_article),'articles'); |
---|
233 | } |
---|
234 | else if (($exec=='naviguer')&&($id_rubrique)){ |
---|
235 | if((lire_config("spip_thelia/produits_rubriques_spip_thelia", "non") == "oui")||(lire_config("spip_thelia/rubriques_rubriques_spip_thelia", "non") == "oui")) |
---|
236 | $flux['data'] .= spip_thelia_formulaire_rubrique($id_rubrique, spip_thelia_rubrique_editable($id_rubrique),'rubriques'); |
---|
237 | } |
---|
238 | } |
---|
239 | return $flux; |
---|
240 | } |
---|
241 | |
---|
242 | function spip_thelia_article_editable($id_article){ |
---|
243 | return autoriser('modifier','article',$id_article); |
---|
244 | } |
---|
245 | |
---|
246 | function spip_thelia_rubrique_editable($id_rubrique) { |
---|
247 | return autoriser('modifier','rubrique',$id_rubrique); |
---|
248 | } |
---|
249 | |
---|
250 | function spip_thelia_formulaire_article($id_article, $flag_editable, $script) { |
---|
251 | |
---|
252 | global $spip_lang_right; |
---|
253 | include_spip("inc/presentation"); |
---|
254 | include_spip('public/assembler'); |
---|
255 | include_spip('inc/charsets'); |
---|
256 | |
---|
257 | global $spip_lang_left, $spip_lang_right, $options; |
---|
258 | global $connect_statut, $options,$connect_id_auteur, $couleur_claire ; |
---|
259 | |
---|
260 | $out = "<div id='editer_produit-$id_article'>"; |
---|
261 | $out .= "<a name='produit'></a>"; |
---|
262 | |
---|
263 | // Quel est le bon titre |
---|
264 | if (lire_config("spip_thelia/produits_articles_spip_thelia", "non") != "oui") { |
---|
265 | $titre = _T('spipthelia:rubriques_associees_article'); |
---|
266 | } elseif (lire_config("spip_thelia/rubriques_articles_spip_thelia", "non") != "oui") { |
---|
267 | $titre = _T('spipthelia:produits_associes_article'); |
---|
268 | } else { |
---|
269 | $titre = _T('spipthelia:produits_et_rubriques_associes_article'); |
---|
270 | } |
---|
271 | |
---|
272 | if (function_exists('bouton_block_depliable')) { // SPIP2.0 |
---|
273 | if ($flag_editable) { |
---|
274 | if (_request('edit')||_request('neweven')) |
---|
275 | $bouton = bouton_block_depliable($titre,true,"produitsarticle"); |
---|
276 | else |
---|
277 | $bouton = bouton_block_depliable($titre,false,"produitsarticle"); |
---|
278 | } |
---|
279 | $out .= debut_cadre_enfonce("../"._DIR_PLUGIN_SPIP_THELIA."/img_pack/logo_thelia_petit.png", true, "", $bouton); |
---|
280 | |
---|
281 | } else { |
---|
282 | if (_request('edit')||_request('neweven')) |
---|
283 | $bouton = bouton_block_visible("produitsarticle").$titre; |
---|
284 | else |
---|
285 | $bouton = bouton_block_invisible("produitsarticle").$titre; |
---|
286 | $out .= debut_cadre_enfonce("../"._DIR_PLUGIN_SPIP_THELIA."/img_pack/logo_thelia_petit.png", true, "", $bouton); |
---|
287 | |
---|
288 | // |
---|
289 | // Afficher les produits associes |
---|
290 | // |
---|
291 | $out .= afficher_rubriques_objet('article',$id_rubrique); |
---|
292 | |
---|
293 | $out .= afficher_produits_objet('article',$id_article); |
---|
294 | |
---|
295 | $out .= debut_block_invisible('produitsarticle'); |
---|
296 | } |
---|
297 | |
---|
298 | |
---|
299 | |
---|
300 | $link = generer_action_auteur('produits_article',"$id_article",generer_url_ecrire('articles','id_article='.$id_article)); |
---|
301 | $out .= "<form method='POST' action='$link'>\n"; |
---|
302 | $out .= form_hidden($link); |
---|
303 | |
---|
304 | //masquer provisoirement les warning de session de Th�lia en attendant une correction |
---|
305 | //Th�lia retourne des warning de session (headers already sent) car elle d�marre trop tard, mais on ne l'utilise pas, on se contente de lister les produits |
---|
306 | $sav_error_reporting = error_reporting(E_ERROR); |
---|
307 | |
---|
308 | //on bloque la sortie vers le navigateur le temps d'y faire quelques substitutions |
---|
309 | $res = recuperer_fond("fonds/produits_associes_article",array("id_article" => $id_article)); |
---|
310 | $res = str_replace("THELIA-", "#", $res); |
---|
311 | |
---|
312 | //avant d'envoyer � th�lia, on convertie en iso pour th�lia |
---|
313 | $res = unicode2charset(charset2unicode($res, 'utf-8'),'iso-8859-1'); |
---|
314 | ob_start(); |
---|
315 | chdir('..'); |
---|
316 | include_once("fonctions/moteur.php"); |
---|
317 | chdir('ecrire'); |
---|
318 | $texte = ob_get_contents(); |
---|
319 | ob_end_clean(); |
---|
320 | $texte = remplacement_sortie_thelia($texte); |
---|
321 | |
---|
322 | //au retour de th�lia, on convertit en utf8 pour SPIP |
---|
323 | if (!is_utf8($texte)) $texte = unicode2charset(charset2unicode($texte, 'iso-8859-1'),'utf-8'); |
---|
324 | $out .= $texte; |
---|
325 | |
---|
326 | //remettre le niveau d'erreur pr�c�dent |
---|
327 | error_reporting($sav_error_reporting); |
---|
328 | |
---|
329 | $out .= "</form>\n"; |
---|
330 | |
---|
331 | $out .= fin_block(); |
---|
332 | |
---|
333 | $out .= fin_cadre_enfonce(true); |
---|
334 | $out .= "</div><br/>"; |
---|
335 | return $out; |
---|
336 | } |
---|
337 | |
---|
338 | function spip_thelia_formulaire_rubrique($id_rubrique, $flag_editable, $script) { |
---|
339 | |
---|
340 | global $spip_lang_right; |
---|
341 | include_spip("inc/presentation"); |
---|
342 | include_spip('public/assembler'); |
---|
343 | include_spip('inc/charsets'); |
---|
344 | |
---|
345 | global $spip_lang_left, $spip_lang_right, $options; |
---|
346 | global $connect_statut, $options,$connect_id_auteur, $couleur_claire ; |
---|
347 | |
---|
348 | // Quel est le bon titre |
---|
349 | if (lire_config("spip_thelia/produits_rubriques_spip_thelia", "non") != "oui") { |
---|
350 | $titre = _T('spipthelia:rubriques_associees_rubrique'); |
---|
351 | } elseif (lire_config("spip_thelia/rubriques_rubriques_spip_thelia", "non") != "oui") { |
---|
352 | $titre = _T('spipthelia:produits_associes_rubrique'); |
---|
353 | } else { |
---|
354 | $titre = _T('spipthelia:produits_et_rubriques_associes_rubrique'); |
---|
355 | } |
---|
356 | |
---|
357 | $out = "<div id='editer_produit-$id_rubrique'>"; |
---|
358 | $out .= "<a name='produit'></a>"; |
---|
359 | if (function_exists('bouton_block_depliable')) { // SPIP2.0 |
---|
360 | if ($flag_editable) { |
---|
361 | if (_request('edit')||_request('neweven')) |
---|
362 | $bouton = bouton_block_depliable($titre,true,"produitsrubrique"); |
---|
363 | else |
---|
364 | $bouton = bouton_block_depliable($titre,false,"produitsrubrique"); |
---|
365 | } |
---|
366 | $out .= debut_cadre_enfonce("../"._DIR_PLUGIN_SPIP_THELIA."/img_pack/logo_thelia_petit.png", true, "", $bouton); |
---|
367 | |
---|
368 | } else { |
---|
369 | if (_request('edit')||_request('neweven')) |
---|
370 | $bouton = bouton_block_visible("produitsrubrique").$titre; |
---|
371 | else |
---|
372 | $bouton = bouton_block_invisible("produitsrubrique").$titre; |
---|
373 | $out .= debut_cadre_enfonce("../"._DIR_PLUGIN_SPIP_THELIA."/img_pack/logo_thelia_petit.png", true, "", $bouton); |
---|
374 | |
---|
375 | // |
---|
376 | // Afficher les produits associes |
---|
377 | // |
---|
378 | $out .= afficher_rubriques_objet('rubrique',$id_rubrique); |
---|
379 | |
---|
380 | $out .= afficher_produits_objet('rubrique',$id_rubrique); |
---|
381 | |
---|
382 | $out .= debut_block_invisible('produitsrubrique'); |
---|
383 | } |
---|
384 | |
---|
385 | |
---|
386 | |
---|
387 | $link = generer_action_auteur('produits_rubrique',"$id_rubrique",generer_url_ecrire('naviguer&id_rubrique='.$id_rubrique,"",false,true)); |
---|
388 | $out .= "<form method='POST' action='$link'>\n"; |
---|
389 | $out .= form_hidden($link); |
---|
390 | |
---|
391 | //masquer provisoirement les warning de session de Th�lia en attendant une correction |
---|
392 | //Th�lia retourne des warning de session (headers already sent) car elle d�marre trop tard, mais on ne l'utilise pas, on se contente de lister les produits |
---|
393 | $sav_error_reporting = error_reporting(E_ERROR); |
---|
394 | |
---|
395 | //on bloque la sortie vers le navigateur le temps d'y faire quelques substitutions |
---|
396 | $res = recuperer_fond("fonds/produits_associes_rubrique",array("id_rubrique" => $id_rubrique)); |
---|
397 | $res = str_replace("THELIA-", "#", $res); |
---|
398 | |
---|
399 | //avant d'envoyer � th�lia, on convertie en iso pour th�lia |
---|
400 | $res = unicode2charset(charset2unicode($res, 'utf-8'),'iso-8859-1'); |
---|
401 | ob_start(); |
---|
402 | chdir('..'); |
---|
403 | include_once("fonctions/moteur.php"); |
---|
404 | chdir('ecrire'); |
---|
405 | $texte = ob_get_contents(); |
---|
406 | ob_end_clean(); |
---|
407 | $texte = remplacement_sortie_thelia($texte); |
---|
408 | |
---|
409 | //au retour de th�lia, on convertit en utf8 pour SPIP |
---|
410 | if (!is_utf8($texte)) $texte = unicode2charset(charset2unicode($texte, 'iso-8859-1'),'utf-8'); |
---|
411 | $out .= $texte; |
---|
412 | |
---|
413 | //remettre le niveau d'erreur pr�c�dent |
---|
414 | error_reporting($sav_error_reporting); |
---|
415 | |
---|
416 | $out .= "</form>\n"; |
---|
417 | |
---|
418 | $out .= fin_block(); |
---|
419 | $out .= fin_cadre_enfonce(true); |
---|
420 | $out .= "</div><br/>"; |
---|
421 | return $out; |
---|
422 | } |
---|
423 | |
---|
424 | function afficher_produits_objet($type, $id) { |
---|
425 | |
---|
426 | if (!preg_match(',^[a-z]*$,',$type)) return ''; |
---|
427 | |
---|
428 | $result = determiner_produits_objet($type,$id); |
---|
429 | if (!spip_num_rows($result)) return ''; |
---|
430 | |
---|
431 | $table = array(); |
---|
432 | |
---|
433 | while ($row = spip_fetch_array($result)) { |
---|
434 | $vals = array(); |
---|
435 | if (!is_utf8($row['titre'])) $row['titre'] = unicode2charset(charset2unicode($row['titre'], 'iso-8859-1'),'utf-8'); |
---|
436 | |
---|
437 | $puce = ($row['ligne'])?find_in_path('images/puce-verte.gif'):find_in_path('images/puce-orange.gif'); |
---|
438 | $etat = ($row['ligne'])?_T('spipthelia:produit_en_ligne'):_T('spipthelia:produit_non_publie'); |
---|
439 | $url = generer_url_ecrire('spip_thelia_catalogue','thelia_url='.urlencode('produit_modifier.php?ref='.$row['ref'].'&rubrique='.$row['rubrique'])); |
---|
440 | $link = "<a class='product_details' href='%s' target='_blank'>%s</a>"; |
---|
441 | |
---|
442 | $vals[] = sprintf($link,$url,"<img src='$puce' alt='$etat'/>"); |
---|
443 | $vals[] = sprintf($link,$url,$row['titre']); |
---|
444 | $vals[] = sprintf(number_format($row['prix'],2)); |
---|
445 | |
---|
446 | $table[] = $vals; |
---|
447 | } |
---|
448 | |
---|
449 | $largeurs = array('14', '', '', '', '', ''); |
---|
450 | $styles = array('arial11', 'arial2', 'arial11', 'arial11', 'arial11', 'arial1'); |
---|
451 | |
---|
452 | $t = afficher_liste($largeurs, $table, $styles); |
---|
453 | if ($spip_display != 4) |
---|
454 | $t = $tranches |
---|
455 | . "<table width='100%' cellpadding='3' cellspacing='0' border='0'>" |
---|
456 | . "<thead><tr><th> </th><th>". _T('spipthelia:nom_du_produit'). "</th><th>". _T('spipthelia:prix'). "</th></tr></head><tbody>" |
---|
457 | . $t |
---|
458 | . "</tbody></table>"; |
---|
459 | return "<div class='liste'>$t</div>\n"; |
---|
460 | } |
---|
461 | |
---|
462 | function determiner_produits_objet($type, $id) { |
---|
463 | $les_produits = array(); |
---|
464 | if (!preg_match(',^[a-z]*$,',$type)) return $les_produits; |
---|
465 | |
---|
466 | $result = spip_query("SELECT titre,ref,prix,ligne,rubrique |
---|
467 | FROM spip_produits_{$type}s |
---|
468 | JOIN produit ON produit.id = spip_produits_{$type}s.id_produit |
---|
469 | JOIN produitdesc ON produitdesc.id = spip_produits_{$type}s.id_produit |
---|
470 | WHERE id_{$type}="._q($id)); |
---|
471 | |
---|
472 | return $result; |
---|
473 | } |
---|
474 | |
---|
475 | function afficher_rubriques_objet($type, $id) { |
---|
476 | |
---|
477 | if (!preg_match(',^[a-z]*$,',$type)) return ''; |
---|
478 | |
---|
479 | $result = determiner_rubriques_objet($type,$id); |
---|
480 | if (!spip_num_rows($result)) return ''; |
---|
481 | |
---|
482 | $table = array(); |
---|
483 | |
---|
484 | while ($row = spip_fetch_array($result)) { |
---|
485 | $vals = array(); |
---|
486 | if (!is_utf8($row['titre'])) $row['titre'] = unicode2charset(charset2unicode($row['titre'], 'iso-8859-1'),'utf-8'); |
---|
487 | |
---|
488 | $puce = ($row['ligne'])?find_in_path('images/puce-verte.gif'):find_in_path('images/puce-orange.gif'); |
---|
489 | $etat = ($row['ligne'])?_T('spipthelia:rubrique_en_ligne'):_T('spipthelia:rubrique_non_publiee'); |
---|
490 | $url = generer_url_ecrire('spip_thelia_catalogue','thelia_url='.urlencode('parcourir.php?parent='.$row['rubrique'])); |
---|
491 | $link = "<a class='product_details' href='%s' target='_blank'>%s</a>"; |
---|
492 | |
---|
493 | $vals[] = sprintf($link,$url,"<img src='$puce' alt='$etat'/>"); |
---|
494 | $vals[] = sprintf($link,$url,$row['titre']); |
---|
495 | |
---|
496 | $table[] = $vals; |
---|
497 | } |
---|
498 | |
---|
499 | $largeurs = array('14', '', '', '', '', ''); |
---|
500 | $styles = array('arial11', 'arial2', 'arial11', 'arial11', 'arial11', 'arial1'); |
---|
501 | |
---|
502 | $t = afficher_liste($largeurs, $table, $styles); |
---|
503 | if ($spip_display != 4) |
---|
504 | $t = $tranches |
---|
505 | . "<table width='100%' cellpadding='3' cellspacing='0' border='0'>" |
---|
506 | . "<thead><tr><th> </th><th>". _T('spipthelia:nom_de_la_rubrique'). "</th></tr></head><tbody>" |
---|
507 | . $t |
---|
508 | . "</tbody></table>"; |
---|
509 | return "<div class='liste'>$t</div>\n"; |
---|
510 | } |
---|
511 | |
---|
512 | function determiner_rubriques_objet($type, $id) { |
---|
513 | $les_produits = array(); |
---|
514 | if (!preg_match(',^[a-z]*$,',$type)) return $les_produits; |
---|
515 | |
---|
516 | $result = spip_query("SELECT titre,ligne,rubrique |
---|
517 | FROM spip_rubriquesthelia_{$type}s |
---|
518 | JOIN rubrique ON rubrique.id = spip_rubriquesthelia_{$type}s.id_rubriquethelia |
---|
519 | JOIN rubriquedesc ON rubriquedesc.rubrique = spip_rubriquesthelia_{$type}s.id_rubriquethelia |
---|
520 | WHERE id_{$type}="._q($id)); |
---|
521 | |
---|
522 | return $result; |
---|
523 | } |
---|
524 | |
---|
525 | ?> |
---|