forked from davidlhoumaud/plxMyShop
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplxMyShop.php
1940 lines (1798 loc) · 81.1 KB
/
plxMyShop.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php if (!defined('PLX_ROOT')) exit;
/**
* Plugin plxMyShop
* Compatible urlRewrite & Multilingue
* @author David L
**/
class plxMyShop extends plxPlugin {
const V = '0.13.1';#$this->getInfo('version') is empty in public mode
public $plugName;
public $aProds = array(); # Tableau de tous les produits
public $donneesModeles = array();
public $plxMotor;
public $cheminImages;
public $idProduit;
public $shortcode = 'boutonPanier';
public $shortcodeactif = false;
public $shipOverload = false;
public $dLang = '';
# plxMyMultilingue
public $lang = '';
public $aLangs = false;
public function onUpdate(){#mise a jour du cache des css
return array('cssCache' => true);
}
public function __construct($default_lang){
if(defined('PLX_MYMULTILINGUE')) {# Si plugin plxMyMultilingue présent
$lang = plxMyMultiLingue::_Lang();# récupération de la langue en cours
if(!empty($lang)) {
if(isset($_SESSION['default_lang']) AND $_SESSION['default_lang']!=$lang) {
$this->lang = $lang.'/';
}
}
$lang = plxMyMultiLingue::_Langs();# récupération du tableau des langues activées
$this->aLangs = empty($lang) ? $this->aLangs : explode(',', $lang);
}
# appel du constructeur de la classe plxPlugin (obligatoire)
parent::__construct($default_lang);
$this->dLang = $default_lang;#fix $plugin->default_lang protected in admin plx.5.2
$this->plugName = $this->plug['name'];# or get_class($this);
# Accès au menu admin réservé au profil administrateur et gestionnaire
$this->setAdminProfil(PROFIL_ADMIN, PROFIL_MANAGER);
# droits pour accèder à la page config.php du plugin
$this->setConfigProfil(PROFIL_ADMIN);
# Personnalisation du menu admin
$this->setAdminMenu(
($this->getParam('shop_name') !== "" ? $this->getParam('shop_name') : "MyShop")
, 5
, $this->getLang('L_ADMIN_MENU_TOOTIP') . ' v' . self::V
);
#hook PluXml : core/lib/class.plx.motor.php
$this->addHook('plxMotorPreChauffageBegin', 'plxMotorPreChauffageBegin');
if(defined('PLX_ADMIN')) {#Déclaration des hooks pour la zone d'administration
$this->addHook('AdminPrepend', 'AdminPrepend');
$this->addHook('AdminTopBottom', 'AdminTopBottom');
$this->addHook('AdminTopEndHead', 'AdminTopEndHead');
}
else{#Déclaration des hooks pour la partie visiteur
#hook PluXml
$this->addHook('plxMotorParseArticle', 'plxMotorParseArticle');
$this->addHook('plxShowStaticListEnd', 'plxShowStaticListEnd');
$this->addHook('plxShowConstruct', 'plxShowConstruct');
$this->addHook('plxShowMeta', 'plxShowMeta');
$this->addHook('plxShowPageTitle', 'plxShowPageTitle');
$this->addHook('plxShowStaticContent', 'plxShowStaticContent');
$this->addHook('SitemapStatics', 'SitemapStatics');
$this->addHook('ThemeEndBody', 'ThemeEndBody');
$this->addHook('ThemeEndHead', 'ThemeEndHead');
#hook plxMyShop
$this->addHook('plxMyShopEditProductBegin', 'changeStock');
$this->addHook('plxMyShopShippingMethod', 'plxMyShopShippingMethod');
$this->addHook('plxMyShopShowMiniPanier', 'plxMyShopShowMiniPanier');
$this->addHook('plxMyShopPanierFin', 'inlineBasketJs');
if($this->getParam('delivery_date')){
$this->addHook('plxMyShopPanierFin', 'inlineDeliverydateJs');
$this->addHook('ThemeEndHead', 'themeEndHeadDeliverydateJs');
}
if($this->getParam('localStorage')){#MyshopCookie
$this->addHook('plxMyShopPanierCoordsMilieu', 'inlineLocalStorageHtml');
$this->addHook('plxMyShopPanierFin', 'inlineLocalStorageJs');
}
if($this->getParam('cookie')){#MyshopCookie
$this->addHook('Index', 'Index');
$this->addHook('IndexEnd', 'IndexEnd');
}
}
#Ajout de variables non protégé facilement accessible via $(plxShow->)plxMotor->plxPlugins->aPlugins['plxMyShop']->aConf['racine_XXX'] dans les themes ou dans d'autres plugins.
$this->aConf['racine_products'] = (!$this->getParam('racine_products')?'data/products/':$this->getParam('racine_products'));
$this->aConf['racine_commandes'] = (!$this->getParam('racine_commandes')?'data/commandes/':$this->getParam('racine_commandes'));
if($this->aLangs && !empty($default_lang)){
$this->aConf['racine_products_lang'] = $this->aConf['racine_products'].$default_lang.'/';
$this->aConf['racine_commandes_lang'] = $this->aConf['racine_commandes'].$default_lang.'/';
}
$this->getProducts();
if (!is_dir(PLX_ROOT.$this->aConf['racine_commandes'])){
mkdir(PLX_ROOT.$this->aConf['racine_commandes'], 0755, true);
}
if (!is_file(PLX_ROOT.$this->aConf['racine_commandes'].'index.html')){
$mescommandeindex = fopen(PLX_ROOT.$this->aConf['racine_commandes'].'index.html', 'w+');
fclose($mescommandeindex);
}
# Créer les dossiers de sauvegarde si MyMultilingue
if($this->aLangs){
foreach ($this->aLangs as $lang){
if (!is_dir(PLX_ROOT.$this->aConf['racine_commandes'].$lang.'/')){
mkdir(PLX_ROOT.$this->aConf['racine_commandes'].$lang.'/', 0755, true);
}
if (!is_file(PLX_ROOT.$this->aConf['racine_commandes'].$lang.'/index.html')){
$mescommandeindex = fopen(PLX_ROOT.$this->aConf['racine_commandes'].$lang.'/index.html', 'w+');
fclose($mescommandeindex);
}
}
}
# méthodes de paiement
$tabMethodespaiement = array(
"cheque" => array(
"libelle" => $this->getLang('L_PAYMENT_CHEQUE') ,
"codeOption" => "payment_cheque",
),
"cash" => array(
"libelle" => $this->getLang('L_PAYMENT_CASH') ,
"codeOption" => "payment_cash",
),
"paypal" => array(
"libelle" => $this->getLang('L_PAYMENT_PAYPAL'),
"codeOption" => "payment_paypal",
),
);
$tabChoixMethodespaiement = array();
foreach ($tabMethodespaiement as $codeMethodespaiement => $m){
if ("1" === $this->getParam($m["codeOption"])){
$tabChoixMethodespaiement[$codeMethodespaiement] = $m;
}
}
$this->donneesModeles["tabChoixMethodespaiement"] = $tabChoixMethodespaiement;
# Mise a jour des variables de sessions du panier
if (isset($_SESSION[$this->plugName]['prods'])){#si on a des produits dans la sessions
foreach ($_SESSION[$this->plugName]['prods'] as $pId => $nb) {#on boucle dessus
# Si Produit désactivé/supprimé/indisponible(noAddCartButton) entre temps
if (!isset($this->aProds[$this->default_lang][$pId]) OR $this->aProds[$this->default_lang][$pId]['active']==0 OR $this->aProds[$this->default_lang][$pId]['noaddcart']==1){
$_SESSION[$this->plugName]['ncart'] -= $nb;#on recalcule le nb de prod
unset($_SESSION[$this->plugName]['prods'][$pId]);#on efface sa variable de session
}
}
# supprimer par mini panier
if(isset($_POST['remProd']) && !empty($_POST['idP']) && isset($_SESSION[$this->plugName]["prods"][$_POST['idP']])){
$_SESSION[$this->plugName]['ncart'] -= $_SESSION[$this->plugName]['prods'][$_POST['idP']];#on recalcule le nb de prod
unset($_SESSION[$this->plugName]["prods"][$_POST['idP']]);#on efface sa variable de session
}
}
# var_dump($this->lang,$this->aLangs,$this->default_lang);
}
/**
* hook plxShow->pageTitle($format='',$sep=";")
* Méthode qui affiche le titre de la page selon le mode
**/
public function plxShowPageTitle() {
if($this->plxMotor->mode == 'product') {
$affiche = "<?php
\$aProd = \$this->plxMotor->plxPlugins->aPlugins['".$this->plugName."']->aProds[ '".$this->default_lang."' ][ '".$this->idProduit."' ];#langue de session (a ajouté & ailleurs i think)
\$title_htmltag = \$aProd['title_htmltag'];
\$title = \$title_htmltag !='' ? \$title_htmltag : \$aProd['name'];
\$subtitle = \$this->plxMotor->aConf['title'];
\$fmt = '';
if(preg_match('/'.\$this->plxMotor->mode.'\s*=\s*(.*?)\s*('.\$sep.'|\$)/i',\$format,\$capture)) {
\$fmt = trim(\$capture[1]);
}
\$format = \$fmt=='' ? '#title - #subtitle' : \$fmt;
\$txt = str_replace('#title', trim(\$title), \$format);
\$txt = str_replace('#subtitle', trim(\$subtitle), \$txt);
echo plxUtils::strCheck(trim(\$txt, ' - '));
return true; ?>";#stop hooked func
echo $affiche;
}
elseif($this->plxMotor->mode == 'boutique') {#panier
echo $this->getLang('L_PUBLIC_BASKET').' - ';
}
}
/**
* hook plxMotor->meta($meta='')
* Méthode qui affiche le meta passé en paramètre
**/
public function plxShowMeta() {
if($this->plxMotor->mode == 'product') {
$affiche = "<?php
\$aProd = \$this->plxMotor->plxPlugins->aPlugins['".$this->plugName."']->aProds[ '".$this->default_lang."' ][ '".$this->idProduit."' ];
if(!empty(\$aProd['meta_'.\$meta]))
echo '<meta name=\"'.\$meta.'\" content=\"'.plxUtils::strCheck(\$aProd['meta_'.\$meta]).'\" />'.PHP_EOL;
elseif(!empty(\$this->plxMotor->aConf['meta_'.\$meta]))
echo '<meta name=\"'.\$meta.'\" content=\"'.plxUtils::strCheck(\$this->plxMotor->aConf['meta_'.\$meta]).'\" />'.PHP_EOL;
return true; ?>";#stop hooked func
echo $affiche;
}
}
/**
* Méthode d'ajout des <link rel="alternate"... sur les pages
*
**/
public function ThemeEndHead() {
if($this->aLangs) {
$affiche = '<?php'.PHP_EOL;
if($this->plxMotor->get=='boutique/panier' || preg_match("#product([0-9]+)/?([a-z0-9-]+)?#", $this->plxMotor->get)) {
foreach($this->aLangs as $k=>$v) {
$url_lang = ($_SESSION['default_lang']!=$v)?$v.'/':'';
$affiche .= 'echo "\t<link rel=\"alternate\" hreflang=\"'.$v.'\" href=\"".$plxMotor->urlRewrite("?'.$url_lang.$this->plxMotor->get.'")."\" />\n";';
}
$affiche .= ' ?>';
echo $affiche;
}
}
}
/**
* Méthode qui charge le code css nécessaire à la gestion de onglet dans l'écran de configuration du plugin
*
* @return stdio
* @author Stephane F
**/
public function AdminTopEndHead() {
if (((basename($_SERVER['SCRIPT_NAME'])=='plugin.php' || basename($_SERVER['SCRIPT_NAME'])=='parametres_plugin.php')) && (isset($_GET['p']) && $_GET['p']==$this->plugName)) {
echo '<link rel="stylesheet" type="text/css" href="'.PLX_PLUGINS.$this->plugName.'/css/administration.css?v='.self::V.'" />'.PHP_EOL;
if($this->aLangs)
echo '<link rel="stylesheet" type="text/css" href="'.PLX_PLUGINS.$this->plugName.'/css/tabs.css?v='.self::V.'" />'.PHP_EOL;
echo '<noscript><style>.hide{display:inherit !important;}</style></noscript>'.PHP_EOL;
echo '<?php '; ?>
if ((isset($plxAdmin->version) && version_compare($plxAdmin->version, "5.3.1", "<=")))#$plxMotor/$plxAdmin->version removed in 5.5
echo '<link rel="stylesheet" type="text/css" href="'.PLX_PLUGINS.'<?php echo $this->plugName ?>/css/5.6.css" />'.PHP_EOL;
<?php echo ' ?>';
}
}
public function plxMyShopShowMiniPanier(){
$class = $this->plxMotor->get=='boutique/panier'?'active':'noactive';
?>
<h3<?php if ($class=="active") echo' class="red"'; ?>>
<span><img src="<?php echo PLX_PLUGINS.$this->plugName; ?>/icon.png" style="float:left;"></span> <?php $this->lang('L_PUBLIC_BASKET'); ?></h3>
<?php
if (isset($_SESSION[$this->plugName]["ncart"]) && $_SESSION[$this->plugName]["ncart"]>0 && !empty($_SESSION[$this->plugName]["prods"])){
echo '<ul class="cat-list unstyled-list">'.PHP_EOL;
foreach($_SESSION[$this->plugName]["prods"] as $k => $v){
echo '<li>
<form method="POST" id="FormRemProd'.$k.'" class="formRemProd">
<input type="hidden" name="idP" value="'.htmlspecialchars($k).'" />
<sub><input class="miniDel badge red" type="submit" id="remProd'.$k.'" name="remProd" value="-" title="'.$this->getLang('L_PUBLIC_DEL_BASKET').'"/></sub>
</form>
<a href="'.$this->productRUrl($k).'">'.$this->aProds[$this->default_lang][$k]['name'].'</a><sup><span class="badge">'.$v.'</span></sup></li>'.PHP_EOL;
}
echo '</ul>
<p>'.($class!="active"?'<a class="button blue" href="'.$this->plxMotor->urlRewrite('?'.$this->lang.'boutique/panier#panier').'" title="'.$this->getLang('L_PUBLIC_BASKET_MINI_TITLE').'">'.$this->getLang('L_PUBLIC_BASKET_MINI').'</a>':'').'</p>'.PHP_EOL;
}else{
echo '<ul class="lastart-list unstyled-list"><li><em>'.$this->getLang('L_PUBLIC_NOPRODUCT').'</em></li></ul>';
}
}
public function ThemeEndBody(){
echo '<?php if($plxMotor->mode == "product" || strstr($plxMotor->template,"boutique") || $plxMotor->plxPlugins->aPlugins["'.$this->plugName.'"]->shortcodeactif ){ ?>';
#javascript de bascule des boutons produits
?>
<script type="text/javascript">function chngNbProd(e,t){var a=document.getElementById("addProd"+e),d=document.getElementById("nbProd"+e);"<?php echo $this->getLang('L_PUBLIC_ADD_BASKET'); ?>"!=a.value&&(d.value==d.getAttribute("data-o")||0==d.value?(t&&(d.value="0"),a.value="<?php echo $this->getLang('L_PUBLIC_DEL_BASKET'); ?>",a.setAttribute("class","red")):(a.value="<?php echo $this->getLang('L_PUBLIC_MOD_BASKET'); ?>",a.setAttribute("class","orange")))}</script>
<?php
echo '<?php } ?>';# fi if mode product || strstr template boutique || shrotcode
if (isset($_SESSION[$this->plugName]["msgProdUpDate"]) && $_SESSION[$this->plugName]["msgProdUpDate"]){
unset($_SESSION[$this->plugName]["msgProdUpDate"]);
#Les messages de MAJ panier
?>
<div id="msgUpDateCart"><?php ((isset($_SESSION[$this->plugName]['prods']) && $_SESSION[$this->plugName]['prods'])?$this->lang('L_PUBLIC_MSG_BASKET_UP'):$this->lang('L_PUBLIC_NOPRODUCT')); ?></div>
<script type="text/javascript">
var msgUpDateCart = document.getElementById("msgUpDateCart");
msgUpDateCart.style.display = "block";
setTimeout(function(){document.getElementById("msgUpDateCart").style.display = "none"; }, 3000);
var shoppingCart = null;
</script>
<?php }# fi Les messages de MAJ panier
}#end ThemeEndBody
public function IndexEnd(){#MyshopCookie
$string = '
/* MyShopCookie IndexEnd hook */';
if(isset($_SESSION[$this->plugName]["prods"])){
# localhost pour test ou véritable domaine ?
$domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false;
# Durée de vie cookie = fin de session par défaut
$temps_du_cookie = 0;
# Durée de vie du cookie = 2 mois si au moins un produit dans le panier
if (isset($_SESSION[$this->plugName]["ncart"]) && $_SESSION[$this->plugName]["ncart"]>0)
$temps_du_cookie = time() + 3600 * 24 * 30 * 2;
$string .= '
if(isset($_SESSION["'.$this->plugName.'"])){
$cookie_path = "/";
$cookie_domain = "'.$domain.'";
$cookie_secure = 0;
$cookie_expire = '.$temps_du_cookie.';
$cookie_value["prods"]=preg_replace("/[^0-9]/","",$_SESSION["'.$this->plugName.'"]["prods"]);
$cookie_value["ncart"]=intval($_SESSION["'.$this->plugName.'"]["ncart"]);
if (version_compare(PHP_VERSION, "5.2.0", ">="))
setcookie("'.$this->plugName.'", json_encode($cookie_value), $cookie_expire, $cookie_path, $cookie_domain, $cookie_secure, true);
else
setcookie("'.$this->plugName.'", serialize($cookie_value), $cookie_expire, $cookie_path."; HttpOnly", $cookie_domain, $cookie_secure);
}';
}
echo "<?php ".$string." ?>";
}
public function Index(){#MyshopCookie
$string = '
/* MyShopCookie Index hook */
if(!empty($_COOKIE["'.$this->plugName.'"]) && !isset($_SESSION["IS_NOT_NEW"])) {
if (version_compare(PHP_VERSION, "5.2.0", ">="))
$cookie_value = json_decode($_COOKIE["'.$this->plugName.'"],true);
else
$cookie_value = unserialize($_COOKIE["'.$this->plugName.'"]);
$_SESSION["'.$this->plugName.'"]["prods"] = preg_replace("/[^0-9]/","",$cookie_value["prods"]);
$_SESSION["'.$this->plugName.'"]["ncart"] = intval($cookie_value["ncart"]);
}
$_SESSION["IS_NOT_NEW"]=true;';
echo "<?php ".$string." ?>";
}
#hook des boutons localStorage du formulaire pour les clients au milieu du Panier
public function inlineLocalStorageHtml(){#MyshopCookie ?>
<p><span id="bouton_sauvegarder"> </span> <span id="bouton_effacer"> </span> <span id="bouton_raz"> </span></p>
<p id="alerte_sauvegarder" class="alert green" style="display:none;"> </p>
<?php
}
#hook js localStorage du formulaire pour les clients à la fin du Panier
public function inlineLocalStorageJs(){#MyshopCookie ?>
<script type="text/JavaScript">
if (window.localStorage){
function lsTest(){
var test = "test";
try {
localStorage.setItem(test, test);
localStorage.removeItem(test);
return true;
} catch(e) {
return false;
}
}
if(lsTest() === true){
function stock(){
document.getElementById("bouton_effacer").style.display = "";
document.getElementById("bouton_sauvegarder").style.display = "none";
var temp = {
firstname:document.getElementById("firstname").value,
lastname:document.getElementById("lastname").value,
email:document.getElementById("email").value,
tel:document.getElementById("tel").value,
adress:document.getElementById("adress").value,
postcode:document.getElementById("postcode").value,
city:document.getElementById("city").value,
country:document.getElementById("country").value,
};
localStorage.setItem("Shop_Deliver_Adress", JSON.stringify(temp));
document.getElementById("alerte_sauvegarder").innerHTML = "<?php echo $this->lang('L_ADDRESS_SAVED'); ?><br /><?php echo $this->lang('L_DO_NOT_SHARED'); ?>";
document.getElementById("alerte_sauvegarder").style.display = "block";
setTimeout(function(){
document.getElementById("alerte_sauvegarder").style.display = "none"; }, 3000);
}
function clear(){
document.getElementById("bouton_effacer").style.display = "none";
document.getElementById("bouton_sauvegarder").style.display = "";
localStorage.removeItem("Shop_Deliver_Adress");
document.getElementById("alerte_sauvegarder").innerHTML = "<?php echo $this->lang('L_ADDRESS_DELETED'); ?>";
document.getElementById("alerte_sauvegarder").style.display = "block";
setTimeout(function(){
document.getElementById("alerte_sauvegarder").style.display = "none"; }, 3000);
}
function raz(){
clear();
document.getElementById("firstname").value = "";
document.getElementById("lastname").value = "";
document.getElementById("email").value = "";
document.getElementById("tel").value = "";
document.getElementById("adress").value = "";
document.getElementById("postcode").value = "";
document.getElementById("city").value = "";
document.getElementById("country").value = "";
}
function detail(event){
if (event.target.id != 'id_deliverydate' && event.target.id != 'nomCadeau')//not #datepicker & #nomCadeau
if (event.target.type == "text" || event.target.type == "email"){
document.getElementById("bouton_effacer").style.display = "none";
document.getElementById("bouton_sauvegarder").style.display = "";
}
}
var gm = JSON.parse(localStorage.getItem("Shop_Deliver_Adress"));
if (gm != null){
document.getElementById("firstname").value = gm["firstname"];
document.getElementById("lastname").value = gm["lastname"];
document.getElementById("email").value = gm["email"];
document.getElementById("tel").value = gm["tel"];
document.getElementById("adress").value = gm["adress"];
document.getElementById("postcode").value = gm["postcode"];
document.getElementById("city").value = gm["city"];
document.getElementById("country").value = gm["country"];
}
var bouton_un = document.getElementById("bouton_sauvegarder");
var input_un = document.createElement("input");
input_un.setAttribute("name","SaveAdress");
input_un.setAttribute("value","<?php echo $this->lang('L_SAVE_MY_ADDRESS'); ?>");
input_un.setAttribute("type","button");
input_un.addEventListener("click",stock, false);
var bouton_deux = document.getElementById("bouton_effacer");
input_deux = document.createElement("input");
input_deux.setAttribute("name","ClearAdress");
input_deux.setAttribute("value","<?php echo $this->lang('L_DELETE_MY_ADDRESS'); ?>");
input_deux.setAttribute("type","button");
input_deux.addEventListener("click",clear, false);
var bouton_raz = document.getElementById("bouton_raz");
input_raz = document.createElement("input");
input_raz.setAttribute("name","RAZAdresse");
input_raz.setAttribute("value","<?php echo $this->lang('L_RESET_ADDRESS'); ?>");
input_raz.setAttribute("type","button");
input_raz.addEventListener("click",raz, false);
var form_client = document.getElementById("formcart");
form_client.addEventListener("change",detail, false);
if (gm != null)
bouton_un.style.display = "none";
else
bouton_deux.style.display = "none";
bouton_un.appendChild(input_un);
bouton_deux.appendChild(input_deux);
bouton_raz.appendChild(input_raz);
}
}
</script>
<?php
}
#hook js du Panier
public function inlineBasketJs(){ ?>
<script type="text/JavaScript">
<?php
echo '<?php
if ($nprod > 0 ) echo "var error=true;\n";
else echo "var error=false;\n";
?>';
?>
var total=0;
var totalkg=0;
var shippingPrice=0;
var nprod=0;
var realnprod=0;
var formCart=document.getElementById('formcart');
var shoppingCart=document.getElementById('shoppingCart');
var btnCart=document.getElementById('btnCart');
var msgCart=document.getElementById('msgCart');
var PRODS=document.getElementById('prodsCart');
var idSuite=document.getElementById('idsuite');
var numCart=document.getElementById('numcart');
var mailCart=document.getElementById('email');
var firstnameCart=document.getElementById('firstname');
var lastnameCart=document.getElementById('lastname');
var adressCart=document.getElementById('adress');
var postcodeCart=document.getElementById('postcode');
var cityCart=document.getElementById('city');
var countryCart=document.getElementById('country');
var telCart=document.getElementById('tel');
var msgCart=document.getElementById('msgCart');
var totalCart=document.getElementById('totalCart');
var totalcommand=document.getElementById('totalcommand');
var shipping=document.getElementById('shipping');
var shipping_kg=document.getElementById('shipping_kg');
var spanshipping=document.getElementById('spanshipping');
if (error) {
PRODS.value=shoppingCart.innerHTML;
formcart.style.display='inline-block';
mailCart.value="<?php echo (isset($_POST['email'])?$_POST['email']:''); ?>";
firstnameCart.value="<?php echo (isset($_POST['firstname'])?preg_replace('/\"/','\\\"',$_POST['firstname']):''); ?>";
lastnameCart.value="<?php echo (isset($_POST['lastname'])?preg_replace('/\"/','\\\"',$_POST['lastname']):''); ?>";
adressCart.value="<?php echo (isset($_POST['adress'])?preg_replace('/\"/','\\\"',$_POST['adress']):''); ?>";
postcodeCart.value="<?php echo (isset($_POST['postcode'])?preg_replace('/\"/','\\\"',$_POST['postcode']):''); ?>";
cityCart.value="<?php echo (isset($_POST['city'])?preg_replace('/\"/','\\\"',$_POST['city']):''); ?>";
countryCart.value="<?php echo (isset($_POST['country'])?preg_replace('/\"/','\\\"',$_POST['country']):''); ?>";
telCart.value="<?php echo (isset($_POST['tel'])?preg_replace('/\"/','\\\"',$_POST['tel']):''); ?>";
msgCart.value="<?php echo (isset($_POST['msg'])?preg_replace('/\"/','\\\"',$_POST['msg']):''); ?>";
idSuite.value="<?php echo (isset($_SESSION[$this->plugName]["ncart"])?$_SESSION[$this->plugName]["ncart"]:""); ?>";
numCart.value="<?php echo (isset($_SESSION[$this->plugName]["ncart"])?$_SESSION[$this->plugName]["ncart"]:""); ?>";
nprod=<?php echo (isset($_SESSION[$this->plugName]["ncart"])?(int)$_SESSION[$this->plugName]["ncart"]:0); ?>;
realnprod=<?php echo (isset($_SESSION[$this->plugName]["ncart"])?(int)$_SESSION[$this->plugName]["ncart"]:0); ?>;
totalcommand.value = "<?php echo '<?php echo $this->pos_devise($totalpricettc+$totalpoidgshipping); ?>'; ?>";//total
}
</script>
<?php
}
#hook js du Panier
public function inlineDeliverydateJs(){
#disallowed Dates
$dDates = array();
$disallowedDates = $this->getParam('delivery_disallowed_dates');
$disallowedDates = explode(',', $disallowedDates);
foreach($disallowedDates AS $dDate){
$dDate = explode('_', trim($dDate));#Found range by _
if(isset($dDate[1])){#create range days
$dFrom = explode('-',$dDate[0]);#YYYY MM DD
$dTo = explode('-',$dDate[1]);#YYYY MM DD
$year = $dFrom[0];
$month = $dFrom[1];
$day = $dFrom[2];
while($year <= $dTo[0]){
while($month <= 12){
while($day <= 31){
$dDay = $year.'-'.str_pad($month, 2, '0', STR_PAD_LEFT).'-'.str_pad($day, 2, '0', STR_PAD_LEFT);
$dDates[] = $dDay;
if($dDay == $dDate[1]){#day == last day
break(2);
}
$day++;
#checkdate ( int $month , int $day , int $year )
if(!checkdate($month, $day ,$year)){
$day = 1;
break;
}
}
$day = 1;
$month++;
if($month > 12){
$month = 1;
break;
}
}
$year++;
}
}else{#classic (one day)
$dDates[] = $dDate[0];
}
}#hcaerof
$disallowedDates = array();#clear
foreach($dDates AS $dDate){
$disallowedDates[] = $dDate;#date + range
}
$disallowedDates = "['" . implode("','", $disallowedDates) . "']";
#disalowed days of week
$delivery_day = $this->getParam('delivery_day');#v0.13.2
$delivery_day_js = '';
if(!!$delivery_day AND $delivery_day != '1,1,1,1,1,1,1'){#weekday (if 1 or more not open)
$delivery_js = '';
$delivery_day = explode(',',$delivery_day);#v0.13.2
foreach($delivery_day AS $day => $v){
if(!$v){#closed weekday
$delivery_js .= 'case '.$day.':';#add js case
}
}
$delivery_day_js = 'if(!outDate)switch(theDate.getDay()){'.$delivery_js.'outDate=!0;break;}'.PHP_EOL;#js switch
}
?>
<script type="text/javascript">
var mindays = <?php echo $this->getParam('delivery_nb_days'); ?>;
var today = new Date();
var nextdelivery = new Date();
nextdelivery.setDate(today.getDate() + mindays);
<?php echo $this->default_lang!='en' ? "moment.locale('".$this->default_lang."');" : ''; ?>
var dDates = [];
var disallowedDates = <?php echo $disallowedDates ?>;
for(var dd = 0; dd < disallowedDates.length; dd++){
var tDate = new Date(disallowedDates[dd] + 'T00:00:00');
if(tDate.toString() != 'Invalid Date')
dDates[dd] = tDate.toISOString().split('T')[0];
}
var picker_date = new Pikaday(
{
disableDayFn: function(theDate) {//inspired by idea of ppmt
var outDate = theDate.toISOString().split('T')[0];
outDate = (dDates.indexOf(outDate) != -1);//only select day
<?php echo $delivery_day_js?>
return outDate;
},
field: document.getElementById('id_deliverydate'),
format: '<?php $this->lang("L_FORMAT_PIKADAY"); ?>',
<?php if($this->default_lang!='en')$this->lang("L_I18N_PIKADAY"); ?>
firstDay: 1,
minDate: nextdelivery,
maxDate: new Date(<?php echo (date('Y')+3) ?>, 12, 31),
yearRange: [<?php echo date('Y') ?>,<?php echo (date('Y')+3) ?>],
onSelect: function() {
var date = document.createTextNode(this.getMoment() + ' ');
}
}
);
</script>
<?php
}
#hook js du Panier
public function themeEndHeadDeliverydateJs(){ ?>
<link rel="stylesheet" href="<?php echo $this->plxMotor->racine . PLX_PLUGINS;?>plxMyShop/css/pikaday.css" media="screen"/>
<script type='text/javascript' src='<?php echo $this->plxMotor->racine . PLX_PLUGINS;?>plxMyShop/js/moment<?php echo $this->default_lang!='en' ? '-with-locales' : ''; ?>.min.js'></script>
<script type='text/javascript' src='<?php echo $this->plxMotor->racine . PLX_PLUGINS;?>plxMyShop/js/pikaday.js'></script>
<?php
}
public function productNumber(){
return $this->idProduit;
}
#Change (') simple quote ' to Right single quotation mark ’ ’ ::: http://ascii-code.com/
static function apostrophe($str){
return str_replace(chr(39),'’',$str);#tips iso = chr(146)
}
/**
* Méthode de traitement du hook plxShowConstruct
* @return stdio
* @author Stephane F, Thomas Ingles
**/
public function plxShowConstruct(){
if (isset($this->aProds[$this->default_lang][$this->productNumber()]['name'])){
# infos sur la page statique
$string = "if(\$this->plxMotor->mode=='product'){";
$string .= " \$this->plxMotor->cible = rtrim(\$this->plxMotor->cible,'form');";#remove "form" in static filename ;)
$string .= " \$array = array();";
$string .= " \$array[\$this->plxMotor->cible] = array(
'name' => '" . $this->aProds[$this->default_lang][$this->productNumber()]["name"] . "',
'menu' => '',
'url' => '/template/affichageProduitPublic',
'readable' => 1,
'active' => 1,
'group' => ''
);";
$string .= " \$this->plxMotor->aStats = array_merge(\$this->plxMotor->aStats, \$array);";
$string .= "}";
echo "<?php ".$string." ?>";
}
}
public function AdminPrepend(){
$this->plxMotor = plxAdmin::getInstance();
if (isset($this->plxMotor->aConf['images'])){
# jusqu'à la version 5.3.1
$this->cheminImages = $this->plxMotor->aConf['images'];
} else {
$this->cheminImages = $this->plxMotor->aConf['medias'];
}
}
/**
* Méthode qui affiche un message si l'adresse email du contact n'est pas renseignée ou si la langue est absente
*
* @return stdio
* @author Stephane F
**/
public function AdminTopBottom() {
echo '<?php
if($plxAdmin->plxPlugins->aPlugins["'.$this->plugName.'"]->getParam("email")=="") {
echo "<p class=\"warning\">Plugin MyShop<br />'.$this->getLang("L_ERR_EMAIL").'</p>";
plxMsg::Display();
}
$file = PLX_PLUGINS."plxMyShop/lang/".$plxAdmin->aConf["default_lang"].".php";
if(!file_exists($file)) {
echo "<p class=\"warning\">Plugin MyShop<br />".sprintf("'.$this->getLang('L_LANG_UNAVAILABLE').'", $file)."</p>";
plxMsg::Display();
}
if(strstr($plxAdmin->get,"'.$this->plugName.'")) echo \'<noscript><p class="warning">Oups! No JS</p></noscript>\';
?>';
}
public function plxMotorParseArticle() {# 4 shortcode in article [boutonPanier ###]
echo "<?php";
?>
if(get_class($this)=='plxMotor'){#only 4 public page!
$plxPlugin = $this->plxPlugins->aPlugins['<?php echo $this->plugName; ?>'];
if(!empty($art['chapo']))
$art['chapo'] = $plxPlugin->traitementPageStatique($art['chapo']);
$art['content'] = $plxPlugin->traitementPageStatique($art['content']);
unset($plxPlugin);
}
?>
<?php
}
public function plxShowStaticContent(){
echo "<?php";
?>
$plxPlugin = $this->plxMotor->plxPlugins->aPlugins['<?php echo $this->plugName; ?>'];
$output = $plxPlugin->traitementPageStatique($output);
unset($plxPlugin);
?>
<?php
}
public function traitementPageStatique($output){# 4 shortcode in static [boutonPanier ###]
preg_match_all("!\\[{$this->shortcode} (.*)\\]!U", $output, $resultat);
if (0 < count($resultat[1])){
$this->shortcodeactif = true;
$resultat[1] = array_unique($resultat[1]);
$tabCodes = array();
$tabRemplacement = array();
$this->donneesModeles["plxPlugin"] = $this;
foreach ($resultat[1] as $codeProduit){
$tabCodes[] = "[{$this->shortcode} $codeProduit]";
ob_start();
$this->donneesModeles["k"] = $codeProduit;
$this->modele("espacePublic/boucle/produitRubrique");
$tabRemplacements[] = ob_get_clean();
}
$output = str_replace($tabCodes, $tabRemplacements, $output);
ob_start();
if (in_array(
$this->getParam("affPanier")
, array("basPage", "partout")
)
){
$_SESSION[$this->plugName]['msgCommand']="";
$this->validerCommande();
$this->modele("espacePublic/panier");
}
//~ else {
//~ $this->modele("espacePublic/ajoutProduit");
//~ }
$output .= ob_get_clean();
}
return $output;
}
/**
* Méthode qui effectue une analyse de la situation et détermine
* le mode à appliquer. Cette méthode alimente ensuite les variables
* de classe adéquates
* @return null
* @author Anthony GUÉRIN, Florent MONTHEL, Stéphane F
**/
public function plxMotorPreChauffageBegin(){
$this->plxMotor = plxMotor::getInstance();
# Hook Plugins
eval($this->plxMotor->plxPlugins->callHook("plxMyShop_debut"));
$media = 'medias';
if (isset($this->plxMotor->aConf['images'])) $media = 'images';# jusqu'à la version 5.3.1
$this->cheminImages = $this->plxMotor->aConf[$media];
$nomPlugin = __CLASS__;
# contrôleur des pages du plugin
if (preg_match("/boutique\/panier/",$this->plxMotor->get)){
$classeVue = "panier";
require_once "classes/vues/$classeVue.php";
$this->vue = new $classeVue();
$this->vue->plxPlugin = $this;
$this->vue->traitement();
$this->plxMotor->mode = "boutique";
$this->plxMotor->cible = $nomPlugin.'/';
$this->plxMotor->template = $this->getParam("template");
$this->plxMotor->aConf["racine_statiques"] = $this->plxMotor->aConf['racine_plugins'];
$this->plxMotor->aStats[$this->plxMotor->cible] = array(
"name" => $this->vue->titre(),
"url" => "/template/vue",#maybe in old pluxml add slash "$nomPlugin/template/vue" ?
"active" => 1,
"menu" => "non",
"readable" => 1,
"title_htmltag" => "",
);
echo "<?php return TRUE;?>";
}
# pages des produits et des catégories
elseif ($this->plxMotor->get AND preg_match("~^".str_replace('/','\\/',$this->lang)."product([0-9]+)\/?([a-z0-9-]+)?~", $this->plxMotor->get, $capture)){
$this->idProduit = str_pad($capture[1], 3, "0", STR_PAD_LEFT);
if(!isset($this->aProds[$this->default_lang][$this->productNumber()]) OR !$this->aProds[$this->default_lang][$this->productNumber()]['active']){
$this->plxMotor->error404(L_ERR_PAGE_NOT_FOUND);
}else{
if(isset($capture[2]) AND $this->aProds[$this->default_lang][$this->productNumber()]['url']==$capture[2]){
$template = $this->aProds[$this->default_lang][$this->productNumber()]["template"] === ""
? $this->getParam('template')
: $this->aProds[$this->default_lang][$this->productNumber()]["template"];
$this->plxMotor->mode = "product";
$this->plxMotor->aConf["racine_statiques"] = "";
$this->plxMotor->cible = "{$this->plxMotor->aConf["racine_plugins"]}$nomPlugin/form";#maybe in old pluxml add slash "/$nomPlugin/form" ?
$this->plxMotor->template = $template;
echo "<?php return TRUE;?>";
}else{
$this->redir301($this->plxMotor->urlRewrite('?product'.intval($this->idProduit).'/'.$this->aProds[$this->default_lang][$this->productNumber()]['url']));
}
}
}
}
/**
* Méthode qui fait une redirection de type 301
* Venant de PluXml 5.6 (garde compat 5.4 & 5.5)
* @return null
* @author Stephane F
**/
public function redir301($url) {
if(method_exists($this->plxMotor,'redir301'))#PluXml 5.6+
$this->plxMotor->redir301($url);
header('Status: 301 Moved Permanently', false, 301);
header('Location: '.$url);
exit;
}
/**
* Méthode qui référence les produits dans le sitemap
* @return stdio
* @author David.L
**/
public function SitemapStatics(){
if (isset($this->aProds[$this->default_lang]) && is_array($this->aProds[$this->default_lang])){
foreach($this->aProds[$this->default_lang] as $key => $value){
if ($value['active']==1 && $value['readable']==1):
echo '<?php
echo PHP_EOL;
echo "\t<url>\n";
echo "\t\t<loc>".$plxMotor->urlRewrite("?'.$this->lang.'product'.intval($key).'/'.$value['url'].'")."</loc>\n";
echo "\t\t<lastmod>'.date('Y-m-d').'</lastmod>\n";
echo "\t\t<changefreq>daily</changefreq>\n";
echo "\t\t<priority>0.8</priority>\n";
echo "\t</url>\n";
?>';
endif;
}
}
}
/**
* Méthode qui parse le fichier les produits et alimente
* le tableau aProds
* @param filename emplacement du fichier XML des produits
* @return null
* @author David.L
**/
public function getProducts($filename=''){
$aLangs = ($this->aLangs)?$this->aLangs:array($this->default_lang);
$filenameOrigin = $filename;
foreach($aLangs as $lang) {
$lgf=($this->aLangs)?$lang.'/':'';#folders
$lng=($this->aLangs)?'_'.$lang:'';#post vars
$filename = $filenameOrigin=='' ? PLX_ROOT.PLX_CONFIG_PATH.$lgf.'products.xml' : $filename;
$this->aProds[$lang]=false;
if(!is_file($filename)){
touch($filename);#create it
continue;
}
# Mise en place du parseur XML
$data = implode('',file($filename));
$parser = xml_parser_create(PLX_CHARSET);
xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,0);
xml_parse_into_struct($parser,$data,$values,$iTags);
xml_parser_free($parser);
if(isset($iTags['product']) AND isset($iTags['name'])){
$nb = sizeof($iTags['name']);
$size=ceil(sizeof($iTags['product'])/$nb);
for($i=0;$i<$nb;$i++){
$attributes = $values[$iTags['product'][$i*$size]]['attributes'];
$number = $attributes['number'];
# Recuperation du nom du produit
$this->aProds[$lang][$number]['name']=plxUtils::getValue($values[$iTags['name'][$i]]['value']);
# Recuperation prix ttc
$pricettc = plxUtils::getValue($iTags['pricettc'][$i]);
$this->aProds[$lang][$number]['pricettc']=plxUtils::getValue($values[$pricettc]['value']);
# Recuperation noaddcart
$noaddcart = plxUtils::getValue($iTags['noaddcart'][$i]);
$this->aProds[$lang][$number]['noaddcart']=plxUtils::getValue($values[$noaddcart]['value']);
$notice_noaddcart = plxUtils::getValue($iTags['notice_noaddcart'][$i]);
$this->aProds[$lang][$number]['notice_noaddcart']=plxUtils::getValue($values[$notice_noaddcart]['value']);
# Recuperation nombre en stock
$iteminstock = plxUtils::getValue($iTags['iteminstock'][$i]);
$this->aProds[$lang][$number]['iteminstock']=plxUtils::getValue($values[$iteminstock]['value']);
# Recuperation poid
$poidg = plxUtils::getValue($iTags['poidg'][$i]);
$this->aProds[$lang][$number]['poidg']=plxUtils::getValue($values[$poidg]['value']);
# Recuperation image
$image = plxUtils::getValue($iTags['image'][$i]);
$this->aProds[$lang][$number]['image']=plxUtils::getValue($values[$image]['value']);
# Recuperation de la balise title
$title_htmltag = plxUtils::getValue($iTags['title_htmltag'][$i]);
$this->aProds[$lang][$number]['title_htmltag']=plxUtils::getValue($values[$title_htmltag]['value']);
# Recuperation du meta description
$meta_description = plxUtils::getValue($iTags['meta_description'][$i]);
$this->aProds[$lang][$number]['meta_description']=plxUtils::getValue($values[$meta_description]['value']);
# Recuperation du meta keywords
$meta_keywords = plxUtils::getValue($iTags['meta_keywords'][$i]);
$this->aProds[$lang][$number]['meta_keywords']=plxUtils::getValue($values[$meta_keywords]['value']);
# Recuperation du groupe du produit
$this->aProds[$lang][$number]['group']=plxUtils::getValue($values[$iTags['group'][$i]]['value']);
# Recuperation du de la variable categorie
$this->aProds[$lang][$number]['pcat']=plxUtils::getValue($values[$iTags['pcat'][$i]]['value']);
$this->aProds[$lang][$number]['menu']=plxUtils::getValue($values[$iTags['menu'][$i]]['value']);
# Recuperation de l'url du produit
$this->aProds[$lang][$number]['url']=strtolower($attributes['url']);
# Recuperation de l'etat du produit
$this->aProds[$lang][$number]['active']=intval($attributes['active']);
# recuperation du fichier template
$this->aProds[$lang][$number]['template']=isset($attributes['template'])?$attributes['template']:$this->getParam('template');
# On verifie que le produit existe bien
if($this->aLangs)
$file = PLX_ROOT.$this->aConf['racine_products_lang'].$number.'.'.$attributes['url'].'.php';
else
$file = PLX_ROOT.$this->aConf['racine_products'].$number.'.'.$attributes['url'].'.php';
# On test si le fichier est lisible
$this->aProds[$lang][$number]['readable'] = (is_readable($file) ? 1 : 0);
}
}
}
}
/**
* Méthode qui édite le fichier XML des produits selon le tableau $content
* @param content tableau multidimensionnel des produits
* @param action permet de forcer la mise àjour du fichier
* @return string
* @author David L.
**/
public function editProducts($content, $action=false){
$retour = $reterr = '';
$dfltLng = '_'.$this->default_lang;
$aLangs = ($this->aLangs)?$this->aLangs:array($this->default_lang);
foreach($aLangs as $lang) {
$save = $this->aProds[$lang];
$lgf=($this->aLangs)?$lang.'/':'';#folders
$lng=($this->aLangs)?'_'.$lang:'';#post vars
# suppression
if(!empty($content['selection']) AND $content['selection']=='delete' AND isset($content['idProduct'])){
foreach($content['idProduct'] as $product_id){
$filename = PLX_ROOT.$this->aConf['racine_products'].$lgf.$product_id.'.'.$this->aProds[$lang][$product_id]['url'].'.php';
if(is_file($filename)) unlink($filename);
# si le produit supprimée est en page d'accueil on met à jour le parametre
unset($this->aProds[$lang][$product_id]);
$action = true;
}
}
# mise à jour de la liste des produits
elseif(!empty($content['update'])){
foreach($content['productNum'] as $product_id){
$stat_name = isset($content[$product_id.'_name'.$lng])?$content[$product_id.'_name'.$lng]:$content[$product_id.'_name'.$dfltLng];
if($stat_name!=''){
$url = (isset($content[$product_id.'_url'.$lng])?trim($content[$product_id.'_url'.$lng]):'');
$stat_url = ($url!=''?plxUtils::title2url($url):plxUtils::title2url($stat_name));
if($stat_url=='') $stat_url = L_DEFAULT_NEW_PRODUCT_URL;
# On vérifie si on a besoin de renommer le fichier du produit
if(isset($this->aProds[$lang][$product_id]) AND $this->aProds[$lang][$product_id]['url']!=$stat_url){
$oldfilename = PLX_ROOT.$this->aConf['racine_products'].$lgf.$product_id.'.'.$this->aProds[$lang][$product_id]['url'].'.php';
$newfilename = PLX_ROOT.$this->aConf['racine_products'].$lgf.$product_id.'.'.$stat_url.'.php';
if(is_file($oldfilename)) rename($oldfilename, $newfilename);
}
$this->aProds[$lang][$product_id]['pcat'] = trim(isset($content[$product_id.'_pcat'.$lng])?$content[$product_id.'_pcat'.$lng]:$content[$product_id.'_pcat'.$dfltLng]);
$this->aProds[$lang][$product_id]['menu'] = trim(isset($content[$product_id.'_menu'.$lng])?$content[$product_id.'_menu'.$lng]:'');
$this->aProds[$lang][$product_id]['group'] = isset($this->aProds[$lang][$product_id]['group'])?$this->aProds[$lang][$product_id]['group']:'';
$this->aProds[$lang][$product_id]['name'] = self::apostrophe($stat_name);
$this->aProds[$lang][$product_id]['url'] = plxUtils::checkSite($url)?$url:$stat_url;
$this->aProds[$lang][$product_id]['active'] = isset($content[$product_id.'_active'.$lng])?$content[$product_id.'_active'.$lng]:$content[$product_id.'_active'.$dfltLng];
$this->aProds[$lang][$product_id]['ordre'] = intval(isset($content[$product_id.'_ordre'.$lng])?$content[$product_id.'_ordre'.$lng]:$content[$product_id.'_ordre'.$dfltLng]);
$this->aProds[$lang][$product_id]['template'] = isset($this->aProds[$lang][$product_id]['template'])?$this->aProds[$lang][$product_id]['template']:$this->getParam('template');