So I'm playing with a developing of a module. One of the data field is also "description", which I would like to be entered as wysiwyg editor.
in mysql I defined the field desciption as
....
desc text NOT NULL
....
then in myclass.php i defined
function __construct()
{
...
$this->initVar("desc", XOBJ_DTYPE_TXTAREA);
...
}
Then in my admin project_admin.php when I am building admin form
I have declared field "desc" as:
$editor_configs=array();
$editor_configs["name"] ="desc";
$editor_configs["value"] = $myts->makeTboxData4Edit($objArray['desc']); $editor_configs["rows"] = 20;
$editor_configs["cols"] = 100;
$editor_configs["width"] = "100%";
$editor_configs["height"] = "400px";
$editor_configs["editor"] = xoops_getModuleOption('general_editor', 'system');
$form->addElement(new XoopsFormEditor(_AM_MYMODULE_PROJECT_DESC, "desc", $editor_configs), false);
The filed is propely displayed.
My BIG problem is, that if I entered smiley or image into text and then save the "desciption" field into DB and reedit that record, Iam getting images and smiley in bad HTML format.
For example: IF i enter in desc filed only (HTMLsource)
<p>this is smiley <img alt="Smile" border="0" src="http://localhost/xoops001/uploads/smilies/smil3dbd4d6422f04.gif" title="Smile" />p>
after saving the record and rediting it I have got (HTML SOURCE)
I know it got something to do with
myts class and sanytizing, but I couldn't figure it out, how to properly use it.
So here are my questions :
1. what function of class myts should I Use in my edit/add function
$obj = $this_handler->get($id);
$obj->setVars($_POST);
$obj->setVar('desc', $myts->addSlashes( $obj->getVar('desc')));
$this_handler->insert($obj)
2. what function of class myts should I Use when I building a admin form
$editor_configs["value"] = $myts->makeTboxData4Edit($objArray['desc']);
3.what function of class myts should I Use when I send to template?
I hope, Its not too hard to answer. It would make me very happy to get a solution, because this is occupying me for last 3 days.
I will post a solution how to upload multi files at once (tomorow), if anyone is interested.