<?php
|
namespace JVBase\registrar\fields;
|
|
|
if (!defined('ABSPATH')) {
|
exit;
|
}
|
|
class UploadField extends Field {
|
protected bool $multiple = false;
|
protected string $subtype;
|
|
protected int $maxUploads;
|
|
public function setMultiple(bool $set):void
|
{
|
$this->multiple = $set;
|
}
|
public function getMultiple():bool
|
{
|
return $this->multiple;
|
}
|
|
public function setMaxUploads(int $maxUploads):void
|
{
|
$max = 20;
|
$this->maxUploads = min($maxUploads, $max);
|
}
|
public function getMaxUploads():int
|
{
|
return $this->maxUploads;
|
}
|
|
public function setSubtype(string $subtype):void
|
{
|
$allowed = ['document', 'video', 'image', 'all'];
|
if (!in_array($subtype, $allowed)) {
|
error_log('Invalid subtype for '.$this->name.' image field: '.$subtype);
|
return;
|
}
|
$this->subtype = $subtype;
|
}
|
public function getSubtype():string
|
{
|
return $this->subtype;
|
}
|
}
|