Module: BBcode version 2 (complete rewrite)
Posted by Maurice Makaay
|
Re: Module: BBcode version 2 (complete rewrite) April 28, 2008 04:42AM |
Registered: 19 years ago Posts: 106 |
Hello.
Thank's for this mod.
French translations for the help languages file here. (choose your way : one utf8, one iso 8859-1). don't forget to create a folder called "french" (or the name of your general translation).
I put only help translation : the french language is yet in the package.
Mickael
my Phorum
Thank's for this mod.
French translations for the help languages file here. (choose your way : one utf8, one iso 8859-1). don't forget to create a folder called "french" (or the name of your general translation).
I put only help translation : the french language is yet in the package.
Mickael
my Phorum
|
Re: Module: BBcode version 2 (complete rewrite) May 12, 2008 02:20PM |
Admin Registered: 20 years ago Posts: 747 |
Hi Maurice,
according to structuring the language file and charset support I attach new german languages files in ISO-8859-1 and UTF-8. Please add them to the next release of your module.
Regards
Oliver
(Files removed. Oliver)
Using Phorum since 7/2000: forum.langzeittest.de (actual version 5.2.23)
Modules "Made in Germany" for version 5.2: Author_as_Sender, CarCost, Close_Topic, Conceal_Message_Timestamp,
Format_Email, Index_Structure, Mailing_List, Pervasive_Forum, Spritmonitor, Terms_of_Service and German_Language_Files_Package.
Edited 1 time(s). Last edit at 01/04/2011 03:23AM by Oliver Riesen.
according to structuring the language file and charset support I attach new german languages files in ISO-8859-1 and UTF-8. Please add them to the next release of your module.
Regards
Oliver
(Files removed. Oliver)
Using Phorum since 7/2000: forum.langzeittest.de (actual version 5.2.23)
Modules "Made in Germany" for version 5.2: Author_as_Sender, CarCost, Close_Topic, Conceal_Message_Timestamp,
Format_Email, Index_Structure, Mailing_List, Pervasive_Forum, Spritmonitor, Terms_of_Service and German_Language_Files_Package.
Edited 1 time(s). Last edit at 01/04/2011 03:23AM by Oliver Riesen.
|
Re: Module: BBcode version 2 (complete rewrite) May 15, 2008 03:47PM |
Admin Registered: 20 years ago Posts: 747 |
Hi Maurice,
uppercase img-tag doesn't work:
(Image removed. Oliver)
Regards
Oliver
[Now it's working]
Using Phorum since 7/2000: forum.langzeittest.de (actual version 5.2.23)
Modules "Made in Germany" for version 5.2: Author_as_Sender, CarCost, Close_Topic, Conceal_Message_Timestamp,
Format_Email, Index_Structure, Mailing_List, Pervasive_Forum, Spritmonitor, Terms_of_Service and German_Language_Files_Package.
Edited 2 time(s). Last edit at 01/04/2011 03:22AM by Oliver Riesen.
uppercase img-tag doesn't work:
(Image removed. Oliver)
Regards
Oliver
[Now it's working]
Using Phorum since 7/2000: forum.langzeittest.de (actual version 5.2.23)
Modules "Made in Germany" for version 5.2: Author_as_Sender, CarCost, Close_Topic, Conceal_Message_Timestamp,
Format_Email, Index_Structure, Mailing_List, Pervasive_Forum, Spritmonitor, Terms_of_Service and German_Language_Files_Package.
Edited 2 time(s). Last edit at 01/04/2011 03:22AM by Oliver Riesen.
|
Re: Module: BBcode version 2 (complete rewrite) May 15, 2008 03:53PM |
Admin Registered: 22 years ago Posts: 8,532 |
Yeah, I know. Version 2.0.4 implements case insensitivity for tags and argument names.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
|
Re: Module: BBcode version 2 (complete rewrite) June 04, 2008 08:07PM |
Admin Registered: 22 years ago Posts: 8,532 |
I wrote an implementation for reselecting text in the editor tools code and for keeping the textarea in its active scroll state. See changeset 3347. These changes will be in the next Phorum release. The code is installed on the phorum.org forums already, so if you want to test it, you can do that here.
Because I had some troubles in finding information about some problems that I had with MSIE, I write the solutions that I found down here, hoping that it will be useful to other programmers that are fighting the same kind of beast beast.
range.text.length counts \r characters, range.move() doesn't
I was able to find out why the construction with splitting on \n in the text was required. This is to not take \r characters into account when moving the selection range. For some odd reason, MSIE thinks it is funny to include the \r characters in the selection text length, but to no account for them when moving the boundaries of a selection. So if you'd have this text:
The solution for this in Optimal's code was to split on "\n". Technically this could work, because a "\r" will normally be followed by a "\n" character. It's a bit more clean to split on "\r", so you actually can count the specific character that is giving us troubles here.
The code for computing the correction to apply to selection range movements over a random string "foo" is:
MSIE problem when selecting newlines at the end of line
Another fun problem that I tackled in the new code, is strange behavior when you included the newline in a text selection. MSIE allows you to do this and will show the newline selection like a selected space at the end of the line. The nasty thing here is that MSIE does not consistently include the newline in the selection. If you replace the selection with a new text, it will overwrite the ending newline character. However, when looking at the selection's text contents, the additional newline is not visible in the text. Therefore, the javascript cannot know whether to handle newlines or not and it will lose newlines when adding tags to a selected piece of tags. E.g. if you had selected the following:
However, when assigning range.text with "something else", the fragment would turn into this:
Here is the resulting code:
All this code can be seen in action in the Phorum file: mods/editor_tools/editor_tools.js
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
Edited 3 time(s). Last edit at 06/05/2008 01:25AM by Maurice Makaay.
Because I had some troubles in finding information about some problems that I had with MSIE, I write the solutions that I found down here, hoping that it will be useful to other programmers that are fighting the same kind of beast beast.
range.text.length counts \r characters, range.move() doesn't
I was able to find out why the construction with splitting on \n in the text was required. This is to not take \r characters into account when moving the selection range. For some odd reason, MSIE thinks it is funny to include the \r characters in the selection text length, but to no account for them when moving the boundaries of a selection. So if you'd have this text:
A text that has\r\n
carriage return characters\r\n
in it.
then a selection from "that" up to and including "carriage" would be the text "that has\r\ncarriage" with a total of 18 characters. If you would have a selection that has its start right after "carriage", then it would be logical to asume that range.moveStart('character', -18) would move the selection start back to the start of the word "that". Unfortunately, that is not the case. The \r is ignored for the range moving, so the selection start would be one character more towards the start of the text.
The solution for this in Optimal's code was to split on "\n". Technically this could work, because a "\r" will normally be followed by a "\n" character. It's a bit more clean to split on "\r", so you actually can count the specific character that is giving us troubles here.
The code for computing the correction to apply to selection range movements over a random string "foo" is:
// -1 is required, since the split parts array will always be one more
// than the number of \r characters in the string (if you cut a string at
// one point, you will end up with two parts).
var correction = foo.split('\r').length - 1;
MSIE problem when selecting newlines at the end of line
Another fun problem that I tackled in the new code, is strange behavior when you included the newline in a text selection. MSIE allows you to do this and will show the newline selection like a selected space at the end of the line. The nasty thing here is that MSIE does not consistently include the newline in the selection. If you replace the selection with a new text, it will overwrite the ending newline character. However, when looking at the selection's text contents, the additional newline is not visible in the text. Therefore, the javascript cannot know whether to handle newlines or not and it will lose newlines when adding tags to a selected piece of tags. E.g. if you had selected the following:
the text that has\r\n
carriage return, which is
Then the range.text would contain "that has" and not "that has\r\n".
However, when assigning range.text with "something else", the fragment would turn into this:
the text something elsecarriage return, which is
Because it's not possible to extend the selection to include the newline, I had to fallback to a different method in the Editor Tools code. I now move the end of the selection range back and do that as often as possible, without seeing a change in the range.text string length. If no change is detected, then apparently a selected newline was skipped and another step can be taken in moving the selection back.
Here is the resulting code:
// Get the currently selected text.
ta.focus();
range = document.selection.createRange();
// Fumbling to work around newline selections at the end of
// the text selection. MSIE does not include them in the
// range.text, but it does replace them when setting range.text
// to a new value :-/
var virtlen = range.text.length;
if (virtlen > 0) {
while (range.text.length == virtlen) {
range.moveEnd('character', -1);
}
range.moveEnd('character', +1);
}
All this code can be seen in action in the Phorum file: mods/editor_tools/editor_tools.js
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauceEdited 3 time(s). Last edit at 06/05/2008 01:25AM by Maurice Makaay.
|
Re: Module: BBcode version 2 (complete rewrite) June 24, 2008 04:13PM |
Registered: 23 years ago Posts: 687 |
Having lists is a killer feature for me, thanks very much!
/\dam
--
My notable Phorum sites:
Movie Deaths Database - "review comments" system mostly powered by Phorum
Learn Chinese! - integrated forum quiz
/\dam
--
My notable Phorum sites:
Movie Deaths Database - "review comments" system mostly powered by Phorum
Learn Chinese! - integrated forum quiz
|
Re: Module: BBcode version 2 (complete rewrite) June 24, 2008 04:36PM |
Admin Registered: 22 years ago Posts: 8,532 |
You're welcome. I am quite
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
- fond of
- a sucker for
- cheerful about
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
|
Re: Module: BBcode version 2 (complete rewrite) July 01, 2008 07:14AM |
Registered: 23 years ago Posts: 687 |
This module seems to have at least one line of code that is PHP5 only (apologies if this is made clear elsewhere, but it was news to me).
It is called when you add an e-mail address with a subject heading and then click preview. On a PHP4 system this causes the following error:
The fix is to paste the following into bbcode/api.php:
Note, the above works on my servers, but see the comments on [uk.php.net] for alternative functions if it does not work on yours.
Hope this helps someone,
/\dam
Edit Maurice: changed "PHP4 only" to "PHP5 only" in the first sentence
--
My notable Phorum sites:
Movie Deaths Database - "review comments" system mostly powered by Phorum
Learn Chinese! - integrated forum quiz
Edited 1 time(s). Last edit at 07/01/2008 09:16AM by Maurice Makaay.
It is called when you add an e-mail address with a subject heading and then click preview. On a PHP4 system this causes the following error:
Fatal error: Call to undefined function: htmlspecialchars_decode() in .[..]/phorum/mods/bbcode/api.php on line 1095
The fix is to paste the following into bbcode/api.php:
if (!function_exists('htmlspecialchars_decode')) {
function htmlspecialchars_decode($text)
{
return strtr($text, array_flip(get_html_translation_table(HTML_SPECIALCHARS)));
}
}
Note, the above works on my servers, but see the comments on [uk.php.net] for alternative functions if it does not work on yours.
Hope this helps someone,
/\dam
Edit Maurice: changed "PHP4 only" to "PHP5 only" in the first sentence
--
My notable Phorum sites:
Movie Deaths Database - "review comments" system mostly powered by Phorum
Learn Chinese! - integrated forum quiz
Edited 1 time(s). Last edit at 07/01/2008 09:16AM by Maurice Makaay.
|
Re: Module: BBcode version 2 (complete rewrite) July 01, 2008 09:41AM |
Admin Registered: 22 years ago Posts: 8,532 |
This module was developed using PHP5.2, which is the recommended minimum for Phorum 5. I don't run PHP4 at all on any of my servers, so I didn't notice this one.
Although you should of course be running a more recent version of PHP, I added a work-around for this problem in the code for the module. If you could please check if 2.0.7 fixes the problem for you out-of-the-box, that would be nice. Because I'm quite busy at the moment, I didn't care to test the changes out myself =)
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
Although you should of course be running a more recent version of PHP, I added a work-around for this problem in the code for the module. If you could please check if 2.0.7 fixes the problem for you out-of-the-box, that would be nice. Because I'm quite busy at the moment, I didn't care to test the changes out myself =)
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
|
Re: Module: BBcode version 2 (complete rewrite) July 01, 2008 10:37AM |
Registered: 23 years ago Posts: 687 |
It seems to work a treat, thank you!
Note to other users - I needed to go into admin and resave my module settings in order for the preview page to render correctly. Prior to doing this, email links with embedded subjects worked when posted, but appeared garbled in preview.
@Maurice: would love to upgrade to PHP5, but I have a lot of client sites that I can't risk breaking, and no time to do a proper controlled upgrade. I still have one large Phorum to upgrade from 5.1 to 5.2 :-(
/\dam
--
My notable Phorum sites:
Movie Deaths Database - "review comments" system mostly powered by Phorum
Learn Chinese! - integrated forum quiz
Note to other users - I needed to go into admin and resave my module settings in order for the preview page to render correctly. Prior to doing this, email links with embedded subjects worked when posted, but appeared garbled in preview.
@Maurice: would love to upgrade to PHP5, but I have a lot of client sites that I can't risk breaking, and no time to do a proper controlled upgrade. I still have one large Phorum to upgrade from 5.1 to 5.2 :-(
/\dam
--
My notable Phorum sites:
Movie Deaths Database - "review comments" system mostly powered by Phorum
Learn Chinese! - integrated forum quiz
Sorry, only registered users may post in this forum.

