1
wishcraft
CKEditor 3 & JSON Form Loading - Editor Crashing

Reported CK Source: http://cksource.com/forums/viewtopic.php?f=11&t=17702&p=45204#p45204

How are you? The old work horse fckeditor has outdone ckeditor with regards to loading via JSON.

Okey I am working on a new PAID module for XOOPS called content. And I am working on a more secure form loading using JQuery and JSON. The XOOPS Wrapping class around ckeditor runs fine it is similar to the fckeditor one, but loads the ckeditor..

When i pass the HTML Code to generate the form via JSON with the following code in HTML generated with smarty as you can see in the first screen capture fckeditor is working.

Resized Image

The html for the form is:
<br style="clear:both;" /><script language="javascript" type="text/javascript"
function 
doJSON_LoadPageForm() {
    var 
params = new Array();
     $.
getJSON("http://localhost/2.4.3/modules/content/dojson_loadform.php?passkey=0cf859d2ddc5c3f7e7cc61eb3582ea2d&form=content&storyid=2"paramsrefreshformdesc);
}
function 
doJSON_LoadPageTemplate() {
    var 
params = new Array();
     $.
getJSON("http://localhost/2.4.3/modules/content/dojson_loadtemplate.php?passkey=0cf859d2ddc5c3f7e7cc61eb3582ea2d&form=content&storyid=2&template=" + $('#template :selected').text() + "&language=" + $('#language').val() + "&catid=" + $('#catid :selected').val() + "&parent_id=" + $('#parent_id :selected').val() + "&title=" escape($('#title').val()) + "&ptitle=" escape($('#ptitle').val()) + "&keywords=" escape($('#keywords').val()) + "&page_description=" escape($('#page_description').val()) + "&address=" escape($('#address').val()), paramsrefreshformdesc);
}
script><body onLoad="javascript:doJSON_LoadPageForm();" /> 
 
<
h1>Content Page 2.7h1
<
p align="center" id='forms'>p>


The Form is placed in the

at the end of the code with a function called refreshformdesc with innerHTML.

The file dojson_loadform.php looks like:


include ('header.php');
include (
$GLOBALS['xoops']->path(_BRC_PATH_PHP_JSON));

$json = new services_JSON();

$values = array();
$submit true;
if (
$passkey!=content_passkey())
{
    
ob_start();
    
xoops_error(_BRC_MSG_SECURITYTOKEN);
    
$msg ob_get_contents();
    
ob_end_clean();
}

    switch(
$form){
    case 
_BRC_URL_FORM_CONTENT:
        if (!
$msg)
            
$values['innerhtml']['forms'] = content_addcontent($storyid$_GET['language']);
        else
            
$values['innerhtml']['forms'] = $msg;
        break;
    case 
_BRC_URL_FORM_CATEGORY:
        if (!
$msg)
            
$values['innerhtml']['forms'] = content_addcategory($catid$_GET['language']);
        else
            
$values['innerhtml']['forms'] = $msg;
        break;        
    case 
_BRC_URL_FORM_BLOCK:
        if (!
$msg)
            
$values['innerhtml']['forms'] = content_addblock($blockid$_GET['language']);
        else
            
$values['innerhtml']['forms'] = $msg;
        break;                
    }

print 
$json->encode($values);
?>


The file dojson_loadform.php which generates a human readable code for Java Objects passes an array for the id of forms to have it innerhtml populated with the form. The function it is talking to is refreshformdesc which looks like:

// JavaScript Document

function refreshformdesc(data){
    $.
each(data, function(in){
        switch(
i){
        case 
'innerhtml':
            $.
each(n, function(yk){
              var 
tmp document.getElementById(y);
              if (
tmp)
                  
tmp.innerHTML k
              
var tmp false;
            });
            break;
        case 
'disable':
            $.
each(n, function(yk){
                switch(
k){
                case 
'':
                case 
'false':
                  var 
tmp document.getElementById(y);
                  if (
tmp)
                      
tmp.disabled false;
                  var 
tmp '';
                  break;
                default:
                  var 
tmp document.getElementById(y);
                  if (
tmp)
                      
tmp.disabled true;
                  var 
tmp '';
                  break;
                }
            });
            break;            
        case 
'checked':
            $.
each(n, function(yk){
                switch(
k){
                case 
'false':
                  var 
tmp document.getElementById(y);
                  if (
tmp
                      
tmp.checked  false;
                  var 
tmp ='';
                  break;
                default:
                  var 
tmp document.getElementById(y);
                  if (
tmp
                      
tmp.checked  true;
                  var 
tmp ='';
                  break;
                }
            });
            break;                        
        case 
'index':
            $.
each(n, function(yk){
                  var 
tmp document.getElementById(y)
                  if (
tmp
                      
tmp.selectedIndex  false;
                  var 
tmp ='';
            });
            break;                        
            
        }
    });
}


All the code works as you can see, if I echo the form, ckeditor loads but if i pass the echo via JSON to innerhtml which is more secure as it means passwords are not in the open text for example even if they are passed to the browser which in some cases is very useful. This is a secure Java exchange for form generation.

Resized Image

But if I load CK Editor by changing the preferences in my new module to ck editor.. This is what it looks like, I can't show you with a YouTube video, it loads for a second, you see it, then it crashes and burns and leaves an open text box.

Resized Image

For some reason when i load ckeditor via JSON to the browser, it will not intialise in any way.. it works fine if passed via a smarty variable but this means i can't have user templates for the editor. But the old work horse FCKEditor works fine..

2
wishcraft
Re: CKEditor 3 & JSON Form Loading - Editor Crashing

the JQuery version of refreshformdesc would be:

function setvalue(data){
    $.
each(data, function(in){
        switch(
i){
        default:
        case 
'val':
            $.
each(n, function(yk){
              $(
"#"+y).val(k);
            });
            break;        
        case 
'text':
            $.
each(n, function(yk){
              $(
"#"+y).text(k);
            });
            break;        
        case 
'html':
            $.
each(n, function(yk){
              $(
"#"+y).html(k);
            });
            break;        
        }
    });
}

3
wishcraft
Re: CKEditor 3 & JSON Form Loading - Editor Crashing

I made this example of the error, and in simplified form it seems to load without a hitch on a couple of them, I have reused the sample :: http://cid-6580d2a11c091017.skydrive.live.com/self.aspx/XOOPS%20Extensions/CK%20Editor/CKEditor%5E_JSON.zip

I wonder why it isn't working in the XOOPS Environment we are using replace by code with xoops... Which is working with the sample but in the control panel or main of XOOPS it is not..

Frankblack... can you contact me to debug this please..

thanks

Simon

4
wishcraft
Re: CKEditor 3 & JSON - A Xoops Core Bug

I made this example of the error, and in simplified form it seems to load without a hitch on a couple of them, I have reused the sample :: http://cid-6580d2a11c091017.skydrive.live.com/self.aspx/XOOPS%20Extensions/CK%20Editor/CKEditor%5E_JSON.zip

I wonder why it isn't working in the XOOPS Environment we are using replace by code with xoops. Cause building this from the samples provided allowed me to show that the editor does work with the method i am using, but not in the XOOPS oxygen code in the control panel or on theme page.

This example consists of:

Paths & Files of : CKEditor_JSON.zip
/ckeditor - Ck Editor 3.1
/js/core.js - Runtime java
/dojson_loadform.php - json proceedure file
/index.php - Index
/JSON.php - PEAR JSON Class

5
frankblack
Re: CKEditor 3 & JSON Form Loading - Editor Crashing
  • 2010/2/18 9:40

  • frankblack

  • Just can't stay away

  • Posts: 830

  • Since: 2005/6/13


[puzzled]How can I help you? [/puzzled]

Can you give or show somewhere the generated HTML code of the non-working version?

I ran into a similar problem, when I was trying to update the tinyMCE engine for tinyeditor. But I had only problems with two text editor fields used as WYSIWYG. One WYSIWYG was running fine. The problem was that tinyMCE was initialized for every instance of the text editor fields. So I made a simple check if tinyMCE was alread defined. Since then it was working. Perhaps it is the same problem with CKeditor?

HTH

6
wishcraft
Re: CKEditor 3 & JSON Form Loading - Editor Crashing

I will email you a copy of the module, please do not distribute it, it will be released soon as a paid module. You know it works using the test case I made of it from the samples provided with Ck Editor.

I think it might be the oxygen java library, they need to be rewritten in JQuery at any rate, but this doesn't explain why it doesn't load on the front screen either unless it is xoops.js which needs to be rewritten in JQuery as well.

You need to have debugging turned off (More Java that needs rewritten in JQuery). FCK Editor and DHTML Editor both work.

Whats your email?

7
frankblack
Re: CKEditor 3 & JSON Form Loading - Editor Crashing
  • 2010/2/19 22:13

  • frankblack

  • Just can't stay away

  • Posts: 830

  • Since: 2005/6/13


I do not need to turn debug off! I use firephp with xoops, so this is no problem. I'll send you my email in pm.

8
ptomter
Re: CKEditor 3 & JSON Form Loading - Editor Crashing
  • 2010/2/22 20:58

  • ptomter

  • Just popping in

  • Posts: 49

  • Since: 2009/3/31


Did you guys find out what was the problem?

9
frankblack
Re: CKEditor 3 & JSON Form Loading - Editor Crashing
  • 2010/2/23 16:54

  • frankblack

  • Just can't stay away

  • Posts: 830

  • Since: 2005/6/13


The problem as I see it is, that CKeditor.replace tries to turn the textareas into wysiwyg, but they are created later via AJAX/JSON. So CKeditor.replace has to react somehow on the dynamic creation of the wysiwyg areas.

10
wishcraft
Re: CKEditor 3 & JSON Form Loading - Editor Crashing

That does not seem to be what is causing it frank.. If you try my test case scenario built out of the samples from cksource it works fine.

It has something to do with the java script being loaded by xoops, probably xoops.js that needs to be rewritten in JQuery.

Yeah the editor works fine with JSON in everything but XOOPS itself..


Login

Who's Online

315 user(s) are online (259 user(s) are browsing Support Forums)


Members: 0


Guests: 315


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits