/** * Apply post-validation operations to the object. * @param object $obj Object being validated. * @access private */ protected function _prepare_for_commit($obj) { parent::_prepare_for_commit($obj); /* Move the file to its final location and set the normalized file name. */ $file = $this->upload_file_for('file_name'); if (isset($file)) { $obj->file_name = $file->normalized_name; $url = new FILE_URL($obj->full_file_name()); /** @var UPLOAD_FILE_FIELD $file_name_field */ $file_name_field = $this->field_at('file_name'); $this->_move_uploaded_file($file_name_field, $file, $url->path()); } /* Create the thumbnail if needed. */ if ($obj->is_image && $this->value_for('create_thumbnail')) { $class_name = $this->app->final_class_name('THUMBNAIL_CREATOR', 'webcore/util/image.php'); /** @var THUMBNAIL_CREATOR $creator */ $creator = new $class_name($this->app); $creator->create_thumbnail_for($obj->full_file_name(), $this->value_for('thumbnail_size')); if ($creator->error_message) { $this->record_error('create_thumbnail', $creator->error_message); } } }
/** * Extract the file to the given location. * If there is an error in the extraction, it is communicated to the optional 'error_callback' * instead of raising an exception (which stops the script). * @param string $path * @param WEBCORE_CALLBACK $error_callback */ public function extract_to($path, $error_callback = null) { $url = new FILE_URL($path); $url->append($this->normalized_name); ensure_path_exists($url->path()); $this->extracted_name = $url->as_text(); $this->_extract_to($this->extracted_name, $error_callback); }