UBB.Dev
Posted By: WrÅith [v5/v6] Underline Tag Add-on for UBB Code - 06/06/2002 8:43 PM
Name: Underline

Description: Allow your users to use underline in their posts. (Optional) Lets the user just click on a link and it will automatically insert the tags into the body of the message.

Example: Click here

Link: http://www.terranbbs.com/ubb/mods/6.0/Underline.txt

Note: This definitely falls under the category of something that should be included in the actual program. I've never understood why the underline code isn't included in either UBB.clasic or UBB.threads.
Posted By: jerry Re: [v5/v6] Underline Tag Add-on for UBB Code - 08/13/2002 5:38 PM
WrÅith,

Using your example, would it be possbile to use CENTER as another option when posting?
Posted By: WrÅith Re: [v5/v6] Underline Tag Add-on for UBB Code - 08/13/2002 6:11 PM
Sure. The code for that is really simple, so you could use the example above and just change the underline tags, text, etc. to center.
Posted By: jerry Re: [v5/v6] Underline Tag Add-on for UBB Code - 08/13/2002 8:22 PM
Here's what I have so far, any suggestions? Comments? See any mistakes?

ubbt.inc.php:
=============
Required - This will create the [underline, align left, center, align right, justify] tag parser

insert:

code:
// ---------------------------
// Begin Encode Underline Hack
$Body =str_replace("","<u>",$Body);
$Body =str_replace("
","</u>",$Body);

// ---------------------------
// Begin Encode Align Left Hack (default)
$Body =str_replace("[align left]","<p align=left>",$Body,"</p>");
$Body =str_replace("[/align left]","<p align=left>",$Body,"</p>");

// ---------------------------
// Begin Encode Center Hack
$Body =str_replace("[center]","<p align=center>",$Body,"</p>");
$Body =str_replace("[/center]","<p align=left>",$Body,"</p>");

// ---------------------------
// Begin Encode Align Right Hack
$Body =str_replace("[align right]","<p align=right>",$Body,"</p>");
$Body =str_replace("[/align right]","<p align=left>",$Body,"</p>");

// ---------------------------
// Begin Encode Justify Hack
$Body =str_replace("[justify]","<p align=justify>",$Body,"</p>");
$Body =str_replace("[/justify]","<p align=left>",$Body,"</p>");



before:

code:
// ---------------------------
// Do list elements



Now, so that the edit function will show UBBCode rather than HTML.. insert:

code:
// ---------------------------
// Convert the underline tags
$Body =str_replace("<u>","",$Body);
$Body =str_replace("</u>","
",$Body);

// ---------------------------
// Convert the align left tags
$Body =str_replace("<p align=left>","[align left]",$Body,"</p>");
$Body =str_replace("</align left>","[/align left]",$Body,"</p>");

// ---------------------------
// Convert the center tags
$Body =str_replace("<p align=center>","[center]",$Body,"</p>");
$Body =str_replace("</center>","[/center]",$Body,"</p>");

// ---------------------------
// Convert the align right tags
$Body =str_replace("<p align=right>","[align right]",$Body,"</p>");
$Body =str_replace("</align right>","[/align right]",$Body,"</p>");

// ---------------------------
// Convert the justify tags
$Body =str_replace("<p align=justify>","[justify]",$Body,"</p>");
$Body =str_replace("</justify>","[/justify]",$Body,"</p>");



before:

code:
// ---------------------------
// Conver the list markup



Would it be wise to add these changes to ubbt_instant_ubbcode.tmpl and instant_markup.php? Would need more room on the UBBCode Panel to add these changes.
This looks good, I bet there are people who want these markups that don't want to install the complete MarkupHack.

There shouldn't be a problem to add them to ubbt_instant_markup.tmpl, you could make four columns of links instead of three as it is now to save some space. You would also have to add the javascript code that inserts the markup into the textarea.
1) Some of the calls to str_replace() have four arguments. I thought that function only had three arguments?

$Body =str_replace("[align left]","<p align=left>",$Body,"</p>");

2) If you want the converted HTML to be XHTML-compliant, the attribute values need to be quoted (I think). For example:

$Body =str_replace("[align left]","<p align="left">",$Body,"</p>");
$Body =str_replace("<p align="left">","[align left]",$Body,"</p>");
Posted By: jerry Re: [v5/v6] Underline Tag Add-on for UBB Code - 08/14/2002 7:03 PM
Dave_L, thanks for your input. Would you agree with these changes:

code:
// ---------------------------
// Begin Encode Center, Align Left/Right/Justify Hack
$Body =str_replace("[align left]","<p align="left">",$Body);
$Body =str_replace("[/align left]","</p><p align="left"></p>",$Body);
$Body =str_replace("[center]","<p align="center">",$Body);
$Body =str_replace("[/center]","</p><p align="left"></p>",$Body);
$Body =str_replace("[align right]","<p align="right">",$Body);
$Body =str_replace("[/align right]","</p><p align="left"></p>",$Body);
$Body =str_replace("[justify]","<p align="justify">",$Body);
$Body =str_replace("[/justify]","</p><p align="left"></p>",$Body);



and this:

code:
// ---------------------------
// Convert the align left/center/right/justify tags
$Body =str_replace("<p align="left">","[align left]",$Body);
$Body =str_replace("</align left>","[/align left]",$Body);
$Body =str_replace("</p>[align left]</p>","[/align left]",$Body);
$Body =str_replace("</p><align left></p>","[/align left]",$Body);
$Body =str_replace("<p align="center">","[center]",$Body);
$Body =str_replace("</center>","[/center]",$Body);
$Body =str_replace("<p align="right">","[align right]",$Body);
$Body =str_replace("</align right>","[/align right]",$Body);
$Body =str_replace("<p align="justify">","[justify]",$Body);
$Body =str_replace("</justify>","[/justify]",$Body);

Posted By: jerry Re: [v5/v6] Underline Tag Add-on for UBB Code - 08/14/2002 7:51 PM
Ooops, I broked it?

-Fixed
© UBB.Developers