Moodle 1.9 + TinyMCE - clean port

Moodle 1.9 + TinyMCE - clean port

by Martín Langhoff -
Number of replies: 204
Over at the MoodleMoot AU, Mathieu told me that if I backported the TinyMCE to 1.9 it'd probably make a lot of people happy. I know we also want to use it for our OLPC Moodle, which will make lots of kids happy (if it works well!).

With Mathieu, I explored the patchseries a bit, and figured out a few interdependencies and tricky bits.

Today back and the office I completed the backport. The main goals are

- series of clean, minimal patches
- TinyMCE working well
- consistent with HEAD (as much as possible)

Many thanks to Mauno and Mathieu for all their work on TinyMCE for 2.0.

The code is on a branch off MOODLE_19_STABLE (from the catalyst repo), right here:

http://dev.laptop.org/git?p=users/martin/moodle.git;a=shortlog;h=mdl19-tinymce

To download, follow the 'tree' link at the top, which will reveal a 'snapshot' link.

To use, set $CFG->defaulthtmleditor='tinymce';

If, like me, you are an avid git user, you can merge from catalyst's MOODLE_19_STABLE import to keep grabbing those good bugfixen from the _STABLE branch, and also merge / pull from that mdl19-tinymce branch for any bugfixes to tinymce. I'll try to defer merging from _STABLE into the -tinymce branch to keep things simple.

This needs your help however, in the form of

- testing
- bugfixes (post your patch right here on this thread or email me)
- polish and enhancements

Note - this is not supported formally. Except when it affects OLPC's XOs... want me to fix a bug that is hurting you? grab an XO test image or a Sugar LiveCD and show me the bug is there too smile
Average of ratings: -
In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by Ralf Seliger -
Hi Martin,

to tell the truth, I'm not quite sure what to do. When I follow your instructions (klick on link -> klick on tree -> klick on snapshot), I have to download the file moodle.git-mdl19-tinymce.tar.gz. During extraction I am asked twice to overwrite the file editor_plugin_src.js because it already exists. I'm not sure whether that makes sense.

The file/folder structure upon extraction looks like this:

editor_plugin_src.js (only one file, of course, even though the archive contains three files of different sizes)
smiley-embarassed.gif
...
users -> martin -> moodle.git -> admin, auth, ...

Now I have two questions:
  1. What do I have to do in order to install the TinyMCE backport into my existing Moodle 1.9.2+?
  2. Did you port TinyMCE2 or TinyMCE3?
Thanks
Ralf Seliger
In reply to Ralf Seliger

Re: Moodle 1.9 + TinyMCE - clean port

by Martín Langhoff -
Ralf - this is meant as a full install, don't unpack it on top of an existing moodle installation, it will make a mess of it.

I'd say unpack it in a different directory, treat it as a separate install - if you are confident with it, you may point it to the same database and moodledata directory as your 'other' moodle, which should be in sync to the latest moodle.

This is the same tinymce on HEAD/2.0: 3.2.0.1
In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean portED

by Ralf Seliger -
Of course I didn't unpack it on top of an existing Moodle but into an empty folder. Nevertheless I got the message that the file editor_plugin_src.js file is going to be overwritten.

The reason is that your archive contains three different files of that name with no path information.

Is this the way it is supposed to be?

Edit:
The three files seem to be identical after extraction, but Winzip shows three different file sizes.
In reply to Ralf Seliger

Re: Moodle 1.9 + TinyMCE - clean portED

by Martín Langhoff -
The tarball is a bit odd, I agree. It prefixes 'users/martin/moodle.git' which I think is incorrect. So I unpacked with

tar --strip-components 2 -xvzf /path/to/moodle.git-mdl19-tinymce.tar.gz

But I could not see any issue with editor_plugin_src.js. There are 37 files with that name, but they are all in different directories. I played around with the tar utility to see if it reported any errors, but it handled the file ok.

Perhaps WinZIP is somehow buggy in how it's handling this file? The directory structure is fairly deep -- could that be the problem?
In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean portED

by Mark Pearson -
>tar --strip-components 2 -xvzf /path/to/moodle.git-mdl19-tinymce.tar.gz

I just used this command line to extract the source and got no warnings about overwriting js files (Ubuntu v7.x server)

However, I must confess to confusion about how to update this using git. Updating a CVS repository is fairly simple; I just use cvs update -dP. But this has me stumped:
"you can merge from catalyst's MOODLE_19_STABLE import to keep grabbing those good bugfixen from the _STABLE branch, and also merge / pull from that mdl19-tinymce branch for any bugfixes to tinymce."

Having expanded the git repository what would be the command line to use to update it (assuming that i've installed git onto Ubuntu)?

Ta
Mark

In reply to Mark Pearson

Re: Moodle 1.9 + TinyMCE - clean portED

by Martín Langhoff -

The tarball is not a git repository. If you want the git repository you do git clone...

A quick workflow...

 # clone the repo - will take a few minutes...
 git clone git://dev.laptop.org/users/martin/moodle.git
 # the "default" branch of this repo is for the
 # moodle version we run in the OLPC School Server
 # - not what you want - so create a local 
 # branch to track the mdl19-tinymce branch, and
 # switch to it
 git checkout -b mdl19-tinymce origin/mdl19-tinymce
 # done! so configure and use...
 # ... some time later...
 # Pull updates from the mdl19-tinymce branch
 git pull

Now, I will be regularly merging fixes from MOODLE_19_STABLE so all you need to do is that "git pull" regularly. But perhaps I fall behind, or get rolled over by a bus. If that happens you can merge in updates from the MOODLE_19_STABLE branch without waiting for me...

 # Setup a new 'remote' to track the
 # MOODLE_19_BRANCH as imported by catalyst
 # (you only need to do this step once)
 git remote add cat-moodle git://git.catalyst.net.nz/moodle-r2.git
 # fetch latest code from the catalyst moodle repo
 # (the first time this will take a minute)
 git fetch cat-moodle
 # before attempting the merge, check that
 # your status is "clean" so it's safe to
 # later "reset" if the merge goes wrong...
 git status
   ... git will tell you about changed files
 # and attempt the merge
 git merge cat-moodle/MOODLE_19_STABLE
   ... some noise from git, hopefully it all
       merges ok and no further steps are needed...
 # if the merge has conflicts...
 #  a) learn a bit more about git and how to
 #     deal with conflict resolution...
 #  b) cancel the merge like this:
 git reset --hard
In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean portED

by Mark Pearson -
Just a couple more comments:
  1. On Ubuntu or other Debian systems use sudo apt-get install git-core and sudo apt-get install cogito rather than sudo apt-get install git. The latter installs gitfm which is quite the wrong package!
  2. Having installed git successfully I follow your instructions above and git clone git://dev.laptop.org/users/martin/moodle.git which takes ages and creates a directory called 'moodle'.
  3. I cd into moodle and then git checkout -b mdl19-tinymce origin/mdl19-tinymce but I get an error: git checkout: branch mdl19-tinymce already exists.

the Moodle directory looks to be exactly the same as in the tar.gzipped version

In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by Eric Merrill -
Picture of Core developers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Is there a way to (easily) get a diff of your changes vs the baseline MOODLE_19_STABLE it is built off of. Im not a git user, but i can learn if needed wink
In reply to Eric Merrill

Re: Moodle 1.9 + TinyMCE - clean port

by Martín Langhoff -
if you have gotten a git clone of that, and have the catalyst repo as well, do

git diff catalyst/MOODLE_19_STABLE...olpc/mdl19-tinymce

(note the 3 dots!)

I've attached the patch. It's a patch that contains binary files (a few gifs) so "normal" patch will get confused with it. Install git and use 'git-apply' just like you would use patch. It can behave like a smart version of 'patch' when used in directories you are not tracking with git itself.

If you don't care about the gifs, use patch and ignore the complaint about the gifs!

Edit: too large to attach, even gzipped.Uploaded it to http://dev.laptop.org/~martin/ - grab it from there!
In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by Larry Elchuck -
Martin

Is there a way to get this adaptation without using git?

I'm running cvs but have not attempted the git thing yet.

Perhaps a full revised version of moodle 1.9.2 or only the parts required, with instructions.

thanks
L


In reply to Larry Elchuck

Re: Moodle 1.9 + TinyMCE - clean port

by Martín Langhoff -
It's not that hard to install git and get started -- just get the windows msi installer for git smile
In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by Larry Elchuck -
Wouldn't do me much good ... running Mac OS X for my personal machine and the servers I support are Mac OS X or linux. Would want to test on a Mac OS X test box before I get brave enough to install on the Mac OS X and linux production boxes.

I did a bit of reading on git lately but did not find a nice easy-to-follow tutorial on how to install and use for OS X.

thanks
larry
In reply to Larry Elchuck

Re: Moodle 1.9 + TinyMCE - clean port

by Martín Langhoff -
Google "git os x". Several good options to get started. Or use the patch I posted earlier.

Note that this is the General Developer Forum.
In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by Larry Elchuck -
1. I'm a bit confused.

Above you stated:
" This needs your help however, in the form of
- testing
- bugfixes (post your patch right here on this thread or email me)
- polish and enhancements

and in your last reply, I think you implied that I should not post here.

I'm trying to test it out but not sure where I should reply ... please enlighten me.

2. I did
from the snapshot
  • installed it in a parallel directory to a working directory and modded the paths to the folder
  • set $CFG->defaulthtmleditor='tinymce'; in config.php on m19g (my new folder)
The parallel directory works but only getting html code in the boxes instead of any editor.

Where did I screw up?
In reply to Larry Elchuck

Re: Moodle 1.9 + TinyMCE - clean port

by Martín Langhoff -
This is the right place, and thanks for helping! -- you just may have to apply programmer skills to the task smile --

So it's not quite working for you... perhaps try a few things:

- Does this earlier version work? http://dev.laptop.org/git?p=users/martin/moodle.git;a=snapshot;h=6d823cc8d76ab7a35995d962d7ae1afae6b19ca8

If it still doesn't work...

- turn on debugging, make sure it's sent to a log (not to the browser, as that will definitely break stuff!). Do the logs say anything interesting / out of the ordinary?

- What does firebug tell you?
In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by Larry Elchuck -
Hi Martin ....

You solved the issue for me.

I had Developer level debugging turned on and set to display in the browser ... and that's what broke the tinymce editor. I deselected the display in browser option and it now works in both builds cited above.

Now, to teach this old dog new tricks with git! ... lol

Thanks for your time,
larry
In reply to Larry Elchuck

Re: Moodle 1.9 + TinyMCE - clean port

by Martín Langhoff -
Good to hear!

That setting (of spitting errors to the browser) is _evil_. It is a relic from the 90s, and it breaks JS, CSS and XHTML.

In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by Pablo Etcheverry -
Picture of Core developers
This one worked for me instead:

 git diff cat-moodle/MOODLE_19_STABLE...origin/mdl19-tinymce

Cheers,
Pablo

In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by Martín Langhoff -
Merged in lots of fixes from the 19_STABLE branch so the mdl19-tinymce branch is up-to-date smile
In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by Scott Tearle -
Hi Martin,

It looks like the port is no longer available. Is there somewhere I can dowload it?


Scott
In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by Eric Merrill -
Picture of Core developers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
I managed to get it merged and running on our site. Is there a way to browse the images in the course like you can in HTMLArea? When I click on the insert image dialog I get the box, and can bring up the 'browse' dialog in there, but no files load into that.

Thanks
-eric
In reply to Eric Merrill

Re: Moodle 1.9 + TinyMCE - clean port

by Eric Merrill -
Picture of Core developers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
I was able to get it to load something by clicking 'move' in the browse window, but it loaded the files for the site (course id 1...)
In reply to Eric Merrill

Re: Moodle 1.9 + TinyMCE - clean port

by Eric Merrill -
Picture of Core developers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Ok... I was able to fix it by adding

$courseid = optional_param('course');

Near the top of lib/editor/tinymce.js.php

Not saying that is the best solution - but it worked...

-Eric
In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by Eric Merrill -
Picture of Core developers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Another bug I ran into. Insert date and insert time are not working.

I found the problem - in lib/editor/tinymce.js.php, around line 185, there are two lines:
plugin_insertdate_dateFormat : "$strdate",
plugin_insertdate_timeFormat : "$strtime",

but $strdate and $strtime are undef, and I couldn't figure out if you can get that from Moodle based on user/site settings.

To fix it, just remove/comment out those two lines, and it will use the defaults.
In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by Eric Merrill -
Picture of Core developers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Lol - one more.

Hopefully this is the last one for now (we are testing this patch for production rollout).

The preview button (next to html view on the third row of buttons) didnt work.

To fix -
In lib/editor/tinymce.js.php, in the block tinyMCE.init around line 172, add
content_css : "/$root/lib/editor/tinymce/moodlecontent.css",

Hope Im not flooding you all too much.... smile
In reply to Eric Merrill

Re: Moodle 1.9 + TinyMCE - clean port

by Mark Pearson -
Eric,
This information would be really great. If I could switch on the Tinymce editor!
I did git clone git://dev.laptop.org/users/martin/moodle.git to get the source but when I installed it together with a working database it updated the database but did not change the editor. The code is there in lib/editor/tinymce, I just can't figure out how to switch it on :-> Any ideas?
Ta
Mark
In reply to Mark Pearson

Re: Moodle 1.9 + TinyMCE - clean port

by Eric Merrill -
Picture of Core developers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
You have to add this line to config.php if it's not in there:

$CFG->defaulthtmleditor = "tinymce";
In reply to Eric Merrill

Re: Moodle 1.9 + TinyMCE - clean port

by Mark Pearson -
Hurrah! That worked!. Now to apply your other hacks.
Cheers
M
In reply to Eric Merrill

Re: Moodle 1.9 + TinyMCE - clean port

by Martín Langhoff -
Hi Eric!

great sleuthing about the fix. I'm finishing off the XS-0.5 release (which is still without these tinymce patches) and will get into integrating your suggestions asap. Thanks!
In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by Eric Merrill -
Picture of Core developers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
One other thing:

The spellchecker doesnt work. This is a known bug in the current moodle version of TinyMCE (in Moodle 2). To fix it, you have to download PHP spellchecker from http://tinymce.moxiecode.com/download.php and replace lib/editor/tinymce/jscripts/tiny_mce/plugins/spellcheck with that.
In reply to Eric Merrill

Re: Moodle 1.9 + TinyMCE - clean port

by Geoffrey Rowland -
Picture of Plugin developers
Thanks Eric - that's got the spellchecker (configured for aspell) working for us.
In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by Mark Pearson -
Modding the editor button bar

I am getting my knickers in a twist with changing the button bar contents in lib/editor/tinymce.js.php as detailed here.

Basically, although I specified two rows of buttons, a third row appears with some random buttons which I did not specify in the above file (see graphic in page linked above). Any ideas would be gratefully received. This is driving me around the proverbial twist.
Mark
In reply to Mark Pearson

Re: Moodle 1.9 + TinyMCE - clean port

by Mauno Korpelainen -

Default settings are defined in advanced theme (most likely ...tinymce/jscripts/tiny_mce/themes/advanced/editor_template.js) to be something like

  theme_advanced_buttons3 : "hr,removeformat,visualaid,|,sub,sup,|,charmap",

I have not used this clean port integration but in all cases you can remove the 3rd button row with following tags in init code

theme_advanced_buttons3 : "",

In reply to Mauno Korpelainen

Re: Moodle 1.9 + TinyMCE - clean port

by Mark Pearson -
You were *exactly* right. And your suggestion solved the problem. Thanks a million mate! This TinyMCE interface is sooooooo good!

Cheers
Mark
In reply to Mauno Korpelainen

Re: Moodle 1.9 + TinyMCE - clean port

by Mark Pearson -
So here's what my button bar looks like now:

2nd try at button bar

and I'm dead chuffed. Thanks for your help Mauno.

My next task is to try to get the Firefox built-in spelling checker to be the spell checker it uses. I have set

gecko_spellcheck : true,

but right-clicking brings up a TinyMCE menu rather than the browser menu. How can I suppress this behaviour in favour of the Firefox right-click menu? I looked in the TinyMCE wiki but didn't find much joy there.
Cheers
Mark
In reply to Mark Pearson

Re: Moodle 1.9 + TinyMCE - clean port

by Mauno Korpelainen -

Well this is a little tricky one - again I had not used Firefox built-in spelling checker but had to check it when you asked...

It's plugin contextmenu that you see when you right click in TinyMCE. If you disable contextmenu (take contextmenu away from plugins row) you get normal right click options and can use Firefox built-in spelling checker (+ install languages for spell checking to Firefox with right click).

If you want to keep contextmenu Google spell checking service (default spellchecker in tinyMCE) should work nicely http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker - you just need to make sure that full spellchecker plugin for TinyMCE is downloaded from http://tinymce.moxiecode.com/download.php (PHP Spellchecker) and configured to use Google spell checking service.

In reply to Mauno Korpelainen

Re: Moodle 1.9 + TinyMCE - clean port

by Mark Pearson -
Thanks Mauno -- I think I'll try this.
So, what's your opinion? Is it better to have spellchecking executed by TinyMCE or by the user's browser?

Pro TinyMCE:
  • works the same way independently of browser
Con TinyMCE speller:
  • can only use languages that are provided by the Moodle server.
Pro Firefox speller:
  • users can easily change spellcheck language to whatever they want. Eg I would use British English.
  • users can save words in the local dictionary
Con Firefox:
  • would need to set up spell check on every machine I use
  • saving words in the dictionary requires some faffing about
Cheers

Mark
In reply to Mark Pearson

Re: Moodle 1.9 + TinyMCE - clean port

by Mauno Korpelainen -
It really depends on your users - Google spell checker can check the spelling of words in any of the following languages if those languages are given in init code:

Danish
Dutch
English
Finnish
French
German
Italian
Polish
Portuguese
Russian
Spanish
Swedish

I might check either english or finnish ... although I usually just write without spell checker. And context menu can be useful - in my test integrations I had a different custom editor theme and I replaced context menu with custom plugin "standard menu" (with some extra code) and used Google spell checking.

If you need some other languages Firefox really has more alternative dictionaries - some kind of external spell checking page (form or demo editor) might also be possible...


In reply to Mauno Korpelainen

Re: Moodle 1.9 + TinyMCE - clean port

by Jason Lohrenz -
This is some great info.  This 'clean' install I see is from December of 2008.  If I wanted to implement updates from the current build of 1.9 how would I go about doing this without destroying the enhancements that this provides?
In reply to Mark Pearson

Re: Moodle 1.9 + TinyMCE - Firefox/Chrome Spell Check

by Paul P. -

Firefox's built-in spell check can be enabled by changing the following in /lib/editor/tinymce/jscripts/tiny_mce/tiny_mce.js:

Change:
if(!v.gecko_spellcheck){q.getBody().spellcheck=0}

To:
if(!v.gecko_spellcheck){q.getBody().spellcheck=1}

You'll have to do a text search for the first line of code since tiny_mce.js is minified.

I hope this helps someone - it took me a long time to figure out.

If anyone knows of a reason why this would be bad, please post!

In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by Thomas Bachert -
Where exactly to you set $CFG->defaulthtmleditor='tinymce';

Also, is there a way to integrate an if-then statement on the course and/or site level, so that if a teacher or admin can have a choice on which one to use? I added the Drag Math plugin to the HTML editor and didn't want to neglect the users from using it.
In reply to Thomas Bachert

Re: Moodle 1.9 + TinyMCE - clean port

by Mark Pearson -
>Where exactly to you set $CFG->defaulthtmleditor='tinymce';

In the config.php located in the moodle root.

>Also, is there a way to integrate an if-then statement on the course and/or site level, so that if a teacher or admin can have a choice on which one to use? I added the Drag Math plugin to the HTML editor and didn't want to neglect the users from using it.

If there is it would likely be a site wide setting rather than course wide setting.

In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by Craig Gunderson -
I'm sorry to be posting a newbie question to such an involved forum thread, but all points lead to here.

Is there no way to have TinyMCE in a 1.9 install besides this patching process? I see that TinyMCE is in the library... why can't I just turn it on?

The integration module is no longer supported (and a link points here).

This guy had a great step-by-step which doesn't work (four javascript errors and no editor).

and he points to this other guy who in turn points to here.

This is very frustrating. Even moreso just to accommodate Safari users, but that's another story.
In reply to Craig Gunderson

Re: Moodle 1.9 + TinyMCE - clean port

by Craig Gunderson -

I just found this post dated a month ago from Mauno Korpelainen:
http://moodle.org/mod/forum/discuss.php?d=116904#p514193

"All version of moodle before 2.0 have an old folder lib/editor/tinymce - Janne Mikkonen added TinyMCE 2 several years ago and some sites may still use integration through weblib.php (or Janne's special cases)

"Also Martín Langhoff made a clean port integration for moodle 1.9 some months ago http://moodle.org/mod/forum/discuss.php?d=107550 , I made some theme based test intgrations about year ago and there may be some other versions and many people use Glen's version... All recent integration are using TinyMCE 3."

So that's a concise history. If I want to use the TinyMCE in the library, how do I do it? If there's a link on the plugin page, I don't see it.

In reply to Craig Gunderson

Re: Moodle 1.9 + TinyMCE - clean port

by Mark Pearson -
>If I want to use the TinyMCE in the library, how do I do it?

Basically, you install git and follow the instructions that Martin gives above. That's what I did and it works. Moreover, Martin does keep his base repository up to date so you're never out of touch. Unless you want to duplicate what he did to make the integration work this would be the best way. For info on what I did you could take a look at http://www.earlham.edu/markp/miss/#git

Cheers
Mark
In reply to Mark Pearson

Re: Moodle 1.9 + TinyMCE - clean port

by Martín Langhoff -
I general Mark is 100% right. In practice, I have piles of work to do smile so the TinyMCE branch is not merged (or tested to merge sanely) with latest 1.9.x code.

Are people merging from _STABLE into my branch successfully? If so, I would love to hear from them, and please do share any fixups.

Is anyone needing this hard enough to be prepared to do (if you're handy with git and moodle internals) or fund (if you have a budget) merge, test and fixup work?

If you code or fund, your contribution it will have a significant positive impact on OLPC! (as well as on your moodle!)
In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by Mark Pearson -
>Are people merging from _STABLE into my branch successfully? If so, I would love to hear from them, and please do share any fixups.


Not now. I have done this successfully a couple of times , but today I get:

$ git merge cat-moodle/~MOODLE_19_STABLE
fatal: 'cat-moodle/~MOODLE_19_STABLE' does not point to a commit
Cheers

Mark

In reply to Mark Pearson

Re: Moodle 1.9 + TinyMCE - clean port

by Bob Puffer -
Hey Mark,
The hackers at Hack-Doc Fest IV implemented TinyMCE and CKEditor into latest weekly 1.95+. Getting ready to publish the patch... only waiting on changing the help files since the hack totally disables htmlarea (which should have happened long ago.
Bob Puffer
In reply to Bob Puffer

Re: Moodle 1.9 + TinyMCE - clean port

by Mark Pearson -
Bob you're a frickking genius! I was just getting ready to drop the idea of TinyMCE because of continually banging my head on git syntax and inability to pull the latest 1.9.5 update. If you'd tell where and how to access the 'patch' (?) I'll volunteer to mangle the Help files in UK English smile.
Here's a link to photos from my trip to Turkey : http://picasaweb.google.com/markhpearson -- 3 1/2 weeks away from Moodle with fabulous Turkish food smile

Mark
In reply to Mark Pearson

Re: Moodle 1.9 + TinyMCE - clean port

by Geoffrey Rowland -
Picture of Plugin developers

I'll second that! Have also got nowhere with the git way of doing things and can't wait to test out the TinyMCE 'patch' tongueout

As we probably have quite a long wait for the release of stable Moodle 2.0, is there any chance that this could be incorporated into core Moodle code e.g. for 1.9.6 or 1.9.7? I appreciate that major new features are not usually incoporated in minor release versions, but we already have the precedent of the new Gradebook in 1.9.5 wink

Thanks again Bob and fellow hackers!

In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by Jonathan Harker -
Hi Martín,

I've rebased your mdl19-tinymce branch onto our copy of the MOODLE_19_STABLE branch. There was one merge conflict in lib/weblib.php - not too bad smile Have a look here. There's also a separate effort by Dan and Stacey here.

Cheers, J
In reply to Craig Gunderson

Re: Moodle 1.9 + TinyMCE - clean port

by Mauno Korpelainen -

Although Glen is not upgrading his files anymore it is still possible to use theme based integration as well with the latest code of tinymce and latest code of moodle 1.7-1.9 - if you want to test one version take a look at http://moodle.org/mod/forum/discuss.php?d=121738

Basicly you just need to disable HTMLArea and render TinyMCE (or some other editor) for textareas with a certain class (form-textarea) but moodle has some special features that make integration of editors a little more complicated.

Main problem is to edit init code and to find such settings and plugins that you need on your site...

In reply to Mauno Korpelainen

Re: Moodle 1.9 + TinyMCE - clean port

by Andreas Stoeffer -
Hello all,

after setup the Moodle Version 1.9 like Martin described above, everything worked as expected and TinyMCE runs fine.

But when I change the Moodle language to german, everytime I change sites or courses the language switches back to english but in the dropdown menu german is active.

Any ideas or hints?

Best
Andreas
In reply to Mauno Korpelainen

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: Moodle 1.9 + TinyMCE - clean port

by Mauno Korpelainen -

Well... I have some opinions:

- Hacks are always hacks and I don't believe that the patch that Bob mentioned could solve the original problem with "moodle modifications" - multilang, translations, administration of settings etc. With theme based integration it has been possible to use not only tinymce or latest CKEditor but also Xinha, FCKEDitor, YUI RTE and in practise any editor because most javascript based editors are ment to be used the same way - to render some init (configuration code) and then replace textareas/divs or some other elements with editors. The main problem has been upgrading and modified editor settings hardcoded in core code of moodle

- theme based integrations work as workarounds because standard code of editor (HTMLArea) of moodle has not been by default pluggable and changable. In moodle 2.0 this will change - Petr Skoda has rewritten editorlib.php and when version 2.0 is stable it will be possible to change both configurations and to create custom editor integrations easier than before.

- many sites allow students to upload files with editor and all students can upload attachments in core moodle as well. I don't think it is a problem if students can't freely upload all types of files and run any scripts they like. Files can include/inject viruses or hidden scripts even if your students don't know it and in some cases students know more about scripts/cracking than teachers but I suppose in 99.9% of cases allowing students to upload files is safe. You have been able to change role settings or override permissions (capabilities) in all versions of moodle since 1.7

- the clean port that Martin wrote was mostly based on code written by Mathieu and current moodle 2.0 is already using a very different code so I suppose Martin won't write a new version for awhile - maybe never. Many people would be happy to see similar changes in moodle 1.9 when 2.0 is stable but I don't believe it will never happen. Moodle 1.9 will stay the last single-default-editor-moodle forever and moodle 2.0 will be using totally different system.

In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by ann dee -
This link is dead.

Any info on installing on windows?
In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by jacques roux -
Hi,

I would like to target different instances of tinyMCE to display in different widths via CSS.

Would anybody know how I can go about doing that?

Thanks so much

Jacques
In reply to Martín Langhoff

Updated Moodle 1.9 + TinyMCE 3 patches

by Mihai Sucan -

I am working towards the integration of my GSOC project, PaintWeb, I will be integrating the project in Moodle 1.9 and 2.0.

One of the requirements for my project is TinyMCE 3 which is not available by default in Moodle 1.9.

This thread caught my eye. Thanks Martin for your important work.

I took the liberty to extend/update this work so I can reuse it for PaintWeb. TinyMCE and Moodle are quite old in Martin's repos.

I have forward-ported Martin's patches to the latest the official MOODLE_19_STABLE branch from the Moodle Git repository.

Additionally, I have updated the patches to the latest version of TinyMCE (3.2.5).

Last, but not least, I made the TinyMCE editor work in Opera, Safari and Chrome as well. Moodle 1.9 had a hard-coded whitelist of browsers which support the HTML editor: only MSIE and Gecko were listed.

If anyone is interested, I have uploaded the patches on my server. Download the Moodle 1.9 + TinyMCE 3 patches.

Note that the patches are generated by the git diff --binary command. I don't know if you can use the generic patch program to apply the patch file. I have only tested the git apply --binary command.

I recommend you do:

# clone the Moodle Git repository git clone git://git.moodle.org/moodle.git ~/src/moodle cd ~/src/moodle # checkout the Moodle 1.9 stable branch git checkout -b MOODLE_19_STABLE origin/MOODLE_19_STABLE # create a branch for the TinyMCE 3 patch git branch mdl19-tinymce # switch to the new branch git checkout mdl19-tinymce # apply the downloaded patch git apply --binary moodle19-tinymce3.patch

When the Moodle 1.9 stable branch is updated, you should be able to simply perform a git rebase, after you update the repository with git pull. I didn't try yet any rebase myself.

As explained by Martin, make sure you update your config.php file to hold:

$CFG->defaulthtmleditor='tinymce';

I would suggest that this kind of code goes into some official Moodle repository, where others can contribute/update the patches when needed. Anyone interested to help with this?

Good luck to everyone!

Average of ratings: Useful (1)
In reply to Mihai Sucan

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Bob Puffer -
This is a great step forward in the endeavor to not go yet another year with an editor that really screws a lot of things up (Htmlarea) i.e., formatting of tables, ghost, unremovable formats, enormous meta-data upon pasting from MSWord.

I used your steps above after confirming the normal patch wouldn't do the job. The editor installed quite well but I am unable to browse for files, either on the Moodle course site or to private, local drives. Any ideas?
In reply to Bob Puffer

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Mihai Sucan -
Hello!

Thanks for trying the work I published.

I tried that myself as well, and I can confirm I can't browse for files either. I don't know what's wrong yet.

I can't browse for files in the Git branch Martin has, the one with the older Moodle 1.9, the older TinyMCE. Perhaps this is something that still needed to be worked on / fixed. I simply updated his patches to the latest Moodle 1.9 stable branch.

Given the fact I am working on PaintWeb, I cannot focus on much of the fixes/improvements needed for the TinyMCE 3 integration into Moodle itself. I am currently working on PaintWeb, and fixing the TinyMCE-related things as I march ahead, as needed for PaintWeb. I made this work public so anyone can contribute. ;)

If anyone has some patches/improvements to contribute I would be happy to merge them.

Thanks again!
In reply to Mihai Sucan

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by David Mosher -
I was able to successfully install your branch via git on mac os x, I have a similar question as Bob: How do I enable image/file browsing for upload? In the old editor this was enabled by default but the "insert/edit image" button in TinyMCE doesn't seem to have any location to upload a file.

Also, am I correct in my assumption that the functionality of these editors is driven ultimately by javascript but within moodle is wrapped in a php class that handles some of this? If so, which particular file is it (editorlib.php?) and how can I add custom javascript to do things like turn on/off rows of buttons in the editor or even add a custom button.
In reply to David Mosher

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Mihai Sucan -
Thanks for trying the work I made public.

The problem is pretty much the same as reported by Bob. Currently I am too focused on the GSOC project. Any patches/improvements are welcome!

It's more complicated. The article editing is ultimately driven by JavaScript on the client-side - in your Web browser. Moodle is the PHP-based platform which glues all the client-side code, and generates most of it dynamically.

Moodle cannot offer the same capabilities from PHP - technically it's not something that can be done (unless someone has a crazy idea). For such editing features, JavaScript is required.

Regarding finding the files responsibile for all of this, I can tell Moodle is organized in the following way:

1. you have the client-side JavaScript code. That's HTMLArea and TinyMCE - the two WYSIWYG editors. You can find them in /lib/editor/htmlarea and /lib/editor/tinymce.

2. you have a PHP library which abstracts away the two editors, in a common API.

3. this common API allows other Moodle developers to easily integrate/use any of the two editors, at any time, without knowing the nitty-gritty details of each implementation.

To achieve all that, there are several PHP files you should look into:

1. weblib.php has the print_textarea() function which is important.
2. moodlelib.php has the can_use_html_editor() and the loadeditor() functions.
3. editorlib.php obviously.
4. then you have several PHP files in the lib/editor/ sub folders. You can look into the glue-code used for each editor.

The story for adding custom functionality to TinyMCE revolves around the TinyMCE 3 API. You should check out:

http://wiki.moxiecode.com/index.php/TinyMCE:API

They provide sufficient API for doing almost anything you want. This is not really much related to Moodle - you just need to add your JavaScript to the list of files needed to be loaded (see tinymce.js.php). Alternatively, you can code your new functionality as TinyMCE plugin - you just add your plugin folder and files, then add the plugin name to the list of plugins needed to be loaded in tinymce.js.php - I do this for PaintWeb.

Good luck!
In reply to Mihai Sucan

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Bob Puffer -
Thanks to Eric Merrill for this hack to get around the browsing files problem:
$courseid = optional_param('course');
Near the top of lib/editor/tinymce.js.php
In reply to Bob Puffer

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Mihai Sucan -
Thanks Bob for passing this to us. Also, thanks to Eric!

I'll try this change as well. If it works fine, I will include it in my patches.
In reply to Bob Puffer

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Mihai Sucan -
Applied the patch. It works, thanks!

This will be part of the next update I'll do for the TinyMCE patches. (some time this week)
In reply to Mihai Sucan

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Mihai Sucan -
I have updated the TinyMCE patch:

http://www.robodesign.ro/moodle/patches/moodle19-tinymce3.tar.bz2

The "insert image" dialog now allows users to nicely browse for files on the Moodle server, using the file picker. Thanks, once again, to Bob and Eric!

I have also included more usage instructions.
Average of ratings: Useful (1)
In reply to Mihai Sucan

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Craig Douglas -
I have never used GIT or a versioning system of any kind. I have made some source code changes to our moodle installation as well as adding new themes etc. What is the best way for me to implement this patch?

Should I follow your directions above? If so, I can't see any step where it points to my current implementation, so how would it know where it exists?

I assume the changes must involve files outside of lib\editor\tinymce ? if not, could you simply supply a zip package with the lib\editor\tinymce directory that I/we could simply replace without having to worry about the rest of my installation and learning git that I am completely unfamiliar with?

Thanks
Craig
In reply to Craig Douglas

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Mihai Sucan -
Hello Craig!

Thanks for your reply.

Last Friday I made public a Git repository which holds the TinyMCE 3 and PaintWeb branches I am working on.

You can take a look at some easier Git usage instructions:

http://www.robodesign.ro/mihai/blog/paintweb-and-moodle-git-repository

Basically, you can just do:

git clone git://repo.or.cz/moodle/mihaisucan.git
git checkout -b mdl19-tinymce3 origin/mdl19-tinymce3

And you're done: you have Moodle 1.9 stable + TinyMCE 3.

Currently I do not have time to make an easy to use zip package that people can unpack in their Moodle folder. This work is kind of experimental at the moment.

If you want to get the changes, here's what you can do:

1. You can go to
http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-tinymce3

3. Click the snapshot tar.gz / zip option to download the entire code base of the branch, as an archive. No need for Git - this is the equivalent of using git clone and checkout.

4. Unpack the archive. Now you have Moodle 1.9 stable + TinyMCE 3.

5. To know which files were changed you can see the differences between my branch and the official Moodle 1.9 stable one. Here's the link:

http://tinyurl.com/l9oq7e

6. Add/delete/replace all the files in your Moodle installation folder, as per the differences listed. Even if the diff looks huge, it's manageable. You need to replace the entire lib/editor/tinymce folder, then you also have to upload /lib/editor/common/dragmath. The rest of the files are:

course/editsection.html
lang/en_utf8/tinymce.php
lib/adminlib.php
lib/deprecatedlib.php
lib/editorlib.php
lib/form/htmleditor.php
lib/moodlelib.php
lib/weblib.php
message/send.php
theme/standard/styles_layout.css

That's all.

It should be noted that if your Moodle installation is not a "clean" one, then it is recommended you check the differences before overwriting any files. You can use software like "meld" on Linux and WinMerge on Windows. Make sure you compare the files you got from my branch with those of your Moodle installation.

Good luck!
In reply to Mihai Sucan

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by James McLean -
Is there plans to have these patches included in the near future, say 1.9.6? smile

Personally I would prefer to wait a little if the patches will be included in the near future rather than bother about with patching Moodle Core which will add maintenance headaches etc...
In reply to James McLean

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
No. We almost never make major changes to functionality on stable branches like 1.9.x. This will be in Moodle 2.0, not before. If you want it in 1.9, you will have to install it.
In reply to Mihai Sucan

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Craig Douglas -
Thanks very much for your help, that is what I was looking for. GIT is on my list to experiment with, just not yet.

I'll try this today.

Many Thanks
Craig
In reply to Mihai Sucan

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Geoffrey Rowland -
Picture of Plugin developers

Hi Mihai et al.

First, a huge thanks for your work on the TinyMCE integration and lucid instructions on how to use Git! It's a superb example of of how the GSOC can help to make things happen. On our Moodle, we are making increasing use of rich text editing for generating learning content, giving feedback and more formal online reporting (e.g. using the ULCC ILP module) so a robust, capable, well-behaving rich text editor is vital.

I can confirm that following the instructions for a local 'git build' and then copying the patched files to a Moodle 1.9.5 server (as described in section 6. above) works rather well.

Here I detail a few other 'tweaks' I had to apply to our setup in case they help others. Note that I didn't use Mihai's latest Git repositories so some or all of these may be already fixed.

1. I removed the iespell plugin and enabled the spellchecker plugin as outlined by Eric Merril in an earlier posting in this thread. We already used Aspell with our Moodle and it was simple to 'point' the spellchecker at that.

See: TinyMCE:Plugins/Spellchecker for more details.

2. To make fonts display consistently, in both edit and display modes, I changed the default TinyMCE font-size to medium (rather than 10pt or 12pt) in the first line of:

/lib/editor/tinymce/jscripts/tiny_mce/themes/advanced/skins/o2k7/content.css

Of course, the details of this will depend on which TinyMCE and Moodle Themes you are using.

3. When using Internet Explorer 6 or 7 (or IE 8 in compatibility mode) some TinyMCE toolbar mouse-overs and menu items did not display correctly. For example 'advanced.h1' rather than 'Heading 1'. Other recent browser versions (IE 8, Firefox, Opera, Safari, Chrome) had no problem.

This was fixed by adding the following to the appropiate lang file (in our case en.js) in: /lib/editor/tinymce/jscripts/tiny_mce/langs/

advanced:{

forecolor_desc:"Select text colour",

backcolor_desc:"Select background colour",

paste_desc:"Paste (Ctrl-V)",

copy_desc:"Copy (Ctrl-C)",

cut_desc:"Cut (Ctrl-X)",

undo_desc:"Undo (Ctrl-Z)",

redo_desc:"Redo (Ctrl-Y)",

removeformat_desc:"Remove formatting",

cleanup_desc:"Clean up messy code",

charmap_desc:"Insert custom character",

code_desc:"Edit HTML source",

newdocument_desc:"New document",

fontdefault:"Font family",

font_size:"Font size",

block:"Format",

paragraph:"Paragraph",

address:"Address",

pre:"Preformatted",

h1:"Heading 1",

h2:"Heading 2",

h3:"Heading 3",

h4:"Heading 4",

h5:"Heading 5",

h6:"Heading 6",

bold_desc:"Bold (Ctrl-B)",

italic_desc:"Italic (Ctrl-I)",

underline_desc:"Underline Ctrl-U)",

striketrough_desc:"Strikethrough",

sup_desc:"Superscript",

sub_desc:"Subscript",

justfyleft_desc:"Align left",

justifycenter_desc:"Align Centre",

justifyright_desc:"Align right",

justifyfull_desc:"Align full",

bullist_desc:"Unordered list",

numlist_desc:"Ordered list",

outdent_desc:"Outdent",

indent_desc:"Indent",

blockquote_desc:"Blockquote",

unlink_desc:"Unlink",

anchor_desc:"Insert/Edit anchor",

hr_desc:"Insert horizontal rule"

},

There may be more elegant ways of doing this, but it worked for us.

Thanks again!

In reply to Geoffrey Rowland

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Mihai Sucan -
Hello Geoffrey!

Thanks for appreciating my work and for your detailed report of the tweaks implemented. Contributing back to the community is very much appreciated.

I will look into implementing these changes into my TinyMCE Git branch. I did not look into these matters because they do not affect my work on PaintWeb integration.

Regarding problem 3: you are describing something which sounds like the language file of the advanced theme does not load. The strings should be in jscript/tiny_mce/themes/advanced/langs.


Good luck and all the best,
Mihai
In reply to Mihai Sucan

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Dmitry Pupinin -
Picture of Core developers Picture of Plugin developers

Hello everybody!

I try to apply patch to Moodle 1.9.6 and I has done it. wink

But I had a problem with localization of TinyMCE. There are some remarks:

  1. Too complex to create localization from XML file which used for language in TinyMCE. It havn't names of modules and plugins. 'create_langfiles.php' useless because localization don't distribute in .js format (maybe I'm wrong?)
  2. In some cases, language strings takes from .js files even so instead of /langs/minymce.php. For example, for popup windows.
  3. Variables ($cols, $rows etc.) and date format (like %Y-%m-%d) brings about disappearing of editor if debugging level allow to show warnings and errors.

My offers

I offer next changes which correct this problems:

  1. Attached XSL file allow to create Moodle's language file from any Tiny's XML language in one click.
  2. Some changes in php scripts guarantee that all language strings always will get from Moodle's langs.

Install changes

  1. Apply patch from http://www.robodesign.ro/moodle/patches/moodle19-tinymce3.tar.bz2
  2. Replace files in /lib/editor from attachment.
  3. Replace english language file in /lang/en_utf8 from attachment because it has changed format.

Creating new language

  1. Download XML file from http://tinymce.moxiecode.com/download_i18n.php
  2. Place file tiny_to_moodle.xsl in same directory as xml.
  3. Add string <?xml-stylesheet type='text/xsl' href='tiny_to_moodle.xsl'?> on second line of file, right before <language-pack>
  4. Open your xml file in browser (File->Open) and you will see localization in Moodle format.
  5. Select all in browser's page, copy, paste in text file and save this as tinymce.php (Be attentive! Save in UTF-8 format without BOM!)
  6. Place tinymce.php in your lang directory.

I'll be much obliged to Mihai Sucan if he test it and include it in his patch.

In reply to Dmitry Pupinin

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Mihai Sucan -
Hello Dmitry!

Thanks for your work.

Language files are distributed in both formats. In the official page you liked (the one at tinymce.moxiecode.com) you can download languages as .js or as XML.

The create_langfiles.php script is taken from the work did by Martin Langhoff. I only made some small fixes. If I am not mistaken the script works with TinyMCE plugins. My PaintWeb plugin has no issues.

However, it is agreed that parsing the JS files is pretty hackish. This is why in Moodle 2.0 there's a script which imports the strings from the distributed XML files. So, you are correct in your approach. smile

I recommend you to take a look the Git branch I made public, which holds the latest Moodle 1.9.x with TinyMCE 3 integrated.

http://repo.or.cz/w/moodle/mihaisucan.git/shortlog/refs/heads/mdl19-tinymce3

The archive you linked is rather old. There have been a number of fixes since then. ;)

One problem I saw is that the tiny_mce.js file you provide is uncompressed, it's not minified. This makes it slower to load - the file is quite bigger. TinyMCE is usually distributed in both forms: compressed (tiny_mce.js) and uncompressed (tiny_mce_src.js).

Again, I want to note that my work for TinyMCE 3 integration is limited around my work on PaintWeb integration. I do not have very much time to maintain the TinyMCE 3 branch, due to university studies.

You should make a fork of my Git branch and apply your patches. Link it here, so anyone interested can get it.

Thanks again for your contribution!
In reply to Mihai Sucan

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Dmitry Pupinin -
Picture of Core developers Picture of Plugin developers
Thanks Mihai!

I agree your observation about uncompressed .js. Could you prompt me what I can use for compressing, because I didn't do it earlier. wink
In reply to Dmitry Pupinin

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Dmitry Pupinin -
Picture of Core developers Picture of Plugin developers
Hello!

I created the patch which include work of Mihai and my changes.
Also this contain XSL file for creating localization for Moodle and Russian language for example.

Be attentive! You should use GIT for applying this patch!

You can get it here: http://train.nspu.ru/course/view.php?id=32
In reply to Geoffrey Rowland

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by James McLean -
Thanks for posting that Language file fix!

Have you noticed any issues with pasted text and character sets going strange? I've got an issue with pasting text (from any source, not just Word) where text with ASCII (proven with a HEX editor) is pasted into TinyMCE - and on Saving is saving a pile of Unicode. The problem mainly appears to be occuring for spaces in my case, however I have noticed a few other errant characters.

RDBMS is Oracle 10, if that matters; but it doesn't appear to be an issue on my local Oracle XE..

To me it sounds like a Database issue - but have you (or indeed anyone else) noticed anything similar?

Edit: I've just updated a field manually using the same source text as was pasted into TinyMCE and the issue does not present itself. It appears it could be a TinyMCE issue with saving.
In reply to James McLean

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by James McLean -
I have managed to rectify my issue; and it was as suspected - TinyMCE and Moodle were not to blame, an Oracle mis-configuration was.

If anyone should come across this issue (and for Google indexing) - the issue was that my Red Hat Linux server where Development was occuring did not have the required NLS_LANG Environment Variable set - specifically it needed to be set in the /etc/sysconfig/httpd file with the ORACLE_HOME variable. In my instance I set NLS_LANG to ENGLISH_AUSTRALIA.AL32UTF8 which suits my locale - your's may be different.

I did not have the issue locally with my Oracle XE install on Windows XP - because NLS_LANG was set via the Registry.
In reply to Mihai Sucan

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Bob Puffer -
Cannot indent a label created using TinyMCE using the item's right-arrow icon from the Moodle course page. It merely moves it down a line.
In reply to Bob Puffer

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Geoffrey Rowland -
Picture of Plugin developers
Bob, I can confirm I see this too. Right-arrow icon moves it down a line. Left-arrow icon moves it back up. Not a complete show-stopper as the indent/outdent buttons in the TinyMCE toolbar are reasonably well behaved - but it would be nice to have a fix - anyone?  wink
In reply to Geoffrey Rowland

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Bob Puffer -
Finding this to be due to TinyMCE's insistance on wrapping everything in <p></p> tags. When I wrap a label using HTMLArea in <p></p> tags I get the same behavior as with TinyMCE. The <p></p> tags kinda suck anyway since they force a good deal of space between each content item which I'd rather control myself. Have been unable to remove the tags through editing the HTML though.
In reply to Geoffrey Rowland

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Bob Puffer -
I guess I coulda just gone out and looked myself... sometimes that seems to easy. This from a forum posting in TinyMCE:

PLACE IN YOUR INIT PARAGRAPH:
forced_root_block : false,
force_br_newlines : true,
force_p_newlines : false,

Average of ratings: Useful (1)
In reply to Bob Puffer

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Geoffrey Rowland -
Picture of Plugin developers
Thanks Bob, that sorts it for us too. By coincidence, the Mahara developers recently encountered much the same issue and fix after upgrading to TinyMCE 3.
In reply to Geoffrey Rowland

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Geoffrey Rowland -
Picture of Plugin developers
Hmmm...

Having done a bit of tinkering and head-scratching, I now have mixed-feelings about this fix replacing <p></p> tags with <br />. As this TinyMCE FAQ emphasises, this may impact the behaviour of the editor and not be consitent with XHTML. It seems a shame that just as we have a more robust, standards-compliant editor in TinyMCE we have to 'break' it sad

Instead, something similar to the following tweaks to /theme/standard/styles_layout.css *almost* fixes things.

p {
margin-top: 0;
margin-bottom: 1em;
padding: 0;
}

#course-view .section .spacer {
height:0.5em;
float: left;
}

This gives a one line-space after paragraphs, so there is not too much wasted space.

However, for a label, the indent/outdent arrows only work on the *first line* of the text, which is (perhaps?) slightly less irritating than nudging the label up-and-down the page. The issue is probably more to do with the use of a spacer image to do the nudging rather than TinyMCE itself.

Any CSS gurus with any other ideas how this can be fixed?

That said, I'm 'happily' using <br /> in this HTMLarea-generated posting, so does it really matter?




In reply to Geoffrey Rowland

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Mauno Korpelainen -

Have you tried adding to init code just:

  forced_root_block : "",

which means that TinyMCE won't add those extra p tags at all...

(without lines force_br_newlines : true and force_p_newlines : false)

In reply to Mauno Korpelainen

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Geoffrey Rowland -
Picture of Plugin developers
Mauno,

Already tried that! Indeed, as you first start typing with that configuration, no opening or closing p tags are present. But, as soon as you press return (i.e. new paragraph!), opening and closing p tags are (quite correctly!) added, which gets you back to 'square one'.

So, unless you force the replacement of all p tags with br tags too (as outlined by Bob), this does not work.

Unless I'm missing something here...
In reply to Geoffrey Rowland

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Mauno Korpelainen -

Gosh, you are right...

Does it cause trouble only for labels or have you noticed some other similar effects?

In reply to Mauno Korpelainen

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Geoffrey Rowland -
Picture of Plugin developers
Not that I have noticed, but I guess that any similar use of spacer images to change position of text may have similar symptoms.

In my hands, a recent download of Moodle 2.0 dev (with built-in TinyMCE) also has the same problem with indenting labels wrapped in p tags.

Indeed, wrapping a label any with any XHTML block-level element (<p>, <div>, <pre>, <h1> etc) will have similar problems as they will all default to a new line rather than being moved sideways by a spacer image. Perhaps, in the longer term, we need to replace the spacer images used by Moodle's indent/outdent functions with mechanisms using CSS margin or padding styles.

In reply to Geoffrey Rowland

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Geoffrey Rowland -
Picture of Plugin developers
In order to live with the <p></p> tags that TinyMCE wraps everything up with, I am currently using the following CSS (e.g. added to the end of /theme/standard/styles_layout.css)

/***
*** TinyMCE 3 tweaks
***/
p:first-child,
h1:first-child,
h2:first-child,
h3:first-child,
h4:first-child,
h5:first-child,
h6:first-child,
table:first-child,
blockquote:first-child
{
display: inline;
}


This simply makes the first set of p tags (or other block-level elements) generated by TinyMCE display as an inline element i.e. does *not* start a new line. This eliminates the initial line-space and also makes single line 'labels' responsive to the indent/outdent arrows.

Subsequent paragraphs are displayed with the usual spacing between them. As usual, you can also force a simple <br /> line feed, with no line-spacing, by [Shift][Return/Enter].

With multi-line labels, only the first line is 'nudged' by the indent/outdent arrows, though from MDL-15781 this would seem to be the default behaviour of the existing text-editor, anyway. If you really need a multi-line label to respond to such nudges, you can always wrap it in a single cell table.

Be warned that the above CSS is very general e.g. it identifies the first p tag in *any* parent element, but that's what makes it a convenient fix for wherever TinyMCE is used in Moodle. If you you find, or are concerned about, unwanted side-effects, then you can use more specific CSS.

e.g.

.label>p:first-child
{
display: inline;
}


will specifically target the first <p tag>in labels (i.e. parent elements with class="label"). If necessary, you can hunt down the relevant classes using your browser's view > source code and/or the FireFox Web developer toolbar.

Note that :first-child is a CSS 2.1 pseudoselector so this won't work for Internet Explorer 6 (though the display should still be usable). Recent browser versions, e.g. IE 7 & 8, Firefox, Safari, Opera, Chrome, should be OK.

Feel free to feed any refinements or better solutions back to this forum wink
In reply to Geoffrey Rowland

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Geoffrey Rowland -
Picture of Plugin developers
Aaarh! This works in simple cases. However if you, say, have both <p> tags and <h3> tags present, the first instance of each is identified as ':first-child' and both of these are 'inlined' - which is not desired! So, it looks as if we need to craft more specific CSS for every (appropriate) context that TinyMCE is used - if it is wished to accommodate the extra <p> tags.

I also suspect there are other problem areas that need careful scrutiny. I have noticed that the TinyMCE-generated description for an assignment is displayed inside <p><p>.....</p></p> tags (at least on our Moodle 1.9.5 + TinyMCE); presumably one set from TinyMCE and one set from Moodle.

Starting to see why the Mahara developers opted against the TinyMCE generated <p> tags and have, for the moment, dropped XHTML 1.0 compliance from their roadmap as being 'too invasive'. sad

Any ideas on how to take this forward ?
In reply to Geoffrey Rowland

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Mihai Sucan -
Thing is, I believe TinyMCE 3 is behaving properly by insisting to use paragraphs. That's what I expect from a well-behaved WYSIWYG editor.

Unfortunately, this was not the case with much older WYSIWYG editors which were used inside Moodle 1.9. Thus, developers at that time coded Moodle expecting the lack of paragraphs.

To fix this issue now, it would require us to adjust all the CSS styling, on each Moodle page where texts from such textareas is displayed. Obviously, the issue at hand is related to how CSS margins and paddings work.

It is not a "big deal" per-se, buuut it's indeed "not nice" to have to fix the styling for each page. Nonetheless, this is the only way to correctly fix the issue.

The ugly fix is to tell TinyMCE 3 to not use paragraphs. It is ugly, because the generated content ends up being a big pile of mess, with
tags and such.
In reply to Mihai Sucan

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
In most (all?) situations where Moodle puts text, paragraph tags are in fact not required in order to ensure valid HTML. However, it's generally more elegant to have them.

The exception is certain places like labels etc. which are usually a single line; if these are indeed a single line, you don't really want a paragraph tag there. It is of course permissible, just becomes inelegant this time!

Without changing TinyMCE settings or the way it works with tags in general, it would be possible to process data received into Moodle at the input (cleaning) stage. For example, you could detect <p>...</p> where the contents don't contain any </p> of its own (= a single paragraph/line) and strip the surrounding <p></p> in this case. This is quite easy to do (but be a bit careful with it as if you mess up, it has a wide effect). I'm not sure whether this is advantageous compared to changing the TinyMCE option.

--sam
In reply to sam marshall

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Geoffrey Rowland -
Picture of Plugin developers
Thanks for all your feedback. It has helped clarify things (I think!).

I have just realised that labels are defined by <span class="label">. So, if my understanding is correct, as inline elements they should only contain other inline-elements and not block-level elements like <p> <h1> etc. So the TinyMCE option suppressing <p> tags is appropriate in this instance. Of course, this is entirely consistent with labels being designed for (mainly) single-line entries.

However, if more complex multi-line constructs and block-level elements are to be allowed in labels they should probably be redesignated as <div class="label">. Perhaps, their style could be set as display:inline so they still behaved like spans in other respects.

Much other TinyMCE generated content is located in <div> or <td> elements, so in this case <p> and other block-level tags are allowed.

Perhaps we should consider two instances of TinyMCE for Moodle, one (suppressing p tags) for 'simple' cases like labels, messages, emails etc and another (including p tags) for richer more complex content. One concern would be whether end-users would appreciate the subtleties of all this. The editor would behave differently in different contexts e.g. the [Return/Enter] key would generate a <br /> newline in one context and a <p> paragraph and linespace in another. So, perhaps Sam's suggestion that Moodle should do the appropriate tag processing/filtering is the best option.

In the context of my earlier postings, I am now using the following CSS as a 'quick fix' to suppress the opening linespace (e.g. paragraph top margin) caused by content being wrapped in <p></p>, or other block-level tags, by TinyMCE.

div.summary > *:first-child,
div.generalbox > *:first-child,

...any other TinyMCE contexts... > *:first-child,

td.content > *:first-child
{
margin-top: 0;
}


or, if you are feeling brave, just...

*:first-child
{
margin-top: 0;
}

*:last-child and margin-bottom: 0; could be similarly used to suppress the closing linespace though :last-child is not so well supported by browsers.

The following also seems to works for, say, <p> tags within label spans (but as noted above, spans should only contain inline elements, anyway).

span.label > *:first-child
{
display: inline;
margin-top:0;
}
In reply to Geoffrey Rowland

Re: Updated Moodle 1.9 + TinyMCE 3 patches

by Bob Puffer -
Thanks Geoffrey,
I did see the TinyMCE FAQ (pretty hard to miss as hard as those guys come down on the breaking of XHTML). I still opted for the <br> tag fix since I needed something similar to what our instructors are used to. HTMLArea acts the same way regarding multi-line paragraphs and indenting. Hoping this all gets worked out for 2.0.
In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by Ali Kaafarani -

Hi Martin..

i'm not using git..how can i install the tinymce on moodle 1.9.5...

need your help..

regards..

In reply to Ali Kaafarani

Re: Moodle 1.9 + TinyMCE - clean port

by Craig Douglas -
I'm just creating a zip file containing just the files that need to be replaced, just testing it now smile
In reply to Craig Douglas

Re: Moodle 1.9 + TinyMCE - clean port

by jason hull -
hi there,

any progress on your zip of just the files that need replacing? would really appreciate these smile

In reply to jason hull

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
I'd love to have this too. The standard html editor is so full of JS errors that it is killing me!

Also, Martin's link at the top appears to be broken.
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Bob Puffer -
CLAMP (Collaborative Liberal Arts Moodle Project) has a release of Moodle 20090729 which uses TinyMCE as the editor. We are using it here at Luther College. There are also numerous extensions and addons out on their website -- http://clamp-it.org
In reply to Bob Puffer

Re: Moodle 1.9 + TinyMCE - clean port

by Lael ... -
Hi Bob,

I downloaded the editor-only install, and copied it over a copy of our current install. Worked great! Just a couple of questions that I am wondering about...

Are you guys using a no-link button at all? Do you know how to add one in? I found http://moodle.org/mod/forum/discuss.php?d=116904 which talks about adding such a button - but I wasn't sure where the init code is in the CLAMP integration.

The other question was to do with fonts - in the editor the font shows up as verdana, but changes after saving to arial - I'm assuming it is because there is not a font selected by default, and it is gaining the arial font from the theme styling (although I tried changing the theme font settings and it didn't seem to change anything - but that is another issue to figure out). Do you know how to make tinymce select a font by default?or what might be the issue?

Thanks!
In reply to Lael ...

Re: Moodle 1.9 + TinyMCE - clean port

by Bob Puffer -
The init settings are in lib/editor/tinymce.js.php.

I'll look into the default font setting.

Bob
In reply to Bob Puffer

Re: Moodle 1.9 + TinyMCE - clean port

by Lael ... -
Thanks Bob, That is great.

I've loaded the Moodle no-link plugin (in editor\tinymce\jscripts\plugins), have loaded it to the toolbar along with a few other buttons - but the search replace button is stubbornly refusing to show... do you know how to find out what the error might be? (I'm curious whether the plugin is loading correctly, but not the image, or whether it simply isn't working at all...)

I was looking at http://corpocrat.com/2007/12/17/changing-default-font-in-tinymce-editor/ to work out how to change the default font, and realised it is controlled by moodlecontent.css in editor\tinymce, rather than editor\tinymce\jscripts\tiny_mce\themes\advanced\css\editorcontent.css. However - after modifying one and then the other,neither change affected the font in the editor... so I am a little confused. (This is my first time messing around with tinymce config).

Thanks so much for your help!

Lael
In reply to Lael ...

Re: Moodle 1.9 + TinyMCE - clean port

by Lael ... -
ha - was using the wrong name for the button - 'searchreplace' instead of 'replace'
In reply to Bob Puffer

Re: Moodle 1.9 + TinyMCE - clean port

by Lael ... -
I do have another question - about images. When inserting an image into the document, is the file manager and dialogue boxes a part of tinyCME or a plugin? is there a way to allow a preview of the image within the same box - like how HTMLarea currently works?
In reply to Lael ...

Re: Moodle 1.9 + TinyMCE - clean port

by Lael ... -
Seems like the existing preview doesn't work as expected - if the image is already there and you click on the insert image icon, the image shows up in the preview box underneath. But if you select a new image from the course files, the preview box does not update the image (resulting in a blank box for a new image or the previous image if updating the new image).

The other thing I have going on in our install is that the fonts appear larger in IE than they should be (1 size or two points) and the dropdowns for font and size and format are showing advanced.xxxx

Are you experiencing any of these issues?
In reply to Lael ...

Re: Moodle 1.9 + TinyMCE - clean port

by Geoffrey Rowland -
Picture of Plugin developers
For fixes for TinyMCE font size and dropdowns see my earlier posting in this thread wink
In reply to Geoffrey Rowland

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
I installed the complete CLAMP version with no modifications (from here: http://www.clamp-it.org/code/moodle-liberal-arts-edition-v10/ ). There are JS errors in IE7 as soon as you get to the front page...

"Line 12 Char: 1 Expected Identifier, string or number"

"Line 63 Char: 1 Expected Identifier, string or number"
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
The errors are coming from moodle/lib/editor/tinymce.js.php if that helps anyone...

edit: specifically from the two tinymce init calls in the above file.
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
The error is in two tiny mce lines:

document_base_url: "$CFG->httpswwwroot",

and

document_base_url: "$CFG->httpswwwroot",


Tiny changed this variable during the switch to 3+. After removing these lines the JS errors go away in IE and the editor seems to function fine.
In reply to Lael ...

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
Yeah, I noticed that the image preview doesn't work when inserting an image. Any fixes for this?
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
I have the LAE version installed and working great, except for Safari support. The plugin is there (in Tiny) but the tool bars are still missing for safari users. Any ideas on where to look to fix this?
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Bob Puffer -
I'm actually running LAE and get the buttons with Safari 4.03. Have made no adaptations to TinyMCE.
In reply to Bob Puffer

Re: Moodle 1.9 + TinyMCE - clean port

by Martín Langhoff -
Grab the "paintweb" code from Mihai Sucan. It includes TinyMCE and the PaintWeb plugin. I am pretty sure he's been testing it with Safari, FF and Opera.
In reply to Bob Puffer

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
weird, they're not there for me in any version of Safari i tried... I did do some work to the code, but didn't touch tiny.
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Bob Puffer -
Am running Safari on Leopard. Moodle LAE on CentOS 5.3. A fresh install produces the same result -- I get the buttons with Safari. Are you getting them with Opera, FF, IE, Chrome? I get buttons with all of those. Most of the TinyMCE in LAE is based off from Mihal's work so I wonder if his git install would result in anything different for you.
In reply to Bob Puffer

Re: Moodle 1.9 + TinyMCE - clean port

by Mihai Sucan -
I have tested my work only in Opera, Firefox and Chromium alpha builds on Linux.

I did not test on Windows nor Mac. I would expect that TinyMCE would work fine in Safari. Chromium uses Webkit, like Safari does.

I suggest testing the latest code I have in the mdl19-tinymce3 Git branch. If TinyMCE fails for some reason in that code, please copy/paste here the errors from the JavaScript console in Safari.

Having the error message might help me determine the actual problem.

John: if you modified other JS code in the Moodle page, you might have unwillingly tampered with something which breaks the TinyMCE editor. Try a "clean" install and see if that works. Also, make sure your system doesn't have any web page filters (like advert removers) which sometimes break web pages.
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Bob Puffer -
This is compliments of Jason Meinzer from Reed. It is my understanding that this was part of the LAE package, but if for some reason you don't have this hack, the information below should help out.

This is a quick addendum to WYSIWYG: YMMV. HTH! which did not explain how to convince Moodle that Safari is WYSIWYG-editor-capable. In lib/moodlelib.php find this function:

function can_use_html_editor() {
global $USER, $CFG;

if (!empty($USER->htmleditor) and !empty($CFG->htmleditor)) {
if (check_browser_version('MSIE', 5.5)) {
return 'MSIE';
} else if (check_browser_version('Gecko', 20030516)) {
return 'Gecko';
}
}
return false;
}
and add a check for WebKit > 525:

function can_use_html_editor() {
global $USER, $CFG;

if (!empty($USER->htmleditor) and !empty($CFG->htmleditor)) {
if (check_browser_version('MSIE', 5.5)) {
return 'MSIE';
} else if (check_browser_version('Gecko', 20030516)) {
return 'Gecko';
} else if (check_browser_version('Safari', 525)) {
return 'KHTML';
}
}
return false;
}

Apologies to Mihai for spelling your name wrong,,, your work is greatly appreciated.
In reply to Bob Puffer

Re: Moodle 1.9 + TinyMCE - clean port

by Mihai Sucan -
Hey Bob!

Yes, that's the function with the problem. My mdl19-tinymce3 branch has the following function:

function can_use_html_editor() {
global $USER, $CFG;

if (!empty($USER->htmleditor) and !empty($CFG->htmleditor)) {
if (check_browser_version('MSIE', 5.5)) {
return 'MSIE';
} else if (check_browser_version('Gecko', 20030516)) {
return 'Gecko';
} else if (check_browser_version('Opera', 9.0)) {
return 'Gecko'; // Gecko-compatible
} else if (check_browser_version('Safari', 525.13)) {
return 'Gecko'; // Gecko-compatible
}
}
return false;
}

It has the check for Gecko (Firefox and friends), Opera, Safari (and friends), and MSIE.

This code works for me with Chromium, Opera, Firefox, etc.

Please paste here your Safari user agent.
In reply to Bob Puffer

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
That was it. Works fine in Safari now. Thanks!!!
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Mihai Sucan -
Great to hear it works now!

Have fun and a happy new year! ;)
In reply to Mihai Sucan

Re: Moodle 1.9 + TinyMCE - clean port

by Keith Chow -
How to merge te TinyMCE with the latest Moodle 1.9.7?
I have followed the posts to modified the weblib.php, moodlelib.php, editorlib.php and etc.

But it shows nothing when I turned it on.
Could somebody help?
In reply to Bob Puffer

Re: Moodle 1.9 + TinyMCE - clean port

by Jean-Luc Delghust -
Hi all,

I'm a newbie to this, but this is probably where I'll find the answers. First, I can't say how happy I am TinyMCE will be integrated in Moodle 2.0. Second, I literally can't wait, so I'll be testing out integration in 1.9.7. Thanks in advance to all on this thread for the work on this!

Now, I'm not a programmer and have only basic understanding of code, so I usually go on a try and miss basis until it's not a miss anymore ^^
Anyways, before I start on this, I wonder if I could have some enlighted advice. Here's my situation (we use Moodle for language teaching): I developed a plugin for TinyMCE which basically allows a teacher to easily mark up written assignments, adding tags for spelling mistakes, good grammar... At the moment, it's on a different website from our Moodle installation and we basically copy/paste between moodle and that website, which is a drag. From what I've read, integrating custom-made plugins is no problem, but here's the question:
- is it possible to display different configs of the editor across the site? What I'm looking for, specifically, is to have TinyMCE with the "markup" plugin on the feedback for the online text assignment module, and regular TinyMCE elsewhere.

Thanks!
In reply to Jean-Luc Delghust

Re: Moodle 1.9 + TinyMCE - clean port

by Mihai Sucan -

Hello Jean-Luc!

First of all you need to use one of the TinyMCE 3 patches provided in this thread, so you can get it into Moodle 1.9.

Then you need to add your 'markup' plugin. Copy the markup plugin folder into the plugins folder of the TinyMCE editor provided in the newly patched Moodle. This should be in: lib/editor/tinymce/jscripts/tiny_mce/plugins.

Next, you need to configure TinyMCE to use your new plugin.

The TinyMCE configuration can be found in lib/editor/tinymce.js.php. Edit this file to add your 'markup' plugin to the list of automatically-loaded TinyMCE plugins.

The above change will affect all the instances of the TinyMCE editor, across the whole Moodle installation.

If you want to load the 'markup' plugin only for a certain case, then add a configuration variable. Say $CFG->tinymceMarkupPlugin. Only add the plugin to the list of TinyMCE plugins if the said variable is set to true. In your config.php you set the variable by default to false. Then edit the PHP of the module you want to display TinyMCE with the 'markup' plugin, and set the $CFG->tinymceMarkupPlugin variable to true.

I am not sure which PHP is the one you are interested of. It might be in mod/assignment.

If you want to see an example of how I implemented conditional loading of a plugin within TinyMCE 3 for Moodle 1.9, take a look at: tinymce.js.php.

Good luck!

In reply to Mihai Sucan

Re: Moodle 1.9 + TinyMCE - clean port

by Mauno Korpelainen -

Well, this is exactly the reason for several role, theme, activity and user based editor integration tests during past 3 years. Since the first integrations by Janne Mikkonen it was possible to use different editors in different activities and some people wanted to use different editor configurations only in some activities like Marc Bria et al in Storytelling. It used old tinymce version 2 although default editor was htmlarea.

Some people wanted to use different editors because these editors had some plugins that other editors did not have and we tested at least 3 different kinds of theme based integrations - see for example http://moodle.org/mod/forum/discuss.php?d=76912 and http://moodle.org/mod/forum/discuss.php?d=96160

Originally functions for editor configurations were built in lib files, in theme based tests these functions were moved from weblib.php to theme files and replaced with different functions for each editor, people in OU & Mathieu changed the whole structure of theme based integration for first versions of moodle 2.0 and Martin L made the first clean port version based on this integration.

Later clean port files were upgraded by Mihai but at the same time Petr changed again all integration files of moodle 2.0. and at the same time I had made new testing with math plugins using theme based code that did not require any changes to core files - htmlarea was just disabled in theme config.php and javascripts in theme files made the rest of the work.

At the moment there are 2 main options - 1) to hack some core code or 2) to disable default editor casewise with settings and write all editor code to themes or filters or custom activities. In my opinion both of these are bad options. Hacking core files makes upgrading moodle a pain and many people are afraid to use any extra packages.

Moodle 2.0 editor integration will allow multiple editor configurations but it has still many of the old problems unfinished/unsolved - in administration of non-default settings and possible overriding of default settings with activity, role, theme or user based settings. Petr has been busy with huge amount of changes made to moodle 2.0 - the whole theming system is literally rewritten, the use of javascripts is rewritten, almost all parts of moodle are rewritten... wink

So if you want to avoid extra work be patient and start testing editors again next summer when Petr has finished most of the current code of moodle 2.0 (themes and editors) wink

In reply to Mauno Korpelainen

Re: Moodle 1.9 + TinyMCE - clean port

by Jean-Luc Delghust -
every time again, I am amazed by the time and effort so many people put into Moodle.
I've been reading about Moodle 2.0 and I can't wait for the first release. I wish I had time to test the beta out

Now I know I should wait for 2.0, but our tutors'd like to see this feature soon, so I'm looking into it. Also, I'm not sure we'll upgrade directly to 2.0 for next academic year for various reasons, and since I'm sure we won't do it in the middle of the year we'll probably postpone it for one year.

So in the current situation, would I be safe to assume that, if I develop a plugin with built-in TinyMCE files & config, there wouldn't be consequences for the whole site? If it proves to be incompatiible, I could just disable it?
In reply to Mihai Sucan

Re: Moodle 1.9 + TinyMCE - clean port

by Jean-Luc Delghust -
Hi Mihai,

Thanks for the reply. I've started working on it and received help from David Smith to duplicate the module (I'm still working on it, but it's more or less functional). Discussion is here

As for the integration of TinyMCE, looking into it at the moment. Our admin won't want to integrate TinyMCE for the whole website, so I'm looking into changing it just for that particular module, possibly including it in the module in a subfolder. Not perfect, I know, but right now it's all I can think of. I have my personal install on which I test things, so no risk for the uni's install smile

Can't wait for Moodle 2.0 smile


In reply to Mihai Sucan

Re: Moodle 1.9 + TinyMCE - clean port

by Jean-Luc Delghust -
Hi Mihai,

Thanks for all the great work. Was a bit lazy to learn how to use git so I used the clamp editor install, integrated TinyMCE into my test platform and added my plugin, it works like a charm. I now only need to figure out the configuration variable but this is really promising.

As I said in an earlier post, our admin will probably not want to integrate TinyMCE on the production platform, but I'll try to convince him, as I think this solution is way better than integrating a separate instance of the editor in the added module.

Now, just in case, the php I'd need to modify to have a separate instance of TinyMCE is mo/assignment/online/assignment.class.php and it should be on the print_textarea line. "Ideally", the TinyMCE files should be in a subfolder of the mod/assignement/online folder. I know it's not ideal at all, but it'd allow me to have easy integration and disabling of the module if necessary, and avoid headaches on upgrading.. Any idea if this is possible at all?

If not we'll just have to try and convince our admin ^^

Thanks!

In reply to Jean-Luc Delghust

Re: Moodle 1.9 + TinyMCE - clean port

by Mihai Sucan -
Well, if the admin won't allow you to upgrade TinyMCE across all the board - through the entire Moodle installation ... with the patches provided in this thread... then your solution sounds doable.

You will have to include somewhere (maybe in the module's own folder) your own copy of TinyMCE 3, and just go ahead and use it your self.

Some thoughts: The TinyMCE 3 installation you see in the patches provided in this thread is customized. For your module you might want to consider using a fresh/clean copy of TinyMCE 3 from their official web site.

Additionally, the print_textarea() function probably does more things than you might actually need in your module. Since you don't want to use the old TinyMCE, but you want to use the new one, you don't need to call print_textarea. You just go ahead and output the necessary HTML markup and JS code for having our new TinyMCE 3 load in the page, from your mod folder. The TinyMCE web site does include such examples. If you choose this approach, still take a look into print_textarea and the associated functions.

Good luck!
In reply to Mihai Sucan

Re: Moodle 1.9 + TinyMCE - clean port

by Jean-Luc Delghust -
Thank you very much, I'll look into it, and try and get some more experienced friends to look at it . I was already trying with the new TinyMCE version.

Now, on my personal site I applied the patch (I really prefer TinyMCE) and created the variable for displaying the plugin only in some instances...

However, I can't get it activated in my module. If I set the variable to true in my config.php, it is applied on all pages of the install, so I guess my variable works. But when I set it to false and try to override it in the assignment module by adding setting the variable to true so it would only display in the feedback field of the tutor, no such luck.. I can't seem to get it activated. I prob put it in the wrong PHP. How can I know where I should put it? (sorry, I know these are probably very basic questions...)

Many thanks again for all the help.
In reply to Jean-Luc Delghust

Re: Moodle 1.9 + TinyMCE - clean port

by Mihai Sucan -
I am not sure of which exact feature/module of Moodle you are talking. smile My involvement with Moodle over the summer did span across the backup/restore system, and across things related to HTML editors (TinyMCE/HTMLArea and my painting tool). Hence, I am not a guru of all Moodle.

Please tell me what feature are you using? How to repro the usage scenario you have? This would help me pinpoint the precise file which needs edited. I will test in a pristine/clean Moodle 1.9 local installation.

Thanks!
In reply to Mihai Sucan

Re: Moodle 1.9 + TinyMCE - clean port

by Jean-Luc Delghust -
Sorry I wasn't clear... My bad.
Here is what I'm trying to do:
I want to duplicate the Online Text assignment module (mod\assignement\type\online). It can be added by a teacher by turn editing on>add activity>assignment>online text This allows students to write an online text, to which the teacher can then give feedback. There is a comment inline feature that copies the student's submission into the teacher's feedback field so he can add comments inside the text. The teacher can access the feedback field by clicking "grade" (or "update", once he has already given some feedback and wants to return to it)
Now, I want to create a separate instance of that online text module so English teachers can use TinyMCE + my markup plugin to easily add feedback for students (it has predefined buttons etc..). I can't modify the existing online text module as it is used by instructors "as is", so not for English teaching.

I managed to duplicate the module (attaching it to this post, please note it's not fully functional, just to be added in mod\assignment\type\ - I didn't include a subfolder with TinyMCE as it's not functional yet) thanks to help from David Smith (see discussion here - there are still a few issues that need to be addressed) who helped me to modify the assignement.class.php file in mod\assignement\type\onlineeslfr

Now, in my install, with integrated TinyMCE, I'd need to have the plugin displayed in the text editor for teacher feedback. I don't know where to set the $CFG-> markupeeslfrplugin: true; .
In our uni install, I'd need a separate TinyMCE editor including my plugin to be loaded from a subfolder in the plugin, so that nothing is changed in the Uni config, but that's another problem smile - once that is sorted, I'll have to make other versions of my plugin for the other languages taught at our institute as well smile

I hope this is clear enough, if you have any quesiton just ask...
Anyways, thanks for offering your help with this, it's really much appreciated, and I hope I'll be able to return the favour ^^ And if it's too much of a hassle, never mind smile
In reply to Jean-Luc Delghust

Re: Moodle 1.9 + TinyMCE - clean port

by Mihai Sucan -
(Take note I looked into the online assignment type, provided in the default Moodle 1.9, with TinyMCE 3 integrated. Thus my comments are valid to this situation.)

Hmm, I just looked through the code, and yes, simply putting the line $CFG->markupeeslfrplugin = true; won't be enough in your assignment type.

Why?

For one, when you work within the assignment module you won't access your assignment type directly. That means there's a bit more code executed before yours.

Additionally, in online assignment class you have the view() method which displays the assignments. There's an invocation of $this->view_header() which in turns invokes print_header() / print_header_simple() from lib/weblib.php. These ultimately end-up including lib/editor/htmlEditor.class.php. Finally, this script tells Moodle to print into the page:

In reply to Mihai Sucan

Re: Moodle 1.9 + TinyMCE - clean port

by Jean-Luc Delghust -
Hi!

Thanks for the reply! It's not lengthy, rather very instructive smile
I've quickly tried to implement the integrated solution on my install, but so far, no luck.. I have to get on with some more urgent work so I'll focus back on this later, but just wanted to say thanks!
Now, for the "do-it-yourself" approach, I'm having second thoughts after your comments here, especially as there could be security issues. I'll see if I can put it to some more experienced people, or try to convince our admin.

I'll try some more and come back here if I have more questions. thx for everything

++
In reply to Jean-Luc Delghust

Re: Moodle 1.9 + TinyMCE - clean port

by Roger Holden -
Hi

Can someone please tell me where I can find a working git repository for the TinyMCE version?

I've installed Git and can get the standard Moodle builds OK but none of the Git URLs here seem to work (they all time out).

Thanks!!


In reply to Mihai Sucan

Re: Moodle 1.9 + TinyMCE - clean port

by charles Requena Palomino -
sorry, it starts in moodle, I have problems with htmlArea, and I use tinymce, the moodle I 000webhost uploaded to a server, but not because it shows the editor, I wonder if you can enable in moodle version 1.97, tinymce,
but please be a little more specific as to which files I have to change to make to enable tinymce in mooldle,
PS: thanks in advance, and sorry for my English, is that I speak Spanish and little English
In reply to charles Requena Palomino

Re: Moodle 1.9 + TinyMCE - clean port

by Blair F. -
Picture of Particularly helpful Moodlers
Does anyone have clear instructions on how to install and use TinyMCE with Moodle? I have been fiddling with this, off and on, for over a month now and simply cannot get it to work.

I have also followed the instructions here:
http://web2life.co.nz/content/tinymce-and-moodle-howto
and still cannot get it to even show up in Moodle.

Thanks.
In reply to Blair F.

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
I started by using CLAMP's version of moodle:

http://www.clamp-it.org/

it was built with tinymce2 installed and working. Then I upgraded to use tinymce3. This was much easier (for me at least) than all of the various other methods mentioned.
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Bob Puffer -
Hi John,
Would you be interested in sharing your upgrade diffs? As maintainer of the CLAMP TinyMCE implementation I can certainly guarantee a lot of schools would be appreciative of being able to move to TinyMCE 3.x. We have a new release of the LAE (Liberal Arts Edition of Moodle) coming this Summer and I'd use your code and you could have all the credit.
Thanks, in advance.
In reply to Bob Puffer

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
Bob,

I can send you the whole moodle dir. by .zip. I am using tiny 3.25. (although I'm sure this could be upgraded) and 1.95+ from CLAMP. Truthfully, I made so many changes that I don't know where they all are. And some are completely custom (like students being able to upload and insert images/files in Tiny, nangong plugin in Tiny, etc).

The biggest changes I made to the CLAMP version are almost all contained in the /lib/editor directory. But there are a few outside of it as well (mainly to get the nanogong plugin working).

So, I'm not sure how useful it will be to you, but let me know your email address and I will send you the files ASAP.
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Bob Puffer -
John,
You've been a great help -- I'm going to check this out and likely use it (with your permission) when we convene in July for our CLAMP Hack-Doc fest (VI). If you've actually got Nanogong working with TinyMCE and aren't getting the kind of errors so prevalent from before, you should toddle over to that discussion and let them know -- everybody wants to use Nanogong but few (if any) seem able to get it to work reliably.
In reply to Bob Puffer

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
I actually got a 1.98 version of moodle with tinymce3 ready now. It installs fine (just tested) as a fresh install or you can upgrade... I used your Editor files (from CLAMP) as a guide and also my files from my 195 version.

It is a base install with no additional mods and all of my (crazier) hacks removed. I haven't tested it extensively, but it would probably be a better starting point.

here is the link:

http://stabinger.us/moodle198T.zip

I only found one JS error in IE so far, and that is for admins when editing the frontpage settings (but the HTML editor still works, so it is minor).

Let me know if it works for you.

As for nanogong in Tiny: I had to do some hardcoded hacks to get it to work. I will take a look at what I did to get it working. I know I had to edit file.php (in the main moodle dir) among other things. So it is not for the faint of heart...
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
Upgrade tinymce version to 3.3.5.1 and fixed a JS error.

Download here or use the url from above.

I'm working on getting the tinymce gzip compressor to work, but so far no luck...
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
Fixed safari support and fixed issue where filebrowser media selection was not being shown in tinymce preview window. Also arranged icons and tiny theme to reflect default moodle 2.0 arrangement. Download is above.
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Michael Spall -
Picture of Core developers Picture of Testers
John St,

Thank you for your work on this. Could you post a diff of your code from Moodle 1.9.8. Or could you post which version of Moodle you based your port off of, e.g., MOODLE_198 or MOODLE_19_WEEKLY from 2010-05-12, so that others could generate the diff.
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Michael Spall -
Picture of Core developers Picture of Testers
John St,

I think I figured it out. Was it based on MOODLE_19_WEEKLY from 2010-05-12?
In reply to Michael Spall

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
Here is the version:

Moodle 1.9.8+ (Build: 20100512).

Most of my mods were done in the lib/editor/ directory. Everything else, I tried to follow along with CLAMP's version of moodle/tinymce2. There are very minimal changes outside of the lib/editor folder. Larry notes the changes below.
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
Also, you'll need to add two lines to the end of your config file:

$CFG->validateforms = 'server';

$CFG->defaulthtmleditor='tinymce';

not sure if this was clear or not...
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Larry Elchuck -
John et al:

I downloaded your latest version of moodle198T and did a new install to get a look at the config file.

Then in my near virgin CVS Moodle 1.9.8+ build from last Wednesday, I replaced the following folders and files
/lib/editor/tinymce (entire folder) after renaming the original folder tinymce-old
/lib/adminlib.php
/lib/depreceatedlib.php
/lib/editorlib.php
/lib/moodlelib.php
/lib/weblib.php
/message/send.php
/admin/settings.php
admin/settings/appearance.php

as per your advice.

I also added other files not previously in /lib/editor

I did not find any tinymce lang file in lang/utf-8/ (in moodle198T ) to add in

After adding
$CFG->validateforms = 'server'; ...... (Don't know if I need this one or not)
$CFG->defaulthtmleditor='tinymce';
below
require_once("$CFG->dirroot/lib/setup.php");
in the config.php file, all appears to work (based on limited testing)

My questions:

1. Is there a tinymce lang file that belongs in the lang/utf-8 folder?

2. What impact will performing weekly CVS updates on this build have on the functionality of the editor?

So as not to congest this topic, rather than entering the CVS report results here, I'm attaching them instead. I omitted those lines that had nothing to do with newly modified/added code

The first run of a CVS update resulted in the output displayed in the first part of the attachment.

Discussion:
  • The ? files indicate new files and folders that will be ignored by future CVS updates ... GOOD
  • The U files in this case are ones that I assume were not in the moodle198T build and will be added (but once) to my CVS version. I conject that these should not impact the running of tinymce 3.
  • The C files show scripts that CVS can not replace, perhaps due to permission errors ... GOOD, I think .... I probably do not want them replaced with files that relate to tinymce 2.
  • The M file should retain the manually added change in future updates involving this file
Are there any flaws in my thinking?


The second CVS update that I conducted (also in the attachment) display the ?, C and M entries, but the U's are no longer present.

thanks
larry


In reply to Larry Elchuck

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
Larry,

There is a tinymce lang file, I must have missed it. I will attach it here and add it to the download. Note, it is from CLAMP's work, I have not done anything with it other than include it (whether it needs to be included or not...).

I don't know enough about the CVS process to help you there. I am a newbie in that area...
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Larry Elchuck -
Thanks John

Hopefully someone else can chime in on the CVS question

L
In reply to Blair F.

Re: Moodle 1.9 + TinyMCE - clean port

by Larry Elchuck -
I followed the instructions on this site (http://web2life.co.nz/content/tinymce-and-moodle-howto) and with a slight modification got it to work in my cvs version ... I instead copied the tinymce/jscripts/tiny_mce contents into the lib/editor/tiny_mce directory of the Moodle installation

There were a couple of issues in testing


When inserting images in Moodle with the TINYMCE 3 adaptation, it tries to find the image at eg /mod/file.php/156/razzie.png instead of at file.php/156/razzie.png ..... It results in a not found on this server error.

The path to the image also appears to have a relative (../) address

Also when trying to add a quicktime movie, it displays a "Selected file is not an image. Please select an image!" error message
In reply to Larry Elchuck

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
I created some mods so that nanogong works in my tinymce version.

Nanogong files are uploaded to a nanogong_files folder in the course moodledata dirs.

Here are the install directions:
Under admin security site policies- enable trusted content

add the nanogong filter to the /filters/ dir. Enable the nanogong filter in admin settings.

copy the nanogong folder into the tinymce plugins folder (/lib/editor/tinymce/jscripts/tiny_mce/plugins/)

replace tinymce.js.php (in /lib/editor/) with the tinymce.js.php in the download.

Let me know how it goes...

Link to zip
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Larry Elchuck -
Hi John

I installed the nanogong add-on as described in your previous post onto two moodle instances.

In one install, all works as expected, when a sample webpage was created with a nanogong entry. A folder called nanogong_files gets installed in the moodledata folder and the recorded file (.spx) gets created in the appropriate course number folder.

BTW, the html code for the activity shows reference to a .spx file within a course folder in nanogong_files.

<nanogong url="/2/nanogong_files/2/2010-05-20_164131.spx" caption="Hello World"><img src="http://localhost/m19/lib/editor/tinymce/jscripts/tiny_mce/plugins/nanogong/sound.gif" /></nanogong>

In the other, NO folder called nanogong_files gets installed in the moodledata folder.
Instead of just showing the speaker icon, it displays the login page between 2 copies of the speaker icon. See the attached file for the screenshot and the error message.

A look at the html code indicates that the sound file is not being created in a folder that it can be accessed.

<p><nanogong url="/&lt;!DOCTYPE html PUBLIC ">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />

etc.

  • I checked permissions and there does not seem to be an issue there.
  • I tried with the standard theme ... no difference.
  • I also manually created the nanogong_files folder (permissions 777) and that did not do it.

Any ideas?


Attachment nanogong_issue.gif
In reply to Larry Elchuck

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
weird... are you logged in as admin in the 2nd instance?

Take a look at the file record2.php in the nanogong folder (in the tinymce plugins folder). Find:

$dir = "$basedir$wdir";

change this to $dir = "1/nanogon_files";

(where 1 is the hardcoded course number) to test where the error might be. I had to use $SESSION->cal_course_referer; to get the course ID, and this may be the culprit in this instance for some reason...
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Larry Elchuck -
Same result John .... no nanogon_files folder created and the login page reference still occurs as illustrated in my previous post.

BTW .. these results are generated when the sample course is accessed using Firefox on a client computer. When the sample course is accessed using Firefox on the server computer, I get a "Failed to initialize audio recorder" error when the record button is pressed on the pop-up recorder. I believe the latter results from this server being a Mac Mini with no sound input capabilities.

Weird indeed!
In reply to Larry Elchuck

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
There was an undeclared variable being called in a function in the nanogong plugin for tinymce. That was causing a ripple effect so that might be the problem as well...

Anyway, I upgraded to the newest versions of the .jars, and modified the newest version of the filter and fixed the plugin variable issue... Link to files

Give the above zip a try. There were no changes to tinymce.js.php.
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Larry Elchuck -
Thanks for the updates, John

... Still the same issue .... It does allow me to perform a recording and play it back before I select Insert. Must be some strange permission issue on the server preventing Moodle from creating the folder and files.

A linux programmer has root access to the server and he may have done something that I'm not aware of that is causing the issue. I do notice a _spotlight hidden user that has custom privileges on the box and this may have something to do with it .... I'll check with him.

Both the working and non-working versions are running MAMP Pro (although the working one is MAMP Pro 1.9 and the non-working one is 1.8.4 ... could also be an issue, but I did not see anything in the log files for the non-working installation to trigger an error.

cheers
larry
In reply to Larry Elchuck

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
The other issue I have found is that if you have debug messages (and general php error messages) set to display, something breaks and it does not work.

So check your server>debugging> and set error reporting to none, and display errors to none.
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Geoffrey Rowland -
Picture of Plugin developers
Hi again John

Your Moodle 1.9.8 + TinyMCE + Nanogong setup is working well for us.

At the risk of stating the obvious, needed to 'Enable Trusted Content' in Administration > Security > Site Policies to stop the link to the Nanogong recording being stripped out on saving.

Thanks again for providing this to the community cool
In reply to Geoffrey Rowland

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
No problem! yes, the 'Enable Trusted Content' seems to be a requirement. I'm not sure if this also needs to be set for users lower than teacher in role defining as well (assuming someone wants users lower than teacher to use the plugin)...
In reply to Larry Elchuck

Re: Moodle 1.9 + TinyMCE - clean port

by Doug Loomer -
I just installed the TinyMCE editor on my sandbox install of Moodle 1.9+. Lots of good features, but I too am getting the "Selected file is not an image. Please select an image!" error message when I try to insert a video clip (same error if it is an .mov or .flv format - I haven't tried any other formats). Any idea how to fix this? I would really like to get this onto our r production server.
In reply to Doug Loomer

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
How are you trying to insert a media clip, through the media plugin? I tested it and it seems okay, the only issue is that when you click on the file you want to play, it does not close the browser window. You have to manually close it. Then, select the appropriate type of video file.

Can you get me a screenshot?
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
i fixed the issue where the filebrowser wasn't closing when inserting non-image media (i.e., video). You still need to manually select the video type after using the filebrowser to pick the video...

You can download at the URL above. For those keeping score at home, the file to change is:
/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlelink/link.php (attached).
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Doug Loomer -
I am trying to insert a media clip by selecting the insert media icon while in the text editor.

Insert Image 1

When I try to select a file/URL however, it tells me that the file I have selected is not an Image file.

Insert File 2


Any ideas about how to fix this would be appreciated.
In reply to Doug Loomer

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
Your screenshots are not displaying... I have not seen this issue, and can't replicate it. Please email me the screenshots at jstabinger@gmail.com when you have a chance.
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
Doug,

As we discussed, your tinymce integration is based on the template integration for older versions. Hope you decide to upgrade to 1.98 and try out the newer integration.

I added filebrowser fix from above into the main package. I also have a student uploading hack (as a separate package). It gives students in a course the ability to upload/select files/images through the filebrowser via a 'student' directory. They cannot get out of this directory or mod/delete files. Nevertheless it probably is risky so test with caution. All of the files are available here:

Link
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Doug Loomer -
John,

I have installed your TinyMCE enabled 1.9.8 on my Moodle sandbox and plan to install it on our production server this Thursday. At last! I would like to enable the html button so that those who want to do some code tweaking (read that me) can do so. Can you give me some idea how, or point me in the right direction?

Thanks, and thanks too for making this TinyMCE integration available.

Doug
In reply to Doug Loomer

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
Doug, there should be one there already. See attached image, it is the icon on the left (this could probably use some tweaking to make it more visible).
Attachment p2.png
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by d morte -
Hello all - I'm new to the conversation, but finding great success in the wonderful discussion. Due to your contributions, I have been able to install TinyMCE into my existing development 1.9.8 server.

Here is what I did:
1. I downloaded the 1.9.8 zip provided by John St. at http://www.stabinger.us/moodle198T.zip

2. I consulted the list of folders provided by Larry Elchuck on May 18th and replaced my existing folders with those from the zip file above.

3. I checked, and the TinyMCE editor is now present and functional in my moodle courses.


My questions:
1. I'm noticing that there are a few things not activated or otherwise absent from the editor. Specifically, I went looking for the word count feature and the dragmath integration. I had dragmath functional on the default Moodle editor (htmlArea?). Can anyone direct me on how to utilize DragMath and the Word Count?

2. I assume that I'm using TinyMCE2 - I don't know how to verify this though. When I check the full example found at http://tinymce.moxiecode.com/examples/full.php , I begin to salivate in anticipation. If I am indeed running TinyMCE2, is there any way for me to upgrade to Tiny3? If so, can you provide detailed instructions (I'm very new to this...)?

Many thanks to everyone who has contributed - your time and effort are greatly appreciated.
In reply to d morte

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
If you used the above, you are using tinymce 3 (the latest version actually).

Dragmath will work. First, replace your /lib/editor/tinymce.js.php with the attached file. Then you can download the tinymce dragmath plugin here.

Unzip and place the plugin in the tinymce plugins folder (lib/editor/tinymce/jscripts/tiny_mce/plugins/).

I don't know of any character counters but take a look at the tinymce forums to see if you can find anything.
Average of ratings: Useful (1)
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by d morte -
John St.,
That worked wonderfully! I now have TinyMCE, Dragmath, and a wordcount! Once you posted the tinymce.js.php, I was able to look at the file and understand how Dragmath was initiated, and thus was able to simply turn on the wordcount plugin that was already in the lib/editor/tinymce/jscripts/tiny_mce/plugins/ directory. Thank you for your help!

In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Doug Loomer -
I upgraded our Moodle site to 1.9.8 today and installed your TinyMCE module (including the student upload and the nanogong portions). Thanks so much for making this available! The only issue I seem to have is with Firefox using the nanogong. It is strange. I can use the editor to insert a nanogong recording box, but if I try to delete it, it won't go away. I can delete it if I use Safari. I am working, by the way, on a Mac using Snow Leopard. I haven't tested it in Windows. Just for information sake, I know it isn't the focus of your work, but Firefox is also failing to function properly on the nanogong activity module. It won't display the nanogong record box. Anyway, thanks again for making TinyMCE available for 1.9.8. It's great to have a better editor.
In reply to Doug Loomer

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
I've noticed some issue in FF (on mac) with nanogong as well. This seems more related to the new version of nanogong as I didn't have these issues with the older version of nanogong...
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Doug Loomer -
I upgraded my java install to version 1.6_20 (update 2 for Snow Leopard), and nanogong now works on my mac under Safari, Firefox, and Chrome. Unfortunately, Dragmath (also a java applet) is now broken. I get the following error:

Java Plug-in 1.6.0_20
Using JRE version 1.6.0_20-b02-279-10M3065 Java HotSpot(TM) 64-Bit Server VM
User home directory = /Users/dougloomer
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to
----------------------------------------------------


load: class Display/MainApplet.class not found.
java.lang.ClassNotFoundException: Display.MainApplet.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:219)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Plugin2ClassLoader.java:532)
at sun.plugin2.applet.Plugin2Manager.createApplet(Plugin2Manager.java:2940)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1444)
at java.lang.Thread.run(Thread.java:637)
Caused by: java.io.IOException: open HTTP connection failed:http://sasoc.saschina.org/lib/editor/common/dragmath/applet/classes/Display/MainApplet/class.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Applet2ClassLoader.java:537)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Applet2ClassLoader.java:51)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Applet2ClassLoader.java:192)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:189)
... 6 more
Exception: java.lang.ClassNotFoundException: Display.MainApplet.class

Also, TinyMCE in Moodle 1.9.8 doesn't work in Opera. Is that expected?

Any thoughts on either issue?
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Doug Loomer -
OK...forget the DragMath problem. I had an issue (self-created) with the path to DragMath in lib/editor/common. I fixed it and it works. So the good news for anyone using Mac is that upgrading to the most recent java (the upgrade is on the Apple site, not on the Sun site - and don't trust the Apple update checker, it lies and says that 10.6_17 is the latest version) makes nanogong and dragmath (and I would assume other applet based plugins) well. The url to the update for 10.6 (Snow Leopard) is http://support.apple.com/kb/dl972. There are also updates for 10.5.
In reply to Doug Loomer

Re: Moodle 1.9 + TinyMCE - clean port

by Bob Puffer -
Very good news indeed.

Am watching fervently hoping to get back to testing soon.
In reply to Bob Puffer

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
I'm working on a tinymce Google docs plugin for the moodle198/tinymce integration to allow users to link to (or embed) their google docs in the tinymce editor. It will also detect if you are using the moodlerooms google SSO and (attempt to) allow you to pick and use that account.

It probably isn't production ready, but if anyone here using the moodle198/tinymce integration wants to do some testing with the plugin, please download from below and send me any bug reports/ideas...

Link to zip
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
I fixed the files above for those using the moodlerooms google SSO. It should work almost seemlessly. The fix is in two files, google.php and dialog.php.

I only have access to one google ed domain, so my testing is limited but it seems to work well. Those not using the SSO are not effected by the bug or the fix (but might as well re-download just in case).
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by d morte -
I feel as though I've read about this problem somewhere already, but can't seem to locate the thread - my apologies for the double post if that is the case.


I have TinyMCE working in Moodle 1.9.9 and generally everything is working fairly well. I'm running into a bit of a problem with embedded media. Specifically, I'm trying to embed a video from our Cisco Show and Share DMS. The DMS provides an embed code that I can place within a label in Moodle, and the video plays perfectly. The problem occurs when I go in to edit the label text and find that TINYMCE has altered the coding, rendering it useless. I'm really at a loss as to what to do. A tangential question: I've attached a picture of my editor, any thoughts on I control the HTML toggle from the bottom left of the page versus the button that is embedded in the toolbar?

This code:
<script type="text/javascript" src="https://myhost.com/vportal/scripts/videoplayer/DmsEmbedLib.js"></script><script>document.write(dmsEmbed.getSimplePlayer("C-be993db7-af87-45ac-99e6-eca8ae448987:5","https://myhost.com/vportal/VideoPlayer.jsp?ccsid=C-be993db7-af87-45ac-99e6-eca8ae448987:5#","false",480));</script>

Becomes:
<script src="https://myhost.com/vportal/scripts/videoplayer/DmsEmbedLib.js" type="text/javascript"></script>
<script type="text/javascript">// <![CDATA[
&#010;&#010;document.write(dmsEmbed.getSimplePlayer("C-be993db7-af87-45ac-99e6-eca8ae448987:5","https://myhost.com/vportal/VideoPlayer.jsp?ccsid=C-be993db7-af87-45ac-99e6-eca8ae448987:5#","false",480));&#010;&#010;
// ]]></script>

As always, thank you!
Attachment tinytool.JPG
In reply to d morte

Re: Moodle 1.9 + TinyMCE - clean port

by Bob Puffer -
Having encountered this before I created a user with almost admin rights with a profile setting not to use the Richtext editor. I login as that user when I want to edit something that fits this description.
In reply to d morte

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
Do you have any code we can test with? Also, your 'after' code is only like that when you are editing, it gets returned to a more normal looking code on save and display.

So, perhaps by modding the allowed tags list in tinymce.js.php we can make the code work.
In reply to d morte

Re: Moodle 1.9 + TinyMCE - clean port

by John St -
Do you have any code we can test with? Also, your 'after' code is only like that when you are editing, it gets returned to a more normal looking code on save and display.

So, perhaps by modding the allowed tags list in tinymce.js.php we can make the code work.
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by d morte -
I have been working with John St. through email, and have some additional information to add to the discussion of my case of the changing code.

The problem exists both in IE and FF. The problem exists in Moodle 1.9.7, 1.9.8, and 1.9.9 (the only ones tested). The problem exists with default installations of Moodle, and with TinyMCE modified installations.

As noted by Bob Puffer, when I go into my profile and choose to use standard web forms, the code does not change between edits.

2. Upon closer examination of the problem code, it reveals that the code begins to be re-written with the CData tag only upon the action performed on the invoked javascript. Even more revealing is that the editor uses the // to comment out the operation being performed. In this case, the operation is document.write

Knowing this, it seems to me that this could imply that there is a safety feature of the Moodle editors - when code is brought from that database and put into the control area to be edited, a filter is executed that prevents the running of a javascript action within the area. It then rewrites the information to comment out the potential threat. This would be a logical safety feature as we wouldn't want students to be able to execute remote javascript on our pages.

Since the script almost always works the first time, before an edit occurs, it appears as though the problem originates from the command to bring that cell's data to the control area, or the reading of the data by the editor itself. Whatever the problem is, it can't be a simple "read" problem since the data is only being rewritten when loaded for editing.

Any thoughts?
In reply to John St

Re: Moodle 1.9 + TinyMCE - clean port

by Neil Birt -
Great work on the TinyMCE integration.

I have been able to get it all set up and running save for the 'insert/edit image' function. It brings up the dialog box just fine, but when you go to browse you get something like:

Fatal error: Call to undefined function print_string() in /home/---/public_html/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlelink/link.php on line 1


Thoughts on how to get this functioning?

Thanks
In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by Furio Petrossi -
I made some template in tinyMCE.
It is easy to add the template plugin button modifying moodle\lib\editor\tinymce\lib.php but the list of templates is blank: in original tinyMCE there's a variable template_external_list_url : "lists/template_list.js" that point to template's list (tinyMCETemplateList variable).

Can I implement template plugin in moodle/tinyMCE ?

Thank you,
Furio
In reply to Martín Langhoff

Re: Moodle 1.9 + TinyMCE - clean port

by James McLean -

Hi Folks,

At the University of South Australia, we've been using this TinyMCE patch on Moodle 1.9, but recently we ran into the iPad/iPhone issue. We have a number of Staff and Students who are using devices such as these to access our learnonline system but due to how Safari renders TinyMCE, the editor was unfortunately not operational in WYSIWYG mode.

I have generated a patch for Moodle 1.9.9 so that if you have implemented the TinyMCE patch and have users complaining that it doesn't work on their iPad/iPod/iPhone; this patch simply disables the HTML editor from displaying and defaults to a plain-text entry area when a user views Moodle on those devices.

Patch file attached.

In reply to James McLean

Re: Moodle 1.9 + TinyMCE - clean port

by Bob Puffer -

Looking hopefully toward November and IOS4 for the iPad.

In reply to Bob Puffer

Re: Moodle 1.9 + TinyMCE - clean port

by James McLean -

iOS4 on iPhone doesn't fix the issue, I don't think it will have any effect on the iPad, either.

In reply to Martín Langhoff

Vastus: Moodle 1.9 + TinyMCE - clean port

by Tõnis Tartes -
Picture of Core developers Picture of Plugin developers Picture of Testers Picture of Translators

Recently i made my own Moodle 1.9 + TinyMCE integration version with backward compatiblity to HTMLArea, so you can easly turn off TinyMCE in config.php.

First of all when i took the John St. version, i just couldnt replace my Moodle installation core files, because it would have overwritten my own changes, thats why i made a detailed documentation which core files to edit.

I used mostly the work done by John St, many many Thanks! (Great job!)
Also made some modifications..

I have written about that in my blog post:

http://www.t6nis.com/wp/moodle/moodle-1-9-tinymce-integration-dragmath-nanogong-included/

When you download, read the Readme.txt file before doing anything!

Hope it helps you!

In reply to Tõnis Tartes

Re: Vastus: Moodle 1.9 + TinyMCE - clean port

by Bob Puffer -

'd like to echo the praise for John St. 's work -- his integration of TinyMCE is in the CLAMP LAE version of Moodle.

In reply to Bob Puffer

Re:Moodle 1.9 + TinyMCE - Spellchecker issues with Internet Explorer

by Geoffrey Rowland -
Picture of Plugin developers

I would also like to thank all those involved in refining the Moodle 1.9 TinyMCE integration.

However, we have identified one particularly frustrating issue and would be grateful for any insights.

Using the spellchecker plugin, with PSpell (ASpell) or PSpellShell, and using Internet Explorer 8, we find that editor content is not saved using e.g. the [Post to...] button at the bottom of the form if the Spellchecker is active (some remaining red squiggles under misspelled words).

This not a problem with Firefox or other browsers. However most of our end-users use IE sad

The same issue has been documented here:

http://tinymce.moxiecode.com/forum/viewtopic.php?id=23414

Though, I have not yet worked out how to apply suggested fixes in the context of Moodle-TinyMCE PHP/JavaScript.

I have also noticed that the Save (disc icon) plugin added to the TinyMCE toolbar works fine (content is saved in IE even if the spellchecker is active) - just need this working for the form submit button too!

Grateful for any response, even if only to confirm that others see the same issue

Regards Geoff

In reply to Geoffrey Rowland

Re:Moodle 1.9 + TinyMCE - Spellchecker issues with Internet Explorer

by Geoffrey Rowland -
Picture of Plugin developers

Looks as if the same issue occurs in at least some instances with Moodle 2 and TinyMCE

MDL-24795

In reply to Geoffrey Rowland

Re:Moodle 1.9 + TinyMCE - Spellchecker issues with Internet Explorer

by Nacho Aguilar -

Great work!

I did. One question, where can I change language into  tinyMCE?

Thanks

In reply to Tõnis Tartes

Vastus: Moodle 1.9 + TinyMCE - clean port

by Tõnis Tartes -
Picture of Core developers Picture of Plugin developers Picture of Testers Picture of Translators

Little hint for those who don't want to enable trusted content but still want to have Tinymce + nanogong working - also for students!

in lib/weblib.php @ around line 2088

$def = $config->getHTMLDefinition(true);
$def->addElement('nanogong', 'Inline', 'Empty', 'I18N', array('url*'=>'URI', 'caption'=>'Text')); // Add this for Nanogong for moodle
$def->addElement('nolink', 'Block', 'Flow', array());                       // skip our filters inside

This modifies the HTML purifier to allow nanogong tags.

Average of ratings: Useful (1)
In reply to Tõnis Tartes

Re: Vastus: Moodle 1.9 + TinyMCE - clean port

by Corey Italiano -

I would like to use the Tiny MCE editor in my 1.9 instance, but the link above doesn't seem to work anymore. Can anyone point me to a link that works?

In reply to Corey Italiano

Re: Vastus: Moodle 1.9 + TinyMCE - clean port

by Corey Italiano -

I would like to use the Tiny MCE editor in my 1.9 instance, but the link above doesn't seem to work anymore. Can anyone point me to a link that works?

In reply to Corey Italiano

Re: Vastus: Moodle 1.9 + TinyMCE - clean port

by Bob Puffer -

If desired, refer to the CLAMP postings earlier in this thread... the LAE version uses TinyMCE -- latest release is based off 1.9.11.

In reply to Bob Puffer

Re: Vastus: Moodle 1.9 + TinyMCE - clean port

by Corey Italiano -

I have a custom Moodle instance, I do not wish to use CLAMP's version.