Firefox PHP

WYSIWYG Editor for Phorum (edit: CKEditor spamvertisement)

Posted by klgordon 
Re: WYSIWYG Editor for Phorum (edit: CKEditor spamvertisement)
October 13, 2010 02:10PM
The HTML module takes care of filtering out possibly malicious code. Using an editor without any protection would be bad, but that is not what Sreenadh is doing.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: WYSIWYG Editor for Phorum (edit: CKEditor spamvertisement)
October 13, 2010 02:28PM
Thanks! Do you have any remaining concerns? What would be your recommendation?
Re: WYSIWYG Editor for Phorum (edit: CKEditor spamvertisement)
October 14, 2010 04:56AM
Hi klgordon,
The following are the things I have done after uploading the ckEditor code to the forum root folder.

1) Enabling the CK Editor
I have located the
<textarea name="body" id="body" class="body" rows="15" cols="50">{POSTING->body}</textarea>

in posting.tpl and replaced that line with the code you supplied -


<textarea name="body" id="body" class="body" rows="15" cols="50">{POSTING->body}</textarea>
<script type="text/javascript" src="./ckeditor/ckeditor.js"></script>
<script type="text/javascript">
CKEDITOR.replace( 'body' );
</script>




But note the small difference in path of ckeditor.js used. Unlike what is mentioned in your post in Phorum community if the ckeditor is copied to phorum root directory the path mentioned in posting.tpl should be ""./ckeditor/ckeditor.js""
Now the CKEditor appeared in below BBCode editor for edit/reply/quote.

2) Disabling the BBCode related modules.
Then I have loggedin to the admin area and disabled all the BBCode related modules such as BBcode (version 2.0.10), BBcode Flash, BBcode GeSHi, BBcode Google, BBcode Tables, BBcode Video and Editor tools. Thus all BBCode related things gone and I am left with the posting textarea with CKEditor toolbar in it.
3) Enabling the HTML in Messages (version 3.0.0)
Download and install the module "HTML in Messages (version 3.0.0)"
Enable this module in admin section. In the module settings screen, in "Control who can enter HTML in forum messages" section choose "Anyone".

4) Customizing the CK Editor
Now I had customize CK Editor toolbar and formatting. So I opened the "config.js" of the CK Editor and defined the toolbars and formatting customizations in it. I have added the following lines to config.js since I didnot want the form related buttons and want to change the positioning of some CK Editor toolbar buttons

CKEDITOR.config.enterMode=CKEDITOR.ENTER_BR;
config.toolbar_Full =
[
['Source','-','Save','NewPage','Preview','-','Templates'],
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],'-',
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
//['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],'-',
['Maximize', 'ShowBlocks'],'-',
['Link','Unlink','Anchor'],
'/',
['Font','FontSize'],
['TextColor','BGColor'],
['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],'-',
['Styles','Format'],'-',
['About'],
];


Now it works excellent and anyone can post using CKEditor without any problem! Great!

5) One more problem!
But now I am faced with a problem. If I am using the "quote" feature, the CKEditor is removing all my line breaks and formatting from the quoted text and quashing it to a mess (without any formatting tags and line breaks)! There must be some work around for this problem- I am searching for it. If you know a solution for this "CK Editor Problem" please let me know. I am certain that there would a workaround using CK Editor configuration or hack or so for this "CK Editor problem".


Note You can visit our forum with CKEditor enabled at: [www.ancientindianastrology.com]
Thanks and Regards,
Sreenadh
Re: WYSIWYG Editor for Phorum (edit: CKEditor spamvertisement)
October 14, 2010 05:32AM
It is not a CK editor problem.

Normally, the BBcode module takes care of nifty quoting by applying the [quote] bbcode to it. Since the bbcode module is not available anymore, the basic text based quoting will be done by the Phorum core. This text based quoting does not contain HTML <br/> line breaks, causing all the lines in the quote to collapse into one, making it look bad.

You need to write a module that handles quoting in a way that works well for use in the HTML environment that you are in now. This module must implement the "quote" hook to take care of converting the quoted test into good looking HTML code.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: WYSIWYG Editor for Phorum (edit: CKEditor spamvertisement)
October 14, 2010 05:56AM
Hi Maurice Makaay,
Quote

It is not a CK editor problem.

Normally, the BBcode module takes care of nifty quoting by applying the
Quote

bbcode to it. Since the bbcode module is not available anymore, the basic text based quoting will be done by the Phorum core. This text based quoting does not contain HTML <br/> line breaks, causing all the lines in the quote to collapse into one, making it look bad.
Thanks for the valuable info.

Quote

You need to write a module that handles quoting in a way that works well for use in the HTML environment that you are in now. This module must implement the "quote" hook to take care of converting the quoted test into good looking HTML code.
Hmm.. that is not within my current capability. :(

But thanks for the clue! ;)
I have enabled the "BBcode (version 2.0.10)" module ON and left the "Editor tools (version 1.2.3)" module OFF. :) Now I don't have that BBCode toolbar, but the (BBCode will work) and the BBCode Toolbar will not appear. For me anyway as of now the outgoing mails goes without formatting and so, both the BBCodes and HTML will get stripped of in out going mails and will appear correctly in the forum pages. That seems to be fine as of now.
A question that comes to mind is - "Is there a way to strip-off only BBCodes from outgoing mails and not html?

Thanks Regards,
Sreenadh
Re: WYSIWYG Editor for Phorum (edit: CKEditor spamvertisement)
October 14, 2010 06:04AM
No, that is not an option. The stripping is done by first formatting the message into HTML and then stripping the HTML from the resulting message. So all HTML is removed in the end.

Stripping only the BBcodes is quite an adventure, where you'd have to dig deep into the tokenizing parser that I wrote for BBcode and where the parser would have to output a text representation for the BBcode tag. Plainly stripping all bbcode would be bad, since there might be BBcodes that contain interesting info.

The quote bbcode is a good example. That one would be perfect to be rendered into text, while still keeping a mentioning of the author of the quote in the text output. When bluntly stripping the bbcode tags, the autohr would get lost.

This is something that I have already planned work for in the 5.3 development tree. There, I want to be able to tell the formatting code what kind of output I expect. This will provide low level control over the output (html / text / collapsed text), instead of doing stripping of messages after rendering to HTML. Unfortunately, this is not something that will be available for 5.2, so if you want this solution, you will have to wait.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: WYSIWYG Editor for Phorum (edit: CKEditor spamvertisement)
October 14, 2010 06:22AM
Quote
Maurice Makaay
No, that is not an option.
But that does work for me!

Quote
Maurice Makaay
The stripping is done by first formatting the message into HTML and then stripping the HTML from the resulting message. So all HTML is removed in the end.
Here you are speaking about removing only BBCode from outgoing emails - I understand.

Quote
Maurice Makaay
Stripping only the BBcodes is quite an adventure, where you'd have to dig deep into the tokenizing parser that I wrote for BBcode and where the parser would have to output a text representation for the BBcode tag.
Hmm..Seems to be something complex that is not suitable for my simple brain. :(

Quote
Maurice Makaay
Plainly stripping all bbcode would be bad, since there might be BBcodes that contain interesting info.
The quote bbcode is a good example. That one would be perfect to be rendered into text, while still keeping a mentioning of the author of the quote in the text output. When bluntly stripping the bbcode tags, the autohr would get lost.
Yes, I agree.

Quote
Maurice Makaay
This is something that I have already planned work for in the 5.3 development tree. There, I want to be able to tell the formatting code what kind of output I expect. This will provide low level control over the output (html / text / collapsed text), instead of doing stripping of messages after rendering to HTML.
Good to know that.

Quote
Maurice Makaay
Unfortunately, this is not something that will be available for 5.2, so if you want this solution, you will have to wait.
That is fine.

Another Connected thought
For me, as of now, since I am not visibly providing the BBCode editor tools none in our forum would be using BBCode much except this quote BBCode etc. If I modify the files of module that sends out outgoing emails (for example Forum Subscription module), so that it won't be using the strip_tags function for outgoing message section, then I hope I would be possibly able to send out HTML formatted messages with just author related or so BBCode alone in those messages I hope. What would be your comment on that?

Thanks and regards,
Sreenadh
Re: WYSIWYG Editor for Phorum (edit: CKEditor spamvertisement)
October 14, 2010 06:27AM
Quote
Sreenadh OG
Quote
Maurice Makaay
No, that is not an option.
But that does work for me!

Okay, phrased differently: There is not an option available that you can enable to get the things working in the way that you want it. It is not a configuration option.

Quote
Sreenadh OG
For me, as of now, since I am not visibly providing the BBCode editor tools none in our forum would be using BBCode much except this quote BBCode etc. If I modify the files of module that sends out outgoing emails (for example Forum Subscription module), so that it won't be using the strip_tags function for outgoing message section, then I hope I would be possibly able to send out HTML formatted messages with just author related or so BBCode alone in those messages I hope. What would be your comment on that?

If you are planning on sending out HTML formatted messages, I would let the BBcode module do its job of formatting the [quote] tags into HTML code. If you want to prevent all other tags from being used in messages, you could disable those in the settings for the BBcode module, so that one will only handle [quote].


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: WYSIWYG Editor for Phorum (edit: CKEditor spamvertisement)
October 14, 2010 07:11AM
Quote
Maurice Makaay
Quote
Sreenadh OG
Quote
Maurice Makaay
No, that is not an option.
But that does work for me!

Okay, phrased differently: There is not an option available that you can enable to get the things working in the way that you want it. It is not a configuration option.
Sorry, I am not getting it. What I wanted to say was that -
1) I have enabled BBCode module without the editor tools module - It is working fine for me.
2) I have enabled the HTML in Messages (version 3.0.0) - It is working fine for me.
3) I have enabled the CK Editor - It is working fine for me.
Now whether I use CK Editor or BBCode for formatting it is appearing correctly in the forum. Mostly it is working the way I want itself - and that is why I am wondering what you mean by "That is not an option" etc. (Anyway the outgoing mails are stripped-off of both BBCode and HTML. If you are talking about that only then sorry for the misunderstanding)

Quote
Maurice Makaay
Quote
Sreenadh OG
For me, as of now, since I am not visibly providing the BBCode editor tools none in our forum would be using BBCode much except this quote BBCode etc. If I modify the files of module that sends out outgoing emails (for example Forum Subscription module), so that it won't be using the strip_tags function for outgoing message section, then I hope I would be possibly able to send out HTML formatted messages with just author related or so BBCode alone in those messages I hope. What would be your comment on that?

If you are planning on sending out HTML formatted messages, I would let the BBcode module do its job of formatting the [quote] tags into HTML code.
OK. Got it. So you mean to say it is a possible option - I think. Thanks for the guidance. I will leave the BBCode module enabled as is, and will try to remove the strip_tags function used in forum subscription module (message section) I use so that HTML messages would be send out. I hope I got it correctly - or is it not?
Regards,
Sreenadh
Re: WYSIWYG Editor for Phorum (edit: CKEditor spamvertisement)
October 14, 2010 07:26AM
Quote
Sreenadh OG
Now whether I use CK Editor or BBCode for formatting it is appearing correctly in the forum. Mostly it is working the way I want itself - and that is why I am wondering what you mean by "That is not an option" etc. (Anyway the outgoing mails are stripped-off of both BBCode and HTML. If you are talking about that only then sorry for the misunderstanding)

That's what I'm talking about. You requested info about stripping only the BBcode and I responded that there is no option available for that.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, only registered users may post in this forum.

Click here to login