I installed as indicated in the instructions. Seemed pretty straight-forward, however, when I click on the button in the dialog box that would normally open ICME (and now TinyBrowser), nothing happens. I'm using WYSIWYG and TinyMCE. I am using a url such as dev.example.com. example.com isn't going to the server hosting dev.example.com. That may have something to do with it, but I'm nott sure which magically combination I should use for the cookie setting. I've tried dev.example.com, example.com, etc with and without the base URL set.

Otherwise, I've enabled TinyBrowser as a button as well as the advanced image browser, etc.

Comments

pixture’s picture

For $cookie_domain setting in the settings.php, dev.example.com and example.com would not make a difference since Drupal core strip $cookie_domain settings and extract just a domain name (in this case, example.com).
Please open the error console and try to get what kind of Javascript error you get when you click on the file browser icon in the small image dialog. There might be an error occuring. Let me know what kind of error you get there.

Also, please do the followings if you have not yet done.

1) Clear the Drupal's cache
2) Clear the browser's cache
3) Restart the browser

Jon Betts’s picture

Thanks! I hadn't cleared the browser's cache. Now when I click on the button, another page pops up with a 404 error. Nothing in the console, but the url looks problematic:

http://example.com/sites/all/libraries/tinymce/jscripts/tiny_mce/plugins... echo $tbmain; &type=image&R

The url above includes php code, should all be on one line, but is formatted otherwise.

pixture’s picture

Are you using Javascript Aggregator module, or Optimize Javascript files setting ON at Administer > Site configuration > Performance page ? If so, TinyBrowser may not work unless you disable them.

Please check this. Thanks,

Jon Betts’s picture

Optimize Javascript was on and not being able to use it would probably be a deal breaker for me, but turning it off just got me back to having nothing happen when I click the button. I checked the console and I get the following error:

"u is undefined"

Hope this helps!

pixture’s picture

"u is undefined" probably means some functions/variables are undefined. I guess this is something to do with cache. Did you do the following after turning OFF the Javascript optmization?

1) Clear the Drupal's cache
2) Clear the browser's cache
3) Restart the browser

If not, please do this and see it helps or not.
Thanks!

Jon Nunan’s picture

Hi pixture!

Love the module.

Generally you shouldn't run a php file through drupal_add_js as it causes this kind of problems. Do you know about the Drupal.settings JS object?

You can rename 'tb_tinymce.js.php' to 'tb_tinymce.js' and make the following changes:


 function tinyBrowser (field_name, url, type, win) {

    /* If you work with sessions in PHP and your client doesn't accept cookies you might need to carry
       the session name and session ID in the request string (can look like this: "?PHPSESSID=88p0n70s9dsknra96qhuk6etm5").
       These lines of code extract the necessary parameters and add them back to the filebrowser URL again. */

    var cmsURL = Drupal.settings.tinybrowser.cmsURL;    // script URL - use an absolute path!
    if (cmsURL.indexOf("?") < 0) {
        //add the type as the only query parameter
        cmsURL = cmsURL + "?type=" + type;
    }
    else {
        //add the type as an additional query parameter
        // (PHP session ID is now included if there is one at all)
        cmsURL = cmsURL + "&type=" + type;
    }
    tinyMCE.activeEditor.windowManager.open({
        file : cmsURL,
        title : 'Tiny Browser',
        width : Drupal.settings.tinybrowser.width, 
        height : Drupal.settings.tinybrowser.height,
        resizable : "yes",
		  scrollbars : "yes",
        inline : "yes",  // This parameter only has an effect if you use the inlinepopups plugin!
        close_previous : "no"
    }, {
        window : win,
        input : field_name
    });
    return false;
  }

So there are no longer any evaluated PHP code in the JS, all dynamic values are now pointing to the Drupal.settings object.

Then in 'tinybrowser.module' when you call the newly renamed file withdrupal_add_js you can provide the variables as well. Code is a bit ugly at the moment but:

if (!isset($integrated[$editor])) {
  $integrated[$editor] = TRUE;
  //add JS settings
  $tbmain ='/'.drupal_get_path('module', 'tinybrowser').'/tinybrowser/tinybrowser.php';
  $tb_js_settings = Array();
  $tb_js_settings['tinybrowser'] = Array();
  $tb_js_settings['tinybrowser']['cmsURL'] = $tbmain;
  $popup_win_size = variable_get('tinybrowser_popup_window_size', '770x480');
  $popup_win_size = preg_replace('/\s*/', '', $popup_win_size);
  $popup_win_size = strtolower($popup_win_size);
  $win_size = split('x', $popup_win_size);
  $tb_js_settings['tinybrowser']['width'] =   intval($win_size[0]);
  $tb_js_settings['tinybrowser']['height'] =  intval($win_size[1]);
  drupal_add_js($tb_js_settings, 'setting');
  drupal_add_js(drupal_get_path('module', 'tinybrowser') .'/tinybrowser/tb_tinymce.js');
  $_SESSION['tinybrowser_module'] = TRUE;
}

I only did a quick hack proof of concept for tinymce at the moment, I'm not on a machine with patch tools sorry, but hopefully the above helps.

pixture’s picture

@meatsack

Very good information. I will give it a try by myself later. Besides, it is the original TinyBrowser JS file that contains PHP code inside. There are some other JS files that uses PHP code too. Since this could be a major code change, I think I need to do it carefully and test a lot before releasing.

Anyway, thank you for the nice information!! :-)

bdichiara’s picture

I am having the same problem as #2 and am not using Javascript Aggregator module, or Optimize Javascript files as suggested in #3, here is my performance page: http://screencast.com/t/cZmUfTek6OdI

I have no errors in Firebug, and have cleared the cache MANY times. Any other suggestions on the echo $tbmain; issue?

UPDATE:
I added the code from #6 and it fixed the popup window, however this is what my popup window looks like:
http://screencast.com/t/7LdIINQVv

Any fix for this?

Jon Nunan’s picture

#8 Which version are you using?

bdichiara’s picture

@meatstack 6.x-1.0-beta1 should I switch to one of the dev versions?

EDIT:
I tried the latest dev: 6.x-1.x-dev tar.gz (362.48 KB) | zip (387.57 KB) 2010-Nov-12

And it goes back to the echo $tbmain; issue. Should i now go back and make your modifications from #6 to the latest dev version?

Jon Betts’s picture

Issue summary: View changes