Saving to DB as parsed?

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
sletts02
Forum Members
Forum Members
Posts: 19
Joined: Sun Sep 21, 2008 9:13 pm

Saving to DB as parsed?

Post by sletts02 »

For some reason this is not saving any HTML codes, rather they are parsed and show in a browser. I.e.
It looks like this:
bold

Instead of:
bold

action.user_editcontent

Code: Select all

<?php

if (!isset($gCms)){
	exit;
}

$feusers = $this->GetModuleInstance('FrontEndUsers');
if( !$feusers )
{
	$this->_DisplayErrorPage( $id, $params, $returnid,
				  $this->Lang('error_nofeusersmodule'));
	return;
}

if(!$feusers->LoggedIn()){
	$this->Redirect($id, 'default', $returnid);
}

$cid = $params['cid'];

if (!isset($params['cid']))
{
	$this->_DisplayErrorPage( $id, $params, $returnid,
				  $this->Lang('error_nocid'));
	return;
}

$query = "SELECT * FROM ".cms_db_prefix()."module_simplewiki WHERE id=$cid";
$row = $db->GetRow($query);
//echo "Row (" . gettype($row) . "): " . $row . "  --  " . print_r($row);

$title = $row['title'];
$content = $row['content'];

$this->smarty->assign('img_path', 'modules/SimpleWiki/images/');
$this->smarty->assign('title_label', $this->Lang('title'));
$this->smarty->assign('content_label', $this->Lang('content'));
$this->smarty->assign('title', $this->CreateInputText($id, 'title', $title));
$this->smarty->assign('content', $this->CreateTextArea(true, $id, $content, 'content', '', 'textbox'));
$this->smarty->assign('cid', $this->CreateInputHidden($id, 'cid', $cid));
$this->smarty->assign('startform', $this->CreateFormStart($id, 'user_do_editcontent', $returnid,'post','multipart/form-data'));
$this->smarty->assign('endform', $this->CreateFormEnd());
$this->smarty->assign('submit', $this->CreateInputSubmit($id, 'submit', $this->Lang('submit')));
$this->smarty->assign('cancel', $this->CreateInputSubmit($id, 'cancel', $this->Lang('cancel')));


echo $this->ProcessTemplate('editor.tpl');


?>

action.user_do_editcontent

Code: Select all

<?php

if (!isset($gCms)){
	exit;
}

$feusers = $this->GetModuleInstance('FrontEndUsers');
if( !$feusers || !$feusers->LoggedIn()){
	$this->Redirect($id, 'default', $returnid);
}


if (isset($params['cancel']))
{
	$this->Redirect($id, 'default', $returnid, array('content_id'=>$cid));
}

$cid = $params['cid'];
$title = $params['title'];
$content = $params['content'];

$query = 'UPDATE '.cms_db_prefix().'module_simplewiki SET title=?, content=? WHERE id=?';

$dbr = $db->Execute($query, array($title, $content, $cid));

//$this->Redirect($id, 'default', $returnid, array('content_id'=>$cid));
$this->RedirectContent($returnid);


?>
sletts02
Forum Members
Forum Members
Posts: 19
Joined: Sun Sep 21, 2008 9:13 pm

Re: Saving to DB as parsed?

Post by sletts02 »

Okay, I am pretty sure it has something to do with textboxes always stripping HTML when submitting from frontend.
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm
Location: MI

Re: Saving to DB as parsed?

Post by Jeff »

Alot depends how it is entered. For example if it is a standard textarea it will be handled differently than if you typed it into TinyMCE editor.
sletts02
Forum Members
Forum Members
Posts: 19
Joined: Sun Sep 21, 2008 9:13 pm

Re: Saving to DB as parsed?

Post by sletts02 »

Well I found a compromise that I am happy with :)

When outputting I just use htmlspecialchars_decode

Thanks for looking :)
Post Reply

Return to “Developers Discussion”