Hi:

I have IMCE and fckeditor on Drupal 5.1 (Firefox 2 as browser).

As title indicates, when I hit "Browse server", sometimes get IMCE; sometimes get the fckeditor browser (or error message re this not working if I disable it in the fckeditor config).
Just possibly: I more often get IMCE if I've first opened and cancelled image assist.

Comments

ufku’s picture

you may try delaying imce integration on page load.
for instance if you change the second line of imce_set_fck.js with:
$(window).load(function() {setTimeout('imceInitiateFCK()', 2000)});
imce will integrate after 2 seconds from the page load.

DocMartin’s picture

Thanks for this.
But, tried it, and getting fckeditor browser only at the moment.
Tried values of 5000, 4000, even 20 - but imce not showing up.

Had a look at recent log entries, and not obvious that of any help.
Getting an error:
preg_match() [ ... a href='function.preg-match' function.preg-match ... ]: Unknown modifier 'c' in /.../modules/fckeditor/fckeditor.module on line 294.
- but figure that's fck related, so may well be nothing to do with whether imce shows up or not.

yopyop’s picture

This has also been happening to me with the FCKeditor - about 20 percent of the time

deciphered’s picture

I'm also experiencing this issue, I haven't tried that workaround yet (intending to though).

In my case so far it appears that my #1 user is constantly getting the FCKEditor internal method whereas my test Authenticated user is getting the correct IMCE method. I have made certain that all the permissions and any related settings are all correct.

Any solutions?

kevbryant’s picture

i get this issue constantly, it sounds like the fix should be easy (for someone who knows what they are doing) can no one address this?

kevbryant’s picture

actually end up getting fck 's window 90% of the time now, with no rhyme or reason as to why. almost makes imce unusable.

ufku’s picture

Currently, IMCE is trying to detect fckeditor in the page and replace the default file browser with itself. When it fails to do so, you see the fck's original file browser. This kind of behaviour is really hard to debug. The only definite solution is to define IMCE as the default file browser in fckeditor side.
I'll need to discuss this with fckeditor developers. They may provide an option to switch between the two browsers.

kevbryant’s picture

that sounds like the right way to go about it. hopefully they will (or someone else will) figure out how to do that soon

deciphered’s picture

Any dirty hacks?

deciphered’s picture

Found a patch for FCKEditor that fixes this issue at http://drupal.org/node/119008

Found it odd that the patch was created by Ufku before his post here yet he failed to mention it...
Seems to work for me.

kevbryant’s picture

i've applied this, seems to be working, we'll see after a few days i guess, thanks for the heads up.

ufku’s picture

oh guys, sorry, i totally forgot about the #119008.
i hope it works for everyone.

spholmes’s picture

Having same issue. I've applied the patch listed in http://drupal.org/node/119008 but didn't seem to change anything.

This is happening in both my live and test environments running on completely seperate platforms. Any other thoughts as to what to try?

spholmes’s picture

Still working at it, issue seems to occur on Firefox...both 1.5 and 2.0 (and in both versions on Win2k and OS X), but thus far haven't been able to reproduce it in IE6. Safari doesn't even show fckeditor...but that's another issue I'm persuing.

SH

nobody1225’s picture

I use #1 is ok
you can try this http://drupal.org/node/122732#comment-203998

jmmec’s picture

Version: 5.x-1.x-dev » 5.x-1.0

Config: Apache Web Server, Drupal 5.3, IMCE 5.x-1.0, FckEditor 5.x-1.2

I'm seeing the problem reported in this thread using the configuration above, but so far only on IE6. It happens randomly. I didn't see the problem when running on XAMPP in WindowsXP, but it happened immediately when I installed it on a Ubuntu Linux server running Apache 2.

I appears that changing the timeout (as in post #1) is no longer possible in the IMCE 5.x-1.0 code?

I added the patch suggested in http://drupal.org/node/119008 to the FckEditor module, but this did not fix the problem (my results are similar to post #13).

I also modified the patch above by removing the "variable_get('imce_settigns_fck', 0)" in case there was a bug there, but I still saw the problem happen on IE6:

if (function_exists('imce_integrate')) {
imce_integrate('fck');
}

I wonder if upgrading to FckEditor 5.x-2.0-beta might help? Probably not - I see that it already has sourced the fix in patch http://drupal.org/node/119008

Any other suggestions about a possible fix / hack?

----

UPDATE #1:

I installed FckEditor 5.x-2.0-beta and the problem described above with IE6 is either fixed, or is more difficult to reproduce. As I said above, the latest version of FckEditor is better integrated with IMCE and already has the patch for http://drupal.org/node/119008

However, now there seems to be a rare interaction problem between the FckEditor "Insert/Edit Image" window not always displaying the "Browse Server" box (which would invoke IMCE). So far I've seen this on IE6, so don't know if it occurs in other browsers.

----

UPDATE #2:

I just found this http://drupal.org/node/103858 so I'll try to troubleshoot why the "Browse Server" randomly shows up! I'm using the Garland theme and the "page.tpl.php" does have the code that prints $closure, and the browser isn't throwing any javascript errors. So I remain stumped.

----

UPDATE #3:

Well, it seems that the race condition of the FCKEditor "add image" window is still present even after upgrading to the FCKEditor version noted above. And I still have the other problem listed in Update #1 and #2. Strange.

I don't know the root cause of the problems I'm seeing in my configuration, but I wished I didn't have them since I would really like to use IMCE - maybe a later version.

Instead I installed a FCKEditor plugin called "Advanced Fckeditor Ajax File/Image Manager":

http://sourceforge.net/tracker/index.php?func=detail&aid=1730121&group_i...

It is very nice and easy to install and works great in my configuration. The pitfalls is that it doesn't provide per-user directories (but that's okay for me), and doesn't auto-resize images like IMCE does (a very nice feature in IMCE imo).

I'll take anoter look at IMCE in the future!

gabrielharrison’s picture

I have created a fix for this for our install of drupal. Please feel free to use it - But back up first!!!

Gabriel

This is caused by the JS files loading in different orders depending on was is in the IE cache.

The fixes below have replaced the imceBrowserURL string with an object which can be instantiated in one of three places; the main page, the FCK javascript and the imce javascript. Depending of where it is instantiated it has different things set.

If the default imce integration method using the window.onload fails the integration will take place either when the FCK js is loaded in or when the FCK editor is instantiated.

If everything is working correctly all files should be loaded (js and php) then the onload function triggered modifying the FCK settings to use the imce browser. It shouldn't matter if this occurs before or after the FCK editor is instantiated.

This can fail for one of the following reasons:
1. The FCK js has not loaded when the onload event is triggered.
2. The onload is attached after the page has loaded. - Need to double check this.
3. The inline js is not executed first

FILE: /modules/fckeditor/fckeditor/fckconfig.js
At the End Of File
ADD:
// Added by Gabriel Harrison
// This object is either created in imce_set_fck.js, fckconfig.js or imce.module
// It is needed to compensate for IE loading things in stupid and random orders
// In IE it looks like any attached window.onload function is not loaded if load completes before the function is attached
if ("undefined" == typeof(parent.imceFCKIntegration)) {
//The editor has loaded before imce_set_fck is called and the inline js run.
parent.imceFCKIntegration = {url: '', ok: null, imce: false}
} else {
//If the following if statement is false either integration was successful or not everything is loaded yet
if(!parent.imceFCKIntegration.ok && parent.imceFCKIntegration.imce && parent.imceFCKIntegration.url != '') {
//If !parent.imceFCKIntegration.ok imce integration through window.onload was either not called or failed
//If parent.imceFCKIntegration.imce the imce JS file has loaded ok already. This can be false if the editor initialises before imce integration is attempted
//If parent.imceFCKIntegration.url != '' the inline JS has not been run yet (in theory this is not possible but we are talking about IE here...)
parent.imceSetFCK({Config: FCKConfig});
parent.imceFCKIntegration.ok = true;
}
}

FILE: /modules/imce/imce_set_fck.js
Replace all code EXCEPT the imceSetFCK function with
// Added by Gabriel Harrison
// This object is either created in imce_set_fck.js, fckconfig.js or imce.module
// It is needed to compensate for IE loading things in stupid and random orders
// In IE it looks like any attached window.onload function is not loaded if load completes before the function is attached
if ("undefined" == typeof(imceFCKIntegration)) {
//This file has loaded before fckconfig is called and the inline js has been run
var imceFCKIntegration = {url: '', ok: null, imce: true}
} else {
imceFCKIntegration.imce = true; //This js file is now loaded...
}

if (Drupal.jsEnabled && !parent.imceFCKIntegration.ok /* Modified by Gabriel Harrison */) {
$(window).load(imceInitiateFCK);
}

function imceInitiateFCK() {
if ("undefined" != typeof(window.FCKeditorAPI)) {
$.each(FCKeditorAPI.__Instances, function(){imceSetFCK(this);});
imceFCKIntegration.ok = true; // Added by Gabriel Harrison
}
else if ("undefined" != typeof(window.FCKeditor_OpenPopup)) {
$('textarea').each(function () {
if (eval('"undefined" != typeof(oFCKeditor_' + this.id.replace(/\-/g, '_') +')')) {
imceSetFCK(eval('oFCKeditor_' + this.id.replace(/\-/g, '_')));
imceFCKIntegration.ok = true; // Added by Gabriel Harrison
}
});
} else {
imceFCKIntegration.ok = false; // Added by Gabriel Harrison
}
}

FILE: /modules/imce/imce.module
LINE 19
REPLACE WITH: return '

if ("undefined" == typeof(imceFCKIntegration)) {var imceFCKIntegration = {url: "'.url('imce/browse').'",ok: null}} else {imceFCKIntegration.url= "'.url('imce/browse').'"}

'. $output;

LINE 894
REPLACE WITH: drupal_add_js('if ("undefined" == typeof(imceFCKIntegration)) {var imceFCKIntegration = {url: "'.url('imce/browse').'",ok: null}} else {imceFCKIntegration.url= "'.url('imce/browse').'"} ', 'inline');

jman’s picture

Your instruction says to replace all EXCEPT the imceSetFCK function in /modules/imce/imce_set_fck.js but that function still refers to the imceBrowserURL variable. I replaced it with imceFCKIntegration.url

FWIW

spyderpie’s picture

Will this fix work for Drupal 5 versions as well? I can't seem to get the "browse server" button to appear!

ufku’s picture

Status: Active » Closed (fixed)