PluginProbe
The Innovative Form Builder – IvyForms / 0.9.1
The Innovative Form Builder – IvyForms v0.9.1
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Services / Template / ProductFeedbackFormTemplate.php

ProductFeedbackFormTemplate.php in The Innovative Form Builder – IvyForms 0.9.1, at backend/src/Services/Template/ProductFeedbackFormTemplate.php

298 lines 10.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace IvyForms\Services\Template;
6
7 // phpcs:disable PSR1.Files.SideEffects
8 if (!defined('ABSPATH')) {
9 exit; // Exit if accessed directly
10 }
11
12 use IvyForms\Services\Translations\BackendStrings;
13
14 /**
15 * Product Feedback Form Template
16 *
17 * Collect feedback about a specific product to improve quality, features, and usability.
18 */
19 class ProductFeedbackFormTemplate
20 {
21 /**
22 * Get the Product Feedback Form template
23 *
24 * @return array<string, mixed>
25 */
26 public static function getTemplate(): array
27 {
28 return [
29 'id' => 'product_feedback_form',
30 'name' => BackendStrings::getTemplateStrings()['product_feedback_form'],
31 'description' => BackendStrings::getTemplateStrings()['product_feedback_form_desc'],
32 'category' => 'feedback-forms',
33 'subcategory' => 'customer-feedback-forms',
34 'is_pro' => false,
35 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'product-feedback-form.svg',
36 'form_data' => [
37 'name' => BackendStrings::getTemplateStrings()['product_feedback_form'],
38 'published' => 1,
39 'showTitle' => 1,
40 'storeEntries' => 1,
41 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
42 'fields' => array_merge(
43 self::getProductNameField(),
44 self::getIssuesExperiencedCheckboxField(),
45 self::getProductQualityRatingField(),
46 self::getValueForMoneyRatingField(),
47 self::getWhatDidYouLikeMostTextareaField(),
48 self::getWhatCanBeImprovedTextareaField()
49 ),
50 'settings' => []
51 ]
52 ];
53 }
54
55 /**
56 * Product name dropdown (required)
57 *
58 * @return array<int, array<string, mixed>>
59 */
60 private static function getProductNameField(): array
61 {
62 return [[
63 'id' => 5,
64 'fieldIndex' => 1,
65 'type' => 'select',
66 'label' => BackendStrings::getTemplateStrings()['product_name'],
67 'required' => true,
68 'parentId' => null,
69 'defaultValue' => '',
70 'placeholder' => BackendStrings::getTemplateStrings()['product_name_placeholder'],
71 'position' => 1,
72 'fieldOptions' => [
73 [
74 'id' => 1,
75 'label' => BackendStrings::getTemplateStrings()['product_a'],
76 'value' => 'product_a',
77 'isDefault' => false,
78 'position' => 1,
79 ],
80 [
81 'id' => 2,
82 'label' => BackendStrings::getTemplateStrings()['product_b'],
83 'value' => 'product_b',
84 'isDefault' => false,
85 'position' => 2,
86 ],
87 [
88 'id' => 3,
89 'label' => BackendStrings::getTemplateStrings()['product_c'],
90 'value' => 'product_c',
91 'isDefault' => false,
92 'position' => 3,
93 ],
94 [
95 'id' => 4,
96 'label' => BackendStrings::getTemplateStrings()['other'],
97 'value' => 'other',
98 'isDefault' => false,
99 'position' => 4,
100 ],
101 ]
102 ]];
103 }
104
105 /**
106 * Issues experienced checkbox (optional)
107 *
108 * @return array<int, array<string, mixed>>
109 */
110 private static function getIssuesExperiencedCheckboxField(): array
111 {
112 return [[
113 'id' => 11,
114 'fieldIndex' => 2,
115 'type' => 'checkbox',
116 'label' => BackendStrings::getTemplateStrings()['issues_experienced'],
117 'required' => false,
118 'parentId' => null,
119 'defaultValue' => '',
120 'placeholder' => '',
121 'position' => 2,
122 'fieldOptions' => [
123 [
124 'id' => 6,
125 'label' => BackendStrings::getNewFormStrings()['difficult_to_use'],
126 'value' => 'difficult_to_use',
127 'isDefault' => false,
128 'position' => 1,
129 ],
130 [
131 'id' => 7,
132 'label' => BackendStrings::getTemplateStrings()['missing_features'],
133 'value' => 'missing_features',
134 'isDefault' => false,
135 'position' => 2,
136 ],
137 [
138 'id' => 8,
139 'label' => BackendStrings::getTemplateStrings()['performance_issues'],
140 'value' => 'performance_issues',
141 'isDefault' => false,
142 'position' => 3,
143 ],
144 [
145 'id' => 9,
146 'label' => BackendStrings::getTemplateStrings()['quality_concerns'],
147 'value' => 'quality_concerns',
148 'isDefault' => false,
149 'position' => 4,
150 ],
151 [
152 'id' => 10,
153 'label' => BackendStrings::getTemplateStrings()['no_issues'],
154 'value' => 'no_issues',
155 'isDefault' => false,
156 'position' => 5,
157 ],
158 ]
159 ]];
160 }
161
162 /**
163 * Product quality rating (required)
164 *
165 * @return array<int, array<string, mixed>>
166 */
167 private static function getProductQualityRatingField(): array
168 {
169 return [[
170 'id' => 12,
171 'fieldIndex' => 3,
172 'type' => 'rating',
173 'label' => BackendStrings::getTemplateStrings()['product_quality'],
174 'required' => true,
175 'defaultValue' => '',
176 'placeholder' => '',
177 'position' => 3,
178 'labelPosition' => 'default',
179 'ratingIcon' => 'star',
180 'fieldOptions' => self::getStandardRatingOptions(5),
181 'showValues' => false,
182 'showRatingText' => true,
183 ]];
184 }
185
186 /**
187 * Value for money rating (required)
188 *
189 * @return array<int, array<string, mixed>>
190 */
191 private static function getValueForMoneyRatingField(): array
192 {
193 return [[
194 'id' => 13,
195 'fieldIndex' => 4,
196 'type' => 'rating',
197 'label' => BackendStrings::getTemplateStrings()['value_for_money'],
198 'required' => true,
199 'defaultValue' => '',
200 'placeholder' => '',
201 'position' => 4,
202 'labelPosition' => 'default',
203 'ratingIcon' => 'star',
204 'fieldOptions' => self::getStandardRatingOptions(10),
205 'showValues' => false,
206 'showRatingText' => true,
207 ]];
208 }
209
210 /**
211 * What did you like the most textarea (optional)
212 *
213 * @return array<int, array<string, mixed>>
214 */
215 private static function getWhatDidYouLikeMostTextareaField(): array
216 {
217 return [[
218 'id' => 14,
219 'fieldIndex' => 5,
220 'type' => 'textarea',
221 'label' => BackendStrings::getTemplateStrings()['what_did_you_like_most'],
222 'placeholder' => BackendStrings::getTemplateStrings()['what_did_you_like_most_placeholder'],
223 'required' => false,
224 'parentId' => null,
225 'defaultValue' => '',
226 'position' => 5,
227 'labelPosition' => 'default',
228 ]];
229 }
230
231 /**
232 * What can be improved textarea (optional)
233 *
234 * @return array<int, array<string, mixed>>
235 */
236 private static function getWhatCanBeImprovedTextareaField(): array
237 {
238 return [[
239 'id' => 15,
240 'fieldIndex' => 6,
241 'type' => 'textarea',
242 'label' => BackendStrings::getTemplateStrings()['what_can_be_improved'],
243 'placeholder' => BackendStrings::getTemplateStrings()['what_can_be_improved_placeholder'],
244 'required' => false,
245 'parentId' => null,
246 'defaultValue' => '',
247 'position' => 6,
248 'labelPosition' => 'default',
249 ]];
250 }
251
252 /**
253 * Standard rating options (1-5)
254 *
255 * @return array<int, array<string, mixed>>
256 */
257 private static function getStandardRatingOptions(int $startId): array
258 {
259 return [
260 [
261 'id' => $startId,
262 'label' => BackendStrings::getNewFormStrings()['good'],
263 'value' => '1',
264 'isDefault' => false,
265 'position' => 1
266 ],
267 [
268 'id' => $startId + 1,
269 'label' => BackendStrings::getNewFormStrings()['nice'],
270 'value' => '2',
271 'isDefault' => false,
272 'position' => 2
273 ],
274 [
275 'id' => $startId + 2,
276 'label' => BackendStrings::getNewFormStrings()['very_good'],
277 'value' => '3',
278 'isDefault' => false,
279 'position' => 3
280 ],
281 [
282 'id' => $startId + 3,
283 'label' => BackendStrings::getNewFormStrings()['awesome'],
284 'value' => '4',
285 'isDefault' => false,
286 'position' => 4
287 ],
288 [
289 'id' => $startId + 4,
290 'label' => BackendStrings::getNewFormStrings()['amazing'],
291 'value' => '5',
292 'isDefault' => false,
293 'position' => 5
294 ],
295 ];
296 }
297 }
298