Tripal
|
Functions | |
hook_file_upload_check ($action, $details, &$message) | |
Tripal provides a convenient HTML5 Javascript uploader. It is automatically embedded into the TripalImporter class. This application programing interface (API) provides support for working with uploaded files.
If you want to use the TripalUploader JavaScript in your own form the following must be performed:
1) Add a Drupal form to your code that contains the following:
2) Edit the theme/js/[module_name].js and in the "Drupal.behaviors.[module]" section add a JQuery show function to the form that converts the table created in the Drupal form to a TripalUploader table. The 'table_id' must be the same as the 'id' attribute set for the table in the Drupal code above. The 'submit_id' must be the id of the upload button added in the Drupal code above. The 'category' for the files. This is the category that will be saved in Tripal for the file. See the addUploadTable function for additional options. Include a 'cardinality' setting to indicate the number of allowed files per upload, and set the 'target_id' to the name of the field that will contain the file ID (fid) after uploading.
3) Files are uploaded automatically to Tripal. Files are saved in the Tripal user's directory. You can retrieve information about the file by querying for the file category for the current project.
4) If the 'target_id' was used in array for step #2 above, then the file ID can be retrieved in the hook_validate() and hook_submit() functions via the $form_state['input'] array (not the $form_state['values'] array.
hook_file_upload_check | ( | $action, | |
$details, | |||
& | $message | ||
) |
Allows a module to interact with the Tripal file uploader during upload.
This function is called prior to an 'action' occurring and allows the module that is responsible for the file upload to halt an upload if needed.
$action | The current action that is being performed during the upload process. The actions are: 'save', 'check' and 'merge'. |
$details | An associative array containing details about the upload process. Valid keys include:
|
$message | An error message to report to the user if the function returns FALSE. |