一个上传对话框 - 两个目标?

发布于 2024-09-12 19:56:39 字数 1325 浏览 4 评论 0原文

使用 CKeditor 3,我创建了图像处理函数:
上传接收器 (filebrowserUploadUrl) 和图像浏览器对话框 (filebrowserBrowseUrl)
- 两者都工作完美

,但当然我的用户想要更多...我们有两个图像数据库:公共和私有
- 图像浏览器允许用户从其中选择图像。

我的上传接收器 (php) 可以轻松地将新图像放入这些容器中。
- 但我如何让用户选择哪一个呢?

三个想法 - 全部涉及修改 upload-dialog-tab ( type=file + upload-button)
通过以下方式添加目标选择器:

Using two different upload-buttons: (Upload to Common) and (Upload to Private)  
both pointing to the same filebrowserUploadUrl but adding a parameter:  
&target=C or &target=P

A couple of "radio switches": Common or Private  
- essentially doing the same: Adding &target=(P or C)  
with one of them selected by default, so the user can't break it by negligence...

Just a single checkbox: Private (or not) ~ adding &target=P (or not)

我确实尝试过(我的手指在流血,而且我气得吐了两次!),但作为一个非 jQuery javascript 开发人员,我只是无法理解这一切。当我添加文本字段时,它显示得很好:)
- 但不是在实际的上传表单(在 iframe 中)上,该表单仍然只包含 type=file 字段?!?

所以我希望有一个如何修改 upload-dialog-tab 来完成它的示例?

我已经准备好启动平台(我认为):

CKEDITOR.on( 'dialogDefinition',
 function( ev )
 {
 var dialogName = ev.data.name;
 var dialogDefinition = ev.data.definition;

 if ( dialogName == 'image' )
   {
   var infoTab = dialogDefinition.getContents( 'Upload' );
   infoTab.add({

     what ?

Using CKeditor 3, I've created image handling functions:
An upload reciever (filebrowserUploadUrl) and an image browser dialog (filebrowserBrowseUrl)
- Both work perfectly

BUT of course my users want more... We have two image-databases: Common and Private
- The image-browser lets the user pick images from either.

My upload-reciever (php) can easily put the new image in either of these containers.
- but how do I let the user pick which one ?

Three ideas - all involving modifying the upload-dialog-tab ( type=file + upload-button)
Adding a target selector by:

Using two different upload-buttons: (Upload to Common) and (Upload to Private)  
both pointing to the same filebrowserUploadUrl but adding a parameter:  
&target=C or &target=P

or

A couple of "radio switches": Common or Private  
- essentially doing the same: Adding &target=(P or C)  
with one of them selected by default, so the user can't break it by negligence...

or

Just a single checkbox: Private (or not) ~ adding &target=P (or not)

I've really tried (my fingers are bleeding, and I've vomited with rage, twice!) but as a non-jQuery javascript developer, I just can't make sense of it all. When I add a text-field, it shows up just fine : )
- but not on the actual upload-form (in an iframe) that one still only contains the type=file field ?!?

So I'd appreciate an example of how to modify the upload-dialog-tab to accomplish it ?

I have my launch platform ready (I think):

CKEDITOR.on( 'dialogDefinition',
 function( ev )
 {
 var dialogName = ev.data.name;
 var dialogDefinition = ev.data.definition;

 if ( dialogName == 'image' )
   {
   var infoTab = dialogDefinition.getContents( 'Upload' );
   infoTab.add({

     what ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

多情出卖 2024-09-19 19:56:39

我自己解决了这个问题,但确实必须对其进行一些修改:)

我认为 CKeditor 中可能存在错误(或者可能是设计使然......)
添加新字段(无论是在 image.js 中还是通过 CKEDITOR.on('dialogDefinition'..))它们只是不会转换为 iframe 中实际上传表单上的新字段。(错误还是功能?)

所以,我添加了/plugins/image/dialogs/image.js
的一个复选框(私人?不是)
在文件字段和按钮之间的 (id : 'Upload',) 部分中,使用执行此操作的 onClick 事件,困难的方法是:

{
    type : 'checkbox',
    id : 'PrivateFlag',
    label: 'Private',
    checked : false,
    onClick: function()
       {
       var theFrame = document.getElementById("125_fileInput");
       var theDoc = theFrame.contentDocument || theFrame.contentWindow.document;
       var theForm = theDoc.forms[0];
       var action = theForm.getAttribute("action"); // alert("pre:"+theForm.getAttribute("action"));

       if (action.indexOf("&target=P") == -1)
          action += "&target=P";
       else
          action = action.replace("&target=P","");

       theForm.setAttribute("action",action); // alert("post: "+theForm.getAttribute("action"));
       }
},

它有效(至少只要 iframe 的 id 是“125_fileInput”)

IE-修改(当然):

if (navigator.appName == 'Microsoft Internet Explorer') // aka BrokenTurd
    {
    var theFrame = document.frames[1]; // may be inaccurate in your case..
    var theDoc = theFrame.document;
    }
else
    {
    var theFrame = document.getElementById("125_fileInput");
    var theDoc = theFrame.contentDocument || theFrame.contentWindow.document;
    }

Solved it myself, but did have to go a bit rouge on it : )

I think there's may be an error in CKeditor here (or maybe it's by design..)
Adding new fields (whether in image.js or through CKEDITOR.on( 'dialogDefinition'..) they just don't translate into new fields on the actual upload-form in the iframe. (Bug or feature?)

SO, I added one checkbox (Private?not) to /plugins/image/dialogs/image.js
in the (id : 'Upload',) section between the file-field and the button, with an onClick-event that does the business, the hard way:

{
    type : 'checkbox',
    id : 'PrivateFlag',
    label: 'Private',
    checked : false,
    onClick: function()
       {
       var theFrame = document.getElementById("125_fileInput");
       var theDoc = theFrame.contentDocument || theFrame.contentWindow.document;
       var theForm = theDoc.forms[0];
       var action = theForm.getAttribute("action"); // alert("pre:"+theForm.getAttribute("action"));

       if (action.indexOf("&target=P") == -1)
          action += "&target=P";
       else
          action = action.replace("&target=P","");

       theForm.setAttribute("action",action); // alert("post: "+theForm.getAttribute("action"));
       }
},

It works (at least as long as the iframe's id is "125_fileInput")

IE-modification (of course):

if (navigator.appName == 'Microsoft Internet Explorer') // aka BrokenTurd
    {
    var theFrame = document.frames[1]; // may be inaccurate in your case..
    var theDoc = theFrame.document;
    }
else
    {
    var theFrame = document.getElementById("125_fileInput");
    var theDoc = theFrame.contentDocument || theFrame.contentWindow.document;
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文