Location: PHPKode > scripts > ContentBBcode Parser > docs.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>
<head>
<title>ContentBBcode Class</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<META name="robots" content="noindex, nofollow">
<META name="Author" content="Riklaunim">
<link rel="stylesheet" href="cbc.css" type="text/css">
</head><body><BR>
<B>About</B>: ContentBBcode - CBC is an advanced BBcode like tags, that can be used to easily add complex php scripts into page text.<BR><BR>
<B>Requirements</B>: PHP5, SQLite<BR>
<B>Author</B>: Piotr Malinski, hide@address.com<BR>
<B>License</B>: GPL<BR><BR>

<B>HOW TO USE</B><BR>
See test.php. The basic usage is:
<div class="code"><pre>
include 'content_bbcode.php';
$cb = new contentbb_code('admin', 'pass', 'database');
echo $cb->parse_content_bbcode($some_text);</pre></div>
The constructor takes 3 arguments - <B>contentbb_code(login, password, patch to sqlite db);</B> where login and password will be used to HTTP Authorization (add/edit CBC definitions) and the sqlite database stores the definitions. If you enter a patch to a non existing database - it will be created with the required table and two starting definitions.<BR><BR>

<B>CBC Definitions</B><BR>
There are two definitions in the suplied SQLite DB:<BR>
<B><code><span style="color: #000000">
&lt;rk:google&nbsp;site="DOMAIN"&nbsp;/&gt;</span>
</code></B> - inserts a google search form. "site" attribute is optional (if set it will search in entered domain).<BR>
<B><code><span style="color: #000000">
&lt;rk_geshi&nbsp;lang="LANG"&gt;Code&lt;/rk_geshi&gt;</span>
</code></B> - Will display highlighted code with line numbers. LANG - is the geshi lang file without *.php. <B>Note</B>: You need to get geshi and extract it to /external.<BR><BR>

<B>TYPES OF CBCs</B><BR>
<B>Single Tag</B>: rk:google is the example, starts witch <B><</B> and ends with <B> /></B> (<B>SPACE /></B>). If it has no attributes - TWO SPACES.<BR>
<B>Double Tag</B>: rk_geshi is the example.<BR><BR>

<B>HOW TO ADD/EDIT CBC DEFINITIONS?</B><BR>
- In each script that uses this class (has new contentbb_code....) add <B>?config=true</B> to the link to get to the config panel (HTTP Authorization). Then select "Managa ContentBBcode"<BR>
- You will see a list of Definitions and their description. You can delete them, edit them and add new ones.<BR><BR>

<U><B>Adding a definition is easy</B></U>:<BR>
<B>ID</B> - text id which the tag uses like rk:google -> google, rk_foo -> foo and so one :)<BR>
<B>Description</B> - describe how the tags works and how it looks like. USE [code]tag here[/code] to get the code to highlight/show<BR>
<B>Code</B> - the CBC Code :)<BR><BR>

You have an array $TAG_NAME like $google for rk:google which contains all rk:google tags. Use <B>foreach($TAG_NAME as $val)</B> and you will get:<BR>
<B>$text</B> - the text which is parsed, used when replacing a CBC tag with the result<BR>
<B>$val[0]</B> - the whole tag, replaced by the result <B>$text = str_replace($val[0], $result, $text);</B><BR>
<B>$val[1]['ATRIBUTE NAME']</B> - value of the atribute<BR>
<B>$val[2]</B> - the text between the tags in the Double Tag (for Double Tags only)<BR><BR>

<B>Simple example, adds two values from two attributes:</B><BR>
<code><span style="color: #000000">
<span style="color: #0000BB">&lt;?PHP<br /></span><span style="color: #007700">foreach(</span><span style="color: #0000BB">$add&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$return&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">][</span><span style="color: #DD0000">'bar'</span><span style="color: #007700">]&nbsp;+&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">][</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$text&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">str_replace</span><span style="color: #007700">(</span><span style="color: #0000BB">$val</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">],&nbsp;</span><span style="color: #0000BB">$result</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$text</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /></span><span style="color: #0000BB">?&gt;<br /></span>&lt;rk:add&nbsp;foo="4"&nbsp;bar="3"&nbsp;/&gt;</span>
</code>
 </body></html>
Return current item: ContentBBcode Parser