Location: PHPKode > scripts > PHP-Lib-Xtreme > php-lib-xtreme/doc/html/bbcode_example.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>PHP-Lib-Xtreme: BBCode-Example</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.3 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
<h1><a class="anchor" name="bbcode_example">BBCode-Example</a></h1><h2><a class="anchor" name="BBCode_Section">
Sections:</a></h2>
<ul>
<li><a class="el" href="bbcode_example.html#BBCode_Supported_BBCodes">Supported BB-Codes</a></li><li><a class="el" href="bbcode_example.html#BBCode_ExampleCode">Example Code</a></li><li><a class="el" href="bbcode_example.html#BBCode_HowToBuild_SmilieFile">How to build a smilie database file</a></li><li><a class="el" href="bbcode_example.html#BBCode_Links">Related links</a></li></ul>
<h2><a class="anchor" name="BBCode_Supported_BBCodes">
Supported BB-Codes</a></h2>
<table border="0" cellspacing="3" cellpadding="3">
<tr>
<td colspan="2"><b>General text: </b> </td></tr>
<tr>
<td><b> [b] [/b] </b></td><td>Text bold  </td></tr>
<tr>
<td><b> [big] [/big] </b></td><td>Text big  </td></tr>
<tr>
<td><b> [center] [/center] </b></td><td>Center text  </td></tr>
<tr>
<td><b> [color=RGB-CODE] [/color] </b></td><td>Colored text  </td></tr>
<tr>
<td><b> [i] [/i] </b></td><td>Text cursive  </td></tr>
<tr>
<td><b> [u] [/u] </b></td><td>Text underlined  </td></tr>
<tr>
<td><b> [sm] [/sm] </b></td><td>Text small <p>
</td></tr>
<tr>
<td colspan="2"><br>
<p>
</td></tr>
<tr>
<td colspan="2"><b>Tables: </b> </td></tr>
<tr>
<td><b> [table] [/table] </b></td><td>Table without border  </td></tr>
<tr>
<td><b> [bordertable] [/bordertable] </b></td><td>Table with border  </td></tr>
<tr>
<td><b> [cell] [/cell] </b></td><td>Table cell  </td></tr>
<tr>
<td><b> [row] [/row] </b></td><td>Table row <p>
</td></tr>
<tr>
<td colspan="2"><br>
<p>
</td></tr>
<tr>
<td colspan="2"><b>Listings: </b> </td></tr>
<tr>
<td><b> [*] </b></td><td>Marker point  </td></tr>
<tr>
<td><b> [block] [/block] </b></td><td>Listing with tabstops <p>
</td></tr>
<tr>
<td colspan="2"><br>
<p>
</td></tr>
<tr>
<td colspan="2"><b>Images: </b> </td></tr>
<tr>
<td><b> [img] [/img] </b></td><td>Show a image <p>
</td></tr>
<tr>
<td colspan="2"><br>
<p>
</td></tr>
<tr>
<td colspan="2"><b>Lines: </b> </td></tr>
<tr>
<td><b> [hr] </b></td><td>Draw a horizontal line <p>
</td></tr>
<tr>
<td colspan="2"><br>
 </td></tr>
</table>
<h2><a class="anchor" name="BBCode_ExampleCode">
Example Code</a></h2>
The following code demonstrates how to use the lib with a small example and some hints.<p>
<div class="fragment"><pre class="fragment">&lt;?php
<span class="comment">/*!***********************************************************************</span>
<span class="comment"> *************************************************************************</span>
<span class="comment"> * \file            bb-code-sample.php</span>
<span class="comment"> *</span>
<span class="comment"> * \author          Kai Klenovsek</span>
<span class="comment"> *</span>
<span class="comment"> * \date            First Step: 2004-12-22</span>
<span class="comment"> *</span>
<span class="comment"> * \note &lt;br&gt;</span>
<span class="comment"> * \b THE \bBEER-WARE \bLICENSE &lt;br&gt;</span>
<span class="comment"> *   As long as you retain this notice you can do whatever you want with &lt;br&gt;</span>
<span class="comment"> *   this stuff. If we meet some day, and you think this stuff is worth it, &lt;br&gt;</span>
<span class="comment"> *   you can buy me a beer in return. &lt;br&gt;</span>
<span class="comment"> *</span>
<span class="comment"> * \b NOTES: &lt;br&gt;</span>
<span class="comment"> *   </span>
<span class="comment">***************************************************************************</span>
<span class="comment">***************************************************************************/</span>

<span class="comment">// NOTE THAT THIS SAMPLE IS OPTIMIZED FOR XAMPP !!</span>

<span class="comment">// First we have to include the phplibex </span>
require(<span class="stringliteral">"../../phplibex.inc.php"</span>);
    
<span class="comment">/* $smilie_file  = Absolut path to the smilie database file</span>
<span class="comment"> * $smilie_url   = URL to the smilie folder with smilies</span>
<span class="comment"> * If you dont want any smilies let the vars empty !! */</span>
$smilie_file = <span class="stringliteral">"C:/apachefriends/xampp/htdocs/phplibex/samples/bb-code/bbcode_smilies/smilielist.db"</span>;
$smilie_url  = <span class="stringliteral">"http://localhost/phplibex/samples/bb-code/bbcode_smilies"</span>;

<span class="comment">// Load BB-Code examples into string variable</span>
$string  = <span class="stringliteral">"[big]General text:[/big]\r"</span>;
$string .= <span class="stringliteral">"[b]This text is bold.[/b]\r"</span>;
$string .= <span class="stringliteral">"[big]This text is big.[/big]\r\r"</span>;
$string .= <span class="stringliteral">"[center]This text is centered.[/center]\r"</span>;
$string .= <span class="stringliteral">"[i]This text is cursive.[/i]\r"</span>;
$string .= <span class="stringliteral">"[u]This text ist underlined.[/u]\r"</span>;

$string .= <span class="stringliteral">"\r[big]URLs:[/big]\r "</span>;
$string .= <span class="stringliteral">"www.sourceforge.net\r "</span>;
$string .= <span class="stringliteral">"http://phplibex.sourceforge.net\r "</span>;
$string .= <span class="stringliteral">"hide@address.com\r "</span>;
$string .= <span class="stringliteral">"ftp://nowhere.org\r "</span>;
  
$string .= <span class="stringliteral">"\r[big]Tables:[/big]\r"</span>;
$string .= <span class="stringliteral">"[table][row][cell]I`m a table without a border.[/cell][/row][/table]\r"</span>;
$string .= <span class="stringliteral">"[bordertable][row][cell]I`m a table with border.[/cell][/row][/bordertable]\r"</span>;
$string .= <span class="stringliteral">"[b][color=#ff0000]This text is colored in red and bold[/color][/b]\r"</span>;
  
$string .= <span class="stringliteral">"\r[big]Listings:[/big]\r"</span>;
$string .= <span class="stringliteral">"[*] &lt;-- This marker point\r"</span>;
$string .= <span class="stringliteral">"[block] 1.1 List1 \r1.2 List2[/block]"</span>;

$string .= <span class="stringliteral">"\r[big]Smilies:[/big]\r"</span>;
$string .= <span class="stringliteral">":( :) :D ;) :angry: :bounce: :confused: :cool: :evil: :headbang: :rolling:\r"</span>;
  
$string .= <span class="stringliteral">"\r[big]Horizontal line:[/big]\r"</span>;
$string .= <span class="stringliteral">"[hr]\r"</span>;

<span class="comment">// Lets create an object from class bbcode.</span>
$bbcode = <span class="keyword">new</span> <a class="code" href="classbbcode.html">bbcode</a>($string, $smilie_file, $smilie_url);

<span class="comment">/* Let us format the string with BB-Code into HTML code</span>
<span class="comment"> * Note that it is also possible to convert the string step by step.</span>
<span class="comment"> * For this take a look into the doc or class source. */</span>  
echo $bbcode-&gt;bbcode_bb2html( );

$error = $bbcode-&gt;bbcode_get_errorlist(); 

<span class="comment">// Echo error messages</span>
<span class="keywordflow">if</span> ( <span class="keyword">sizeof</span>($error) &gt;= 1 )
{
    echo <span class="stringliteral">"&lt;b&gt;Error Messages:&lt;/b&gt;&lt;br&gt;"</span>;
    <span class="keywordflow">for</span> ( $loop=0; $loop &lt;= <span class="keyword">sizeof</span>($error); $loop++ )
        echo $error[$loop].<span class="stringliteral">"&lt;br&gt;"</span>;    
}

?&gt;
</pre></div><h2><a class="anchor" name="BBCode_HowToBuild_SmilieFile">
How to build a smilie database file</a></h2>
<div class="fragment"><pre class="fragment">:(|cry.gif
:)|lol.gif
:D|lollol.gif
;)|zwinker.gif
:angry:|angry.gif
:bounce:|bounce.gif
:confused:|confused.gif
:cool:|cool.gif
:evil:|evil.gif
:headbang:|headbang.gif
:rolling:|rolling.gif
</pre></div><p>
The "|" sign is the seperate sign between the BB-Code (eg. ":cool:") and the name of the gif (eg. "cool1.gif"). The database file must be saved in the same folder like the smilie pictures.<h2><a class="anchor" name="BBCode_Links">
Related links</a></h2>
What is BB-Code: <a href="http://en.wikipedia.org/wiki/Bbcode">http://en.wikipedia.org/wiki/Bbcode</a> <hr size="1"><address style="align: right;"><small>Generated on Fri Aug 26 08:13:54 2005 for PHP-Lib-Xtreme by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.3 </small></address>
</body>
</html>
Return current item: PHP-Lib-Xtreme