For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > October 2005 > Re: [PEAR] Suggestion for new Quickform htmltextarea element AND fckeditor









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PEAR] Suggestion for new Quickform htmltextarea element AND fckeditor
Justin Patrin

2005-10-10, 6:58 pm

On 10/10/05, Denis Willems <deniswillems@yahoo.fr> wrote:
> I use fckeditor (http://www.fckeditor.net) like this (after typical
> fckeditor install):
>
> 1. Modify peardir/html/quickform/textarea.php and save it as
> fckeditor.php (see source below):
> 2. Update html/quickform.php, adding a line on #50
> ($GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'
] array definition):
> 'fckeditor'
> =3D>array('HTML/QuickForm/fckeditor.php','HTML_QuickForm_fckeditor'),html=

/quickform/fckeditor.php

It's not a good idea to alter your QuickForm.php. Instead, put
something like this at the bottom of fckeditor.php:

if (class_exists('HTML_QuickForm')) {
HTML_QuickForm::registerElementType('sub
Form', __FILE__,
'HTML_QuickForm_SubForm');
}

This way people can include your new element and it will register itself.

>
> 3. Use it like textarea elem; but attributes are:
> array( 'baserep' =3D> "/fckeditor/", // path to fckeditor
> 'toolbar' =3D> "Standard", // toolbar preset -
> see fckeditor.ini or fckeditor help
> 'width' =3D>510, //width in PIXEL (not
> like textarea)
> 'height' =3D>300, //height in PIXEL (no=

t
> lije textarea)
> ),
>
>
> What do you think about it ?
>
> Denis.
>
>
> fckeditor.php:
> THIS IS (working but) TEMPORARY CODE, BASED ON textarea.php, NOT FULLY
> UPDATED:
> <?php
> /* vim: set expandtab tabstop=3D4 shiftwidth=3D4: */
> // +---------------------------------------------------------------------=

-+
> // | PHP version 4.0 =

|
> // +---------------------------------------------------------------------=

-+
> // | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group =

|
> // +---------------------------------------------------------------------=

-+
> // | This source file is subject to version 2.0 of the PHP license, =

|
> // | that is bundled with this package in the file LICENSE, and is =

|
> // | available at through the world-wide-web at =

|
> // | http://www.php.net/license/2_02.txt. =

|
> // | If you did not receive a copy of the PHP license and are unable to =

|
> // | obtain it through the world-wide-web, please send a note to =

|
> // | license@php.net so we can mail you a copy immediately. =

|
> // +---------------------------------------------------------------------=

-+
> // | Authors: Adam Daniel <adaniel1@eesus.jnj.com> =

|
> // | Bertrand Mansion <bmansion@mamasam.com> =

|
> // +---------------------------------------------------------------------=

-+
> //
> // $Id: textarea.php,v 1.11 2004/02/28 22:10:16 avb Exp $
>
> require_once("HTML/QuickForm/element.php");
>
> /**
> * HTML class for a textarea type field
> *
> * @author Adam Daniel <adaniel1@eesus.jnj.com>
> * @author Bertrand Mansion <bmansion@mamasam.com>
> * @version 1.0
> * @since PHP4.04pl1
> * @access public
> */
> class HTML_QuickForm_fckeditor extends HTML_QuickForm_element
> {
> // {{{ properties
>
> /**
> * Field value
> * @var string
> * @since 1.0
> * @access private
> */
> var $_value =3D 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=3D
null,
> $elementLabel=3Dnull, $attributes=3Dnull)
> {
> HTML_QuickForm_element::HTML_QuickForm_e
lement($elementName,
> $elementLabel, $attributes);
> $this->_persistantFreeze =3D true;
> $this->_type =3D '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'=3D>$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 =3D $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
>
> // }}}
> // {{{ setBasedir()
>
> /**
> * Sets basedir for fckeditor scripts
> *
> * @param string $baserep Baserep
> * @since 1.0
> * @access public
> * @return void
> */
> function setBasedir($baserep)
> {
> $this->updateAttributes(array('baserep' =3D> $baserep));
> } //end func setWrap
>
> // }}}
> // {{{ setToolbar()
>
> /**
> * Sets toolbar for fckeditor
> *
> * @param string $toolbar Toolbar name (see fckeditor config
> file)
> * @since 1.0
> * @access public
> * @return void
> */
> function setToolbar($toolbar)
> {
> $this->updateAttributes(array('toolbar' =3D> $toolbar));
> } //end func setRows
>
> // }}}
> // {{{ setWidth()
>
> /**
> * Sets width for fckeditor element
> *
> * @param string $width Width expressed in pixel
> * @since 1.0
> * @access public
> * @return void
> */
> function setWidth($width)
> {
> $this->updateAttributes(array('width' =3D> $width));
> } //end func setCols
>
> // }}}
> // {{{ setHeight()
>
> /**
> * Sets height for fckeditor element
> *
> * @param string $height Height expressed in pixel
> * @since 1.0
> * @access public
> * @return void
> */
> function setHeight($height)
> {
> $this->updateAttributes(array('height' =3D> $height));
> } //end func setCols
>
> // }}}
> // {{{ toHtml()
>
> /**
> * Returns the textarea element in HTML
> *
> * @since 1.0
> * @access public
> * @return string
> */
> function toHtml()
> {
> if ($this->_flagFrozen) {
> return $this->getFrozenHtml(); // a faire !
> } else {
> $contenu =3D ereg_replace("(\n|\r|\r\n)", "",
> addslashes($this->_value));
> return $this->_getTabs() .
> '<script type=3D"text/javascript" src=3D"=

'.
> $this->_attributes["baserep"].'fckeditor.js"></script>
> <script type=3D"text/javascript">
> var oFCKeditor =3D new FCKeditor(
> "'.$this->getName().'" ) ;
> oFCKeditor.BasePath =3D
> "'.$this->_attributes["baserep"].'";
> oFCKeditor.ToolbarSet =3D
> "'.$this->_attributes["toolbar"].'";
> oFCKeditor.Width =3D
> "'.$this->_attributes["width"].'" ;
> oFCKeditor.Height =3D
> "'.$this->_attributes["height"].'" ;
> oFCKeditor.Value =3D "'.$contenu.'";
> oFCKeditor.Create() ;
> </script>';
>
>
> }
> } //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 =3D htmlspecialchars($this->getValue());
> if ($this->getAttribute('wrap') =3D=3D 'off') {
> $html =3D $this->_getTabs() . '<pre>' . $value."</pre>\n";
> } else {
> $html =3D nl2br($value)."\n";
> }
> return $html . $this->_getPersistantData();
> } //end func getFrozenHtml
>
> // }}}
>
> } //end class HTML_QuickForm_textarea
> ?>
>
>
>
>
>
>
>
>
>
>
> ________________________________________
_________________________________=

__
> Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenge=

r
> T=E9l=E9chargez cette version sur http://fr.messenger.yahoo.com
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



--
Justin Patrin
Dan Rossi

2005-10-10, 9:56 pm

I had a look at Xinha and the setup is alot more complex than HtmlArea =20=

in terms of embedding it cleanly into a quickform element, all elements =20=

require to be started up in a xinha_editors js array variable, instead =20=

of starting the editor when each element is loaded.

Here was my first implementation for htmlarea , i was also attempting =20=

to only include the js file once on the page in terms of multiple =20
editor elements and if it buggered things up.

http://www.electroteque.org/pear/Qu...tmltextarea/=20
htmltextarea.phps

If an element was available i wouldnt really be trying to reinvent the =20=

wheel, i did make a suggestion earlier this year, if people find it =20
useful i could have a shot at making an element for xinha, the plugins =20=

look insane especially the file browser , however im gonna modify the =20=

file browser to use the jupload applet for handling more than one file =20=

at a time :D

Ok i assume this is the element you are talking about ?

http://helios.wh2.tu-dresden.de/~skywalker/fckeditor/

Could someone suggest to propose it, as standard element would be nice, =20=

ok my idea is def way off scale i was sending the configs via the =20
constructor rather setting the element vairables.


On 11/10/2005, at 3:09 AM, Justin Patrin wrote:

> On 10/10/05, Denis Willems <deniswillems@yahoo.fr> wrote:
>
> It's not a good idea to alter your QuickForm.php. Instead, put
> something like this at the bottom of fckeditor.php:
>
> if (class_exists('HTML_QuickForm')) {
> HTML_QuickForm::registerElementType('sub
Form', __FILE__,
> 'HTML_QuickForm_SubForm');
> }
>
> This way people can include your new element and it will register =20
> itself.
>
fckeditor[color=darkred]
-[color=darkred]
[color=darkred]
=20[color=darkred]
FULLY[color=darkred]
+---------------------------------------------------------------------=20=
[color=darkred]
=20[color=darkred]
+---------------------------------------------------------------------=20=
[color=darkred]
=20[color=darkred]
+---------------------------------------------------------------------=20=
[color=darkred]
=20[color=darkred]
=20[color=darkred]
=20[color=darkred]
=20[color=darkred]
[color=darkred]
=20[color=darkred]
=20[color=darkred]
+---------------------------------------------------------------------=20=
[color=darkred]
=20[color=darkred]
=20[color=darkred]
+---------------------------------------------------------------------=20=
[color=darkred]
=20[color=darkred]
[color=darkred]
$value."</pre>\n";[color=darkred]
________________________________________
______________________________=20=
[color=darkred]
>
>
> --
> Justin Patrin
>
> --=20
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Dan Rossi

2005-10-10, 9:56 pm

Hmm , this fckeditor does take a while to load, and wouldnt load in
firefox osx properly, i dont think its developed yet like xinha, which
one should i choose ?

On 11/10/2005, at 11:53 AM, Dan Rossi wrote:

> I had a look at Xinha and the setup is alot more complex than HtmlArea
> in terms of embedding it cleanly into a quickform element, all
> elements require to be started up in a xinha_editors js array
> variable, instead of starting the editor when each element is loaded.
>
> Here was my first implementation for htmlarea , i was also attempting
> to only include the js file once on the page in terms of multiple
> editor elements and if it buggered things up.
>
> http://www.electroteque.org/pear/Qu...m/htmltextarea/
> htmltextarea.phps
>
> If an element was available i wouldnt really be trying to reinvent the
> wheel, i did make a suggestion earlier this year, if people find it
> useful i could have a shot at making an element for xinha, the plugins
> look insane especially the file browser , however im gonna modify the
> file browser to use the jupload applet for handling more than one
> file at a time :D
>
> Ok i assume this is the element you are talking about ?
>
> http://helios.wh2.tu-dresden.de/~skywalker/fckeditor/
>
> Could someone suggest to propose it, as standard element would be
> nice, ok my idea is def way off scale i was sending the configs via
> the constructor rather setting the element vairables.
>
>

Dan Rossi

2005-10-11, 7:57 am

Read the previous messages we have been told that HtmlArea is now
vapourware, Xinha is its replacement, FckEditor seems really slow, Id
prefer if we could work on a Xinha element ? Im keen to help out or
start on it, just let me know noone else has already done so, the
config for xinha is a beast because it requires all editors to be
started in a array with array of plugins etc, and logically its prob
not even worth building an element because of this and just adding the
javascript for normal textarea elements after ? Im still testing if its
possible to start an editor when loading each element rather than at
the begging of the file as I had done with the html area element.

On 11/10/2005, at 7:13 PM, Jan Wagner wrote:
>
> Hi there,
>
> as there seems to be much interest in those elements lately, I will try
> to propose the fckeditor and htmlarea elements as separate packages
> later this w. I have not used the xinha stuff, but it seems to be a
> spinoff from htmlarea? The website is down at the moment, so I cant
> have
> a look. The thing I like about fckeditor is, that is easy to configure
> via a JavaScript config file, while I found the htmlarea config a bit
> confusing. Dont know about the speed of xinha, but htmlarea is not
> faster than fckeditor.
>
> Cheers Jan
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Dan Rossi

2005-10-11, 7:57 am


On 11/10/2005, at 7:39 PM, Jan Wagner wrote:
>
> Hi,
>
> have you seen this one yet?
> http://helios.wh2.tu-dresden.de/~skywalker/htmlarea/
>
> Don't know if the configuration of xinha changed much, but this used to
> work quite well. I just don't use it anymore as it didnt seem to be
> maintained anymore, which makes sense, now that I know of xinha. Could
> you check if this works like xinha? Then it should be no problem.
>
> Jan
>
>


Yeh that was in my previous email, it looks fiarly similar to the xinha
setup lemme take a look ;)
Dan Rossi

2005-10-11, 7:57 am


On 11/10/2005, at 8:28 PM, Dan Rossi wrote:
[color=darkred]
>
> On 11/10/2005, at 7:39 PM, Jan Wagner wrote:

Ok i ran the test upon both htmlarea and xinha the element loads xinha
perfectly, however when i went to register the imagebrowser plugin it
broke. The second textarea also doesnt come up both both xinha and
htmlarea in firefox on osx.

http://musictrade.electrocode.net:1...age/example.php

Its my dev domain so may be down in a few hours.
Dan Rossi

2005-10-11, 6:57 pm

Yeh as I was saying, it freakily seems to work, but xinha is loaded
differently, and as Gorgon suggested not worry with an element and just
add it to js in the header. I kinda like the idea of an element for
ease of implementation etc etc. Ill take a look but someone please post
source code if they are also onto it :D

On 11/10/2005, at 10:01 PM, Jan Wagner wrote:

> Am Dienstag, den 11.10.2005, 21:01 +1000 schrieb Dan Rossi:
>
>
> Well, this looks quite promising. Over here with firefox on Linux both
> of the elements show up. It could be that plugin loading differs these
> days from last year, which prevents imagebrowser plugin from working
> right away.
>
> Having a quick look at the examples from xinha, does show some
> differences in plugin and config loading. Especially creating multiple
> instances looks different. One would have to test that out, as you cant
> do javascript stuff in the page header with quickform.
>
> So do you want to step forward and reimplement the element for xinha?
>
> Jan
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Dan Rossi

2005-10-11, 6:57 pm


On 11/10/2005, at 10:56 PM, Jan Wagner wrote:

>
> But then the element would not work transparently. One quickform
> element
> does not know about the other. All necessary JS code should be
> "rendered" with the element. You can't add JS to the header or the
> global Quickform JS from within an element. You would have to do that
> in
> your template or whatever you are using. But then you do not need an
> extra element, as you would have to do everything for yourself anyway.
> So you could add the necessary JS to your page header and keep your
> textarea element with quickform, which will be overwritten from your
> header JS, or am I missing a point here somewhere?
>
> Jan
>


I dont iknow where u got that from, I mearely trying to say I am
running tests to see if you can idividually start an edtior rather than
starting it as an array in the header, its looking extremely unlikely.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com