UncleCheese\Dropzone\FileAttachmentField
Defines the FileAttachementField form field type
- Author: Uncle Cheese <unclecheese@leftandmain.com>
Synopsis
class FileAttachmentField
extends FileField
{
- // members
- private static array $allowed_actions = ;
- private static array $url_handlers = ;
- private static boolean $track_files = false;
- protected array $settings = ;
- protected array $params = ;
- protected DataObject $record = NULL;
- protected array $permissions = ;
- protected string $view = 'list';
- protected string $previewTemplate = 'UncleCheese\\Dropzone\\FileAttachmentField_preview';
- protected $displayFolderName;
- protected $hasInvalidFileID;
- // methods
- public static string camelise()
- public static string underscorise()
- public static int get_filesize_from_ini()
- public void __construct()
- public SSViewer FieldHolder()
- public SSViewer SmallFieldHolder()
- protected void defineFieldHolderRequirements()
- public FileAttachmentField saveInto()
- public FileAttachmentField setMethod()
- public boolean getTrackFiles()
- public FileAttachmentField setTrackFiles()
- public FileAttachmentField setParallelUploads()
- public FileAttachmentField setMultiple()
- public FileAttachmentField setMaxFilesize()
- public $this setMaxFiles()
- public $this setAllowedMaxFileNumber()
- public FileAttachmentField setParamName()
- public FileAttachmentField setCreateImageThumbnails()
- public FileAttachmentField setMaxThumbnailFilesize()
- public void addValidFileIDs()
- public array getValidFileIDs()
- public boolean validate()
- public $this setValue()
- public FileAttachmentField setThumbnailWidth()
- public FileAttachmentField setThumbnailHeight()
- public FileAttachmentField setView()
- public string getView()
- public FileAttachmentField setClickable()
- public FileAttachmentField setAcceptedFiles()
- public FileAttachmentField imagesOnly()
- public FileAttachmentField setAcceptedMimeTypes()
- public FileAttachmentField setAutoProcessQueue()
- public FileAttachmentField setPreviewsContainer()
- public void setMaxResolution()
- public void setMinResolution()
- public FileAttachmentField setPreviewTemplate()
- public FileAttachmentField addParam()
- public FileAttachmentField setPermissions()
- public FileAttachmentField setPermission()
- public void setDisplayFolderName()
- public String getDisplayFolderName()
- public boolean isCMS()
- private string getUploadUserError()
- public HTTPResponse upload()
- public UploadField_ItemHandler handleSelect()
- protected boolean deleteFileByID()
- public boolean IsMultiple()
- public string InputName()
- public SS_List AttachedFiles()
- public string RootThumbnailsDir()
- public string ThumbnailsDir()
- public void CSSSize()
- public string DropzoneDir()
- public string|array Value()
- public boolean CanUpload()
- public boolean CanDelete()
- public boolean CanDetach()
- public boolean CanAttach()
- public void PreviewTemplate()
- public int TemplateThumbnailSize()
- public boolean AutoProcess()
- protected boolean checkPerm()
- public string getFileClass()
- public DataObject getRecord()
- protected string getRelation()
- protected mixed getSetting()
- protected array getDefaults()
- public int getSelectedThumbnailWidth()
- public int getSelectedThumbnailHeight()
- public string getConfigJSON()
- public void performReadonlyTransformation()
Hierarchy
Extends
- SilverStripe\Forms\FileField
Members
private
- $allowed_actions
—
array
The allowed actions for the RequestHandler - $track_files
—
boolean
Track files that are uploaded and remove the tracked files when they are saved into a record. - $url_handlers
protected
- $displayFolderName
—
string
UploadField compatability. Used for the select handler, when KickAssets is not installed - $hasInvalidFileID
—
boolean
Set to true if detected invalid file ID - $params
—
array
Extra params to send to the server with the POST request - $permissions
—
array
A list of custom permissions for this instance Options available: - upload - attach (select from existing) - detach (remove from record, but don't delete) -delete (delete from files) - $previewTemplate
—
string
The preview template for uploaded files. Does not necessarily apply to files that were on the record at load time, but rather to files that have been attached to the uploader client side - $record
—
SilverStripe\ORM\DataObject
The record that this FormField is editing - $settings
—
array
A list of settings for this instance - $view
—
string
The style of uploader. Options: "grid", "list"
Methods
private
protected
- checkPerm() — Checks for a given permission. If it is a closure, invoke the method
- defineFieldHolderRequirements() — Define some requirements and settings just before rendering the Field Holder.
- deleteFileByID() — Deletes a file. Ensures user has permissions and the file is part of the current record, so as not to allow arbitrary deletion of files
- getDefaults() — Gets the default settings in the actual Javascript object so that the config JSON doesn't get polluted with default settings
- getRelation() — Gets the name of the relation, if attached to a record
- getSetting() — Gets a given setting. Falls back on Config defaults
public
- __construct() — Constructor. Sets some default permissions
- AttachedFiles() — Gets a list of all the files that are attached to the record
- AutoProcess() — Returns true if the uploader auto-processes
- CSSSize()
- CanAttach() — Returns true if the "attach" permission returns true
- CanDelete() — Returns true if the "delete" permission returns true
- CanDetach() — Returns true if the "detach" permission returns true
- CanUpload() — Returns true if the "upload" permission returns true
- DropzoneDir() — The directory that the module is installed to. A template accessor
- FieldHolder() — Renders the form field, loads requirements. Sets file size based on php.ini Adds the security token
- InputName() — The name of the input, e.g. the "has_one" or "many_many" relation name
- IsMultiple() — A template accessor that determines if the uploader is in "multiple" mode
- PreviewTemplate() — Renders the preview template, optionally for a given file
- RootThumbnailsDir() — Gets the directory that contains all the file icons organised into sizes
- SmallFieldHolder() — Renders the small form field holder, loads requirements. Sets file size based on php.ini Adds the security token
- TemplateThumbnailSize() — Gets the closest thumbnail size for the template, given the list of icon_sizes (e.g. 32px, 64px, 128px)
- ThumbnailsDir() — Gets the directory to the file icons for the current thumbnail size
- Value() — Gets the value
- addParam() — Adds an arbitrary key/val params to send to the server with the upload
- addValidFileIDs() — Add an array of IDs
- camelise() — Helper function to translate underscore_case to camelCase
- getConfigJSON() — Creates a JSON representation of the settings. Augments the list with various parameters calculated at run time.
- getDisplayFolderName()
- getFileClass() — Gets the classname for the file, e.g. from the declared file relation on the record.
- getRecord() — Get the record that this form field is editing
- getSelectedThumbnailHeight() — Gets the thumbnail height given the current view type
- getSelectedThumbnailWidth() — Gets the thumbnail width given the current view type
- getTrackFiles() — Return whether files are tracked or not.
- getValidFileIDs() — Get an associative array of File IDs uploaded through this field during this session or attached to the file field.
- getView() — Gets the current view
- get_filesize_from_ini() — Looks at the php.ini and takes the lower of two values, translates it into an int representing the number of bytes allowed per upload
- handleSelect()
- imagesOnly() — A helper method to only allow images files
- isCMS() — Returns true if the uploader is being used in CMS context
- performReadonlyTransformation()
- saveInto() — Saves the field into a record
- setAcceptedFiles() — A list of accepted file extensions
- setAcceptedMimeTypes() — Sets the allowed mime types
- setAllowedMaxFileNumber() — Maximum number of files allowed to be attached (Keeps API consistent with UploadField)
- setAutoProcessQueue() — Set auto-processing. If true, uploads happen on addition to the queue
- setClickable() — Set the selector for the clickable element. Use a boolean for the entire dropzone.
- setCreateImageThumbnails() — Allow or disallow image thumbnails created client side
- setDisplayFolderName()
- setMaxFiles() — Maximum number of files allowed to be attached
- setMaxFilesize() — Max filesize for uploads, in megabytes.
- setMaxResolution() — Sets the max resolution for images, in pixels
- setMaxThumbnailFilesize() — Set the threshold at which to not create an image thumbnail
- setMethod() — Set the form method, e.g. PUT
- setMinResolution() — Sets the min resolution for images, in pixels
- setMultiple() — Allow multiple files
- setParallelUploads() — Sets number of allowed parallel uploads
- setParamName() — Sets the name of the upload parameter, e.g. "Files"
- setPermission() — Sets a specific permission for this uploader: "detach", "upload", "delete", "attach" Permissions can be boolean or Callable
- setPermissions() — Sets permissions for this uploader: "detach", "upload", "delete", "attach" Permissions can be boolean or Callable
- setPreviewTemplate() — Sets selector for the preview template
- setPreviewsContainer() — Set the selector for the container element that holds all of the uploaded files
- setThumbnailHeight() — The thumbnail height
- setThumbnailWidth() — The thumbnail width
- setTrackFiles() — Enable/disable file tracking on uploads
- setValue()
- setView() — The layout of the uploader, either "grid" or "list"
- underscorise() — Translate camelCase to underscore_case
- upload() — Action to handle upload of a single file
- validate() — Check that the user is submitting the file IDs that they uploaded.