To CK Source,
How are you? The old work horse fckeditor has outdone ckeditor with regards to loading via JSON. I am one of the Xoops Project developers - We have with the 2.4 series decided to go with an inclusion of JQuery as well as ckeditor..
Don't worry you will be happy to know with this bug.. Your competitors like Tinymce & Xihna and many of the others didn't work either.
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.
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", params, refreshformdesc); } 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()), params, refreshformdesc); } </script><body onLoad="javascript:doJSON_LoadPageForm();" /> <h1>Content Page - 2.7</h1> <p align="center" id='forms'></p>
The Form is placed in the <p> at the end of the code with a function called refreshformdesc with innerHTML.
The file dojson_loadform.php looks like:
<?php 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(i, n){ switch(i){ case 'innerhtml': $.each(n, function(y, k){ var tmp = document.getElementById(y); if (tmp) tmp.innerHTML = k var tmp = false; }); break; case 'disable': $.each(n, function(y, k){ 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(y, k){ 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(y, k){ 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.
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.
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..
Re: CKEditor 3 & JSON Form Loading - Editor Crashing
Re: CKEditor 3 & JSON Form Loading - Editor Crashing
I can send you a copy of the code if you like... There is not much more to explain apart from when echo the form to the screen buffer ckeditor loads in all browsers...
When I use the same code but populate it using JSON to a id it doesn't..
You can experiment with it if you like :: http://wishcraft.thruhere.net/2.3.4 (username: wishcraft, password: password)..
The module is called content. When I use ckeditor the code example you provide for loading the editor doesn't work when loaded with JSON.. ie <p id="forms"></p> is populate via json with the form HTML the editor doesn't work (fckeditor does however) - but if the form is populated with Smarty (http://www.smarty.net) there is no worries, just means with ckeditor you cannot have an interactive form.
I orginally attempt also to retrieve the value of the object with JSON (a $_POST) with something similar to $('#text').val() with JQuery and there is no data returned (so I have revised my code and gone with this method, otherwise i wouldn't have to post to the server i could scoop it up...
Re: CKEditor 3 & JSON Form Loading - Editor Crashing
I am just wondering if there is any other method I can try for loading ckeditor.. currenty in xoops the editor is spawned by ckeditor.php contained within /class/xoopseditor/ckeditor/ckeditor.php - This if you like is a bootstrap for ckeditor anywhere in the xoops form construct.
Looks like:
The function responsible for outputing the html for ckeditor is render..
It will output html where the ckeditor script is buffered to the html then output the required fields for it; i think the use of !CDATA is causing the conflict in this example..
ie.
Re: CKEditor 3 & JSON Form Loading - Editor Crashing
But you can't expect anyone else to digg through a lot of code and frameworks to understand what's your problem. The simpler the code that you provide, the higher chances of being able to reproduce and fix the problem
it says 404 Not found
Can you provide this modified sample?
Re: CKEditor 3 & JSON Form Loading - Editor Crashing
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.li ... E_JSON.zip
I wonder why it isn't working in the XOOPS Environment we are using replace by code with xoops...
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
Re: CKEditor 3 & JSON Form Loading - Editor Crashing
and
parts. Is that intended?
Also, trying to use replacebyclass if you inject new content after the page has been loaded won't work.
Re: CKEditor 3 & JSON Form Loading - Editor Crashing
The text area is just to display what JSON passed to the browser, via the ajax loader with php. But FCKEditor works no worries with being loaded with JSON..