Calling FCKEditor in a front end module

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
katon

Calling FCKEditor in a front end module

Post by katon »

I am developing a Front End module, and I need FrontEnd users to be able to enter their data through a WYSIWYG editor.  I can call a regular textarea with CreateTextArea, but changing the $enablewysiwyg parameter from false to true doesn't change a thing.  Maybe there is another way of doing this? ???

Thank you in advance.
katon

Re: Calling FCKEditor in a front end module

Post by katon »

To do this, I have created and called the following method:

Code: Select all


	/**
	 * Returns the xhtml equivalent of a FCK wysiwyg editor.
	 *
	 * @param string The id given to the module on execution
	 * @param string The text to display in the textarea's content
	 * @param string The html name of the textarea
	 * @param string The CSS class to associate this textarea to
	 * @param string The html id to give to this textarea
	 * @param string The encoding to use for the content
	 * @param string The text of the stylesheet associated to this content.  Only used for certain WYSIWYGs
	 * @param string The number of characters wide (columns) the resulting textarea should be
	 * @param string The number of characters high (rows) the resulting textarea should be
	 */
    
    function create_fe_wysiwyg($mid, $text, $name, $classname='', $id='', $encoding='', $stylesheet='', $width='', $height='')
    {
	global $gCms;
	$result = '';

	$wysiwyg = $this->GetModuleInstance('FCKeditorX');
	if( $wysiwyg )
	{
	    $enablewysiwyg = true;
	}
	else
	{
	    $enablewysiwyg = false;
	}

	if ($enablewysiwyg == true)
	{
	    foreach($gCms->modules as $key=>$value)
	    {
		if ($gCms->modules[$key]['installed'] == true &&
		    $gCms->modules[$key]['active'] == true &&
		    $gCms->modules[$key]['object']->IsWYSIWYG())
		{
		    $result = '';
		    ob_start();
		    echo $gCms->modules[$key]['object']->WYSIWYGTextarea($mid.$name,$width,$height,$encoding,$text,$stylesheet);
		    $result = ob_get_contents();
		    ob_end_clean();
		}
	    }
	}

	if ($result == '')
	{
	    $result = '<textarea name="'.$name.'" cols="'.$width.'" rows="'.$height.'"';
	    if ($classname != '')
	    {
		$result .= ' class="'.$classname.'"';
	    }
	    if ($mid != '')
	    {
		$result .= ' id="'.$mid.'"';
	    }
	    $result .= '>'.cms_htmlentities($text,ENT_NOQUOTES,get_encoding($encoding)).'</textarea>';
	}

	return $result;
}

Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

Re: Calling FCKEditor in a front end module

Post by Ted »

Glad you worked that out.  I didn't have a quick reply to give you when I originally read this.
Post Reply

Return to “Developers Discussion”