publish.html.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php include $app->getModuleRoot() . 'common/view/header.html.php';?>
  2. <?php $biPath = $this->app->getModuleExtPath('bi', 'view');?>
  3. <div id='mainContent' class='main-content'>
  4. <div class='center-block'>
  5. <div class='main-header'>
  6. <h2><?php echo $title;?></h2>
  7. </div>
  8. </div>
  9. <form id='ajaxForm' method='post' target='hiddenwin' action='<?php echo inlink('publish', "screenID={$screen->id}");?>'>
  10. <table class='table table-form'>
  11. <tr>
  12. <th class='w-100px'><?php echo $lang->screen->name;?></th>
  13. <td><?php echo html::input('name', $screen->name, "class='form-control'")?></td>
  14. </tr>
  15. <tr>
  16. <th><?php echo $lang->screen->desc;?></th>
  17. <td><?php echo html::textarea('desc', $screen->desc, "class='form-control' rows='5'");?></td>
  18. </tr>
  19. <?php $acl = $screen->acl;?>
  20. <?php $aclList = $lang->screen->aclList;?>
  21. <?php $whitelist = $screen->whitelist;?>
  22. <?php include $biPath['common'] . 'aclbox.html.php';?>
  23. <tr class="hidden">
  24. <td><?php echo html::input('status', 'published', "class='form-control'")?></td>
  25. <td><?php echo html::input('scheme', '', "class='form-control'")?></td>
  26. <td><?php echo html::input('uuid', 'screen_thumbnail' . $screen->id, "class='form-control'")?></td>
  27. <td><input name="thumbnail" type="file" id="thumbnail" /></td>
  28. </tr>
  29. <tr>
  30. <td colspan='2' class='text-center form-actions'>
  31. <?php echo html::submitButton();?>
  32. </td>
  33. </tr>
  34. </table>
  35. </form>
  36. </div>
  37. <script>
  38. $(document).ready(function()
  39. {
  40. $('.hidden input#scheme').val(JSON.stringify(parent.window.storageInfo));
  41. if(!parent.window.fileDataUrl)
  42. {
  43. $('#thumbnail').remove();
  44. return;
  45. }
  46. const blob = dataURLToBlob(parent.window.fileDataUrl);
  47. // 获取文件输入字段
  48. const fileInput = document.getElementById('thumbnail');
  49. // 创建一个新的DataTransfer对象
  50. const dataTransfer = new DataTransfer();
  51. // 从Blob创建一个新的File对象
  52. const file = new File([blob], 'screen_thumbnail_' + parent.window.screen.id + '.png', { type: 'png' });
  53. // 将File对象添加到DataTransfer对象中
  54. dataTransfer.items.add(file);
  55. // 使用DataTransfer对象设置输入元素的files属性
  56. fileInput.files = dataTransfer.files;
  57. })
  58. // 将数据 URL 转换为 Blob 对象的函数
  59. function dataURLToBlob(dataURL) {
  60. const arr = dataURL.split(',');
  61. const mime = arr[0].match(/:(.*?);/)[1];
  62. const bstr = atob(arr[1]);
  63. let n = bstr.length;
  64. const u8arr = new Uint8Array(n);
  65. while (n--) {
  66. u8arr[n] = bstr.charCodeAt(n);
  67. }
  68. return new Blob([u8arr], { type: mime });
  69. }
  70. </script>
  71. <?php include $app->getModuleRoot() . 'common/view/footer.html.php';?>