Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Jan 2002
Posts: 218
Enthusiast
Enthusiast
Offline
Joined: Jan 2002
Posts: 218
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.

Sponsored Links
Joined: Jun 2002
Posts: 37
User
User
Offline
Joined: Jun 2002
Posts: 37
WrÅith,

Using your example, would it be possbile to use CENTER as another option when posting?

Joined: Jan 2002
Posts: 218
Enthusiast
Enthusiast
Offline
Joined: Jan 2002
Posts: 218
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.

Joined: Jun 2002
Posts: 37
User
User
Offline
Joined: Jun 2002
Posts: 37
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.

Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
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.

Sponsored Links
Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768
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>");

Joined: Jun 2002
Posts: 37
User
User
Offline
Joined: Jun 2002
Posts: 37
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);


Last edited by jerry; 08/14/2002 2:43 PM.
Joined: Jun 2002
Posts: 37
User
User
Offline
Joined: Jun 2002
Posts: 37
Ooops, I broked it?

-Fixed

Last edited by jerry; 08/14/2002 2:45 PM.

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
AllenAyres
AllenAyres
Texas
Posts: 21,079
Joined: March 2000
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)