[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/image_fupload/ -> swfupload-settings.tpl.php (source)

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


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7