Yii Framework Forum: [EXTENSION] TinyMCE using jQuery - Yii Framework Forum

Jump to content

  • (5 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • 5
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] TinyMCE using jQuery Rate Topic: -----

#41 User is offline   makro 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 71
  • Joined: 05-November 09
  • Location:Novara, IT

Posted 27 November 2009 - 09:37 AM

Hi!!
How about posts #39 and #40??
0

#42 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 11 December 2009 - 03:30 AM

Dynamically loading tinymce into jQuery UI/Dialog.

There is a problem with dynamic loading both "native" tinymce and lazy loading
with gzip compressor.
Saying "dynamic loading" I mean complete dynamic loading when tiny_mce.js or
tiny_mce_gzip.js also loaded into the page dynamically.

Here is my use case:
I have GUI builder which creates dynamically tabled views (for example, news
list) and edit forms where none or one or more textareas with tinyMCE can be used.
Forms are added to the page dynamically into jQuery / UI Dialog.
Forms is generated as a set of widget and I have a widget for tinyMCE.

Since this GUI builder is generic I do not want to include tinymce core script
to all pages, but load it dynamically when appropriate widget is rendered on the
form.

Now I get to work both loading tiny_mce.js or tiny_mce_gzip.js dynamically and
had to solve some problems.

1. Dynamic loading of tiny_mce.js.
We have here two major issues: first - tinyMCE._init fails to set correct baseURL so other scripts not
loaded and second - scriptLoader.loadScripts by default
loads scripts with document.write and this breaks the page (all page content is gone).

Both problems where solved with following approach:
    if (!window.tinymce) {
       //set base URL for tinymce
       window.tinyMCEPreInit = {base : '$assets/tinymce', suffix : '', query : ''};

       //load tinymce
       jQuery.ajax({
                        type : 'GET',
                        url : '$assets/tinymce/tiny_mce.js',
                        async : false,
                        success : function(co) {
                            var w = window;

                            // Evaluate script
                            if (!w.execScript) {
                               try {
                                   eval.call(w, co);
                               } catch (ex) {
                                   eval(co, w); // Firefox 3.0a8
                               }
                            } else {
                              w.execScript(co); // IE
                            }
                            //load scripts with dom manipulation instead of document.write
                            w.tinymce.dom.Event.domLoaded = true;
                         }

       });
    }
    // Init textarea with jquery plugin
    jQuery("#{$id}").tinyMCE({$tinyOptions}, '{$jsMode}', {$jsUseCookies});


I add js code to the page to load core tinymce script dynamically and create
window.tinyMCEPreInit object before script is loaded to set correct baseURL to solve first problem
and set tinymce.dom.Event.domLoaded = true after script is loaded to solve second.

Full text of modified ETinyMCE::init() method:
Spoiler


2. Dynamic loading of tiny_mce_gzip.js
Here also two problems exist: first with base URL mentionad above and second -
with sequential calls of tinyMCE_GZ.init for more then one textareas.
I need to call tinyMCE_GZ.init more then once becuse when dialog with form is generated I
could not know how many tinymce widgets exists and each widget initializes
itself with such code:
       function initTinyGZ_$id() {
           // Init textarea with jquery plugin
           jQuery("#{$id}").tinyMCE({$tinyOptions}, '{$jsMode}', {$jsUseCookies});
       }
       // this is for tinymce core when it will be loaded by tiny_mce_gzip.js
       window.tinyMCEPreInit = {base : '$assets/tinymce', suffix : '', query : ''};
       // init compressor and pass textarea initialization as callback
       tinyMCE_GZ.init({$gzOptions}, function() { initTinyGZ_$id(); });


To solve problems I have with tiny_mce_gzip.js I had to modify its code.
To fix problem with base URL I added special setting to provide external base
URL through options and changed init() method to take that parameter.

To solve problem with sequential init() calls I changed init() function to
invoke callback even if core scripts are already loaded:

       if (!t.coreLoaded)
            t.loadScripts(1, s.themes, s.plugins, s.languages, cb, sc);
       else
           // SEB - scripts are loaded only once (loadScripts method sets t.coreLoaded to true)
           // if we have two textareas on the page and provide tiniymce initialization in the
           // callback function then second callback was never called
           cb.call(sc || t, null);


and changed loadScripts to load core synchronously so second init() call will be
performed when scripts are actually loaded into the page:
        //SEB - make syncronous call
        x.open('GET', t.baseURL + '/' + s.page_name + '?' + q, false);
        //x.setRequestHeader('Content-Type', 'text/javascript');
        x.send('');

        if (co)
            t.coreLoaded = 1;

        // SEB - Handle syncronous loading
        if (cb && x.status == 200) {
           t.loaded = 1;
           t.eval(x.responseText);
           tinymce.dom.Event.domLoaded = true;

           cb.call(sc || t, x);
        } else {
          t.eval(x.responseText);
        }


Modified text of tiny_mce_gzip.js:
Spoiler

0

#43 User is offline   MetaYii 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 393
  • Joined: 07-October 08
  • Location:The Matrix

Posted 11 December 2009 - 09:27 AM

Thanks for posting your modifications. I'll try to update the extension soon. It's been a difficult second part of the year, and I was dedicated mostly to system administration, so I stopped the development a bit :(
Ah! on-off, simplement!
0

#44 User is offline   gnome 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 10-January 10

Posted 10 January 2010 - 05:10 PM

View Postalaevka, on 24 November 2009 - 05:05 AM, said:

Hi to all and thanks for extension. Its great, but when i add some plugins as Image manager it`s not work :unsure:

My code is:
<?php $this->widget('application.extensions.tinymce.ETinyMce',
                array(
                    'name'=>'Text1[data]',
                    'id'=>'Text1_text1_data',
                    'plugins' => array('filemanager','imagemanager','safari','pagebreak','style','layer','table','save','advhr','advimage','advlink','emotions','iespell','inlinepopups','insertdatetime','preview','media','searchreplace','print','contextmenu','paste','directionality','fullscreen','noneditable','visualchars','nonbreaking','xhtmlxtras','template'),
                    'options' => array(
                        'theme' => 'advanced',
                        'skin' => 'o2k7',
                        'theme_advanced_buttons1' => 'preview,bold,italic,underline,fontselect,fontsizeselect,link,justifyfull,justifyleft,justifycenter,justifyright,pasteword,pastetext,table,image,|,bullist,numlist,|,undo,redo,|,code,fullscreen',
                        'theme_advanced_buttons2' => '',
                        'theme_advanced_buttons3' => '',
                    ),
                    'value' => $model->data, 
                 ));
             ?>



Hi I have the same problem with the image manager, did you ever get this to work? If so I would greatly appreciate some advice...
0

#45 User is offline   revo110 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 78
  • Joined: 04-March 09

Posted 10 February 2010 - 07:50 PM

Hi all,

How do you set "document_base_url" with this extension ?

Thanks!
0

#46 User is offline   lgoss007 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 88
  • Joined: 01-October 09

Posted 12 February 2010 - 02:21 PM

Anyone have any idea why the tiny_mce_###.gz file is not being created in assets?

I have my own server with a site running this extension fine. I use the same exact code on a web host I don't own and I can't get this extension to load. The one thing I'm noticing is that on the one that doesn't work the compressed file doesn't get created in the assets directory (under the tiny_mce folder). Anyone have any ideas why or what I can do to debug it? I don't get any errors on the page, it just loads a text box with no TinyMCE.
0

#47 User is offline   jackass 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 41
  • Joined: 05-January 09

Posted 15 May 2010 - 09:59 AM

View Postseb, on 11 December 2009 - 03:30 AM, said:

Dynamically loading tinymce into jQuery UI/Dialog.

There is a problem with dynamic loading both "native" tinymce and lazy loading
with gzip compressor.
Saying "dynamic loading" I mean complete dynamic loading when tiny_mce.js or
tiny_mce_gzip.js also loaded into the page dynamically.

Here is my use case:
I have GUI builder which creates dynamically tabled views (for example, news
list) and edit forms where none or one or more textareas with tinyMCE can be used.
Forms are added to the page dynamically into jQuery / UI Dialog.
Forms is generated as a set of widget and I have a widget for tinyMCE.

Since this GUI builder is generic I do not want to include tinymce core script
to all pages, but load it dynamically when appropriate widget is rendered on the
form.

Now I get to work both loading tiny_mce.js or tiny_mce_gzip.js dynamically and
had to solve some problems.

1. Dynamic loading of tiny_mce.js.
We have here two major issues: first - tinyMCE._init fails to set correct baseURL so other scripts not
loaded and second - scriptLoader.loadScripts by default
loads scripts with document.write and this breaks the page (all page content is gone).

Both problems where solved with following approach:
    if (!window.tinymce) {
       //set base URL for tinymce
       window.tinyMCEPreInit = {base : '$assets/tinymce', suffix : '', query : ''};

       //load tinymce
       jQuery.ajax({
                        type : 'GET',
                        url : '$assets/tinymce/tiny_mce.js',
                        async : false,
                        success : function(co) {
                            var w = window;

                            // Evaluate script
                            if (!w.execScript) {
                               try {
                                   eval.call(w, co);
                               } catch (ex) {
                                   eval(co, w); // Firefox 3.0a8
                               }
                            } else {
                              w.execScript(co); // IE
                            }
                            //load scripts with dom manipulation instead of document.write
                            w.tinymce.dom.Event.domLoaded = true;
                         }

       });
    }
    // Init textarea with jquery plugin
    jQuery("#{$id}").tinyMCE({$tinyOptions}, '{$jsMode}', {$jsUseCookies});


I add js code to the page to load core tinymce script dynamically and create
window.tinyMCEPreInit object before script is loaded to set correct baseURL to solve first problem
and set tinymce.dom.Event.domLoaded = true after script is loaded to solve second.

Full text of modified ETinyMCE::init() method:
Spoiler


2. Dynamic loading of tiny_mce_gzip.js
Here also two problems exist: first with base URL mentionad above and second -
with sequential calls of tinyMCE_GZ.init for more then one textareas.
I need to call tinyMCE_GZ.init more then once becuse when dialog with form is generated I
could not know how many tinymce widgets exists and each widget initializes
itself with such code:
       function initTinyGZ_$id() {
           // Init textarea with jquery plugin
           jQuery("#{$id}").tinyMCE({$tinyOptions}, '{$jsMode}', {$jsUseCookies});
       }
       // this is for tinymce core when it will be loaded by tiny_mce_gzip.js
       window.tinyMCEPreInit = {base : '$assets/tinymce', suffix : '', query : ''};
       // init compressor and pass textarea initialization as callback
       tinyMCE_GZ.init({$gzOptions}, function() { initTinyGZ_$id(); });


To solve problems I have with tiny_mce_gzip.js I had to modify its code.
To fix problem with base URL I added special setting to provide external base
URL through options and changed init() method to take that parameter.

To solve problem with sequential init() calls I changed init() function to
invoke callback even if core scripts are already loaded:

       if (!t.coreLoaded)
            t.loadScripts(1, s.themes, s.plugins, s.languages, cb, sc);
       else
           // SEB - scripts are loaded only once (loadScripts method sets t.coreLoaded to true)
           // if we have two textareas on the page and provide tiniymce initialization in the
           // callback function then second callback was never called
           cb.call(sc || t, null);


and changed loadScripts to load core synchronously so second init() call will be
performed when scripts are actually loaded into the page:
        //SEB - make syncronous call
        x.open('GET', t.baseURL + '/' + s.page_name + '?' + q, false);
        //x.setRequestHeader('Content-Type', 'text/javascript');
        x.send('');

        if (co)
            t.coreLoaded = 1;

        // SEB - Handle syncronous loading
        if (cb && x.status == 200) {
           t.loaded = 1;
           t.eval(x.responseText);
           tinymce.dom.Event.domLoaded = true;

           cb.call(sc || t, x);
        } else {
          t.eval(x.responseText);
        }


Modified text of tiny_mce_gzip.js:
Spoiler


I don't understand why for me this solution don't work. I open dialog so:
$('.update').live('click',(function(){
		var id=$(this).attr('id');
			$.ajax({
			  url: '".Yii::app()->createUrl("admin/offerte/update")."&id='+id,
			  success: function(data) {
			    $('#dialog').html(data);
			    var buttons = $( '#dialog' ).dialog( 'option', 'buttons' );
			    $('#dialog').dialog('open');
			    return false;
		  }});
		  }));

0

#48 User is offline   Ismael 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 163
  • Joined: 02-June 09
  • Location:Brazil

Posted 26 June 2010 - 09:09 PM

View PostJaime, on 28 August 2009 - 10:04 PM, said:

Hello... I had the same problem with undefined variable and I solved by adding
error_reporting(E_ALL ^ E_NOTICE);

but.. I don't think this is the correct solution. It seems like a patch.

The line that causes the error is:

$tinyOptions = $this->makeOptions($tinymce);


That line calls

protected function makeOptions($url='')


so, $tinymce variable is a url. But, which URL is it?

Thanks
Jaime



Same here, why it wasn't solved yet?
What is the purpose of $tinymce variable?

1 - I don't want to change the core.
2 - I don't want do disable warning.

What is the best approach?

Thanks
0

#49 User is offline   prof1 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 10-June 10
  • Location:Tomsk, Russian Federation

Posted 11 August 2010 - 11:35 PM

When I try to change the list of plugins:

$this->widget('application.extensions.tinymce.ETinyMce',
array(
'name'=>'html',
'editorTemplate' => 'full',
'options' => array('plugins' => 'test1,test2'),
)
);


Then the list of plug-ins for tinyMCE_GZ remains not changed in page script:

tinyMCE_GZ.init({'plugins':'safari,pagebreak,style,...);

But:

window.onload=function() {
jQuery("#html").tinyMCE({...,'plugins':'test1,test2'}, 'html', true);
};

Is it correct?
0

#50 User is offline   _wk_ 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 152
  • Joined: 22-January 10

Posted 24 September 2010 - 02:30 PM

View PostIsmael, on 26 June 2010 - 09:09 PM, said:

Same here, why it wasn't solved yet?
What is the purpose of $tinymce variable?

1 - I don't want to change the core.
2 - I don't want do disable warning.

What is the best approach?

Thanks


It appears the $tinymce variable should be the $assets variable as it is used by makeFullEditor(). I've changed this and it appears to be working correctly.
0

#51 User is offline   toli 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 58
  • Joined: 22-January 10

Posted 11 October 2010 - 03:08 AM

Hello mates,
I have integrated this extension and it works great.
I have a little problem with generated xhtml code. It is written in db as it should be but when I generate view to show the entered elements I see the tags and they are not interpreted by the browser (i see html code on my page, I mean tags).
What could be wrong ?
0

#52 User is offline   got 2 doodle 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 248
  • Joined: 12-December 08
  • Location:Beautiful Nova Scotia, Canada

Posted 12 October 2010 - 06:07 PM

I'm not sure if anyone has figured this out yet but the extension bailed in Windows Vista running wampp after using it successfully on a linux box and a linux server.

I see some others have found the anomololy but I didn't read all posts to see if it was solved. This worked for me :)

     // $tinyOptions = $this->makeOptions($tinymce); // broken in Wampp on Vista but works on Linux box ??
      $tinyOptions = $this->makeOptions(); // this works on both    


It seems that $tinymce just evaluates to null on the linux box, wampp croaks.

dunno why!!

doodle
Check out myYii powered website
0

#53 User is offline   got 2 doodle 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 248
  • Joined: 12-December 08
  • Location:Beautiful Nova Scotia, Canada

Posted 12 October 2010 - 06:10 PM

View Postkevinb, on 24 September 2010 - 02:30 PM, said:

It appears the $tinymce variable should be the $assets variable as it is used by makeFullEditor(). I've changed this and it appears to be working correctly.


Could you post your changes? Probably better than my approach
Check out myYii powered website
0

#54 User is offline   Kochiro 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 16-September 10
  • Location:Göteborg, Sweden

Posted 22 October 2010 - 08:57 AM

View Postgot 2 doodle, on 12 October 2010 - 06:10 PM, said:

Could you post your changes? Probably better than my approach


I believe this is what he did, but I've made several other modifications so I'm not 100% sure that this fixed it completely.

In protected/extensions/tinymce/ETinyMce.php, line 842:

find:
$tinyOptions = $this->makeOptions($tinymce);


change to:
$tinyOptions = $this->makeOptions($assets);

0

#55 User is offline   alek 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 22-September 10

Posted 29 October 2010 - 04:43 AM

hi everyone, had just founded out a problem maybe it is described already in a topic list just have no time to read them all), i integrated tinymcy into my system and need to remove status/path bar from it, puted
"theme_advanced_path"=> false, removed "theme_advanced_statusbar_location" from list, but it steal showes me path bar, hm thats the problem i decided to dig a source ETinyMce.php and founded out that developers defined it for the user $options['theme_advanced_path_location'] = 'bottom'; twice at line 691 and 698, and other parameter that must be removed $options['theme_advanced_path_location'] at line 701 plugin version 1.1 no problems for developer greate thx for him o her just make a remark
0

#56 User is offline   ianaré 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 50
  • Joined: 05-November 10
  • Location:Terra (III in Sol system)

Posted 26 November 2010 - 05:26 PM

I've made some fixes and improvements to the extension :

. Fixed $tinymce variable issue (replaced with $assets)
. Upgraded to latest version of tinymce, 3.3.9.2
. Fixed certain plugins from autoloading, due to the $this->plugins being hardcoded. Now looks to see if the plugins array is empty before applying default plugins.

I'd like to share these with the community, how should I go about doing that ?

Thanks
0

#57 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 26 November 2010 - 06:15 PM

It looks like the author abandoned the project some time ago?

I can see that the extension hasn't been updated since Aug 18, 2009.

And that means that the author wrote the extension, uploaded the initial version, and then made an update to it two months later.

And then left it behind.




I would create a new extension (page) and put the code up on a public repository.

Google code, Github, Bitbucket?

IMO, that's the best approach. :)



<edit>


Of course, you could ask 'someone' (moderator/team?) to allow you to take over the extension..

</edit>


"Less noise - more signal"
0

#58 User is offline   kmindi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 19-November 10

Posted 21 February 2011 - 05:19 AM

View Postianaré, on 26 November 2010 - 05:26 PM, said:

I've made some fixes and improvements to the extension :

. Fixed $tinymce variable issue (replaced with $assets)
. Upgraded to latest version of tinymce, 3.3.9.2
. Fixed certain plugins from autoloading, due to the $this->plugins being hardcoded. Now looks to see if the plugins array is empty before applying default plugins.

I'd like to share these with the community, how should I go about doing that ?

Thanks


Can you or did you publish your changes somewhere?
0

#59 User is offline   Mairel Theafila 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 02-May 11

Posted 02 May 2011 - 06:14 PM

Hello,
I used this extension and it works perfect on localhost, but when I upload it to my web server, it stops working.
After looking I found out that it's caused because the file tiny_mce_gzip.php could not be accessed because of its containing folder having permission of 777. If I change the permission of the whole folder (/assets/tiny_mce) to 755, then it works.

Why is this happening?


Thanks :)
0

#60 User is offline   phunehehe 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 09-June 11

Posted 09 June 2011 - 07:07 AM

Today I was bit by Bug #48885 hxxp://bugs.php.net/48885. (This is my first post and I cannot embed links yet so replace hxxp with http.) After spending hours trying to find out what's wrong I came up with this patch that fixes the problem. I hope that it will be put into the extension soon so others can use it.

Attached File  mime_type.diff.txt (1.95K)
Number of downloads: 19
0

Share this topic:


  • (5 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • 5
  • You cannot start a new topic
  • You cannot reply to this topic

6 User(s) are reading this topic
0 members, 6 guests, 0 anonymous users