public function __construct($options = null, $initialize = false, $error_messages = null) { parent::__construct($options, $initialize, $error_messages); $this->fm = $this->options['fm']['instance']; $this->fmData = $this->options['fm']['data']; $this->options['upload_dir'] = $this->fmData['upload_dir']; $this->options['param_name'] = $this->fm->config['upload']['paramName']; $this->options['readfile_chunk_size'] = $this->fm->config['upload']['chunkSize']; $this->options['max_file_size'] = $this->fm->config['upload']['fileSizeLimit']; // BaseFilemanager::is_allowed_file_type() is used instead of this regex check $this->options['accept_file_types'] = '/.+$/i'; // may be overridden with $this->fm->config['images']['imagesExt'], but this list can be better for images handling libs $this->options['image_file_types'] = '/\\.(gif|jpe?g|png)$/i'; // Only GD was tested for local and S3 uploaders $this->options['image_library'] = 0; // Use GD on Windows OS because Imagick "readImage" method causes fatal error: // http://stackoverflow.com/a/10037579/1789808 //$this->options['image_library'] = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? 0 : 1; $images = $this->fm->config['images']; // original image settings $this->options['image_versions'] = array('' => array('auto_orient' => $images['main']['autoOrient'], 'max_width' => $images['main']['maxWidth'], 'max_height' => $images['main']['maxHeight'])); // image thumbnail settings if (isset($images['thumbnail']) && $images['thumbnail']['enabled'] === true) { $this->options['image_versions']['thumbnail'] = array('upload_dir' => $this->fmData['thumbnails_dir'], 'crop' => $images['thumbnail']['crop'], 'max_width' => $images['thumbnail']['maxWidth'], 'max_height' => $images['thumbnail']['maxHeight']); } $this->error_messages['accept_file_types'] = $this->fm->lang('INVALID_FILE_TYPE'); $this->error_messages['max_file_size'] = sprintf($this->fm->lang('UPLOAD_FILES_SMALLER_THAN'), round($this->fm->config['upload']['fileSizeLimit'] / 1000 / 1000, 2) . ' ' . $this->fm->lang('mb')); $this->error_messages['max_storage_size'] = sprintf($this->fm->lang('STORAGE_SIZE_EXCEED'), round($this->fm->config['options']['fileRootSizeLimit'] / 1000 / 1000, 2) . ' ' . $this->fm->lang('mb')); }
/** * These methods are handled by the BaseUploadHandler * * public function Start(); * public function get_response(); * public function get_headers(); * public function set_option(string $key, string $value); */ function __construct($options, $arguments = null) { $folder = $arguments; if (!$folder instanceof \Album and (!is_numeric($arguments) or !($folder = \Album::find($arguments)))) { throw new \Exception("DatabaseUploadHandler needs the Album id or the Album model to start!"); } $this->folder = $folder; $options['upload_dir'] = $folder->upload_dir; $options['upload_url'] = $folder->upload_url; parent::__construct($options); }
/** * These methods are handled by the BaseUploadHandler * * public function Start(); * public function get_response(); * public function get_headers(); * public function set_option(string $key, string $value); * * Actually the BaseUploadHandler itself already * handles the files so really nothing to do here. * */ function __construct($options, $arguments = null) { parent::__construct($options); }