Browse code

Reimplement extended registration and personal data form handling

Benjamin Roth authored on22/03/2023 12:59:10
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,81 @@
1
+<?php
2
+
3
+/**
4
+ * eSales Media Formilicious for Contao Open Source CMS
5
+ *
6
+ * Copyright (C) 2013-2014 eSalesMedia
7
+ *
8
+ * @package    eSM_formilicious
9
+ * @link       http://www.esales-media.de
10
+ * @license    http://www.gnu.org/licenses/lgpl-3.0.html LGPL
11
+ *
12
+ * @author     Benjamin Roth <benjamin@esales-media.de>
13
+ */
14
+
15
+
16
+/**
17
+ * Run in a custom namespace, so the class can be replaced
18
+ */
19
+namespace vonRotenberg\FormiliciousBundle\Controller\Frontend\Module;
20
+
21
+use Contao\ModuleRegistration as OrgModuleRegistration;
22
+use Contao\PageModel;
23
+use Contao\System;
24
+
25
+/**
26
+ * Class ModuleRegistration
27
+ *
28
+ * Front end module "registration".
29
+ * @copyright  Leo Feyer 2005-2014
30
+ * @author     Leo Feyer <https://contao.org>
31
+ * @package    Core
32
+ */
33
+class ModuleRegistration extends OrgModuleRegistration
34
+{
35
+  protected $originalDca;
36
+
37
+  public function generate()
38
+  {
39
+    $return = parent::generate();
40
+    $GLOBALS['TL_DCA']['tl_member'] = $this->originalDca;
41
+
42
+    return $return;
43
+  }
44
+
45
+
46
+  /**
47
+   * Generate the module
48
+   */
49
+  protected function compile()
50
+  {
51
+    /** @var PageModel $objPage */
52
+    global $objPage;
53
+
54
+    $GLOBALS['TL_LANGUAGE'] = $objPage->language;
55
+
56
+    System::loadLanguageFile('tl_member');
57
+    $this->loadDataContainer('tl_member');
58
+    $this->originalDca = $GLOBALS['TL_DCA']['tl_member'];
59
+
60
+    $arrEditable = [];
61
+    foreach ($this->editable as $key=>$fielddata)
62
+    {
63
+      // Split formilicious editable data in single vars
64
+      list($field, $fieldWidth, $fieldClr, $fieldMandatory) = array_values($fielddata);
65
+      $GLOBALS['TL_DCA']['tl_member']['fields'][$field]['eval']['eSM_fl_width'] = $fieldWidth;
66
+      $GLOBALS['TL_DCA']['tl_member']['fields'][$field]['eval']['eSM_fl_clear'] = $fieldClr;
67
+      if ($fieldMandatory)
68
+      {
69
+        $GLOBALS['TL_DCA']['tl_member']['fields'][$field]['eval']['mandatory'] = $fieldMandatory;
70
+      } else {
71
+        $GLOBALS['TL_DCA']['tl_member']['fields'][$field]['eval']['mandatory'] = false;
72
+
73
+      }
74
+      $arrEditable[$key] = $field;
75
+    }
76
+    $this->editable = $arrEditable;
77
+
78
+    parent::compile();
79
+
80
+  }
81
+}