|
@@ -75,7 +75,6 @@ function tripal_init() {
|
|
|
}
|
|
|
|
|
|
function tripal_menu_alter(&$items) {
|
|
|
- //drupal_debug($items);
|
|
|
}
|
|
|
/**
|
|
|
* Implements hook_menu().
|
|
@@ -626,6 +625,7 @@ function tripal_import_api() {
|
|
|
module_load_include('inc', 'tripal', 'api/tripal.jobs.api');
|
|
|
module_load_include('inc', 'tripal', 'api/tripal.notice.api');
|
|
|
module_load_include('inc', 'tripal', 'api/tripal.variables.api');
|
|
|
+ module_load_include('inc', 'tripal', 'api/tripal.upload.api');
|
|
|
module_load_include('inc', 'tripal', 'api/tripal.DEPRECATED.api');
|
|
|
}
|
|
|
|
|
@@ -950,11 +950,15 @@ function tripal_element_info() {
|
|
|
// - #title: The title that will appear above the element.
|
|
|
// - #description: The description that will appear below the element.
|
|
|
// - #usage_type: Required. The type of file. This will be stored in
|
|
|
- // the 'type' column of the file_usage table.
|
|
|
+ // the 'type' column of the file_usage table.
|
|
|
// - #usage_id: Required. A unique numeric ID representing an entity, node
|
|
|
- // or some other record identifier. This can be any identifier that
|
|
|
- // makes sense to the module that implements a form that uses this
|
|
|
- // element.
|
|
|
+ // or some other record identifier. This can be any identifier that
|
|
|
+ // makes sense to the module that implements a form that uses this
|
|
|
+ // element.
|
|
|
+ // -#usage_module: The module that will be using the file. This will be
|
|
|
+ // stored in the 'module' column of the file_usage table.
|
|
|
+ // -#allowed_types: An array of file extensions that are allowed for
|
|
|
+ // to be uploaded.
|
|
|
$elements['html5_file'] = array(
|
|
|
'#input' => 'TRUE',
|
|
|
'#process' => array('tripal_html5_file_process'),
|
|
@@ -971,8 +975,10 @@ function tripal_html5_file_process($element, $form_state, $complete_form) {
|
|
|
|
|
|
$module = array_key_exists('#usage_module', $element) ? $element['#usage_module'] : 'tripal';
|
|
|
$type = $element['#usage_id'] . '-' . $element['#usage_type'] . '-' . $module;
|
|
|
+ $type_var_name = 'uploader_' . $element['#usage_id'] . '_' . $element['#usage_type'] . '_' . $module;
|
|
|
$name = $element['#name'];
|
|
|
$name = preg_replace('/[^\w]/', '_', $name);
|
|
|
+ $allowed_types = array_key_exists('#allowed_types', $element) ? $element['#allowed_types'] : array();
|
|
|
|
|
|
$headers = array(
|
|
|
array('data' => 'File'),
|
|
@@ -1023,6 +1029,18 @@ function tripal_html5_file_process($element, $form_state, $complete_form) {
|
|
|
)
|
|
|
);
|
|
|
|
|
|
+ $uploader_settings = array(
|
|
|
+ 'table_id' => '#tripal-html5-file-upload-table-' . $type,
|
|
|
+ 'submit_id' => '#tripal-html5-file-upload-submit-' . $type,
|
|
|
+ 'category' => array($element['#usage_id'] . '-' . $element['#usage_type']),
|
|
|
+ 'cardinality' => 1,
|
|
|
+ 'target_id' => 'tripal-html5-upload-fid-' . $type,
|
|
|
+ 'module' => $module,
|
|
|
+ 'allowed_types' => $allowed_types,
|
|
|
+ );
|
|
|
+
|
|
|
+
|
|
|
+ drupal_add_js(array($type_var_name => $uploader_settings), 'setting');
|
|
|
drupal_add_js(drupal_get_path ('module', 'tripal') . '/theme/js/TripalUploader.js');
|
|
|
drupal_add_js(drupal_get_path ('module', 'tripal') . '/theme/js/TripalUploadFile.js');
|
|
|
drupal_add_js(drupal_get_path ('module', 'tripal') . '/theme/js/tripal.file.js');
|