PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.0
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.0
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 / v1 / includes / Core / Fallback / FormEntryMetaChange.php

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

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