\FileStorage
Allows to attach files to random items in some scope
Synopsis
class FileStorage
{
- // constants
- const TABLE_STORAGE = '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 array $filesCount = ;
- protected string $scope = '';
- protected string $itemId = '';
- protected string $myLogin = '';
- protected bool $filesLoadedFlag = false;
- protected $storageDb = '';
- protected integer $filePreviewSize = 128;
- protected array $allowedExtensions = ;
- protected $messages = '';
- protected string $storagePath = 'content/documents/filestorage/';
- // methods
- public void __construct()
- protected void initMessages()
- protected void loadAlter()
- protected void setOptions()
- public string getStoragePath()
- protected void setAllowedExtenstions()
- protected void setScope()
- public void setItemid()
- protected void setLogin()
- protected void initDatabase()
- protected void loadAllFiles()
- public void registerFile()
- protected void unregisterFile()
- protected string fileControls()
- public string uploadControlsPanel()
- protected string backUrlHelper()
- public int getFilesCount()
- public string getFilesIndicator()
- protected string renderFilePreviewIcon()
- public string renderFilesPreview()
- public string renderNavigationButton()
- public string renderFilesList()
- public void catchDownloadFile()
- public void catchDeleteFile()
- public void catchFileUpload()
- public string renderUploadForm()
Constants
| Name | Value |
|---|---|
| TABLE_STORAGE | '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 - $filesCount
—
array
Contains loaded files count for each item in some scope as scope=>itemid=>count - $filesLoadedFlag
—
bool
Flag for preventing multiple database requests when building files count map - $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 - $storagePath
—
string
Contains files storage path. May be specified in FILESTORAGE_DIRECTORY option.
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
- renderFilePreviewIcon() — Renders file preview icon
- setAllowedExtenstions() — Sets allowed file extensions for this instance
- setLogin() — Administrator login setter
- setOptions() — Sets some current instance specific options.
- 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
- getFilesCount() — Returns count of loaded files for some itemid in current scope
- getFilesIndicator() — Returns indicator of files count for some itemId in current scope
- getStoragePath() — Returns configured files storage directory path
- registerFile() — Registers uploaded file in database
- 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