\FileStorage
Allows to attach files to random items in some scope
Synopsis
class FileStorage
{
- // constants
- const TABLE_STORAGE = 'filestorage';
- const STORAGE_PATH = 'content/documents/filestorage/';
- const URL_ME = '?module=filestorage';
- const URL_UPLOAD_FILE = '?module=filestorage&uploadfile=true';
- const EX_NOSCOPE = 'NO_OBJECT_SCOPE_SET';
- const EX_WRONG_EXT = 'WRONG_FILE_EXTENSION';
- // members
- protected array $altCfg = ;
- protected array $allFiles = ;
- protected string $scope = '';
- protected string $itemId = '';
- protected string $myLogin = '';
- protected $storageDb = '';
- protected integer $filePreviewSize = 128;
- protected array $allowedExtensions = ;
- protected $messages = '';
- // methods
- public void __construct()
- protected void initMessages()
- protected void loadAlter()
- protected void setAllowedExtenstions()
- protected void setScope()
- public void setItemid()
- protected void setLogin()
- protected void initDatabase()
- protected void loadAllFiles()
- protected void registerFile()
- protected void unregisterFile()
- protected string fileControls()
- public string uploadControlsPanel()
- protected string backUrlHelper()
- protected string renderFilePreviewIcon()
- public string renderFilesPreview()
- public string renderFilesList()
- public void catchDownloadFile()
- public void catchDeleteFile()
- public void catchFileUpload()
- public string renderUploadForm()
Constants
Name | Value |
---|---|
TABLE_STORAGE | 'filestorage' |
STORAGE_PATH | 'content/documents/filestorage/' |
URL_ME | '?module=filestorage' |
URL_UPLOAD_FILE | '?module=filestorage&uploadfile=true' |
EX_NOSCOPE | 'NO_OBJECT_SCOPE_SET' |
EX_WRONG_EXT | 'WRONG_FILE_EXTENSION' |
Members
protected
- $allFiles
—
array
Contains array of available files in database as id=>filedata - $allowedExtensions
—
array
Contains allowed file extensions. May be configurable in future. - $altCfg
—
array
Contains system alter config as key=>value - $filePreviewSize
—
int
Contains default file preview container size in px - $itemId
—
string
Contains current instance item ID in the current scope - $messages
—
System message helper placeholder - $myLogin
—
string
Contains current administrator login - $scope
—
string
Contains current filestorage items scope - $storageDb
—
Current instance database abstraction layer placeholder
Methods
protected
- backUrlHelper() — Returns custom module backlinks for some scopes
- fileControls() — Returns basic file controls
- initDatabase() — Inits protected database absctaction layer for current instance
- initMessages() — Inits system message helper for further usage
- loadAllFiles() — Loads files list from database into private prop
- loadAlter() — Loads system alter config into private prop
- registerFile() — Registers uploaded file in database
- renderFilePreviewIcon() — Renders file preview icon
- setAllowedExtenstions() — Sets allowed file extensions for this instance
- setLogin() — Administrator login setter
- setScope() — Object scope setter
- unregisterFile() — Deletes uploaded file from database
public
- __construct() — Initializes filestorage engine for some scope/item id
- catchDeleteFile() — Deletes file from database and FS by its ID
- catchDownloadFile() — Downloads file by its id
- catchFileUpload() — Catches file upload in background
- renderFilesList() — Returns current scope/item files list
- renderFilesPreview() — Renders attached files preview with optional navigation button
- renderUploadForm() — Returns file upload form
- setItemid() — Object scope item Id setter
- uploadControlsPanel() — Returns file upload controls