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 / includes / Core / Fallback / FormEntryMetaChange.php

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

90 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 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 public function __construct() {
15 $this->fallbackModel = new FallbackModel();
16 }
17
18 public function changeMeta() {
19 $formHandler = FormHandler::getInstance();
20 $all_forms = $formHandler->admin->getAllForm();
21 foreach ($all_forms as $form) {
22 $this->formID = $form->id;
23 $formManager = new AdminFormManager($this->formID);
24 $allFields = $formManager->getFormContent()->fields;
25 foreach ($allFields as $fieldKey => $fieldVal) {
26 $this->fieldKey = $fieldKey;
27 $this->field_name = preg_replace('/[\`\~\!\@\#\$\'\.\s\?\+\-\*\&\|\/\\\!]/', '_', $fieldVal->lbl);
28 $this->fallbackModel->changeMetaKey($this->fieldKey, $this->field_name);
29 $this->changeIntegKey();
30 $this->changeWorkflowKey();
31 $this->changeSuccessMessageKey();
32 $this->changeEmailTempKey();
33 }
34 }
35 }
36
37 private function changeIntegKey() {
38 $integrationHandler = new IntegrationHandler($this->formID);
39
40 $formIntegrations = $integrationHandler->getAllIntegration();
41
42 foreach ($formIntegrations as $integration) {
43 $integId = $integration->id;
44 $integstr = str_replace("{$this->fieldKey}{$this->field_name}", $this->fieldKey, $integration->integration_details);
45 $this->fallbackModel->changeIntegKey($integId, $integstr);
46 }
47 }
48
49 private function changeWorkflowKey() {
50 $workflowHandler = new WorkFlowHandler($this->formID);
51 $formWorkflows = $workflowHandler->getAllworkFlow();
52 foreach ($formWorkflows as $workflow) {
53 $workflowId = $workflow['id'];
54 $logics = wp_json_encode($workflow['logics']);
55 $actions = wp_json_encode($workflow['actions']);
56 $successAction = wp_json_encode($workflow['successAction']);
57 $workflowAction = '{"action":' . $actions . ',"successAction":' . $successAction . '}';
58
59 $logics = str_replace("{$this->fieldKey}{$this->field_name}", $this->fieldKey, $logics);
60 $workflowAction = str_replace("{$this->fieldKey}{$this->field_name}", $this->fieldKey, $workflowAction);
61
62 $this->fallbackModel->changeWorkflowKey($workflowId, $logics, $workflowAction);
63 }
64 }
65
66 private function changeSuccessMessageKey() {
67 $successMessageModel = new SuccessMessageModel();
68 $allSuccessMessages = $successMessageModel->get();
69
70 foreach ($allSuccessMessages as $message) {
71 $messageId = $message->id;
72 $title = str_replace("{$this->fieldKey}{$this->field_name}", $this->fieldKey, $message->message_title);
73 $content = str_replace("{$this->fieldKey}{$this->field_name}", $this->fieldKey, $message->message_content);
74 $this->fallbackModel->changeSuccessMessageKey($messageId, $title, $content);
75 }
76 }
77
78 private function changeEmailTempKey() {
79 $emailTemplateModel = new EmailTemplateModel();
80 $allEmailTemp = $emailTemplateModel->get();
81
82 foreach ($allEmailTemp as $temp) {
83 $tempId = $temp->id;
84 $sub = str_replace("{$this->fieldKey}{$this->field_name}", $this->fieldKey, $temp->sub);
85 $body = str_replace("{$this->fieldKey}{$this->field_name}", $this->fieldKey, $temp->body);
86 $this->fallbackModel->changeEmailTempKey($tempId, $sub, $body);
87 }
88 }
89 }
90