KXStudio Website https://kx.studio/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
4.8KB

  1. <?php
  2. class SWFUpload extends Modules {
  3. public $insert_swfupload = array();
  4. public function admin_head() {
  5. if (substr_count($_SERVER['HTTP_USER_AGENT'], "MSIE"))
  6. return;
  7. $config = Config::current();
  8. if (!empty($this->insert_swfupload)) {
  9. echo ' <script src="'.$config->chyrp_url.'/modules/swfupload/lib/swfupload.js" type="text/javascript" charset="utf-8"></script>'."\n";
  10. echo ' <script src="'.$config->chyrp_url.'/modules/swfupload/lib/handlers.js" type="text/javascript" charset="utf-8"></script>'."\n";
  11. echo ' <link rel="stylesheet" href="'.$config->chyrp_url.'/modules/swfupload/style.css" type="text/css" media="screen" title="no title" charset="utf-8" />'."\n";
  12. echo ' <script type="text/javascript">'."\n";
  13. echo " $(function(){\n";
  14. foreach ($this->insert_swfupload as $id => $options) {
  15. $upload_url = $config->chyrp_url."/modules/swfupload/upload_handler.php";
  16. $flash_url = $config->chyrp_url."/modules/swfupload/lib/swfupload.swf";
  17. $file_types = "*";
  18. $file_types_description = "All Files";
  19. $debug = false;
  20. $file_queue_error_handler = "fileQueueError";
  21. $file_dialog_complete_handler = "fileDialogComplete";
  22. $upload_start_handler = "uploadStart";
  23. $upload_progress_handler = "uploadProgress";
  24. $upload_error_handler = "uploadError";
  25. $upload_success_handler = "uploadSuccess";
  26. $upload_complete_handler = "uploadComplete";
  27. if (is_string($options))
  28. $file_types = $options;
  29. else
  30. foreach ($options as $key => $val)
  31. $$key = $val;
  32. echo ' $("#'.$id.'_field").clone().attr("id", "'.$id.'_fake").addClass("swfupload_button").insertBefore("#'.$id.'_field")'."\n";
  33. echo " ".$id." = new SWFUpload({\n";
  34. echo ' upload_url : "'.$upload_url.'",'."\n";
  35. echo ' flash_url : "'.$flash_url.'",'."\n";
  36. echo ' post_params: {"PHPSESSID" : "'.session_id().'", "PHPSESSNAME" : "'.session_name().'", "ajax" : "true" },'."\n";
  37. echo ' file_size_limit : "100 MB",'."\n";
  38. echo ' file_types : "'.$file_types.'",'."\n";
  39. echo ' file_types_description : "'.$file_types_description.'",'."\n";
  40. if ($debug)
  41. echo ' debug: true,'."\n";
  42. echo ' '."\n";
  43. echo ' file_queue_error_handler : '.$file_queue_error_handler.','."\n";
  44. echo ' file_dialog_complete_handler : '.$file_dialog_complete_handler.','."\n";
  45. echo ' upload_start_handler : '.$upload_start_handler.','."\n";
  46. echo ' upload_progress_handler : '.$upload_progress_handler.','."\n";
  47. echo ' upload_error_handler : '.$upload_error_handler.','."\n";
  48. echo ' upload_success_handler : '.$upload_success_handler.','."\n";
  49. echo ' button_placeholder_id : "'.$id.'_field",'."\n";
  50. echo ' button_width : $("#'.$id.'_fake").width(),'."\n";
  51. echo ' button_height : $("#'.$id.'_fake").height(),'."\n";
  52. echo ' button_action : SWFUpload.BUTTON_ACTION.SELECT_FILES,'."\n";
  53. echo ' upload_complete_handler : '.$upload_complete_handler.''."\n";
  54. echo ' })'."\n";
  55. echo ' $("#SWFUpload_0")'."\n";
  56. echo ' .css({ position: "absolute", top: $("#'.$id.'_fake").offset().top, left: $("#'.$id.'_fake").offset().left })'."\n";
  57. echo ' .before(\'<div id="progress"><div class="back"><div class="fill"></div><div class="clear"></div></div></div>\')'."\n";
  58. }
  59. echo " })\n";
  60. echo " </script>\n";
  61. }
  62. }
  63. public function prepare_swfupload($id, $extensions) {
  64. $this->insert_swfupload[$id] = $extensions;
  65. }
  66. }