A directory of browser-based WYSIWYG editors


Home: htmlArea 3 (beta): htmlArea 2 & 3 archive (read only): htmlArea v3.0 - Add-Ons:
File Upload Manager: Changed behaviour

The htmlArea 2 & 3 editors have been discontinued.

We've made these forums available as a read-only reference and knowledge-base for people using or developing editors based on htmlArea 2 or 3.

Anyone who is interested in taking over version 2 or 3 is free to do so. All we ask is that you choose a new name that doesn't have "htmlarea" in it to avoid confusion with this site. We'll even give you a link in the directory to make it easier for people to find you. If you are developing or hosting an htmlArea based-editor under a new name, please submit it to our directory.



Jul 27, 2004, 2:30 PM

Post #1 of 1 (6200 views)
File Upload Manager: Changed behaviour Can't Post

I wrote a small extension to AlRashid's File Upload Manager. I wanted to be able to select a word and put a file Download behind it, without the download manager inserting its own stuff with file name, file size, date, time and all that.

To use this, replace the buttonPress prototype function in insert-file.js by the following code:

InsertFile.prototype.buttonPress = function(editor) { 
var sel = editor._getSelection();
var range = editor._createRange(sel);

var outparam = null;
if (typeof image == "undefined") {
image = this.getParentElement();
if (image && !/^img$/i.test(image.tagName))
image = null;
if (image) outparam = {
f_url : HTMLArea.is_ie ? image.src : image.getAttribute("src"),
f_alt : image.alt,
f_border : image.border,
f_align : image.align,
f_vert : image.vspace,
f_horiz : image.hspace,
f_width : image.width,
f_height : image.height
var manager = _editor_url + 'plugins/InsertFile/insert_file.php';

Dialog(manager, function(param) {
if (!param) { // user must have pressed Cancel
return false;

selection_text = new String();
temp_sel = editor._getSelection();
var tmp = editor._createRange(temp_sel);
selection_text = editor.getSelectedHTML();

var doc = editor._doc;
var insertText = "";
for (var k in param["folders"]){
var folderValues = param["folders"][k];
var alink = new String(param["format"]);

if (selection_text.length < 1) caption = folderValues[1];
else caption = selection_text;

alink = alink.replace(/IF_URL/g, param["path"]+folderValues[1]);
alink = alink.replace(/IF_CAPTION/g, caption);
alink = alink.replace(/IF_ICON/g, folderValues[0]);
alink = alink.replace(/IF_SIZE/g, folderValues[2]);
alink = alink.replace(/IF_DATE/g, folderValues[3]);
alink = alink.replace(/_editor_url/g, _editor_url);
insertText = insertText + alink.toString()+ "&nbsp;";

for (var k in param["files"]){
var fileValues = param["files"][k];
var alink = new String(param["format"]);

if (selection_text.length < 1) caption = fileValues[1];
else caption = selection_text;

alink = alink.replace(/IF_URL/g, param["path"]+fileValues[1]);
alink = alink.replace(/IF_CAPTION/g, caption);
alink = alink.replace(/IF_ICON/g, fileValues[0]);
alink = alink.replace(/IF_SIZE/g, fileValues[2]);
alink = alink.replace(/IF_DATE/g, fileValues[3]);
alink = alink.replace(/_editor_url/g, _editor_url);
insertText = insertText + alink.toString() + "&nbsp;";

}, outparam);


As you can see, the IF_CAPTION label is replaced by the text selected - if any text is selected; Otherwise, the file name is used. This does *not* surround the exact selected HTML with the file link; It rather fetches the text and uses it for IF_CAPTION. You might have to correct your Format pattern in the php file accordingly. With me, it looks like this:

$MY_LINK_FORMAT = '<span class="filelink"><img src="_editor_urlplugins/InsertFile/IF_ICON" alt="IF_URL" border="0">&nbsp;<a href="IF_URL" target=_blank>IF_CAPTION</a> &nbsp;</span>&nbsp;';

Works fine with me as of now - on questions or comments, drop me a line.


Search for (options)