From: Joshua Rüsweg Date: Mon, 7 Jan 2019 21:48:52 +0000 (+0100) Subject: Add UploadField X-Git-Tag: 5.2.0_Alpha_1~296^2~54 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=64929f47407ea2ed97c1bc4b12b156cbb099f9b4;p=GitHub%2FWoltLab%2FWCF.git Add UploadField See #2825 --- diff --git a/wcfsetup/install/files/lib/system/file/upload/UploadField.class.php b/wcfsetup/install/files/lib/system/file/upload/UploadField.class.php new file mode 100644 index 0000000000..481697a069 --- /dev/null +++ b/wcfsetup/install/files/lib/system/file/upload/UploadField.class.php @@ -0,0 +1,149 @@ + + * @package WoltLabSuite\Core\System\File\Upload + * @since 5.2 + */ +class UploadField { + /** + * The max number of files for this field. + * + * @var int + */ + public $maxFiles = 10; + + /** + * The intern field id. Should be unique for each form. + * + * @var string + */ + public $fieldId; + + /** + * The internalId for uploads. + * + * @var string|null + */ + public $internalId = null; + + /** + * The name of the field. + * + * @var string + */ + public $name; + /** + * The description of the field. + * + * @var tring + */ + public $description; + + /** + * Indicates whether the field is image only. + * + * @var boolean + */ + public $imageOnly = false; + + /** + * UploadField constructor. + * + * @param String $fieldId + * @param String $fieldName + * @param String $fieldDescription + */ + public function __construct($fieldId, $fieldName = 'Upload', $fieldDescription = null) { + $this->fieldId = $fieldId; + $this->name = $fieldName; + $this->description = $fieldDescription; + } + + /** + * Indicates the support of multiple files. + * + * @return boolean + */ + public function supportMultipleFiles() { + return $this->maxFiles > 1; + } + + /** + * Returns the max number of files. + * + * @return int + */ + public function getMaxFiles() { + return $this->maxFiles; + } + + /** + * Returns true, if the upload is image only. + * + * @return boolean + */ + public function isImageOnly() { + return $this->imageOnly; + } + + /** + * Returns the fieldId. + * + * @return String + */ + public function getFieldId() { + return $this->fieldId; + } + + /** + * Sets the internalId for this field. + * + * @param String $internalId + */ + public function setInternalId($internalId) { + $this->internalId = $internalId; + } + + /** + * Returns the internalId of this field. + * + * @return String|null + */ + public function getInternalId() { + return $this->internalId; + } + + /** + * Returns the name of the field. + * + * @return String + */ + public function getName() { + return WCF::getLanguage()->get($this->name); + } + + /** + * Returns the description of the field. + * + * @return String + */ + public function getDescription() { + return WCF::getLanguage()->get($this->description); + } + + /** + * Set the image only flag. + * + * @param boolean $imageOnly + */ + public function setImageOnly($imageOnly) { + $this->imageOnly = (bool) $imageOnly; + } +}