help with FCKeditor and QF
| From: | Alexander Petri | Date: | Fri, 21 Jan 2005 16:01:22 +0000 |
| Subject: | help with FCKeditor and QF | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-17084@lists.php.net to get a copy of this message | ||
I tried to make fckeditor available for QF
so i wrote the file fckeditor.php and the filse test.php
i copied the fck files without docs and samples in a folder called /inc/
this works for me...
but there are several problems:
- basepath: i dont know exacty how to set the basepath,
what basepath means, ->it seems that it only accepts a relative path to the
classfile
so i want to set a FULL PATH (i.e. '/home/www/myApp/inc/')
so that it works everytime correctly
- next thing is that i am unable to set a style (i guess it depends on the
basename problem)
- and i want to create my custom Toolbar
can someone give me a hint?
a also dont get the samples to work, because $_SERVER['PATH_INFO'] isnt set
here are my Files
php/test.php:
############################################################################
##
require_once("HTML/QuickForm.php");
$f = new HTML_QuickForm();
$f->addElement("text","test",'text');
$f->registerElementType('fckeditor','HTML/QuickForm/fckeditor.php','HTML_Qui
ckForm_fckeditor');
$f->addElement("fckeditor","sfdsdf",'news',array(
'basepath'=>'../inc/',
'toolbarset'=>'Basic'));
$f->display();
############################################################################
##
HTML/QuickForm/fckeditor.php
############################################################################
##
require_once("HTML/QuickForm/element.php");
class HTML_QuickForm_fckeditor extends HTML_QuickForm_element
{
// {{{ properties
/**
* Field value
* @var string
* @since 1.0
* @access private
*/
var $_value = null;
// }}}
// {{{ constructor
/**
* Class constructor
*
* @param string Input field name attribute
* @param mixed Label(s) for a field
* @param mixed Either a typical HTML attribute string or an
associative array
* @since 1.0
* @access public
* @return void
*/
function HTML_QuickForm_fckeditor($elementName=null, $elementLabel=null,
$attributes=null)
{
HTML_QuickForm_element::HTML_QuickForm_element($elementName,
$elementLabel, $attributes);
$this->_persistantFreeze = true;
$this->_type = 'fckeditor';
} //end constructor
// }}}
// {{{ setName()
/**
* Sets the input field name
*
* @param string $name Input field name attribute
* @since 1.0
* @access public
* @return void
*/
function setName($name)
{
$this->updateAttributes(array('name'=>$name));
} //end func setName
// }}}
// {{{ getName()
/**
* Returns the element name
*
* @since 1.0
* @access public
* @return string
*/
function getName()
{
return $this->getAttribute('name');
} //end func getName
// }}}
// {{{ setValue()
/**
* Sets value for textarea element
*
* @param string $value Value for textarea element
* @since 1.0
* @access public
* @return void
*/
function setValue($value)
{
$this->_value = $value;
} //end func setValue
// }}}
// {{{ getValue()
/**
* Returns the value of the form element
*
* @since 1.0
* @access public
* @return string
*/
function getValue()
{
return $this->_value;
} // end func getValue
// }}}
// {{{ toHtml()
/**
* Returns the textarea element in HTML
*
* @since 1.0
* @access public
* @return string
*/
function toHtml()
{
if ($this->_flagFrozen) {
return $this->getFrozenHtml();
} else {
require_once("../inc/fckeditor.php");
$fck = new FCKeditor('FCKeditor1');
if(isset($this->_attributes['basepath'])) $fck->BasePath =
$this->_attributes['basepath'];
//if(isset($this->_attributes['skin'])) $fck->Config['SkinPath'] =
$fck->BasePath."editor/skins/".$this->_attributes['skin']."/";
if(isset($this->_attributes['toolbarset']))$fck->ToolbarSet=$this->_attribut
es['toolbarset'];
$fck->Height="400";
$fck->Value=$this->_value;
$output = $fck->CreateHtml();
return $this->_getTabs() .$output;
/*'<textarea' . $this->_getAttrString($this->_attributes)
. '>' .
// because we wrap the form later we don't want the text
indented
preg_replace("/(\r\n|\n|\r)/", '
',
htmlspecialchars($this->_value)) .
'</textarea>';*/
}
} //end func toHtml
// }}}
// {{{ getFrozenHtml()
/**
* Returns the value of field without HTML tags (in this case, value is
changed to a mask)
*
* @since 1.0
* @access public
* @return string
*/
function getFrozenHtml()
{
$value = htmlspecialchars($this->getValue());
if ($this->getAttribute('wrap') == 'off') {
$html = $this->_getTabs() . '<pre>' .
$value."</pre>\n";
} else {
$html = nl2br($value)."\n";
}
return $html . $this->_getPersistantData();
} //end func getFrozenHtml
// }}}