This one is based off the original, with my custom patches. Original
didn't work for me either and it didn't have some of the functionality
I needed (esp generating XHTML valid code) so I went and created this
one.

There is only one thing I'm not happy with, and that's line 110, the
part of the GZip version that defines which languages to be included.
I should probably just rewrite that with sfContext::getInstance()-
>getUser()->getCulture() instead of the current "en/bg".

Taking into account the way symfony autoloading works, all you need to
do is create a sfWidgetFormTextareaTinyMCE.class.php file with the
widget in your lib folder. It superseeds the one in the
sfFormExtraPlugin. Also, this widget is thoroughly tested and is
working in several of my released applications. I could create
a .patch file for the sfFormExtraPlugin, but I don't think it'd make
it into the plugin. Probably if you guys support the changes ?



On Feb 27, 1:20 pm, Denis Fingonnet <[email protected]> wrote:
> Thanks for your custom widget.
>
> But I wish I could make the original sfWidgetFormTextareaTinyMCE works,
> because it is bundled with the sfFormExtraPlugin.
>
> I can say you're able to make it works and to provide a patch if there is a
> bug in it.
>
> Could you have a look or have you done a custom widget because you weren't
> able to make the original widget works ?
>
> On Fri, Feb 27, 2009 at 11:58 AM, Crafty_Shadow <[email protected]> wrote:
>
> > This is gonna be a pretty long, but here's my custom
> > sfWidgetFormTextareaTinyMCE.class.php
> > It works with TinyMCE 3 and up, and also produces fully XHTML
> > compatible output.
> > It also allows for gzip compression; Sample usage:
>
> >    $this->widgetSchema['content']      = new
> > sfWidgetFormTextareaTinyMCE(array('tinymce_gzip' => true),array
> > ('size'=>'102x30'));
>
> > class sfWidgetFormTextareaTinyMCE extends sfWidgetFormTextarea
> > {
>
> >  public function __construct($options = array(), $attributes = array
> > ())
> >  {
> >  /**
> >  * We need to override the constructor in order to be able to remove
> > keys from the $attributes array;
> >  * if we don't remove the pseudo key 'size', it results in invalid
> > xhtml markup
> >  */
> >    if (array_key_exists('size', $attributes))
> >    {
> >      //This code handles textarea size input in 140x30 format
> >      list ($cols, $rows) = explode ('x', $attributes['size']);
> >      unset ($attributes['size']);
> >      $attributes['cols'] = $cols;
> >      $attributes['rows'] = $rows;
> >      $this->setAttributes($attributes);
> >    }
>
> >    parent::__construct($options, $attributes);
> >  }
>
> >  /**
> >   * Constructor.
> >   *
> >   * Available options:
> >   *
> >   *  ** Options **
> >   *  * theme:  The Tiny MCE theme
> >   *  * width:  Width
> >   *  * height: Height
> >   *  * config: The javascript configuration
> >   *  * tinymce_gzip: Wether to use gzip compression for TinyMCE
> >   *  * file_browser_callback:  a JS callback function for embending a
> > file browser into TinyMCE
> >   *  * content_css:  A css file that will be applied to the editor
> > window; Should be the same css as the one used in the real output
> >   *
> >   *  ** Attributes **
> >   *  * cols/rows or size: sets the size of the TinyMCE window; size
> > is used in the format: COLSxROWS (100x30)
> >   *
> >   * @param array $options     An array of options
> >   * @param array $attributes  An array of default HTML attributes
> >   *
> >   * @see sfWidgetForm
> >   */
> >  protected function configure($options = array(), $attributes = array
> > ())
> >  {
> >    $this->addOption('theme', 'advanced');
> >    $this->addOption('width');
> >    $this->addOption('height');
> >    $this->addOption('config', '');
> >    $this->addOption('tinymce_gzip');
> >    $this->addOption('file_browser_callback',
> > 'sfAssetsLibrary.fileBrowserCallBack');
> >    $this->addOption('content_css', '/js/tiny_mce/css/
> > default.css');
>
> >    if (!$this->getAttribute('cols') || !$this->getAttribute('rows'))
> >    {
> >      $this->setAttribute('cols', 140);
> >      $this->setAttribute('rows', 30 );
> >    }
> >  }
>
> >  /**
> >   * @param  string $name        The element name
> >   * @param  string $value       The value selected in this widget
> >   * @param  array  $attributes  An array of HTML attributes to be
> > merged with the default HTML attributes
> >   * @param  array  $errors      An array of errors for the field
> >   *
> >   * @return string An HTML tag string
> >   *
> >   * @see sfWidgetForm
> >   */
> >  public function render($name, $value = null, $attributes = array(),
> > $errors = array())
> >  {
> >    // use tinymce's gzipped js?
> >    $tinymce_file = $this->getOption('tinymce_gzip') ? '/
> > tiny_mce_gzip.js' : '/tiny_mce.js';
>
> >    // tinymce installed?
> >    $js_path = sfConfig::get('sf_rich_text_js_dir') ? '/'.sfConfig::get
> > ('sf_rich_text_js_dir').$tinymce_file : '/sf/tinymce/js'.
> > $tinymce_file;
> >    if (!is_readable(sfConfig::get('sf_web_dir').$js_path))
> >    {
> >      throw new sfConfigurationException('You must install TinyMCE to
> > use this widget (see rich_text_js_dir in settings.yml).');
> >    }
>
> >    sfContext::getInstance()->getResponse()->addJavascript
> > ($js_path);
>
> >    $gz_init = '
> >  tinyMCE_GZ.init({
> >    plugins :
>
> > "safari,spellchecker,pagebreak,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",
> >    themes: "simple,advanced",
> >    languages: "en,bg",
> >    disc_cache: true,
> >    debug: false
> >  });';
>
> >    $js = sprintf(<<<EOF
> > <script type="text/javascript">
> > //<![CDATA[
>
> >  // Start section reserved for GZIP init
> >  %s
> >  // End section reserved for GZIP init
>
> >  tinyMCE.init({
> >    mode:                               "exact",
> >    elements:                           "%s",
> >    theme:                              "%s",
> >    language:                           "%s",
> >    file_browser_callback:              "%s",
> >    content_css:                        "%s",
> >    %s                                  //width
> >    %s                                  //height
> >    plugins :
>
> > "safari,spellchecker,pagebreak,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",
>
> >    // Theme options
> >    theme_advanced_buttons1 :
>
> > "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect,styleselect",
> >    theme_advanced_buttons2 :
>
> > "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
> >    theme_advanced_buttons3 :
>
> > "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
> >     theme_advanced_toolbar_location : "top",
> >    theme_advanced_toolbar_align : "left",
> >    theme_advanced_statusbar_location : "bottom",
> >    theme_advanced_resizing : true,
> >     theme_advanced_toolbar_location : "external",
>
> >    verify_html : true,
> >    valid_elements : ""
> >    +"a[accesskey|charset|class|coords|dir<ltr?rtl|href|hreflang|id|
> > lang|name"
> >      +"|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|
> > onkeyup"
> >      +"|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rel|
> > rev"
> >      +"|shape<circle?default?poly?rect|style|tabindex|title|target|
> > type],"
> >    +"abbr[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|
> > onkeypress"
> >      +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|
> > onmouseup|style"
> >      +"|title],"
> >    +"acronym[class|dir<ltr?rtl|id|id|lang|onclick|ondblclick|
> > onkeydown|onkeypress"
> >      +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|
> > onmouseup|style"
> >      +"|title],"
> >    +"address[class|align|dir<ltr?rtl|id|lang|onclick|ondblclick|
> > onkeydown"
> >      +"|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|
> > onmouseover"
> >      +"|onmouseup|style|title],"
> >    +"applet[align<bottom?left?middle?right?top|alt|archive|class|code|
> > codebase"
> >      +"|height|hspace|id|name|object|style|title|vspace|width],"
> >    +"area[accesskey|alt|class|coords|dir<ltr?rtl|href|id|lang|
> > nohref<nohref"
> >      +"|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|
> > onkeyup"
> >      +"|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup"
> >      +"|shape<circle?default?poly?rect|style|tabindex|title|target],"
> >    +"base[href|target],"
> >    +"basefont[color|face|id|size],"
> >    +"bdo[class|dir<ltr?rtl|id|lang|style|title],"
> >    +"big[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|
> > onkeypress"
> >      +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|
> > onmouseup|style"
> >      +"|title],"
> >    +"blockquote[dir|style|cite|class|dir<ltr?rtl|id|lang|onclick|
> > ondblclick"
> >      +"|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|
> > onmouseout"
> >      +"|onmouseover|onmouseup|style|title],"
> >    +"body[alink|background|bgcolor|class|dir<ltr?rtl|id|lang|link|
> > onclick"
> >      +"|ondblclick|onkeydown|onkeypress|onkeyup|onload|onmousedown|
> > onmousemove"
> >      +"|onmouseout|onmouseover|onmouseup|onunload|style|title|text|
> > vlink],"
> >    +"br[class|clear<all?left?none?right|id|style|title],"
> >    +"button[accesskey|class|dir<ltr?rtl|disabled<disabled|id|lang|
> > name|onblur"
> >      +"|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|
> > onmousedown"
> >      +"|onmousemove|onmouseout|onmouseover|onmouseup|style|tabindex|
> > title|type"
> >      +"|value],"
> >    +"caption[align<bottom?left?right?top|class|dir<ltr?rtl|id|lang|
> > onclick"
> >      +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|
> > onmousemove"
> >      +"|onmouseout|onmouseover|onmouseup|style|title],"
> >    +"center[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|
> > onkeypress"
> >      +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|
> > onmouseup|style"
> >      +"|title],"
> >    +"cite[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|
> > onkeypress"
> >      +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|
> > onmouseup|style"
> >      +"|title],"
> >    +"code[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|
> > onkeypress"
> >      +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|
> > onmouseup|style"
> >      +"|title],"
> >    +"col[align<center?char?justify?left?right|char|charoff|class|
> > dir<ltr?rtl|id"
> >      +"|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|
> > onmousedown"
> >      +"|onmousemove|onmouseout|onmouseover|onmouseup|span|style|
> > title"
>
> ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to