PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.1.2
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.1.2
V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 2.10.2 All 137 releases
bit-form / includes / Core / Fallback / FormEntryMetaChange.php

FormEntryMetaChange.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 3.1.2, at includes/Core/Fallback/FormEntryMetaChange.php

105 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Core\Fallback;
4
5 use BitCode\BitForm\Admin\Form\AdminFormManager;
6 use BitCode\BitForm\Core\Database\EmailTemplateModel;
7 use BitCode\BitForm\Core\Database\FallbackModel;
8 use BitCode\BitForm\Core\Database\SuccessMessageModel;
9 use BitCode\BitForm\Core\Form\FormHandler;
10 use BitCode\BitForm\Core\Integration\IntegrationHandler;
11 use BitCode\BitForm\Core\WorkFlow\WorkFlowHandler;
12
13 class FormEntryMetaChange
14 {
15 private $formID;
16
17 private $fieldKey;
18
19 private $field_name;
20
21 private $fallbackModel;
22
23 public function __construct()
24 {
25 $this->fallbackModel = new FallbackModel();
26 }
27
28 public function changeMeta()
29 {
30 $formHandler = FormHandler::getInstance();
31 $all_forms = $formHandler->admin->getAllForm();
32 foreach ($all_forms as $form) {
33 $this->formID = $form->id;
34 $formManager = new AdminFormManager($this->formID);
35 $allFields = $formManager->getFormContent()->fields;
36 foreach ($allFields as $fieldKey => $fieldVal) {
37 $this->fieldKey = $fieldKey;
38 $this->field_name = preg_replace('/[\`\~\!\@\#\$\'\.\s\?\+\-\*\&\|\/\\\!]/', '_', $fieldVal->lbl);
39 $this->fallbackModel->changeMetaKey($this->fieldKey, $this->field_name);
40 $this->changeIntegKey();
41 $this->changeWorkflowKey();
42 $this->changeSuccessMessageKey();
43 $this->changeEmailTempKey();
44 }
45 }
46 }
47
48 private function changeIntegKey()
49 {
50 $integrationHandler = new IntegrationHandler($this->formID);
51
52 $formIntegrations = $integrationHandler->getAllIntegration();
53
54 foreach ($formIntegrations as $integration) {
55 $integId = $integration->id;
56 $integstr = str_replace("{$this->fieldKey}{$this->field_name}", $this->fieldKey, $integration->integration_details);
57 $this->fallbackModel->changeIntegKey($integId, $integstr);
58 }
59 }
60
61 private function changeWorkflowKey()
62 {
63 $workflowHandler = new WorkFlowHandler($this->formID);
64 $formWorkflows = $workflowHandler->getAllworkFlow();
65 foreach ($formWorkflows as $workflow) {
66 $workflowId = $workflow['id'];
67 $logics = wp_json_encode($workflow['logics']);
68 $actions = wp_json_encode($workflow['actions']);
69 $successAction = wp_json_encode($workflow['successAction']);
70 $workflowAction = '{"action":' . $actions . ',"successAction":' . $successAction . '}';
71
72 $logics = str_replace("{$this->fieldKey}{$this->field_name}", $this->fieldKey, $logics);
73 $workflowAction = str_replace("{$this->fieldKey}{$this->field_name}", $this->fieldKey, $workflowAction);
74
75 $this->fallbackModel->changeWorkflowKey($workflowId, $logics, $workflowAction);
76 }
77 }
78
79 private function changeSuccessMessageKey()
80 {
81 $successMessageModel = new SuccessMessageModel();
82 $allSuccessMessages = $successMessageModel->get();
83
84 foreach ($allSuccessMessages as $message) {
85 $messageId = $message->id;
86 $title = str_replace("{$this->fieldKey}{$this->field_name}", $this->fieldKey, $message->message_title);
87 $content = str_replace("{$this->fieldKey}{$this->field_name}", $this->fieldKey, $message->message_content);
88 $this->fallbackModel->changeSuccessMessageKey($messageId, $title, $content);
89 }
90 }
91
92 private function changeEmailTempKey()
93 {
94 $emailTemplateModel = new EmailTemplateModel();
95 $allEmailTemp = $emailTemplateModel->get();
96
97 foreach ($allEmailTemp as $temp) {
98 $tempId = $temp->id;
99 $sub = str_replace("{$this->fieldKey}{$this->field_name}", $this->fieldKey, $temp->sub);
100 $body = str_replace("{$this->fieldKey}{$this->field_name}", $this->fieldKey, $temp->body);
101 $this->fallbackModel->changeEmailTempKey($tempId, $sub, $body);
102 }
103 }
104 }
105