Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/fluentform/app/Modules/Form/Inputs.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 +
3 + namespace FluentForm\App\Modules\Form;
4 +
5 + use FluentForm\App\Modules\Acl\Acl;
6 + use FluentForm\Framework\Foundation\Application;
7 + use FluentForm\App\Services\FormBuilder\EditorShortCode;
8 + use FluentForm\Framework\Helpers\ArrayHelper;
9 +
10 + class Inputs
11 + {
12 + /**
13 + * Request object
14 + *
15 + * @var \FluentForm\Framework\Request\Request
16 + */
17 + private $request;
18 +
19 + /**
20 + * Build the class instance
21 + *
22 + * @throws \Exception
23 + */
24 + public function __construct(Application $application)
25 + {
26 + $this->request = $application->request;
27 + }
28 +
29 + /**
30 + * Get all the flatten form inputs for shortcode generation.
31 + */
32 + public function index()
33 + {
34 + $formId = $this->request->get('formId');
35 +
36 + $form = wpFluent()->table('fluentform_forms')->find($formId);
37 +
38 + $fields = FormFieldsParser::getShortCodeInputs($form, [
39 + 'admin_label', 'attributes', 'options',
40 + ]);
41 +
42 + $fields = array_filter($fields, function ($field) {
43 + return in_array($field['element'], $this->supportedConditionalFields());
44 + });
45 +
46 + wp_send_json($this->filterEditorFields($fields), 200);
47 + }
48 +
49 + public function supportedConditionalFields()
50 + {
51 + $supportedConditionalFields = [
52 + 'select',
53 + 'ratings',
54 + 'net_promoter',
55 + 'textarea',
56 + 'shortcode',
57 + 'input_url',
58 + 'input_text',
59 + 'input_date',
60 + 'input_email',
61 + 'input_radio',
62 + 'input_number',
63 + 'select_country',
64 + 'input_checkbox',
65 + 'input_password',
66 + 'terms_and_condition',
67 + 'gdpr_agreement',
68 + 'input_hidden',
69 + 'input_file',
70 + 'input_image',
71 + 'subscription_payment_component',
72 + ];
73 +
74 + $supportedConditionalFields = apply_filters_deprecated(
75 + 'fluentform_supported_conditional_fields',
76 + [
77 + $supportedConditionalFields
78 + ],
79 + FLUENTFORM_FRAMEWORK_UPGRADE,
80 + 'fluentform/supported_conditional_fields',
81 + 'Use fluentform/supported_conditional_fields instead of fluentform_supported_conditional_fields.'
82 + );
83 +
84 + return apply_filters('fluentform/supported_conditional_fields', $supportedConditionalFields);
85 + }
86 +
87 + public function filterEditorFields($fields)
88 + {
89 + foreach ($fields as $index => $field) {
90 + $element = ArrayHelper::get($field, 'element');
91 + if ('select_country' == $element) {
92 + $fields[$index]['options'] = getFluentFormCountryList();
93 + } elseif ('gdpr-agreement' == $element || 'terms_and_condition' == $element) {
94 + $fields[$index]['options'] = ['on' => 'Checked'];
95 + }
96 + }
97 +
98 + return $fields;
99 + }
100 + }
101 +