[size=x-small]
Purpose of this thread:We have seen some hacks in the past and there is also stuff on the patch tracker over on sf.net. There are not many but some well established bb codes XOOPS is not supporting so far. This topic is to discuss whether we should add some more. At the end of the discussion we will put this into either the feature request or patches tracker to get it into the current XOOPS distribution if reasonable.[/size]
Whats this about?Lets get some more bb-codes supported in XOOPS
module.textsanitizer.php which are quite common these days but did not make their way into Xoops.
Sorry, what are bb-codes?BB-Codes are a simple replacement for html tags which serve two purposes:
1. you can allow the use of formatting without allowing access to html for the user
2. they are easier to remember and use
Lets say you create a reply in this thread. All the editor buttons that have an effect on the formatting will create a bb-code tag for your actions. Lets say you want to put some
bold text. You woulder enter your text, click on the b button and then the add button. The result would be:
Quote:
[ b ]your text[ /b ] in the editor and your text in the output. [size=x-small](note that the tags usually would have no blanks inside. This is just to show it here because otherwise they would not be displayed)[/size]
First: Lets see which codes we have right now as of XOOPS 2.0.15?Quote:
List of bb-codes:
siteurl --> creating a link with the Url of your XOOPS site plus the folder you entered and displays the given description text
url --> creating a link with the Url provided and displays the given description text
color --> change the font color
size --> change the font-size
font --> change the font type
email --> create an email adress link with a descriptive text displayed
b --> bold text formatting
i --> italic text formatting
u --> underlined text formatting
d --> deleted (aka strikethrough) text formatting
img --> linking an image into the post
quote --> create an outlined box containing a quote of text. This text will have linebreaks to fit into the page
code --> create an outlined box containing a quote of text. This could be program code but could also be anything else. The difference to the quote tag is that there will be no linebreaks. Depending on the handling this means it will either have scrollbars or break your layout if lines are too long to fit in the current screen width.
javascript --> insert a piece of jacascript
Which other ones are out there?Uhmm, well there are a lot of tags out there if you have a look around. Though some of them are browser specific (IE only) and some others are really used only in special cases so we should not go after finding everyone we could possibly add but see which ones would be commonly used and add only a limited number of new codes.
So which ones are you actually suggesting?First ones coming to mind would be the list tags. Pretty simple in use and i hate rebuilding list with indention and take care of every single list item manually.
Having a look at all the major forums you could come to the conclusion that the most common approch consists of the following syntax for list tags:
[list][/list] start/end an (unordered) list
[*] marks a list item
an advanced version of this would be support for ordered lists:
[lists=1] list items will be numbered (1,2,3,...)
[lists=a] list items will be given a letter a, b, ...
Another tag which has been discussed in this forum in the past would be the spoiler tag. This one works similar to the Quote code just that the textcolor will be set to the background color which makes it unreadable. To read the text you will have to select it. Something thats for example often used when you don´t want to spoil a movie end or a solution for someone else.
[spoiler][/spoiler] hides text by displaying it in the background color
A very simple one would be the use of the separator line which actually would be the only one without a closing tag.
[hr] displays a line
Ok, how do we do this?As mentioned in the top these tags are handled within the textsanitizer file so we would just need to add them there. We can steal some code from the existing ones so this should not be to difficult.
So i added those lines to the existing ones for the list tags: $patterns[] = "/[list](.*)[/list]/sU";
$replacements[] = '';
$patterns[] = "/[list=1](.*)[/list]/sU";
$replacements[] = '\1
';
$patterns[] = "/[list=a](.*)[/list]/sU";
$replacements[] = '\1
';
$patterns[] = '/[*](.*)r?n/sU';
$replacements[] = '\1';
// some guessing on this tag ... but it works ;)
$patterns[] = "/[hr](.*)/sU";
$replacements[] = '
';
As you can see i was not able to create a correct sanitizing of [*] so i had to use [li] instead. Guess someone will be able to help out here.[size=x-small][edit: found the required code in XOOPS 2.2.x sanitizer file.][/size]And those for the spoiler: $patterns[] = "/[spoiler]/sU";
$replacements[] = 'Spoiler: ';
$patterns[] = "/[/spoiler]/sU";
$replacements[] = '
';
--------------------------------------------------------
[size=x-small]
Notes:- spoiler tag was discussed here with different (more advanced) solutions by X-Bandit and dgbauer:
New Spoiler Tag Hack!However in this thread i stick to a simple definition since it only requires modifying the sanitizer. Providing a version that requires editing files not distributed with XOOPS core is not an option i think. Since those who prefer the more advanced versions would need to edit other files anyway they can then also hack the sanitizer.
- the sanitizer contained an old list regexpattern that was commented out. Seems someone wanted to do this in the past already
- there is a patch for syntax highlighting based on the language for the code tag in the patch tracker on sourceforge.net
(
[ 1054035 ] New bbcode - Source Code Highlighting )
Maybe ackbarr or someone else can pick it up and continue it. Would be a nice addition and if only supplied with a limited number of language files not blowing up XOOPS to much. (Should check with skalpa and dj first if thats an option though before putting work in it; and yes its gpl v2)[/size]
--------------------------------------------------------
Questions:- color in spoiler tag is currently hardcoded ... need to change this to be taken from theme css file
- more common tags on your mind?
- what about the speed impact with adding more tags to the sanitizer?
Sorry, this signature is experiencing technical difficulties. We will return you to the sheduled signature as soon as possible ...