Just downloaded the wysiwyg(2.0) module, and loaded it into my site. Then downloaded fckeditor(2.6.4) and put the uncompressed folder into the sites/all/libraries folder as directed under site configuration/wysiwyg.

I've created a new input type ('WYSIWYG'), and set all the settings. But when I use the editor (which works fine for formatting and layout), the image upload pop-up window (titled 'image properties') is missing the 'Upload' tab, and the URL field in the 'Image Info' tab is missing the 'Browse Server' button.

I thought maybe my permissions were wrong, but when I use the sample that comes with fckeditor (e.g. at http://www.mysite.com/sites/all/libraries/fckeditor/_samples/html/sample...), the browse server button is there and I can upload images fine using the (now present) Upload tab.

Presumably there is therefore something about the way fckeditor is being embedded into the create content form that makes it behave in this reduced way. But I cannot find any options under the wysiwyg site configuration to switch this on.

Can anyone please help as I really like this editor combination, but without the browse/upload feature my editors will need to delve too deeply into the HTML - something I'm trying to avoid!

(Running Drupal 6.12 on Mac OSX 10.5.6 with Apache, MySQL & PHP 5.2.6)

Comments

alpirrie’s picture

Title: wysiwyg and fckeditor - problems with image upload and server browse » wysiwyg and fckeditor - problems with image upload and browse server
alpirrie’s picture

It seems that Drupal is squirting out these settings in the document head. All those falses are what's causing the problem. How do I set them to true?

<script type="text/javascript">
<!--//--><![CDATA[//><!--
jQuery.extend(Drupal.settings, { "basePath": "/", "wysiwyg": { "configs": { "fckeditor": { "format3": { "EditorPath": "/sites/all/libraries/fckeditor/", "SkinPath": "/sites/all/libraries/fckeditor/editor/skins/default/", "CustomConfigurationsPath": "/sites/all/modules/wysiwyg/editors/js/fckeditor.config.js", "Width": "100%", "Height": 420, "LinkBrowser": false, "LinkUpload": false, "ImageBrowser": false, "ImageUpload": false, "FlashBrowser": false, "FlashUpload": false, "IncludeLatinEntities": false, "IncludeGreekEntities": false, "FontFormats": "p;address;pre;h2;h3;h4;h5;h6;div", "FormatSource": 0, "FormatOutput": 0, "EditorAreaCSS": "/sites/all/themes/cache/style.css" } },  .....  });
//--><!]]>
</script>
alpirrie’s picture

OK. The defaults appear to be set in the wysiwyg module in the file editors/fckeditor.inc

...
function wysiwyg_fckeditor_settings($editor, $config, $theme) {
  $settings = array(
    'EditorPath' => base_path() . $editor['library path'] . '/',
    'SkinPath' => base_path() . $editor['library path'] . '/editor/skins/' . $theme . '/',
    'CustomConfigurationsPath' => base_path() . drupal_get_path('module', 'wysiwyg') . '/editors/js/fckeditor.config.js',
    'Width' => '100%',
    'Height' => 420,
    'LinkBrowser' => FALSE,
    'LinkUpload' => FALSE,
    'ImageBrowser' => FALSE,
    'ImageUpload' => FALSE,
    'FlashBrowser' => FALSE,
    'FlashUpload' => FALSE,
    // By default, FCKeditor converts most characters into HTML entities. Since
    // it does not support a custom definition, but Drupal supports Unicode, we
    // disable at least the additional character sets. FCKeditor always converts
    // XML default characters '&', '<', '>'.
    // @todo Check whether completely disabling ProcessHTMLEntities is an option.
    'IncludeLatinEntities' => FALSE,
    'IncludeGreekEntities' => FALSE,
  );

...

}

Changing them to 'TRUE' solves the problem. But isn't there a better way to do this in site configuration/wysiwyg?

alpirrie’s picture

I think I have got to the bottom of this. I thought I'd post what I've done here in case it sparks an improvement - which I think this functionality might do.

This is how I've created the possibility for editor specific options under admin/settings/wysiwyg.

1. Create a new file called 'fckeditor.admin.inc' and stick it alongside 'fckeditor.inc' in the wysiwyg module's 'editors' folder. This new file contains one function that defines the editor-specific admin form we want.

function wysiwyg_fckeditor_form($form_state, $profile) {
  $form = array();
  $form['fck'] = array(
    '#type' => 'fieldset',
    '#title' => t('FCKeditor Options'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );

  $form['fck']['image_browser'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable image browsing'),
    '#default_value' => $profile->settings['image_browser'],
    '#return_value' => 1,
    '#description' => t('Allow users to browse the server for images to include.'),
  );

  $form['fck']['image_upload'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable image uploads'),
    '#default_value' => $profile->settings['image_upload'],
    '#return_value' => 1,
    '#description' => t('Allow users to upload images onto the server.'),
  );
  
  return $form;
}

2. Add the following lines into 'wysiwyg.admin.inc' in the wysiwyg_profile_form function, just above the first definition of $form['basic']:

  ... 

  // Create editor specific admin menu
  $func = 'wysiwyg_'.$profile->editor.'_form';
  if (function_exists($func)) $form = array_merge($form,$func($form_state, $profile));

  $form['basic'] = array(
    '#type' => 'fieldset',
    '#title' => t('Basic setup'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );

  ... 

3. Update the function wysiwyg_fckeditor_settings in fckeditor.inc to include the following lines anywhere after the default settings are defined (see #3 - just after this is fine)

  ...

  if (isset($config['image_browser'])) {
    $settings['ImageBrowser'] = $config['image_browser'];
  }
  if (isset($config['image_upload'])) {
    $settings['ImageUpload'] = $config['image_upload'];
  }

  ...

That way the admin settings only appear if you have set the editor to fckeditor in this case, and the settings in the admin section overwrite the default ones hard-coded into fckeditor.inc.

It would probably be worth doing the same thing for the other values (LinkBrowser, LinkUpload, FlashBrowser and FlashUpload), but the image ones were the only ones I was interested in changing.

Any use?

alpirrie’s picture

Status: Active » Needs review
sun’s picture

Status: Needs review » Closed (won't fix)

The internal file browsers/uploading features are purposively disabled, because one needs to edit PHP/whatever files to make them work. Additionally, Drupal knows nothing of what you do in those file helpers.

You might want to investigate a Drupal-based solution: For example, http://drupal.org/project/imce_wysiwyg or http://drupal.org/project/img_assist.

pitxels’s picture

@alpirrie: this post shows what I think is a easier way to achieve the same:

http://techdad.wordpress.com/2009/05/24/drupal-wyswyg-fckeditor-tips/

(The only thing is that is missing is that now the fckeditor is in sites/all/libraries/fckeditor)