Hi, this is my HTML_Quickform_element extension for the FCKEditor.
I hope copy/paste worked out well.
It has all the normal element features I think, plus a specific method:
setFckProps(). The arguments are:
- The Basepath (absolute path from root tested only)
- Name of the toolbarset
- Width
- Height
- The config options, an associaltive array with as key the exact configkey, like 'GeckoUseSpan'and stuff. Write it wrong and it is ignored. Everything in fckconfig.js until StylesXmlPath is supported ... you can add extra in the private var array $_aFckConfigProps.
A note on the skinpath. If a relative path is given, it will be preceded by the set basepath.
If any options in the method is set to NULL, the default value will be kept.
Anyone wanna test it please?
I hope copy/paste worked out well.
It has all the normal element features I think, plus a specific method:
setFckProps(). The arguments are:
- The Basepath (absolute path from root tested only)
- Name of the toolbarset
- Width
- Height
- The config options, an associaltive array with as key the exact configkey, like 'GeckoUseSpan'and stuff. Write it wrong and it is ignored. Everything in fckconfig.js until StylesXmlPath is supported ... you can add extra in the private var array $_aFckConfigProps.
A note on the skinpath. If a relative path is given, it will be preceded by the set basepath.
If any options in the method is set to NULL, the default value will be kept.
<?php /** * Custom HTML_Quickform elementtype voor FCKEditor textarea * * This elementtype buidls an FCK Editor instance for PEAR::HTML_Quick_websitform * class * * @author Jordi Backx */ class HTML_Quickform_fckeditor extends HTML_Quickform_element { /** * Path to FCK class * * @var string Path to PHP FCK class * @access private */ var $_sFckBasePath = NULL; /** * Toolbar * * @var string Requested toolbarset * @access private */ var $_sToolbarSet = NULL; /** * Height of editor * * @var string Height * @access private */ var $_sHeight = NULL; /** * Width of editor * * @var string Width * @access private */ var $_sWidth = NULL; /** * FCK properties * * @var array Set of FCK only properties * @access private */ var $_aFckConfigProps = array('CustomConfigurationsPath' => NULL ,'EditorAreaCSS' => NULL ,'Debug' => NULL ,'SkinPath' => NULL ,'PluginsPath' => NULL ,'AutoDetectLanguage' => NULL ,'DefaultLanguage' => NULL ,'EnableXHTML' => NULL ,'EnableSourceXHTML' => NULL ,'GeckoUseSPAN' => NULL ,'StartupFocus' => NULL ,'ForcePasteAsPlainText' => NULL ,'ForceSimpleAmpersand' => NULL ,'TabSpaces' => NULL ,'UseBROnCarriageReturn' => NULL ,'LinkShowTargets' => NULL ,'LinkTargets' => NULL ,'LinkDefaultTarget' => NULL ,'ToolbarStartExpanded' => NULL ,'ToolbarCanCollapse' => NULL ,'StylesXmlPath' => NULL ); /** * Class constructor * * @param string $sElementName Name attribute of element * @param mixed $mElementLabel Label attribute of element * @param mixed $mAttributes Other non-FCK optional attributes * * @access public * @return void */ function HTML_Quickform_fckeditor($sElementName = NULL ,$mElementLabel = NULL ,$mAttributes = NULL) { HTML_Quickform_element::HTML_Quickform_element($sElementName, $mElementLabel, $mAttributes); $this->_persistantFreeze = TRUE; $this->_type = 'fckeditor'; }// End constructor /** * Set properties for FCKEditor instance * * @param string $sFckBasePath Basepath * @param string $sFckStylesXMLPath Path to XML styles * @param string $sToolbarSet Toolbar * @param string $sWidth Width of the editor * @param string $sHeight Height of the editor * @param mixed $mFckRequestedAttrs Set of FCK only attributes * @access public * @return void */ function setFCKProps ($sFckBasePath = NULL ,$sToolbarSet = NULL ,$sWidth = NULL ,$sHeight = NULL ,$mFckRequestedAttrs = NULL) { /* * Set the paths */ $this->_sFckBasePath = $sFckBasePath; /* * Set public FCK attributes */ $this->_sWidth = $sWidth; $this->_sHeight = $sHeight; $this->_sToolbarSet = $sToolbarSet; /* * Set configuration array if not NULL */ if ($mFckRequestedAttrs !== NULL) { // Collect keys of requested attributes $aFckRequestedAttrKeys = array_keys($mFckRequestedAttrs); // Search in supported attribute array for the keys foreach ($this->_aFckConfigProps as $sFckProp => $sFckValue) { $mArraySearchResult = array_search($sFckProp, $aFckRequestedAttrKeys); if ($mArraySearchResult === FALSE) { unset($this->_aFckConfigProps[$sFckProp]); } else { $this->_aFckConfigProps[$sFckProp] = $mFckRequestedAttrs[$sFckProp]; } } } else { // No properties requested $this->_aFckConfigProps[$sFckProp] = NULL; } } /** * Register name atribute * * @param string $sName Name attribute of element * @access public * @return void */ function setName($sName) { $this->updateAttributes(array('name' => $sName)); }// End function setName /** * Naam teruggeven (name attribute) * * @access public * @return string Name attribute element */ function getName() { return $this->getAttribute('name'); }// End function getName /** * Waarde/inhoud registreren (value attribute) * * @param string $sWaarde Value attribute of element * @access public * @return void */ function setValue($sValue) { $this->updateAttributes(array('value' => $sValue)); }// End function setValue /** * Waarde/inhoud teruggeven(value attribute) * * @access public * @return string Value attribute element */ function getValue() { return $this->getAttribute('value'); }// End function getValue /** * HTML code genereren en teruggeven * * @access public * @return string HTML code element */ function toHtml() { if ($this->_flagFrozen) { return $this->getFrozenHtml(); } else { /* * FCK editor aanmaken */ // FCKeditor klasse inladen require_once('mod_fckeditor.inc.php'); // instantiëring $oFCKeditor = new FCKeditor($this->getAttribute('name')); // Parameters instellen if ($this->_sToolbarSet !== NULL) { $oFCKeditor->BasePath = $this->_sFckBasePath; } if ($this->_sToolbarSet !== NULL) { $oFCKeditor->ToolbarSet = $this->_sToolbarSet; } if ($this->_sWidth !== NULL) { $oFCKeditor->Width = $this->_sWidth; } if ($this->_sHeight !== NULL) { $oFCKeditor->Height = $this->_sHeight; } if ($this->_aFckConfigProps !== NULL) { $oFCKeditor->Config = $this->_aFckConfigProps; // If a relative path is given, then precede it with the editor's baspath (like in fckconfig.js)' if (isset($oFCKeditor->Config['SkinPath']) && substr($oFCKeditor->Config['SkinPath'], 0, 1) != '/') { $oFCKeditor->Config['SkinPath'] = $this->_sFckBasePath.$oFCKeditor->Config['SkinPath']; } } $oFCKeditor->Value = $this->getValue(); // Generate the HTML code for the editor $sFCKCode = $oFCKeditor->CreateHTML(); // Verwijderen FCKEditor object //unset($oFCKeditor); /* * return code */ return $this->_gettabs().$sFCKCode; } }// End function toHtml /** * Inhoud teruggeven zonder HTML tags * * @access public * @return string Teskt inhoud element */ function getFrozenHtml() { $sValue = htmlspecialchars($this->getValue()); if ($this->getAttribute('wrap') == 'off') { $sHtml = $this->_getTabs(). '<pre>' .$sValue. '</pre>' . "\n"; } else { $sHtml = nl2br($sValue). "\n"; } return $sHtml.$this->_getPersistantData(); }// End function getFrozenHtml } ?>
Anyone wanna test it please?
RE: PEAR::HTML_Quickform_fckeditor: it works!
The file (with the above code) may be anything you like of course.
And of course, require_once the Quickform class.
RE: PEAR::HTML_Quickform_fckeditor: it works!
And excuses if haven't translated all comments from Dutch to English.

'HTML code genereren en teruggeven' actually means 'generate HTML code and return it'. It really does!
RE: PEAR::HTML_Quickform_fckeditor: it works!
But I didn't get the point how to change the options like CustomConfigurationsPath or UseBROnCarriageReturn.
Heres the relevant code:
$fck =& $form -> addElement('fckeditor', 'profil', 'Profil:', array('cols' => 50, 'rows' => 15));
$fck -> setFCKProps('../fckeditor/', 'DSR', '100%', '300', array('CustomConfigurationsPath' => '../fckconfig/myconfig.js', 'UseBROnCarriageReturn' => true));
Maybe anyone could give me a hint, at the moment neither the config-file seems to be used, nor does he use the BROnCarriageReturn when activated manually.
RE: PEAR::HTML_Quickform_fckeditor: it works!
I just found out what the reason was:

I had to take the following code out, otherwise the fckeditor didn't show up, instead I just got a blank page where the editor should be:
/*
if ($this->_aFckConfigProps !== NULL) {
$oFCKeditor->Config = $this->_aFckConfigProps;
// If a relative path is given, then precede it with the editor's baspath (like in fckconfig.js)'
if (isset($oFCKeditor->Config['SkinPath']) && substr($oFCKeditor->Config['SkinPath'], 0, 1) != '/') {
$oFCKeditor->Config['SkinPath'] = $this->_sFckBasePath.$oFCKeditor->Config['SkinPath'];
}
} */
Now I took this code back in and everything works just fine
RE: PEAR::HTML_Quickform_fckeditor: it works!
I'm trying this out but getting inhertance errors:
Cannot inherit from undefined class html_quickform_element
// Config file
require_once 'HTML/QuickForm.php';
requie_once 'fckeditor.php';
// fckeditor.php
cut and paste your class.
Am I doing this right?
RE: PEAR::HTML_Quickform_fckeditor: it works!
Didn't have this in the top of my fckeditor.php file:
require_once('HTML/QuickForm/element.php');
RE: PEAR::HTML_Quickform_fckeditor: it works!
RE: PEAR::HTML_Quickform_fckeditor: it works!
Haven't been here for a while. Stupid of me not to check my own post once in a while for questions.
I have updated the extension with an installation example in the main comment block and translated all the other comments, some were still in Dutch.
If anyone of the posters above is still reading this thread, do these problems still occur?
Thanks to the person who added the class to the Wiki, a good idea.
@msteudel: the inclusion of element.php is not really necessary (anymore) I think. I don't need it. I personally have never had any header problems. I am using Smarty as an template engine by the way.
RE: PEAR::HTML_Quickform_fckeditor: it works!
I'm trying to use fckeditor on HTML_QuickForm but I have found no examples. So I've to follow the instructions I've found on http://wiki.fckeditor.net/Developer%27s ... /Quickform
In effect if there is no require_once('HTML/QuickForm/element.php');
i get the error "Cannot inherit from undefined class html_quickform_element."
But I have another problem: I can't see any toolbar.
I have simply paste the class on the file HTML_Quickform_fckeditor.php in the same directory where I have put FCKeditor. Furthermore I have created a file with the following code:
require_once 'HTML/QuickForm.php';
require_once 'FCKeditor/fckeditor.php';
HTML_Quickform::registerElementType('fckeditor','/var/www/prove/FCKeditor/HTML_Quickform_fckeditor.php','HTML_Quickform_fckeditor');
$form1 = new HTML_QuickForm('Form','POST');
$sFCKBasePath = '/prove/FCKeditor/'; // BasePath
$sToolbarSet='Default'; // Toolbarset
$sWidth='800'; // Width
$sHeight='300'; // Height
$pippo=$form1->addElement('fckeditor', 'pippo', 'Testo prova:');
$pippo->setFCKProps($sFCKBasePath,$sToolbarSet,$sWidth,$sHeight
,array('SkinPath' => 'editor/skins/default/'
,'DefaultLanguage' => 'it'
,'StylesXmlPath' => 'fckstyles.xml'
,'UseBROnCarriageReturn' => 'true'
,'StartupFocus' => 'false'
,'CustomConfigurationsPath' => 'fckconfig.js'
,'EditorAreaCSS' => 'editor/css/fck_editorarea.css'));
Where I wrong??!!
Thank you very much
Piviul
RE: PEAR::HTML_Quickform_fckeditor: it works!
In that case try :
That way $pippo is a reference to the element in your QF form object instead of a copy without any relationship with the form object.
You dont'need the CustomConfigurationsPath property if you don't use your own extra config file.
RE: PEAR::HTML_Quickform_fckeditor: it works!
I'm using fckeditor 2.2, the last I found on the web, on a debian sarge with apache2, PHP4, PEAR 1.4.9 and PEAR::HTML_QuickForm 3.2.5.
I have unzipped fckeditor in /var/www/prove/fckeditor where /var/www is the apache2 root; I've pasted the code you posted on this thread and saved it in /var/www/prove/fckeditor/HTML_Quickform_fckeditor.php.
Furthermore I've created /var/www/prove/pippo.php having the following code:
When I load pippo.php I have the following error code:
Fatal error: Class html_quickform_fckeditor: Cannot inherit from undefined class html_quickform_element in /var/www/prove/FCKeditor/HTML_Quickform_fckeditor.php on line 38
So I have added at the top of HTML_Quickform_fckeditor.php
require_once 'HTML/QuickForm/element.php';
Now, loading pippo.php I have no error but I can't view any bar. If I remove from the $sProp array the key CustomConfigurationsPath I get the error “Error loading /var/www/prove/FCKeditor/fckstyles.xml”
If I remove stylesXmlPath too all seems to work but I can't have any customized bar.
Any way I found fckdeitor a very good project.
Thank you very much indeed
Piviul
RE: PEAR::HTML_Quickform_fckeditor: it works!
Hi Piviul,
I have tried your code and got it working after some changes.
You fed absolute filepaths to HTML_Quickform::registerElementType, the $sFCKBasePath and the StylesXmlPath property. The first should be relative from the script location. The last two should be the absolute paths from the documentroot of the webserver.
I have added the modified code below. I used a 'test' subdirectory directly below the documentroot. The browser pointed tot http://127.0.0.1/test/pippo.php to run my test.
BTW: I added the requirement for element.php as a warning in the Wiki, thanks.
Jordi
======= code =======
<?php require_once 'HTML/QuickForm.php'; require_once 'HTML/QuickForm/element.php'; /* * MOD: Relative path from script location * to class file */ HTML_Quickform::registerElementType('fckeditor','fckeditor/HTML_Quickform_fckeditor.php','HTML_Quickform_fckeditor'); $form1 = new HTML_QuickForm('Form','POST'); /* * MOD: Absolute path from docroot */ $sFCKBasePath = '/test/fckeditor/'; // BasePath $sToolbarSet = 'Default'; // Toolbarset $sWidth = '800'; // Width $sHeight = '300'; // Height $sProp=array( 'SkinPath' => 'editor/skins/office2003/', 'DefaultLanguage' => 'it', /* * MOD: Absolute path from docroot */ 'StylesXmlPath' => '/test/fckeditor/fckstyles.xml', 'UseBROnCarriageReturn' => 'true', 'StartupFocus' => 'false', 'CustomConfigurationsPath' => 'fckconfig.js', 'EditorAreaCSS' => 'fck_editorarea.css' ); $pippo =& $form1->addElement('fckeditor', 'pippo', 'Testo prova:'); $pippo->setFCKProps($sFCKBasePath,$sToolbarSet,$sWidth,$sHeight,$sProp); $form1->display(); ?>
======= code =======
RE: PEAR::HTML_Quickform_fckeditor: it works!
Jordi
RE: PEAR::HTML_Quickform_fckeditor: it works!
Thanks
Piviul
RE: PEAR::HTML_Quickform_fckeditor: it works!
Thanks a lot
Piviul
RE: PEAR::HTML_Quickform_fckeditor: it works!
Hi, I think the file fckconfig.js isn't available in your fckeditor directory.

Try using the tail tool on your webserver's errorlog .... you get a lot of helpful debugging info.
That's how I found the problems with your code.
Only FF? I got your code working with FF. Didn't even bother to try Exploder
RE: PEAR::HTML_Quickform_fckeditor: it works!
fckconfig.js is the default config file for the editor. You shouldn't tell FCKE it is your own customized config file. This may be the reason errors occur.
If you don't use this feature, exclude it from the property list.
As for tail. Open a console window to your webserver and enter the command (change path to match config on your server):
tail -f 15 /path/to/apaches/errorlog
This way you'll see the error messages (15 lines) appear realtime while Apache processes HTTP requests.
With Ctrl+C you exit tail.
Jordi
RE: PEAR::HTML_Quickform_fckeditor: it works!
As you suggested me I looked the apache error.log and in effect I've found what the problem is: as you said me FCKeditor doesn't find fckconfig.js. The strange is that sometimes fckeditor.html is looking for fckconfig.js into the FCKeditor/editor directory sometimes in FCKeditor. So I've created a simbolic link to the FCKeditor/fckconfig.js in the FCKeditor/editor directory and all seems to work... but perhaps this strange behavior hide a little bug.
Thank you very much once more.
Pivul
RE: PEAR::HTML_Quickform_fckeditor: it works!
I did my test with a custom config namd icc_config.js and it is placed in de same directory as the standard fckconfig.js shipped with the editor. Referring to icc_config.js in the CustomConfigurationPath prop worked just fine for me.
I think your problem has to do with naming our own config fle exactly like FCKE's own config file.
ut ey .... it works for you now, so ope up your beer!
You're welcome.
Problems With Path configurations
we register an element Htmlfckeditor to the QF,
like this:
HTML_Quickform::registerElementType('fckeditor' ,'fckeditor/HTML_Quickform_fckeditor.php' ,'HTML_Quickform_fckeditor');//*/
we belibe than when we use the "toHtml" function,
we lose all the element configurations setted before
HOPE YOU CAN HELP
please tell us if we can use it with "HTML_QuickForm_Page"
our mails: ezeprimo@gmail.com
msn: ezeprimo@hotmail.com
arielin82@gmail.com
RE: PEAR::HTML_Quickform_fckeditor: it works!
HTML_Quickform::registerElementType('fckeditor','/FCKeditor/HTML_Quickform_fckeditor.php','HTML_Quickform_fckeditor');
$form = new HTML_QuickForm('Form','POST');
$fck =& $form -> addElement('fckeditor', 'message', 'Message:', array('cols' => 50, 'rows' => 15));
$fck -> setFCKProps('./fckeditor/', 'Basic', '400', '300', array('CustomConfigurationsPath' => './fckconfig/myconfig.js', 'UseBROnCarriageReturn' => true));
No problem appears until i tried to add more elements to form object.
when i add this line
$form->addElement('text','Name','Name:');
it gives an error that "Cannot redeclare class html_quickform_element".
How can add more elements to my form?
Thanks.