Misc Links
Forum Archive
News Archive
File DB
 

Ads
 

Advertisement
Age of Valor - Ultima Online Free Shard
AoS/SE/ML/Custom - advanced code, dedicated staff, peerless bosses, non overpowered customs + much much more
 

Latest Forum Topics
Possibly shutting down forum in near future
Posted by Red Squirrel
on Jan 21 2012, 5:19:43 pm

How to solve "ZoneMinder Console - Stopped"
Posted by Red Squirrel
on Jan 14 2012, 12:28:31 am

had fun on last day of 2011
Posted by rovingcowboy
on Jan 01 2012, 5:30:47 pm

Merry Christmas!
Posted by rovingcowboy
on Jan 01 2012, 5:11:32 pm

How to solve SMF directory not writable
Posted by Red Squirrel
on Oct 15 2011, 12:03:38 am

 

BBcode editor: PHP - The sensible approach
More with bbcode
By Jonathan Street


I’ll skip over setting PEAR up and fetching the HTML_BBCodeParser package and get straight into the actual use of the package.

First of all we’ll set up a form so that we can submit BBcode formatted text for conversion to html.

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">

    <textarea name="bbcode">
        <?php echo @$_POST['bbcode']; ?>
    </textarea>

</form>


In the same file, and I suggest at the top, you want to add the following code to handle the bbcode.

if (!empty($_POST['bbcode'])) {
 
    //bbcode has been submitted through the text area
   
    //Process it
   
    require_once 'HTML/BBCodeParser.php';
    $parser = new HTML_BBCodeParser();
   
    $parser->setText($_POST['text']);
    $parser->parse();
    echo $parser->getParsed();
 
}


This code block checks whether text has been submitted and if it has it creates an instance of the HTML_BBCodeParser class. It then uses three functions to get the text to be parsed, parse the text and then to return it. These three functions can be wrapped up into one function and I’ll use the faster method from now on. Before proceeding however a quick note on what this script is capable of doing. At present it is fairly limited. HTML_BBCodeParser is based around filters making it possible to create custom bbcode tags and significantly extend its capabilities. The reason why the above script can so far only handle bold, italic, underline, strikethrough, subscript and superscript is that only the first filter, Basic, is being used. To use other filters a configuration file is needed.

[HTML_BBCodeParser]

; possible values: single|double
; use single or double quotes for attributes
quotestyle  = double

; possible values: all|nothing|strings
; quote all attribute values, none, or only the strings
quotewhat   = all

; the opening tag character
open        = "["

; the closing tag character
close       = "]"

; possible values: true|false
; use xml style closing tags for single html tags (<img> or <img />)
xmlclose    = true

; possible values: a comma seperated list of filters
; comma seperated list of filters to use
filters     = Basic,Extended,Links,Images,Lists,Email


This is the complete configuration file I’m using but we only really need to discuss the last line dealing with the filters. Listed are the five filters that are supplied with HTML_BBCodeParser. To make use of this increased functionality we need to alter the code used previously.

if (!empty($_POST['bbcode'])) {
 
    //bbcode has been submitted through the text area
   
    //Process it
   
    require_once 'HTML/BBCodeParser.php';
    $parser = new HTML_BBCodeParser(parse_ini_file('BBCodeParser.ini'));
   
    echo $parser->qParse($_POST['bbcode']);
 
}


When instantiating the new HTML_BBCodeParser class we supply options by parsing the configuration ini file. This then allows us to use the full set of filters supplied.






Next Page
spacer
15113 Hits Pages: [1] [2] [3] 2 Comments
spacer


Latest comments (newest first)
Posted by Streety on August 08th 2006 (14:37)
What can I say richardj, I've learnt a lot since the first two articles.

I've just made a new post on my blog looking in detail at Text_Wiki_BBCode. It has some potential uses but HTML_BBCodeParser would still be my pick.

spacer
Posted by richardj on August 08rd 2006 (19:10)
QUOTE (Red Squirrel @ Aug 2 2006, 07:35 PM)
In truth, as complex as I thought the problem was, in reality it was probably more complex still.





blink.gif

user posted image em319.gif

spacer
View all comments
Post comment

Age of Valor Ultima Online Server

Top Articles Latest Articles
- What are .bin files for? (28303 reads)
- Text searching in linux with grep (22879 reads)
- SPFDisk (Special Fdisk) Partition Manager (17123 reads)
- Creating your own content management system with php (16875 reads)
- PSP User's Guide (16612 reads)
- How to Use MDADM Linux Raid (14870 reads)
- What is Cloud Computing? (14904 reads)
- Dynamic Forum Signatures (version 2) (15271 reads)
- Successfully Hacking your iPhone or iTouch (15981 reads)
- Ultima Online Newbie Guide (16430 reads)
corner image

This site best viewed in a W3C standard browser at 800*600 or higher
Site design by Red Squirrel | Contact
© Copyright 2012 Ryan Auclair/IceTeks, All rights reserved