PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
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
← All changes | backend/src/ValueObjects/Field/FieldAdvancedSettings.php +97 -18 0.8.1 → 1.5 View file →
@@ -6,15 +6,8 @@
6 6 */
7 7
8 8 namespace IvyForms\ValueObjects\Field;
9 9
10 -// phpcs:disable PSR1.Files.SideEffects
11 -if (!defined('ABSPATH')) {
12 - exit; // Exit if accessed directly
13 -}
14 -
15 -use IvyForms\Common\Exceptions\ValidationException;
16 -
17 10 /**
18 11 * Class FieldAdvancedSettings
19 12 *
20 13 * @package IvyForms\ValueObjects\Field
@@ -56,8 +49,18 @@
56 49 */
57 50 private string $inputSuffix;
58 51
59 52 /**
53 + * @var string Type of rating icon (star, heart, etc.)
54 + */
55 + private string $ratingIcon;
56 +
57 + /**
58 + * @var FileUploadFieldAdvancedSettings
59 + */
60 + private FileUploadFieldAdvancedSettings $fileUploadSettings;
61 +
62 + /**
60 63 * FieldAdvancedSettings constructor.
61 64 *
62 65 * @param string $defaultValue
63 66 * @param bool $limitMaxLength
@@ -65,9 +68,10 @@
65 68 * @param string $labelPosition
66 69 * @param bool $noDuplicates
67 70 * @param string $inputPrefix
68 71 * @param string $inputSuffix
69 - *
72 + * @param string $ratingIcon
73 + * @param FileUploadFieldAdvancedSettings $fileUploadSettings
70 74 */
71 75 public function __construct(
72 76 string $defaultValue,
73 77 bool $limitMaxLength,
@@ -74,9 +78,11 @@
74 78 int $maxLength,
75 79 string $labelPosition,
76 80 bool $noDuplicates,
77 81 string $inputPrefix,
78 - string $inputSuffix
82 + string $inputSuffix,
83 + string $ratingIcon,
84 + FileUploadFieldAdvancedSettings $fileUploadSettings
79 85 ) {
80 86 $this->defaultValue = $defaultValue;
81 87 $this->limitMaxLength = $limitMaxLength;
82 88 $this->maxLength = $maxLength;
@@ -83,8 +89,10 @@
83 89 $this->labelPosition = $labelPosition;
84 90 $this->noDuplicates = $noDuplicates;
85 91 $this->inputPrefix = $inputPrefix;
86 92 $this->inputSuffix = $inputSuffix;
93 + $this->ratingIcon = $ratingIcon;
94 + $this->fileUploadSettings = $fileUploadSettings;
87 95 }
88 96
89 97 /**
90 98 * Get the default value.
@@ -226,8 +234,75 @@
226 234 $this->inputSuffix = $suffix;
227 235 }
228 236
229 237 /**
238 + * Get the rating icon type.
239 + *
240 + * @return string
241 + */
242 + public function getRatingIcon(): string
243 + {
244 + return $this->ratingIcon;
245 + }
246 +
247 + /**
248 + * Set the rating icon type.
249 + *
250 + * @param string $ratingIcon
251 + */
252 + public function setRatingIcon(string $ratingIcon): void
253 + {
254 + $this->ratingIcon = $ratingIcon;
255 + }
256 +
257 + public function getFileUploadSettings(): FileUploadFieldAdvancedSettings
258 + {
259 + return $this->fileUploadSettings;
260 + }
261 +
262 + /**
263 + * Maximum file size in MB for file-upload fields (0 = server default).
264 + */
265 + public function getMaxFileSizeMb(): int
266 + {
267 + return $this->fileUploadSettings->getMaxFileSizeMb();
268 + }
269 +
270 + public function setMaxFileSizeMb(int $maxFileSizeMb): void
271 + {
272 + $this->fileUploadSettings->setMaxFileSizeMb($maxFileSizeMb);
273 + }
274 +
275 + /**
276 + * Target storage for uploads: ivyforms or media_library.
277 + */
278 + public function getSaveUploadsTo(): string
279 + {
280 + return $this->fileUploadSettings->getSaveUploadsTo();
281 + }
282 +
283 + public function setSaveUploadsTo(string $saveUploadsTo): void
284 + {
285 + $this->fileUploadSettings->setSaveUploadsTo($saveUploadsTo);
286 + }
287 +
288 + /**
289 + * @return array<int, string>
290 + */
291 + public function getAllowedFileExtensions(): array
292 + {
293 + return $this->fileUploadSettings->getAllowedFileExtensions();
294 + }
295 +
296 + /**
297 + * @param array<int, string> $allowedFileExtensions
298 + */
299 + public function setAllowedFileExtensions(array $allowedFileExtensions): void
300 + {
301 + $this->fileUploadSettings->setAllowedFileExtensions($allowedFileExtensions);
302 + }
303 +
304 + /**
230 305 * Convert the advanced settings to an array.
231 306 *
232 307 * @return array<string, mixed>
233 308 */
@@ -232,15 +307,19 @@
232 307 * @return array<string, mixed>
233 308 */
234 309 public function toArray(): array
235 310 {
236 - return [
237 - 'defaultValue' => $this->getDefaultValue(),
238 - 'limitMaxLength' => $this->isLimitMaxLength(),
239 - 'maxLength' => $this->getMaxLength(),
240 - 'labelPosition' => $this->getLabelPosition(),
241 - 'noDuplicates' => $this->isNoDuplicates(),
242 - 'inputPrefix' => $this->getInputPrefix(),
243 - 'inputSuffix' => $this->getInputSuffix(),
244 - ];
311 + return array_merge(
312 + [
313 + 'defaultValue' => $this->getDefaultValue(),
314 + 'limitMaxLength' => $this->isLimitMaxLength(),
315 + 'maxLength' => $this->getMaxLength(),
316 + 'labelPosition' => $this->getLabelPosition(),
317 + 'noDuplicates' => $this->isNoDuplicates(),
318 + 'inputPrefix' => $this->getInputPrefix(),
319 + 'inputSuffix' => $this->getInputSuffix(),
320 + 'ratingIcon' => $this->getRatingIcon(),
321 + ],
322 + $this->fileUploadSettings->toArray()
323 + );
245 324 }
246 325 }