| 1 |
<?php
|
| 2 |
// $Id: swfupload-settings.tpl.php,v 1.17 2009/03/21 08:32:50 grandcat Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
*/
|
| 7 |
?>
|
| 8 |
var swfu;
|
| 9 |
var jsTimer = false;
|
| 10 |
var error_send = false; // Indicates whether swfUpload has already been stopped because of a form error
|
| 11 |
var upload_complete = false; // All queued files uploaded?
|
| 12 |
var queue_complete = 0; // contains number of queued and successfully uploaded images
|
| 13 |
var count_failed_uploads = 0; // Number of failed uploads
|
| 14 |
|
| 15 |
window.onload = function() {
|
| 16 |
var settings = {
|
| 17 |
flash_url : "<?php print $modulepath; ?>/swfupload/swfupload.swf",
|
| 18 |
upload_url: "<?php print $uploadpath; ?>", // Relative to the SWF file
|
| 19 |
post_params: {"PHPSESSID" : "<?php print $sessionid; ?>" , "nodetype" : "<?php print $nodetype; ?>", "fieldname" : "<?php print $fieldname; ?>"},
|
| 20 |
file_post_name: "Filedata",
|
| 21 |
file_size_limit : "<?php print $maxfilesize; ?>",
|
| 22 |
file_types : "<?php print $fileextensions; ?>",
|
| 23 |
file_types_description : "Only images",
|
| 24 |
file_upload_limit : "<?php print $uploadlimit; ?>",
|
| 25 |
file_queue_limit : "0",
|
| 26 |
custom_settings : {
|
| 27 |
progressTarget : "fsUploadProgress",
|
| 28 |
cancelButtonId : "btnCancel"
|
| 29 |
},
|
| 30 |
debug: false,
|
| 31 |
|
| 32 |
// Button settings
|
| 33 |
button_width: "36",
|
| 34 |
button_height: "37",
|
| 35 |
button_placeholder_id: "spanUploadButton",
|
| 36 |
button_image_url: "<?php print $modulepath; ?>/swfupload/select_images.png", // Relative to the Flash file
|
| 37 |
button_cursor: SWFUpload.CURSOR.HAND,
|
| 38 |
|
| 39 |
// The event handler functions are defined in handlers.js
|
| 40 |
file_queued_handler : fileQueued,
|
| 41 |
file_queue_error_handler : fileQueueError,
|
| 42 |
file_dialog_complete_handler : fileDialogComplete,
|
| 43 |
upload_start_handler : uploadStart,
|
| 44 |
upload_progress_handler : uploadProgress,
|
| 45 |
upload_error_handler : uploadError,
|
| 46 |
upload_success_handler : uploadSuccess,
|
| 47 |
upload_complete_handler : uploadComplete,
|
| 48 |
queue_complete_handler : queueComplete // Queue plugin event
|
| 49 |
};
|
| 50 |
swfu = new SWFUpload(settings);
|
| 51 |
|
| 52 |
};
|
| 53 |
|
| 54 |
function startUploadProcess() {
|
| 55 |
var redirect_url = "<?php print $redirect_url; ?>";
|
| 56 |
var imagefield_required = <?php print $field_required; ?>;
|
| 57 |
|
| 58 |
if (!upload_complete) {
|
| 59 |
// Reset all variables and indicators
|
| 60 |
error_send = false;
|
| 61 |
count_failed_uploads = 0;
|
| 62 |
if (isNaN(document.getElementById('form_errors')))
|
| 63 |
document.getElementById('form_errors').value = '0';
|
| 64 |
if (isNaN(document.getElementById('num_queued_images')))
|
| 65 |
document.getElementById('num_queued_images').value = '1'; // Pretend that there's at least one image in queue so that it works
|
| 66 |
|
| 67 |
// return warning if no images has been selected yet
|
| 68 |
if (swfu.getStats().files_queued == 0) {
|
| 69 |
// only create gallery node without any images, if field is not required
|
| 70 |
if (!imagefield_required) {
|
| 71 |
// new node
|
| 72 |
result = confirm(Drupal.t('No images have been selected yet.') + ' ' + Drupal.t('If you continue (OK), a node without any images will be created.\n If you want to add some images to queue, click "Cancel" and use the icon on the left to queue some images.'));
|
| 73 |
} else {
|
| 74 |
// node is edited
|
| 75 |
result = false;
|
| 76 |
alert(Drupal.t('No images have been selected yet.') + ' ' + Drupal.t('Please click the icon on the left to queue some images.'));
|
| 77 |
}
|
| 78 |
// user wants to create a node without any images ... ok =)
|
| 79 |
if (result && !jsTimer)
|
| 80 |
document.getElementById('edit-submit').click();
|
| 81 |
}
|
| 82 |
|
| 83 |
// hey, let's go =)
|
| 84 |
swfu.startUpload();
|
| 85 |
}
|
| 86 |
}
|
| 87 |
|
| 88 |
function UploadComplete(numFilesUploaded) {
|
| 89 |
// Provide a second step to be able to edit captions of image if supported
|
| 90 |
var redirect_url_main = "<?php print $redirect_url; ?>";
|
| 91 |
var redirect_url_updated = "";
|
| 92 |
if (isNaN(document.getElementById('redirect_url'))) {
|
| 93 |
// updated redirect url
|
| 94 |
redirect_url_updated = document.getElementById('redirect_url').value;
|
| 95 |
}
|
| 96 |
|
| 97 |
// user is allowed to enter preview page
|
| 98 |
if (redirect_url_main != "" && numFilesUploaded > 0) {
|
| 99 |
upload_complete = true;
|
| 100 |
// Disable Select button
|
| 101 |
swfu.setButtonDisabled(true);
|
| 102 |
|
| 103 |
// if available, update our redirect url
|
| 104 |
if (redirect_url_updated != "")
|
| 105 |
redirect_url_main = redirect_url_updated;
|
| 106 |
|
| 107 |
try {
|
| 108 |
var url_next = '<a href="' + redirect_url_main + '">' + Drupal.t('next step') + '</a>';
|
| 109 |
document.getElementById('startuploadbutton').value = Drupal.t('Next step');
|
| 110 |
document.getElementById('startuploadbutton').onclick = function() {fupload_redirect(redirect_url_main);};
|
| 111 |
document.getElementById('divStatus').innerHTML = (Drupal.formatPlural(numFilesUploaded, '1 file uploaded in queue.', '@count files uploaded in queue.') + ' ' + Drupal.t('Enter the !link to be able to edit all captions.', { '!link': url_next }));
|
| 112 |
document.getElementById('imagepreviewlistbutton').style.visibility = 'visible';
|
| 113 |
document.getElementById('imagepreviewlistbutton').onclick = function() {fupload_redirect(redirect_url_main);};
|
| 114 |
|
| 115 |
// if node is edited, change save button to "next step" button and remove other buttons
|
| 116 |
//document.getElementById('edit-submit').value = Drupal.t('Next step');
|
| 117 |
}
|
| 118 |
catch(err) {
|
| 119 |
// not interesting in this case
|
| 120 |
}
|
| 121 |
}
|
| 122 |
|
| 123 |
// no access to preview page: redirect directly to newly created nodeName
|
| 124 |
if (redirect_url_main == "" && numFilesUploaded > 0)
|
| 125 |
fupload_redirect();
|
| 126 |
|
| 127 |
}
|