\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 = ;
- protected array $settings = ;
- protected array $params = ;
- protected DataObject $record = NULL;
- protected array $permissions = ;
- protected string $view = 'list';
- protected string $previewTemplate = 'FileAttachmentField_preview';
- // methods
- public static string camelise()
- public static string underscorise()
- public static int get_filesize_from_ini()
- public void __construct()
- public SSViewer FieldHolder()
- public FileAttachmentField saveInto()
- public FileAttachmentField setMethod()
- public FileAttachmentField setParallelUploads()
- public FileAttachmentField setMultiple()
- public FileAttachmentField setMaxFilesize()
- public FileAttachmentField setParamName()
- public FileAttachmentField setCreateImageThumbnails()
- public FileAttachmentField setMaxThumbnailFilesize()
- 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 boolean isCMS()
- public SS_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()
Hierarchy
Extends
- FileField
Members
private
- $allowed_actions
—
array
The allowed actions for the RequestHandler - $url_handlers
protected
- $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
—
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
protected
- checkPerm() — Checks for a given permission. If it is a closure, invoke the method
- 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
- 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
- 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.
- 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
- 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
- saveInto() — Saves the field into a record
- setAcceptedFiles() — A list of accepted file extensions
- setAcceptedMimeTypes() — Sets the allowed mime types
- 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
- 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
- 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