-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshortcodes.php
More file actions
976 lines (914 loc) · 48.7 KB
/
Copy pathshortcodes.php
File metadata and controls
976 lines (914 loc) · 48.7 KB
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
<?php
/**
* ShortCodes - Moteur de shortcodes pour PrestaShop
* Insère des shortcodes (produits, sliders, descriptions, marques, etc.) dans les
* contenus CMS et autres zones HTML. Compatible PrestaShop 1.7 / 8 / 9+.
*
* @author ZM40 — Nicolas Michaud (Magic Garden)
* @copyright 2026 Nicolas Michaud — ZM40 / Magic Garden
* @license https://opensource.org/licenses/OSL-3.0 Open Software License version 3.0
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
*/
declare(strict_types=1);
use PrestaShop\PrestaShop\Core\Module\WidgetInterface;
if (!defined('_PS_VERSION_')) {
exit;
}
require_once _PS_MODULE_DIR_ . 'shortcodes/lib/zm40/Zm40Common.php';
class ShortCodes extends Module
{
public function __construct()
{
$this->name = 'shortcodes';
$this->tab = 'administration';
$this->version = '1.0.11';
$this->author = 'ZM40';
$this->need_instance = 0;
$this->bootstrap = true;
$this->ps_versions_compliancy = ['min' => '1.7.0.0', 'max' => _PS_VERSION_];
parent::__construct();
$this->displayName = $this->l('ShortCodes');
$this->description = $this->l('Insérez des shortcodes (produits, sliders, descriptions, etc.) dans les contenus CMS et autres zones HTML.');
$this->confirmUninstall = $this->l('Êtes-vous sûr de vouloir désinstaller ShortCodes ?');
// Lazy include of classes (PS autoload loads classes/ automatically, but ensure availability for CLI/contextless)
$base = __DIR__ . '/classes/';
if (is_dir($base)) {
@require_once $base . 'Support/ShortcodeHelpers.php';
@require_once $base . 'Core/ShortcodeEngine.php';
@require_once $base . 'ShortcodeRegistry.php';
@require_once $base . 'ShortcodeParser.php';
@require_once $base . 'Shortcodes/ProductShortcode.php';
@require_once $base . 'Shortcodes/ProductsShortcode.php';
@require_once $base . 'Shortcodes/ProductDescriptionShortcode.php';
@require_once $base . 'Shortcodes/LastProductsShortcode.php';
@require_once $base . 'Shortcodes/CategoryProductsShortcode.php';
}
}
public function install(): bool
{
$ok = parent::install()
&& $this->registerHook('displayHeader')
&& $this->registerHook('actionFrontControllerSetMedia')
&& $this->registerHook('actionOutputHTMLBefore')
&& $this->registerHook('displayShortcodesProductCard');
if ($ok) {
// Defaults for slider behavior (global). Overrides (HOME/CMS) left unset to fallback to global.
try {
// Assets loading (front)
Configuration::updateValue('MGSC_LOAD_SWIPER_ASSETS', true);
Configuration::updateValue('MGSC_ASSETS_LOAD_ENABLED', true);
Configuration::updateValue('MGSC_SLIDER_AUTOPLAY_ENABLED', false);
Configuration::updateValue('MGSC_SLIDER_SPACE_BETWEEN', 20);
Configuration::updateValue('MGSC_SLIDER_SPEED', 600);
Configuration::updateValue('MGSC_SLIDER_AUTO_HEIGHT', false);
Configuration::updateValue('MGSC_SLIDER_CENTER_ENABLED', false);
// Default Slides Per View per breakpoint (used when shortcode doesn't override)
Configuration::updateValue('MGSC_SLIDER_SPV', '1');
Configuration::updateValue('MGSC_SLIDER_SPV_XL', '4');
Configuration::updateValue('MGSC_SLIDER_SPV_LG', '4');
Configuration::updateValue('MGSC_SLIDER_SPV_MD', '3');
Configuration::updateValue('MGSC_SLIDER_SPV_SM', '2');
Configuration::updateValue('MGSC_SLIDER_SPV_XS', '1');
// Center per breakpoint defaults (empty = inherit from base)
Configuration::updateValue('MGSC_SLIDER_CENTER_ENABLED_XL', '');
Configuration::updateValue('MGSC_SLIDER_CENTER_ENABLED_LG', '');
Configuration::updateValue('MGSC_SLIDER_CENTER_ENABLED_MD', '');
Configuration::updateValue('MGSC_SLIDER_CENTER_ENABLED_SM', '');
Configuration::updateValue('MGSC_SLIDER_CENTER_ENABLED_XS', '');
// ZM40 Common — interrupteur réseau (activé par défaut, opt-out)
Configuration::updateValue('ZM40_NET_ENABLED', 1);
// Force un re-fetch du feed au prochain rendu (sinon cache 24h obsolète
// survit aux upgrades et fait afficher une vieille version de l'écosystème).
if (class_exists('Zm40CommonSc')) { Zm40CommonSc::clearFeedCache(); }
} catch (\Throwable $e) { /* ignore */ }
}
return $ok;
}
public function uninstall(): bool
{
// Clean configuration keys
try {
$keys = [
'MGSC_LOAD_SWIPER_ASSETS',
'MGSC_ASSETS_LOAD_ENABLED',
'MGSC_SLIDER_AUTOPLAY_ENABLED', 'MGSC_SLIDER_SPACE_BETWEEN', 'MGSC_SLIDER_SPEED', 'MGSC_SLIDER_AUTO_HEIGHT', 'MGSC_SLIDER_CENTER_ENABLED',
'MGSC_SLIDER_AUTOPLAY_ENABLED_HOME', 'MGSC_SLIDER_SPACE_BETWEEN_HOME', 'MGSC_SLIDER_SPEED_HOME', 'MGSC_SLIDER_AUTO_HEIGHT_HOME', 'MGSC_SLIDER_CENTER_ENABLED_HOME',
'MGSC_SLIDER_AUTOPLAY_ENABLED_CMS', 'MGSC_SLIDER_SPACE_BETWEEN_CMS', 'MGSC_SLIDER_SPEED_CMS', 'MGSC_SLIDER_AUTO_HEIGHT_CMS', 'MGSC_SLIDER_CENTER_ENABLED_CMS',
'MGSC_SLIDER_SPV', 'MGSC_SLIDER_SPV_XL', 'MGSC_SLIDER_SPV_LG', 'MGSC_SLIDER_SPV_MD', 'MGSC_SLIDER_SPV_SM', 'MGSC_SLIDER_SPV_XS',
'MGSC_SLIDER_CENTER_ENABLED_XL', 'MGSC_SLIDER_CENTER_ENABLED_LG', 'MGSC_SLIDER_CENTER_ENABLED_MD', 'MGSC_SLIDER_CENTER_ENABLED_SM', 'MGSC_SLIDER_CENTER_ENABLED_XS',
// ZM40 Common
'ZM40_NET_ENABLED', 'ZM40_FEED_CACHE', 'ZM40_FEED_CACHE_TS',
'ZM40_FEED_CACHE2', 'ZM40_FEED_CACHE_TS2',
'ZM40_LASTCHECK_SHORTCODES', 'ZM40_LATEST_SHORTCODES',
];
foreach ($keys as $k) { Configuration::deleteByName($k); }
} catch (\Throwable $e) { /* ignore */ }
return parent::uninstall();
}
public function hookDisplayHeader($params)
{
if (!isset($this->context->controller) || $this->context->controller->controller_type !== 'front') {
return '';
}
// Register Smarty plugins (FO only)
$this->registerSmartyPlugins(false);
// Register assets conditionally.
$loadAssets = (bool) Configuration::get('MGSC_ASSETS_LOAD_ENABLED');
if ($loadAssets && isset($this->context->controller)) {
$this->context->controller->registerStylesheet(
$this->name . '-front-css',
$this->_path . 'views/css/front.css',
['media' => 'all', 'priority' => 200]
);
// Optionally load Swiper from CDN so Swiper mode is available everywhere
if ((bool) Configuration::get('MGSC_LOAD_SWIPER_ASSETS')) {
try {
$this->context->controller->registerStylesheet(
$this->name . '-swiper-css',
'https://cdn.jsdelivr.net/npm/swiper@9/swiper-bundle.min.css',
['server' => 'remote', 'priority' => 120, 'media' => 'all']
);
} catch (\Throwable $e) {}
try {
$this->context->controller->registerJavascript(
$this->name . '-swiper-js',
'https://cdn.jsdelivr.net/npm/swiper@9/swiper-bundle.min.js',
['server' => 'remote', 'position' => 'bottom', 'priority' => 150]
);
} catch (\Throwable $e) {}
}
// Front behaviors (slider init, fallbacks)
$this->context->controller->registerJavascript(
$this->name . '-front-js',
$this->_path . 'views/js/front.js',
['position' => 'bottom', 'priority' => 200]
);
}
}
/**
* PS 1.7/8+: Reliable place to register FO CSS/JS. Some themes may not surface assets registered in displayHeader.
*/
public function hookActionFrontControllerSetMedia($params)
{
if (!isset($this->context->controller) || $this->context->controller->controller_type !== 'front') {
return;
}
if ((bool) Configuration::get('MGSC_ASSETS_LOAD_ENABLED')) {
$c = $this->context->controller;
// Primary (PS 1.7/8): register* API
try {
$c->registerStylesheet(
$this->name . '-front-css',
$this->_path . 'views/css/front.css',
['media' => 'all', 'priority' => 200]
);
} catch (\Throwable $e) {}
// Swiper (remote) before our JS so window.Swiper exists
if ((bool) Configuration::get('MGSC_LOAD_SWIPER_ASSETS')) {
try {
$c->registerStylesheet(
$this->name . '-swiper-css',
'https://cdn.jsdelivr.net/npm/swiper@9/swiper-bundle.min.css',
['server' => 'remote', 'priority' => 120, 'media' => 'all']
);
} catch (\Throwable $e) {}
try {
$c->registerJavascript(
$this->name . '-swiper-js',
'https://cdn.jsdelivr.net/npm/swiper@9/swiper-bundle.min.js',
['server' => 'remote', 'position' => 'bottom', 'priority' => 150]
);
} catch (\Throwable $e) {}
}
try {
$c->registerJavascript(
$this->name . '-front-js',
$this->_path . 'views/js/front.js',
['position' => 'bottom', 'priority' => 200]
);
} catch (\Throwable $e) {}
// Compatibility fallback: legacy addCSS/addJS if theme overrides asset stack
try { if (method_exists($c, 'addCSS')) { $c->addCSS($this->_path . 'views/css/front.css', 'all'); } } catch (\Throwable $e) {}
// Legacy helpers for remote assets (best effort)
if ((bool) Configuration::get('MGSC_LOAD_SWIPER_ASSETS')) {
try { if (method_exists($c, 'addCSS')) { $c->addCSS('https://cdn.jsdelivr.net/npm/swiper@9/swiper-bundle.min.css', 'all'); } } catch (\Throwable $e) {}
try { if (method_exists($c, 'addJS')) { $c->addJS('https://cdn.jsdelivr.net/npm/swiper@9/swiper-bundle.min.js'); } } catch (\Throwable $e) {}
}
try { if (method_exists($c, 'addJS')) { $c->addJS($this->_path . 'views/js/front.js'); } } catch (\Throwable $e) {}
// Diagnostics removed after validation
}
}
public function hookDisplayBackOfficeHeader($params)
{
// Intentionally do nothing in BO to avoid interfering with Back Office rendering
return '';
}
/**
* Custom hook: displayShortcodesProductCard
* This module exposes the hook for other modules, but does not render anything itself.
* Keeps templates-only rendering with no PHP fallback output.
*
* @param array<string,mixed> $params
* @return string
*/
public function hookDisplayShortcodesProductCard($params)
{
return '';
}
/**
* Global FO HTML parser: parse shortcodes in final HTML response.
* Note: This hook provides $params['html'] string by reference in PS 1.7+/8/9.
* We only act on Front controllers to avoid BO interference.
*
* @param array<string,mixed> $params
* @return void|string
*/
public function hookActionOutputHTMLBefore(&$params)
{
// Safety checks
if (!isset($this->context->controller) || $this->context->controller->controller_type !== 'front') {
return '';
}
if (!isset($params['html']) || !is_string($params['html'])) {
return '';
}
$html = $params['html'];
// Micro-guard: avoid work if no shortcode-like pattern
if (strpos($html, '[') === false || strpos($html, ']') === false) {
return '';
}
// Parse and replace
$parsed = $this->parseShortcodes($html);
if (is_string($parsed) && $parsed !== $html) {
$params['html'] = $parsed;
}
return '';
}
protected function registerSmartyPlugins(bool $backOffice = false): void
{
if (!isset($this->context) || !isset($this->context->smarty)) {
return;
}
$smarty = $this->context->smarty;
if (method_exists($smarty, 'registerPlugin')) {
// Always register unique plugin names for this module
try { $smarty->registerPlugin('function', 'shortcodes', [$this, 'smartyShortcodeFunction']); } catch (\Throwable $e) {}
try { $smarty->registerPlugin('modifier', 'shortcodes', [$this, 'smartyShortcodeModifier']); } catch (\Throwable $e) {}
// Front office alias for convenience (may already exist in other modules)
if (!$backOffice) {
try { $smarty->registerPlugin('function', 'shortcode', [$this, 'smartyShortcodeFunction']); } catch (\Throwable $e) {}
try { $smarty->registerPlugin('modifier', 'shortcode', [$this, 'smartyShortcodeModifier']); } catch (\Throwable $e) {}
}
}
}
public function smartyShortcodeFunction($params, $smarty)
{
$text = isset($params['text']) ? (string) $params['text'] : '';
return $this->parseShortcodes($text);
}
public function smartyShortcodeModifier($text)
{
return $this->parseShortcodes((string) $text);
}
public function parseShortcodes(string $content): string
{
$registry = new \ShortCodes\ShortcodeRegistry($this);
// Register built-in handlers
$registry->registerDefaults();
$parser = new \ShortCodes\ShortcodeParser($registry, $this->context);
return $parser->parse($content);
}
/**
* Back Office configuration page content
*/
public function getContent(): string
{
// Register BO-only smarty plugins aliases if needed
$this->registerSmartyPlugins(true);
$output = '';
// Handle form submit
if (Tools::isSubmit('submitMgShortcodeConfig')) {
$this->postProcess();
// Redirect to clear POST and display persisted values from Configuration
$url = AdminController::$currentIndex . '&configure=' . $this->name . '&conf=4&token=' . Tools::getAdminTokenLite('AdminModules');
Tools::redirectAdmin($url);
}
// Success message handled by conf parameter after redirect
if (isset($this->context) && isset($this->context->smarty)) {
// Forms split by tab : 'config' (assets + slider + overrides) | 'ecosystem' (MAJ + ZM40)
$formsByTab = $this->renderFormsByTab();
$this->context->smarty->assign([
'module_dir' => $this->_path,
'module_name' => $this->displayName,
'module_version' => $this->version,
'zm40_ah_name' => 'ShortCodes',
'zm40_ah_sub' => $this->l('Moteur de shortcodes pour CMS et HTML'),
'zm40_ah_version' => $this->version,
'zm40_ah_shop' => Configuration::get('PS_SHOP_NAME'),
// Forms HTML per tab
'form_config' => $formsByTab['config'],
'form_ecosystem' => $formsByTab['ecosystem'],
// ── ZM40 Common (footer + notice MAJ + bloc open source + autres modules) ──
'zm40_net_enabled' => Zm40CommonSc::isNetEnabled() ? 1 : 0,
'zm40_footer_html' => Zm40CommonSc::footer('ShortCodes', $this->version, 'shortcodes'),
'zm40_update' => Zm40CommonSc::checkUpdate('shortcodes', $this->version),
'zm40_modules' => Zm40CommonSc::modulesFeed('shortcodes'),
'zm40_about_name' => 'ShortCodes',
'zm40_about_license' => 'OSL 3.0',
'zm40_about_github' => Zm40CommonSc::githubUrl('shortcodes'),
'zm40_about_site' => Zm40CommonSc::siteUrl('shortcodes', 'panel', '/contact'),
'zm40_about_modules' => Zm40CommonSc::siteUrl('shortcodes', 'panel', '/'),
]);
try {
return $output . (string) $this->context->smarty->fetch('module:shortcodes/views/templates/admin/configure.tpl');
} catch (\Throwable $e) {
$msg = htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8');
return '<div class="alert alert-danger">' . $this->l('Erreur de rendu du panneau de configuration: ') . $msg . '</div>';
}
}
return '<div class="alert alert-info">' . $this->l('Contexte Smarty indisponible.') . '</div>';
}
protected function renderForm(): string
{
$defaultLang = (int) Configuration::get('PS_LANG_DEFAULT');
$fieldsForm = $this->buildFieldsForm();
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->table;
$helper->module = $this;
$helper->default_form_language = $defaultLang;
$helper->allow_employee_form_lang = (int) Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG', 0);
$helper->identifier = $this->identifier;
$helper->submit_action = 'submitMgShortcodeConfig';
$helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->tpl_vars = [
'fields_value' => $this->getConfigFormValues(),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id,
];
return $helper->generateForm($fieldsForm);
}
/**
* Construit le tableau $fieldsForm — partagé par renderForm() (HTML legacy)
* et renderFormsByTab() (HTML par onglet).
*
* Ordre des forms : 0=Assets FO, 1=Slider global, 2=Home overrides, 3=CMS overrides,
* 4=MAJ & écosystème ZM40. L'ordre est important : renderFormsByTab() slice par
* indice pour répartir dans les onglets.
*/
protected function buildFieldsForm(): array
{
$defaultLang = (int) Configuration::get('PS_LANG_DEFAULT');
$fieldsForm = [];
// Assets (FO)
$fieldsForm[] = [
'form' => [
'legend' => [
'title' => $this->l('Assets Front Office'),
'icon' => 'icon-code',
],
'input' => [
[
'type' => 'switch',
'label' => $this->l('Charger Swiper (CDN)'),
'name' => 'MGSC_LOAD_SWIPER_ASSETS',
'is_bool' => true,
'desc' => $this->l('Active le chargement de Swiper JS/CSS depuis jsDelivr. Désactivez si votre thème inclut déjà Swiper.'),
'values' => [
['id' => 'MGSC_LOAD_SWIPER_ASSETS_on', 'value' => 1, 'label' => $this->l('Oui')],
['id' => 'MGSC_LOAD_SWIPER_ASSETS_off', 'value' => 0, 'label' => $this->l('Non')],
],
],
[
'type' => 'switch',
'label' => $this->l('Charger le CSS/JS du module'),
'name' => 'MGSC_ASSETS_LOAD_ENABLED',
'is_bool' => true,
'desc' => $this->l('Désactivez si votre thème gère déjà le style et le JS des sliders.'),
'values' => [
['id' => 'MGSC_ASSETS_LOAD_ENABLED_on', 'value' => 1, 'label' => $this->l('Oui')],
['id' => 'MGSC_ASSETS_LOAD_ENABLED_off', 'value' => 0, 'label' => $this->l('Non')],
],
],
],
'submit' => [
'title' => $this->l('Enregistrer'),
'class' => 'btn btn-default pull-right',
],
],
];
// Global behavior
$fieldsForm[] = [
'form' => [
'legend' => [
'title' => $this->l('Comportement du slider (global)'),
'icon' => 'icon-cogs',
],
'input' => [
[
'type' => 'switch',
'label' => $this->l('Lecture automatique (autoplay)'),
'name' => 'MGSC_SLIDER_AUTOPLAY_ENABLED',
'is_bool' => true,
'values' => [
['id' => 'on', 'value' => 1, 'label' => $this->l('Oui')],
['id' => 'off', 'value' => 0, 'label' => $this->l('Non')],
],
],
[
'type' => 'text',
'label' => $this->l('Espacement entre slides (px)'),
'name' => 'MGSC_SLIDER_SPACE_BETWEEN',
'class' => 'fixed-width-sm',
'desc' => $this->l('Nombre entier. Défaut: 20'),
],
[
'type' => 'text',
'label' => $this->l('Vitesse de transition (ms)'),
'name' => 'MGSC_SLIDER_SPEED',
'class' => 'fixed-width-sm',
'desc' => $this->l('Nombre entier. Défaut: 600'),
],
[
'type' => 'switch',
'label' => $this->l('Hauteur automatique'),
'name' => 'MGSC_SLIDER_AUTO_HEIGHT',
'is_bool' => true,
'values' => [
['id' => 'on', 'value' => 1, 'label' => $this->l('Oui')],
['id' => 'off', 'value' => 0, 'label' => $this->l('Non')],
],
],
[
'type' => 'switch',
'label' => $this->l('Centrer les slides'),
'name' => 'MGSC_SLIDER_CENTER_ENABLED',
'is_bool' => true,
'values' => [
['id' => 'on', 'value' => 1, 'label' => $this->l('Oui')],
['id' => 'off', 'value' => 0, 'label' => $this->l('Non')],
],
],
[
'type' => 'html',
'name' => 'center_help',
'label' => $this->l('Centrage par breakpoint'),
'html_content' => '<div class="help-block">' . $this->l('Laisser vide pour hériter du réglage global ci-dessus. Sinon, forcer le centrage par breakpoint.') . '</div>',
],
[
'type' => 'select',
'label' => $this->l('Centrer – XL (≥1200px)'),
'name' => 'MGSC_SLIDER_CENTER_ENABLED_XL',
'options' => [
'query' => [
['id' => '', 'name' => $this->l('Hériter du global')],
['id' => '1', 'name' => $this->l('Oui')],
['id' => '0', 'name' => $this->l('Non')],
],
'id' => 'id',
'name' => 'name',
],
],
[
'type' => 'select',
'label' => $this->l('Centrer – LG (≥992px)'),
'name' => 'MGSC_SLIDER_CENTER_ENABLED_LG',
'options' => [
'query' => [
['id' => '', 'name' => $this->l('Hériter du global')],
['id' => '1', 'name' => $this->l('Oui')],
['id' => '0', 'name' => $this->l('Non')],
],
'id' => 'id',
'name' => 'name',
],
],
[
'type' => 'select',
'label' => $this->l('Centrer – MD (≥768px)'),
'name' => 'MGSC_SLIDER_CENTER_ENABLED_MD',
'options' => [
'query' => [
['id' => '', 'name' => $this->l('Hériter du global')],
['id' => '1', 'name' => $this->l('Oui')],
['id' => '0', 'name' => $this->l('Non')],
],
'id' => 'id',
'name' => 'name',
],
],
[
'type' => 'select',
'label' => $this->l('Centrer – SM (≥480px)'),
'name' => 'MGSC_SLIDER_CENTER_ENABLED_SM',
'options' => [
'query' => [
['id' => '', 'name' => $this->l('Hériter du global')],
['id' => '1', 'name' => $this->l('Oui')],
['id' => '0', 'name' => $this->l('Non')],
],
'id' => 'id',
'name' => 'name',
],
],
[
'type' => 'select',
'label' => $this->l('Centrer – XS (<480px)'),
'name' => 'MGSC_SLIDER_CENTER_ENABLED_XS',
'options' => [
'query' => [
['id' => '', 'name' => $this->l('Hériter du global')],
['id' => '1', 'name' => $this->l('Oui')],
['id' => '0', 'name' => $this->l('Non')],
],
'id' => 'id',
'name' => 'name',
],
],
[
'type' => 'html',
'name' => 'spv_help',
'label' => $this->l('Articles par vue (Slides Per View)'),
'html_content' => '<div class="help-block">' . $this->l('Valeurs par défaut pour le nombre de cartes visibles selon la taille d\'écran. Accepte des décimaux (ex: 2.5). Les shortcodes peuvent surcharger ces valeurs, par ex:') . ' <code>[products 1,2,3 slider 5,4,3,2,2.5,1]</code><br>' . $this->l('La valeur Base sert de valeur par défaut pour toutes les tailles. Le champ XS (<480px) est optionnel : s\'il est vide, la valeur Base sera utilisée.') . '</div>',
],
[
'type' => 'text',
'label' => $this->l('SPV – Base (défaut)'),
'name' => 'MGSC_SLIDER_SPV',
'class' => 'fixed-width-sm',
'desc' => $this->l('Par défaut: 1'),
],
[
'type' => 'text',
'label' => $this->l('SPV – SM (≥480px)'),
'name' => 'MGSC_SLIDER_SPV_SM',
'class' => 'fixed-width-sm',
'desc' => $this->l('Par défaut: 2'),
],
[
'type' => 'text',
'label' => $this->l('SPV – MD (≥768px)'),
'name' => 'MGSC_SLIDER_SPV_MD',
'class' => 'fixed-width-sm',
'desc' => $this->l('Par défaut: 3'),
],
[
'type' => 'text',
'label' => $this->l('SPV – LG (≥992px)'),
'name' => 'MGSC_SLIDER_SPV_LG',
'class' => 'fixed-width-sm',
'desc' => $this->l('Par défaut: 4'),
],
[
'type' => 'text',
'label' => $this->l('SPV – XL (≥1200px)'),
'name' => 'MGSC_SLIDER_SPV_XL',
'class' => 'fixed-width-sm',
'desc' => $this->l('Par défaut: 4'),
],
[
'type' => 'text',
'label' => $this->l('SPV – XS (<480px) (optionnel)'),
'name' => 'MGSC_SLIDER_SPV_XS',
'class' => 'fixed-width-sm',
'desc' => $this->l('Si vide, la valeur Base est utilisée.'),
],
],
'submit' => [
'title' => $this->l('Enregistrer'),
'class' => 'btn btn-default pull-right',
],
],
];
// Accueil (Home) overrides
$fieldsForm[] = [
'form' => [
'legend' => [
'title' => $this->l('Accueil / HomePage — Overrides (laisser vide pour hériter)'),
'icon' => 'icon-home',
],
'input' => [
[
'type' => 'select',
'label' => $this->l('Autoplay – Accueil'),
'name' => 'MGSC_SLIDER_AUTOPLAY_ENABLED_HOME',
'options' => [
'query' => [
['id' => '', 'name' => $this->l('Hériter du global')],
['id' => '1', 'name' => $this->l('Oui')],
['id' => '0', 'name' => $this->l('Non')],
],
'id' => 'id',
'name' => 'name',
],
],
[
'type' => 'text',
'label' => $this->l('Espacement – Accueil (px)'),
'name' => 'MGSC_SLIDER_SPACE_BETWEEN_HOME',
'class' => 'fixed-width-sm',
],
[
'type' => 'text',
'label' => $this->l('Vitesse – Accueil (ms)'),
'name' => 'MGSC_SLIDER_SPEED_HOME',
'class' => 'fixed-width-sm',
],
[
'type' => 'select',
'label' => $this->l('Hauteur auto – Accueil'),
'name' => 'MGSC_SLIDER_AUTO_HEIGHT_HOME',
'options' => [
'query' => [
['id' => '', 'name' => $this->l('Hériter du global')],
['id' => '1', 'name' => $this->l('Oui')],
['id' => '0', 'name' => $this->l('Non')],
],
'id' => 'id',
'name' => 'name',
],
],
[
'type' => 'select',
'label' => $this->l('Centrer – Accueil'),
'name' => 'MGSC_SLIDER_CENTER_ENABLED_HOME',
'options' => [
'query' => [
['id' => '', 'name' => $this->l('Hériter du global')],
['id' => '1', 'name' => $this->l('Oui')],
['id' => '0', 'name' => $this->l('Non')],
],
'id' => 'id',
'name' => 'name',
],
],
],
'submit' => [
'title' => $this->l('Enregistrer'),
'class' => 'btn btn-default pull-right',
],
],
];
// CMS pages overrides
$fieldsForm[] = [
'form' => [
'legend' => [
'title' => $this->l('Pages CMS — Overrides (laisser vide pour hériter)'),
'icon' => 'icon-file-text',
],
'input' => [
[
'type' => 'select',
'label' => $this->l('Autoplay – CMS'),
'name' => 'MGSC_SLIDER_AUTOPLAY_ENABLED_CMS',
'options' => [
'query' => [
['id' => '', 'name' => $this->l('Hériter du global')],
['id' => '1', 'name' => $this->l('Oui')],
['id' => '0', 'name' => $this->l('Non')],
],
'id' => 'id',
'name' => 'name',
],
],
[
'type' => 'text',
'label' => $this->l('Espacement – CMS (px)'),
'name' => 'MGSC_SLIDER_SPACE_BETWEEN_CMS',
'class' => 'fixed-width-sm',
],
[
'type' => 'text',
'label' => $this->l('Vitesse – CMS (ms)'),
'name' => 'MGSC_SLIDER_SPEED_CMS',
'class' => 'fixed-width-sm',
],
[
'type' => 'select',
'label' => $this->l('Hauteur auto – CMS'),
'name' => 'MGSC_SLIDER_AUTO_HEIGHT_CMS',
'options' => [
'query' => [
['id' => '', 'name' => $this->l('Hériter du global')],
['id' => '1', 'name' => $this->l('Oui')],
['id' => '0', 'name' => $this->l('Non')],
],
'id' => 'id',
'name' => 'name',
],
],
[
'type' => 'select',
'label' => $this->l('Centrer – CMS'),
'name' => 'MGSC_SLIDER_CENTER_ENABLED_CMS',
'options' => [
'query' => [
['id' => '', 'name' => $this->l('Hériter du global')],
['id' => '1', 'name' => $this->l('Oui')],
['id' => '0', 'name' => $this->l('Non')],
],
'id' => 'id',
'name' => 'name',
],
],
],
'submit' => [
'title' => $this->l('Enregistrer'),
'class' => 'btn btn-default pull-right',
],
],
];
// Mises à jour & écosystème (ZM40) — opt-out réseau
$fieldsForm[] = [
'form' => [
'legend' => [
'title' => $this->l('Mises à jour & écosystème (ZM40)'),
'icon' => 'icon-refresh',
],
'input' => [
[
'type' => 'switch',
'label' => $this->l('Vérifier les mises à jour'),
'name' => 'ZM40_NET_ENABLED',
'is_bool' => true,
'desc' => $this->l('Vérifie au maximum une fois par jour si une nouvelle version est disponible via l\'API publique de GitHub, et affiche les autres modules ZM40 depuis zm40.com. Requêtes anonymes : aucune donnée de votre boutique n\'est transmise. Décochez pour tout désactiver.'),
'values' => [
['id' => 'ZM40_NET_ENABLED_on', 'value' => 1, 'label' => $this->l('Oui')],
['id' => 'ZM40_NET_ENABLED_off', 'value' => 0, 'label' => $this->l('Non')],
],
],
],
'submit' => [
'title' => $this->l('Enregistrer'),
'class' => 'btn btn-default pull-right',
],
],
];
return $fieldsForm;
}
/**
* Retourne les forms regroupés par onglet BO en HTML.
*
* Onglet 'config' : Assets FO + Slider global + Home overrides + CMS overrides (forms 0-3)
* Onglet 'ecosystem' : MAJ & écosystème ZM40 (form 4)
*/
protected function renderFormsByTab(): array
{
$defaultLang = (int) Configuration::get('PS_LANG_DEFAULT');
$fieldsForm = $this->buildFieldsForm();
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->table;
$helper->module = $this;
$helper->default_form_language = $defaultLang;
$helper->allow_employee_form_lang = (int) Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG', 0);
$helper->identifier = $this->identifier;
$helper->submit_action = 'submitMgShortcodeConfig';
$helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->tpl_vars = [
'fields_value' => $this->getConfigFormValues(),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id,
];
$configForms = array_slice($fieldsForm, 0, 4);
$ecosystemForms = array_slice($fieldsForm, 4, 1);
return [
'config' => $configForms ? $helper->generateForm($configForms) : '',
'ecosystem' => $ecosystemForms ? $helper->generateForm($ecosystemForms) : '',
];
}
protected function getConfigFormValues(): array
{
$get = static function(string $k) {
$v = Configuration::get($k);
return $v;
};
return [
'MGSC_LOAD_SWIPER_ASSETS' => (int) (($v = Configuration::get('MGSC_LOAD_SWIPER_ASSETS')) !== false ? (int)$v : 1),
'MGSC_ASSETS_LOAD_ENABLED' => (int) (($v = Configuration::get('MGSC_ASSETS_LOAD_ENABLED')) !== false ? (int)$v : 1),
'MGSC_SLIDER_AUTOPLAY_ENABLED' => (int) (Configuration::get('MGSC_SLIDER_AUTOPLAY_ENABLED') ? 1 : 0),
'MGSC_SLIDER_SPACE_BETWEEN' => (string) ($get('MGSC_SLIDER_SPACE_BETWEEN') !== false ? $get('MGSC_SLIDER_SPACE_BETWEEN') : '20'),
'MGSC_SLIDER_SPEED' => (string) ($get('MGSC_SLIDER_SPEED') !== false ? $get('MGSC_SLIDER_SPEED') : '600'),
'MGSC_SLIDER_AUTO_HEIGHT' => (int) (Configuration::get('MGSC_SLIDER_AUTO_HEIGHT') ? 1 : 0),
'MGSC_SLIDER_CENTER_ENABLED' => (int) (Configuration::get('MGSC_SLIDER_CENTER_ENABLED') ? 1 : 0),
// Center per breakpoint (tri-state: '', '1', '0')
'MGSC_SLIDER_CENTER_ENABLED_XL' => ($get('MGSC_SLIDER_CENTER_ENABLED_XL') !== false ? (string)$get('MGSC_SLIDER_CENTER_ENABLED_XL') : ''),
'MGSC_SLIDER_CENTER_ENABLED_LG' => ($get('MGSC_SLIDER_CENTER_ENABLED_LG') !== false ? (string)$get('MGSC_SLIDER_CENTER_ENABLED_LG') : ''),
'MGSC_SLIDER_CENTER_ENABLED_MD' => ($get('MGSC_SLIDER_CENTER_ENABLED_MD') !== false ? (string)$get('MGSC_SLIDER_CENTER_ENABLED_MD') : ''),
'MGSC_SLIDER_CENTER_ENABLED_SM' => ($get('MGSC_SLIDER_CENTER_ENABLED_SM') !== false ? (string)$get('MGSC_SLIDER_CENTER_ENABLED_SM') : ''),
'MGSC_SLIDER_CENTER_ENABLED_XS' => ($get('MGSC_SLIDER_CENTER_ENABLED_XS') !== false ? (string)$get('MGSC_SLIDER_CENTER_ENABLED_XS') : ''),
// SPV defaults
'MGSC_SLIDER_SPV' => (string) ($get('MGSC_SLIDER_SPV') !== false ? $get('MGSC_SLIDER_SPV') : '1'),
'MGSC_SLIDER_SPV_XL' => (string) ($get('MGSC_SLIDER_SPV_XL') !== false ? $get('MGSC_SLIDER_SPV_XL') : '4'),
'MGSC_SLIDER_SPV_LG' => (string) ($get('MGSC_SLIDER_SPV_LG') !== false ? $get('MGSC_SLIDER_SPV_LG') : '4'),
'MGSC_SLIDER_SPV_MD' => (string) ($get('MGSC_SLIDER_SPV_MD') !== false ? $get('MGSC_SLIDER_SPV_MD') : '3'),
'MGSC_SLIDER_SPV_SM' => (string) ($get('MGSC_SLIDER_SPV_SM') !== false ? $get('MGSC_SLIDER_SPV_SM') : '2'),
'MGSC_SLIDER_SPV_XS' => (string) ($get('MGSC_SLIDER_SPV_XS') !== false ? $get('MGSC_SLIDER_SPV_XS') : '1'),
'MGSC_SLIDER_AUTOPLAY_ENABLED_HOME' => ($get('MGSC_SLIDER_AUTOPLAY_ENABLED_HOME') !== false ? (string)$get('MGSC_SLIDER_AUTOPLAY_ENABLED_HOME') : ''),
'MGSC_SLIDER_SPACE_BETWEEN_HOME' => (string) ($get('MGSC_SLIDER_SPACE_BETWEEN_HOME') !== false ? $get('MGSC_SLIDER_SPACE_BETWEEN_HOME') : ''),
'MGSC_SLIDER_SPEED_HOME' => (string) ($get('MGSC_SLIDER_SPEED_HOME') !== false ? $get('MGSC_SLIDER_SPEED_HOME') : ''),
'MGSC_SLIDER_AUTO_HEIGHT_HOME' => ($get('MGSC_SLIDER_AUTO_HEIGHT_HOME') !== false ? (string)$get('MGSC_SLIDER_AUTO_HEIGHT_HOME') : ''),
'MGSC_SLIDER_CENTER_ENABLED_HOME' => ($get('MGSC_SLIDER_CENTER_ENABLED_HOME') !== false ? (string)$get('MGSC_SLIDER_CENTER_ENABLED_HOME') : ''),
'MGSC_SLIDER_AUTOPLAY_ENABLED_CMS' => ($get('MGSC_SLIDER_AUTOPLAY_ENABLED_CMS') !== false ? (string)$get('MGSC_SLIDER_AUTOPLAY_ENABLED_CMS') : ''),
'MGSC_SLIDER_SPACE_BETWEEN_CMS' => (string) ($get('MGSC_SLIDER_SPACE_BETWEEN_CMS') !== false ? $get('MGSC_SLIDER_SPACE_BETWEEN_CMS') : ''),
'MGSC_SLIDER_SPEED_CMS' => (string) ($get('MGSC_SLIDER_SPEED_CMS') !== false ? $get('MGSC_SLIDER_SPEED_CMS') : ''),
'MGSC_SLIDER_AUTO_HEIGHT_CMS' => ($get('MGSC_SLIDER_AUTO_HEIGHT_CMS') !== false ? (string)$get('MGSC_SLIDER_AUTO_HEIGHT_CMS') : ''),
'MGSC_SLIDER_CENTER_ENABLED_CMS' => ($get('MGSC_SLIDER_CENTER_ENABLED_CMS') !== false ? (string)$get('MGSC_SLIDER_CENTER_ENABLED_CMS') : ''),
'ZM40_NET_ENABLED' => (int) (Zm40CommonSc::isNetEnabled() ? 1 : 0),
];
}
protected function postProcess(): void
{
// Sanitize and persist values; empty strings for overrides mean fallback to global
$bool = static function($k) {
$v = Tools::getValue($k, null);
if ($v === null) { return false; }
$s = strtolower(trim((string)$v));
if ($s === '0' || $s === 'off' || $s === 'false' || $s === '') { return false; }
if ($s === '1' || $s === 'on' || $s === 'true' || $s === 'yes') { return true; }
return (bool) $v;
};
$intOrEmpty = static function($k) {
$v = Tools::getValue($k, '');
if ($v === '' || $v === null) { return ''; }
return (int) $v;
};
$floatSanitized = static function($k, $def) {
$v = Tools::getValue($k, null);
if ($v === null || $v === '') { return (string)$def; }
$s = str_replace(',', '.', (string)$v);
$s = preg_replace('/[^0-9\.]/', '', (string)$s);
if ($s === '' || !preg_match('/^-?\d+(?:\.\d+)?$/', (string)$s)) { return (string)$def; }
return (string)$s;
};
try {
// Update assets loading flag ONLY if the field is posted (this page has multiple forms)
if (Tools::getIsset('MGSC_LOAD_SWIPER_ASSETS')) {
Configuration::updateValue('MGSC_LOAD_SWIPER_ASSETS', $bool('MGSC_LOAD_SWIPER_ASSETS'));
}
if (Tools::getIsset('MGSC_ASSETS_LOAD_ENABLED')) {
Configuration::updateValue('MGSC_ASSETS_LOAD_ENABLED', $bool('MGSC_ASSETS_LOAD_ENABLED'));
}
Configuration::updateValue('MGSC_SLIDER_AUTOPLAY_ENABLED', $bool('MGSC_SLIDER_AUTOPLAY_ENABLED'));
Configuration::updateValue('MGSC_SLIDER_SPACE_BETWEEN', (int) Tools::getValue('MGSC_SLIDER_SPACE_BETWEEN', 20));
Configuration::updateValue('MGSC_SLIDER_SPEED', (int) Tools::getValue('MGSC_SLIDER_SPEED', 600));
Configuration::updateValue('MGSC_SLIDER_AUTO_HEIGHT', $bool('MGSC_SLIDER_AUTO_HEIGHT'));
Configuration::updateValue('MGSC_SLIDER_CENTER_ENABLED', $bool('MGSC_SLIDER_CENTER_ENABLED'));
// Center per breakpoint
$ov = Tools::getValue('MGSC_SLIDER_CENTER_ENABLED_XL', '');
Configuration::updateValue('MGSC_SLIDER_CENTER_ENABLED_XL', ($ov === '' ? '' : (int)((bool)$ov)));
$ov = Tools::getValue('MGSC_SLIDER_CENTER_ENABLED_LG', '');
Configuration::updateValue('MGSC_SLIDER_CENTER_ENABLED_LG', ($ov === '' ? '' : (int)((bool)$ov)));
$ov = Tools::getValue('MGSC_SLIDER_CENTER_ENABLED_MD', '');
Configuration::updateValue('MGSC_SLIDER_CENTER_ENABLED_MD', ($ov === '' ? '' : (int)((bool)$ov)));
$ov = Tools::getValue('MGSC_SLIDER_CENTER_ENABLED_SM', '');
Configuration::updateValue('MGSC_SLIDER_CENTER_ENABLED_SM', ($ov === '' ? '' : (int)((bool)$ov)));
$ov = Tools::getValue('MGSC_SLIDER_CENTER_ENABLED_XS', '');
Configuration::updateValue('MGSC_SLIDER_CENTER_ENABLED_XS', ($ov === '' ? '' : (int)((bool)$ov)));
// SPV per breakpoint (store as string to keep decimals)
Configuration::updateValue('MGSC_SLIDER_SPV', $floatSanitized('MGSC_SLIDER_SPV', '1'));
Configuration::updateValue('MGSC_SLIDER_SPV_XL', $floatSanitized('MGSC_SLIDER_SPV_XL', '4'));
Configuration::updateValue('MGSC_SLIDER_SPV_LG', $floatSanitized('MGSC_SLIDER_SPV_LG', '4'));
Configuration::updateValue('MGSC_SLIDER_SPV_MD', $floatSanitized('MGSC_SLIDER_SPV_MD', '3'));
Configuration::updateValue('MGSC_SLIDER_SPV_SM', $floatSanitized('MGSC_SLIDER_SPV_SM', '2'));
// XS is optional: if left empty, store empty string to inherit Base at runtime
$xsRaw = Tools::getValue('MGSC_SLIDER_SPV_XS', null);
if ($xsRaw === null || $xsRaw === '') {
Configuration::updateValue('MGSC_SLIDER_SPV_XS', '');
} else {
Configuration::updateValue('MGSC_SLIDER_SPV_XS', $floatSanitized('MGSC_SLIDER_SPV_XS', '1'));
}
// Overrides: store empty string if not provided
$ov = Tools::getValue('MGSC_SLIDER_AUTOPLAY_ENABLED_HOME', '');
Configuration::updateValue('MGSC_SLIDER_AUTOPLAY_ENABLED_HOME', ($ov === '' ? '' : (int)((bool)$ov)));
Configuration::updateValue('MGSC_SLIDER_SPACE_BETWEEN_HOME', $intOrEmpty('MGSC_SLIDER_SPACE_BETWEEN_HOME'));
Configuration::updateValue('MGSC_SLIDER_SPEED_HOME', $intOrEmpty('MGSC_SLIDER_SPEED_HOME'));
$ov = Tools::getValue('MGSC_SLIDER_AUTO_HEIGHT_HOME', '');
Configuration::updateValue('MGSC_SLIDER_AUTO_HEIGHT_HOME', ($ov === '' ? '' : (int)((bool)$ov)));
$ov = Tools::getValue('MGSC_SLIDER_CENTER_ENABLED_HOME', '');
Configuration::updateValue('MGSC_SLIDER_CENTER_ENABLED_HOME', ($ov === '' ? '' : (int)((bool)$ov)));
$ov = Tools::getValue('MGSC_SLIDER_AUTOPLAY_ENABLED_CMS', '');
Configuration::updateValue('MGSC_SLIDER_AUTOPLAY_ENABLED_CMS', ($ov === '' ? '' : (int)((bool)$ov)));
Configuration::updateValue('MGSC_SLIDER_SPACE_BETWEEN_CMS', $intOrEmpty('MGSC_SLIDER_SPACE_BETWEEN_CMS'));
Configuration::updateValue('MGSC_SLIDER_SPEED_CMS', $intOrEmpty('MGSC_SLIDER_SPEED_CMS'));
$ov = Tools::getValue('MGSC_SLIDER_AUTO_HEIGHT_CMS', '');
Configuration::updateValue('MGSC_SLIDER_AUTO_HEIGHT_CMS', ($ov === '' ? '' : (int)((bool)$ov)));
$ov = Tools::getValue('MGSC_SLIDER_CENTER_ENABLED_CMS', '');
Configuration::updateValue('MGSC_SLIDER_CENTER_ENABLED_CMS', ($ov === '' ? '' : (int)((bool)$ov)));
// ZM40 Common — interrupteur réseau (switch is_bool, posté 0/1)
if (Tools::getIsset('ZM40_NET_ENABLED')) {
Configuration::updateValue('ZM40_NET_ENABLED', (int) Tools::getValue('ZM40_NET_ENABLED'));
}
// Sauvegarde = rafraîchir le feed ZM40 au prochain rendu
Zm40CommonSc::clearFeedCache();
} catch (\Throwable $e) {
// Swallow errors in BO; PS will display PHP error logs if necessary
}
}
}