I'm using FCKeditor module 6.x-2.0-alpha4 with a recent (Dec 12/13) nightly build of FCKeditor.

With FCKeditor enabled, when I create a new page node, the 'Save as Draft' button is not saving the body to the database. It does create a db row, but the body length is 0. The db contents look like this:

a:20:{s:5:"title";s:20:"TEST - DRAFT 6 - fck";s:16:"menu(link_title)";s:0:"";s:12:"menu(parent)";s:15:"primary-links:0";s:12:"menu(weight)";s:1:"0";s:8:"language";s:0:"";s:14:"teaser_include";s:1:"1";s:9:"teaser_js";s:0:"";s:4:"body";s:0:"";s:6:"format";s:1:"2";s:7:"changed";s:0:"";s:7:"form_id";s:14:"page_node_form";s:8:"revision";s:0:"";s:3:"log";s:0:"";s:4:"path";s:0:"";s:7:"comment";s:1:"0";s:4:"name";s:8:"[userNameRemoved]";s:4:"date";s:0:"";s:6:"status";s:1:"1";s:7:"promote";s:0:"";s:6:"sticky";s:0:"";}

If I disable FCKeditor and just use a plain textarea, then 'Save as draft' is functioning as I would expect. I click that button and a draft is created which I can view later (I can even see it in FCKeditor if I re-enable it). This is a successful db entry:

a:20:{s:5:"title";s:25:"TEST - DRAFT 5 - textarea";s:16:"menu(link_title)";s:0:"";s:12:"menu(parent)";s:15:"primary-links:0";s:12:"menu(weight)";s:1:"0";s:8:"language";s:0:"";s:14:"teaser_include";s:1:"1";s:9:"teaser_js";s:0:"";s:4:"body";s:37:"maybe just using text area will work
";s:6:"format";s:1:"2";s:7:"changed";s:0:"";s:7:"form_id";s:14:"page_node_form";s:8:"revision";s:0:"";s:3:"log";s:0:"";s:7:"comment";s:1:"0";s:4:"path";s:0:"";s:4:"name";s:8:"[userNameRemoved]";s:4:"date";s:0:"";s:6:"status";s:1:"1";s:7:"promote";s:0:"";s:6:"sticky";s:0:"";}

I haven't noticed any related warnings in the Drupal log, or any .js errors in the FireFox error console.

Maybe this is normal, but I noticed that there are some rows in drafts where the data column is totally empty. Also I don't see any sign that the module is autosaving anything, even when FCKeditor is disabled - but perhaps I just don't yet understand how that's meant to work since I've never use this module before. I've only tested so far by creating entirely new content, not editing old content.

Other modules installed include: i18n 6.x-1.0-beta6, CCK 6.x-2.1, Views 6.x-2.1

I will try to investigate further, but I'm reporting this now in case there's some obvious solution that I've missed.

Comments

darren.ferguson’s picture

I have not used newer versions of the fckeditor. Does the same occur with the previous version of the fckeditor module?

I will try and get a download and determine what is occurring but currently working on some other pieces so probably be monday before i get around to looking into this.

bsimon’s picture

I replaced the FCKeditor nightly build with the older current stable release, 2.6.3 - that seems to have made no difference

I'll try downgrading the FCKeditor module tomorrow.

darren.ferguson’s picture

Thanks, will wait on your reply to this.

bsimon’s picture

I downgraded the FCKeditor module from 6.x-2.0-alpha4 to 6.x-1.3-rc6. Unfortunately it's still not working, but it looks like that could be a separate issue.

6.x-2.0-alpha4

For FCKeditor module 6.x-2.0-alpha4, which I installed originally:

I followed the execution of draft.js with Firebug (breakpoint on line 38)

37 // adding FCKEditor support
38 if (typeof FCKeditorAPI == 'object' && typeof fckLaunchedJsId != 'undefined') {
39 for( var i = 0 ; i < fckLaunchedJsId.length ; i++ ) {
40 var fck = FCKeditorAPI.GetInstance( fckLaunchedJsId[i] );
41 fck.UpdateLinkedField();
42 };
43 };
44 // utilizing the jquery.fields.js plugin here for form hash
45 var form_data = $('#' + Drupal.settings.draft.form_id).formHash();

Single-stepping with Firebug shows that the script execution jumps straight from line 38 to line 45... apparently because fckLaunchedJsId is undefined...
(also i and fck remain undefined, as you would expect)

Looking at the differences between FCKeditor module 6.x-1.3-rc6 and 6.x-2.0-alpha4, there have been major changes in fckeditor.utils.js - fckLaunchedJsId apparently isn't defined any more (although it is still referenced in img_assist_fckeditor.js - but maybe that's a bug in FCKeditor?)

6.x-1.3-rc6

After downgrading to 6.x-1.3-rc6, I'm still seeing the same external symptoms (i.e. 1- nothing in the body area when I look at the saved draft, 2- Drafts work ok if I disable FCKeditor). However, I guess the reasons are different, because that i loop in draft.js is being executed now. Also, in the db, the body column in drafts contains the correct body text now.

I'll take a look and try to see if I've messed up anything when I downgraded FCKeditor

BTW, just in case I'm actually using Drafts wrongly, the way I'm normally testing this is: 1) create a new page 2) enter title and body text 3) click 'save as drafts', leave that window open 4) open /draft/list 5) open the most recent draft in a new tab and examine it

bsimon’s picture

I tried downgrading again. Wiped all trace of FCKeditor and Drafts files and database. And I tried FCKeditor 6.x-1.3-rc1 + FCKeditor Module 2.6.3. and Drafts 6.x-1.1 - but this also didn't work.

It looks like it's failing to put the body into the db and also not able to repopulate the FCKeditor form even when there is a body data :/

As before, it works OK with FCKeditor disabled.

Perhaps this indicates some other problem is involved in my case (such as i18n, or some mistake I'm making), because the 3 components involved in this test were released at roughly the same time, so I'd expect them to be working together...

So... can someone please suggest a combination of versions of Draft Module, FCKeditor Module and the FCKeditor code that is known to be working with Drupal 6.8 so that I can try that?

edit- corrected rc6 to rc1

darren.ferguson’s picture

This was the old code

// Replace line 38 through 41 with this code please
if (typeof FCKeditor == 'object' && fckLaunchedTextareaId.length) {
for ( var i = 0; i < fckLaunchedTextareaId.length; i++) {
var text = FCKeditorAPI.GetInstance( fckLaunchedJsId[i] ).GetXHTML();
document.getElementById( fckLaunchedTextareaId[i] ).value = text;
};
};

//Replace 109 through 115 with this code please
// for FCKEditor
if (typeof FCKeditor == 'object' && fckLaunchedTextareaId.length) {
for ( var i = 0; i < fckLaunchedTextareaId.length; i++) {
var text = document.getElementById(fckLaunchedTextareaId[i]).value;
if (text) {
FCKeditorAPI.GetInstance(fckLaunchedJsId[i]).InsertHtml(text);
}
}
}

This should work for you with the versions.

Please let me know if it works, if it does i will re-place it again.

bsimon’s picture

OK, thanks, this works with FCKeditor module 6.x-1.3-rc1 if change it to

typeof FCKeditor == 'function'

for the initial check in both sections

I'll try upgrading the FCKeditor components again to see if this fix still works. Is this code likely to work with FCKeditor module 6.x-2.0-alpha4?

darren.ferguson’s picture

Honestly not sure, it has not been tested with the alpha version.

I will add that code back into the FCK Editor portion. Thanks for getting back to me on it.

bsimon’s picture

This also seems to be working fine with FCKeditor module 6.x-1.3-rc6 [+ 2.6.3]

bsimon’s picture

Not working with 6.x-2.0-alpha4, unfortunately

the old code produces:
Error: fckLaunchedTextareaId is not defined

and the most recent code says
Error: fckLaunchedJsId is not defined (or just doesn't work if it checks for fckLaunchedJsId first)

I guess this is to do with the changes in FCKeditor I described here:
http://drupal.org/node/348165#comment-1160661

At the moment, I'm happy enough be running FCKeditor 1.3, but if anyone wants Draft working with FCKeditor 2.0 soon, then maybe the way to start is to post this as a support request in the FCKeditor issue queue - to get some ideas on the new way FCKeditor is being loaded and assigned to textareas.

miruoss’s picture

I had the same issue using draft 6.x-1.1 and fckeditor 6.x-1.3-rc6 (FCKEditor 2.6.3)
I managed to fix it by changing Line 109 through 115 to:

  // for FCKEditor
  if (typeof FCKeditorAPI == 'object') {
    for( var i = 0 ; i < fckLaunchedJsId.length ; i++ ) {
      var fck = FCKeditorAPI.GetInstance( fckLaunchedJsId[i] );
      fck.SetHTML($('#edit-body')[i].value);
    };
  };

edit: in draft.js of course.

Apollo610’s picture

Thank you Miruoss. I made the change you suggested and everything works now. I'm on Draft 6.x-1.1 and FCKEditor 6.x-1.3-rc7.

But god did it suck to try to restore a loooooooong draft and have nothing come up, and then check the DB to see it was blank. Thank god I backed it all up in notepad++. :/

Thanks again!

Apollo610’s picture

Ok, spoke too soon... this KIND of works for me.

If I follow these steps (after adding the updated code above):
1) Create a node (story in this example) and save a draft.
2) Pull the draft up. All the fields populate correctly.
3) Select "Preview Content".

At this point I get the following error:
warning: Invalid argument supplied for foreach() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\modules\taxonomy\taxonomy.module on line 70.

I also get an "Access is denied" error, and then the draft is deleted from the drafts table.

If I create a node that has 0 taxonomy references, I only receive the "Access is denied" error, but the outcome is the same (draft is deleted).

Has anyone else gotten this? I'm backing everything up so I haven't lost anything, luckily, but in case anyone else is using my configuration I just wanted to give the forewarning.

Thanks -

bsimon’s picture

I don't have much clue about the errors you're seeing, but the older version of the code that I ended up using, based on Darren's advice (see details above), is working perfectly with Draft 6.x-1.1 FCKeditor module 6.x-1.3-rc7 with the FCKeditor 2.6.3 code. (that's the same FCKeditor setup as miruoss is using, but I suspect his code won't work for me, since my system definitely didn't like typeof FCKeditor == 'object' before... )

I needed to edit two separate parts of draft.js. Here's the full code I'm using (I think this includes everything that I changed)

1 Code that gets the data from the FCKeditor form to save in the database

// adding FCKEditor support

if (typeof FCKeditor == 'function' && fckLaunchedTextareaId.length) {
for ( var i = 0; i < fckLaunchedTextareaId.length; i++) {
var text = FCKeditorAPI.GetInstance( fckLaunchedJsId[i] ).GetXHTML();
document.getElementById( fckLaunchedTextareaId[i] ).value = text;
};
};

2 Code that repopulates the form (i.e. puts the stored text from the DB back into the FCKeditor form when you open a saved draft)

// for FCKEditor
if (typeof FCKeditor == 'function' && fckLaunchedTextareaId.length) {
for ( var i = 0; i < fckLaunchedTextareaId.length; i++) {
var text = document.getElementById(fckLaunchedTextareaId[i]).value;
if (text) {
FCKeditorAPI.GetInstance(fckLaunchedJsId[i]).InsertHtml(text);
}
}
} 
Apollo610’s picture

Ok so in case anyone's keeping score, a summary:

Draft: Draft 6.x-1.1
FCKEditor 6.x-1.3-rc7

Scenario 1: Default install of both allows me to save to the drafts table correctly. Everything looks fine. When I recall a draft node, the title populates, but no body content is displayed (though I see it in the table). If I preview the recalled draft node, I get an "Access Denied" error and the record in the draft table is deleted.

Scenario 2: Tweak the draft.js file exactly per Darren's recommendations above. A record in this case is saved to the drafts table, however the BODY tag in the data field is always empty. When I recall the draft node, the title is populated but obviously nothing is put in the body. Attempting to preview the draft causes the Access Denied error again, followed by the record being deleted.

Scenario 3: Change the "object" type in Darren's code to "function" per bsimon's suggestion. This works perfectly insofaras the node draft is stored properly in the database and recalled properly in the draft node. I'm able to save the draft multiple times in a single node and the changes are reflected correctly. So this is definitely the way to go (thanks bsimon).

But I still get the Access Denied error if I attempt to view a preview of a draft node (and the record is deleted from the DB)... is anyone else having this happen? I wouldn't even know where to begin with this. Permissions are set across the board for the admin account i'm testing on, and I can view the preview as long as I don't save it as a draft first... I'll bounce this into a different thread if noone here is sure, I don't want to hijack the OP.

bsimon’s picture

The only time I got 'access denied' from Draft was when I tried to view a saved draft created by another account (I modified the View to show me all the drafts in the DB, not only the current user's). This happened even with the User#1 account with all permissions, which seemed strange. I haven't tested this recently, so might have just been a temporary problem.

Apollo610’s picture

Hmmm, that's definitely not what's going on from my side. I haven't modified the view and I'm just trying to preview the drafts immediately after they're created from the same author.

But also, something must be getting coughed up in the write process when I hit the preview button which is what's causing the drafts to get deleted.. I wonder if Drafts does a write before it attempts to preview? Just odd, but I guess good to know so I can be cautious of it...

miruoss’s picture

Again, I had the same error. I tried to preview a draft and got "access denied" because the draft was deleted in the meantime. I fixed this by changing draft.module as follows:

Line 189: Add a ($form_state['values']['op'] != 'Preview') to the if-statement. The function then should look like this:

/**
 * Submission handler for when the node is submitted
 */
function draft_node_form_submit($form, &$form_state) {
  // check if we have a draft id associated with this submission if so we can remove it
  if (isset($form_state['values']['draft_id']) && is_numeric($form_state['values']['draft_id']) && $form_state['values']['op'] != 'Preview') {
    db_query("DELETE FROM {drafts} WHERE draft_id = %d", $form_state['values']['draft_id']);
  }
}

But then I had the problem that the form got filled twice, once by drupal (preview) and again by the draft module. I therefore packed lines 110 through 142 into another if-statement:

        if($form_state['post']['op'] != 'Preview') {
          if ($_GET['draft_id'] && is_numeric($_GET['draft_id'])) {
            $result = db_fetch_object(db_query("SELECT * FROM {drafts} WHERE draft_id = %d", $_GET['draft_id']));
            if ($result->uid != $user->uid) {
              drupal_access_denied();
              die();
            }
            drupal_add_js('$(document).ready(function() { setTimeout("Drupal.draft.populateForm();", 3000); });', 'inline');
            $settings['draft']['form_data'] = unserialize($result->data);
          }
          // adding the pertinent javascript files to the page
          drupal_add_js(DRAFT_PATH .'/jquery.field.js');
          drupal_add_css(DRAFT_PATH .'/draft.css');
          drupal_add_js(DRAFT_PATH .'/draft.js');
          // setting the javascript settings we will require in order to utilize saving the form
          $settings['draft']['form_id'] = 'node-form';
          $settings['draft']['autosave'] = 0;
          $settings['draft']['img_url'] = url('draft/images');
          $settings['draft']['interval'] = variable_get('draft_autosave_interval', 30000);
          $settings['draft']['url'] = url('draft/save');
          $settings['draft']['button_id'] = 'edit-save-as-draft';
          $settings['draft']['form_elements_ignore'] = variable_get('draft_form_elements_ignore', 'op|form_token|form_build_id');
          $settings['draft']['node_type'] = $node->type;
          // checking to see if autosave is enabled or not for this account
          if (variable_get('draft_autosave_'. $user->uid, 0)) {
            drupal_add_js('Drupal.draft.saveTimeout();', 'inline');
            // setting the autosave interval if the user has it set in their account since it can
            // over ride the administrator autosave timeout incase the user wishes it to be longer or shorter
            if (($interval = variable_get('draft_autosave_interval_'. $user->uid, 0))) {
              $settings['draft']['interval'] = $interval;
            }
            $settings['draft']['autosave'] = 1;
          }
          drupal_add_js($settings, 'setting');
        }

I hope this helps.

Michael

pingvinen’s picture

Im having the same problem. The code that miruoss posted at #18 did not change anything for me. The drafted nodes turns out to be empty.
Im using FCKeditor too.

miruoss’s picture

#18 is an attempt to fix the preview functionality. Did you try the code in #11?

pingvinen’s picture

I have changed the code in draft.js and in draft.module like the suggestions in #11 and #18. Still getting the same results.
The draft can be found empty in ?q=draft/list and if I try to preview it from the draft I get a Access deny to that page...

Im using
FCKeditor 6.x-2.0-alpha5
Draft 6.x-1.1 (modified, see http://drupal.org/node/348165)
Core 6.10
Jolt-Cola 1 every hour

darren.ferguson’s picture

Have not tried the new FCKEditor but will be pushing to make updates to the Draft module in the coming weeks. Will be certain to make sure we have functionality for TinyMCE and FCKEditor and hopefully the latest versions will not break anything.

bsimon’s picture

@pingvinen

I'd suggest you use FCKeditor 6.x-1.3 for now. I tried for a while but I couldn't get Draft working with FCKeditor 6.x-2.0, and I think the other users posting on this page are all using 6.x-1.3

There is very little difference in features between FCKeditor 6.x-1.3 and 2.0 at the moment. Though perhaps in future, 2.0 will be developed further.

adshill’s picture

Hi Apollo,

Did you ever discover what created the taxonomy module error you are receiving above? I am using Draft module, however I'm getting the EXACT same error, but from a node type that is not using the Draft features...

Any pointers on how you got rid of it would be great!

Thanks,

Adam

Apollo610’s picture

Hi Adam, are you able to narrow down exactly what's causing the Taxonomy error? If you disable Draft, does the error go away?

I can't recall exactly what fixed the taxonomy error from my side, though I know it's no longer an issue. I'll try to help you troubleshoot where I can, talking through the problem may cause me to remember what the problem was and how it was resolved. ;)

adshill’s picture

Hi Apollo,

Actually... the error appeared to disappear for me also. I'm not quite sure how, but in these circumstances, and given that the code referenced in the taxonomy module appears to have no relevance to what I'm working on I'm going to pretend it never happened unless I see it again :) I'm actually working with the Workflow and Rules modules so... not quite sure how taxonomy was brought into it!

Anyway, thanks so much for getting back to me and apologies to the maintainer for slightly hijacking this thread! :)

All the best,

Adam

darren.ferguson’s picture

Status: Active » Fixed

FCKEditor support now seems to be fully functional in the Draft module in CVS.

Closing out this ticket.

darren.ferguson’s picture

Status: Fixed » Closed (fixed)