PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 1.2.4
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v1.2.4
6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 3.6.66 All 195 releases
fluentform / app / Modules / Integration / BaseIntegration.php

BaseIntegration.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 1.2.4, at app/Modules/Integration/BaseIntegration.php

103 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace FluentForm\App\Modules\Integration;
2
3 class BaseIntegration
4 {
5 private $setting_key = '';
6 private $isMultiple = false;
7 private $formId = false;
8 private $isJsonValue = true;
9
10 public function __construct($settings_key = '', $form_id = false, $isMultiple = false)
11 {
12 $this->setting_key = $settings_key;
13 $this->isMultiple = $isMultiple;
14 $this->formId = $form_id;
15 }
16
17 public function setSettingsKey($key)
18 {
19 $this->setting_key = $key;
20 }
21
22 public function setIsMultiple($isMultiple)
23 {
24 $this->isMultiple = $isMultiple;
25 }
26
27 public function setFormId($formId)
28 {
29 $this->formId = $formId;
30 }
31
32 public function setJasonType($type)
33 {
34 $this->isJsonValue = $type;
35 }
36
37 public function save($settings)
38 {
39 return wpFluent()->table('fluentform_form_meta')
40 ->insert(array(
41 'meta_key' => $this->setting_key,
42 'form_id' => $this->formId,
43 'value' => json_encode($settings)
44 ));
45 }
46
47 public function update($settingsId, $settings)
48 {
49 return wpFluent()->table('fluentform_form_meta')
50 ->where('id', $settingsId)
51 ->update(array(
52 'value' => json_encode($settings)
53 ));
54 }
55
56 public function get($settingsId)
57 {
58 $settings = wpFluent()->table('fluentform_form_meta')
59 ->where('form_id', $this->formId)
60 ->where('meta_key', $this->setting_key)
61 ->find($settingsId);
62 $settings->formattedValue = $this->getFormattedValue($settings);
63 return $settings;
64 }
65
66 public function getAll()
67 {
68 $settingsQuery = wpFluent()->table('fluentform_form_meta')
69 ->where('form_id', $this->formId)
70 ->where('meta_key', $this->setting_key);
71 if($this->isMultiple) {
72 $settings = $settingsQuery->get();
73 foreach ($settings as $setting) {
74 $setting->formattedValue = $this->getFormattedValue($setting);
75 }
76 } else {
77 $settings = $settingsQuery->first();
78 $settings->formattedValue = $this->getFormattedValue($settings);
79 }
80 return $settings;
81 }
82
83 public function delete($settingsId)
84 {
85 return wpFluent()->table('fluentform_form_meta')
86 ->where('meta_key', $this->setting_key)
87 ->where('form_id', $this->formId)
88 ->where('id', $settingsId)
89 ->delete();
90 }
91
92 public function deleteAll()
93 {
94
95 }
96
97 private function getFormattedValue($setting)
98 {
99 if($this->isJsonValue)
100 return json_decode($setting->value, true);
101 return $setting->value;
102 }
103 }