Impact factor for posts is a measurement of importance.

Impact factor for users reflect their authority, reputation and contribution on a particular topic.

Rating reflects the quality of posts.

Rating on Voofie is not a simple average of all ratings, but a weighted average of rating, weighted by the impact factor of users who rated.

Explore exciting communities of

One upload dialog - Two targets ?

Bookmark and Share
06 Aug 10

I have already 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 browser lets the user pick from either.

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

Two ideas - both involving modifying the upload-dialog-tab ( file-field + upload-button) adding a target selector:

A) Two different upload-buttons: (Upload to Common) + (Upload to Private)
- both pointing to the same filebrowserUploadUrl but adding a parameter ~ &target=C or &target=P

B) A couple of "radio" selectors: 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...

I've really tried, but as a non-jQuery javascript developer, I just can't make sense of it all  ;(

So I'd appreciate an example of how to modify the upload-dialog-tab to accomplish (either of) these ?

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' );

 

Then what ?
 
PS: How to pick a level of difficulty - Everything is hard when you don't know how...?
Add comments >
12
08 Aug 10

Thank you George, but that gets me the same result as when add'ing it using CKEDITOR.on( 'dialogDefinition'..
- except that this way, the checkboxes show up between the file-field and the upload button - better.

The actual form in the iframe (and also the recieved one) still doesn't contain the new fields (form-action wasn't changed)

SO - Rouge to the rescue - I went ahead and hacked it - Successfully 

Just one new checkbox in /plugins/image/dialogs/image.js
(It's always one OR the other in this case, but good thinking, enabling either or BOTH with two checkboxes.)

 

 

{
    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("action pre: "+theForm.getAttribute("action"))    

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

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

This works perfectly (only tested in Firefox so far..) 
- just a little concerned about the hardcoded "125_fileInput"...
 
PS: Idea (silly!) for dificulty-rating:
"How long have you spent trying to make it work before giving up and asking"
- Less than 1 hour : Easy.
- Less that 1 day: Medium.
- Longer: Rocket Science.

Last update: 08 Aug 10

1 comment >
0
07 Aug 10

The solution should be very easy.  I think modifying the CKEditor image plugin will be the most easy way to achieve your goal.  Just add the following code to the element list of the Upload tab definitation of /plugins/image/dialogs/image.js

{
    type : 'checkbox',
    id : 'PrivateServer',
    label: 'Upload to private server',
    checked : true, //set your default value to true
    onClick: function(){
        CKEDITOR.config.filebrowserUploadUrl = "private server url";
    }
},
{
    type : 'checkbox',
    id : 'PublicServer',
    label: 'Upload to public server',
    onClick: function(){
        CKEDITOR.config.filebrowserUploadUrl = "public server url";                            
    }
}

Rememeber you have to pack the source code using ckpackager.


PS: For the difficulty tag, pick simple when you think the post do not need much prior knowledge in the topic.  Tag intermediate if you think you need some knowledge on the topic and Advanced when you need a lot of prior knowledge on the topic to understand the post.  Of course this definition is not perfect, probably more difficulty tags/a more clear definition is needed.  Your suggestions are very welcomed!

Add comments >

Please login to post answer.

Page Info
36Impacts
0/0 rates
699
Your Rating: