phpBB

Development Wiki

Difference between revisions of "Tutorial.Parsing text"

From phpBB Development Wiki

m
(Edits from Confluence)
 
(19 intermediate revisions by 10 users not shown)
Line 1: Line 1:
[http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=356 free tracfone ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=92&forum=13 clomid online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=344 ativan] [http://news.engin.brown.edu/forums/thread-view.asp?tid=155 buy xanax] [http://news.engin.brown.edu/forums/thread-view.asp?tid=178 buy nexium] [http://wc1.worldcrossing.com/WebX/.1de60a04 sonyericsson ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=182 cheap clomid] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=82&forum=13 adipex online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=343 cialis] [http://news.engin.brown.edu/forums/thread-view.asp?tid=170 cheap hydrocodone] [http://news.engin.brown.edu/forums/thread-view.asp?tid=169 levitra online] [http://wc1.worldcrossing.com/WebX/.1de609f3 midi ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=111&forum=13 order lisinopril] [http://news.engin.brown.edu/forums/thread-view.asp?tid=224 wwe ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=153 phentermine online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=147&forum=13 tracfone ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=181 cheap sildenafil] [http://news.engin.brown.edu/forums/thread-view.asp?tid=212 free verizon ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=223 midi ringtones] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=335 phentermine online] [http://wc1.worldcrossing.com/WebX/.1de60a00 cheap rivotril] [http://wc1.worldcrossing.com/WebX/.1de60a0a vicodin] [http://news.engin.brown.edu/forums/thread-view.asp?tid=187 cheap celexa] [http://wc1.worldcrossing.com/WebX/.1de609eb free funny ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=197 cheap flexeril] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=105&forum=13 hoodia online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=188 cheap tenuate] [http://news.engin.brown.edu/forums/thread-view.asp?tid=180 prozac online] [http://wc1.worldcrossing.com/WebX/.1de60a05 sprint ringtones] [http://wc1.worldcrossing.com/WebX/.1de609f9 order norco] [http://wc1.worldcrossing.com/WebX/.1de609f2 online meridia] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=145&forum=13 free sprint ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=96&forum=13 diazepam online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=338 fioricet] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=358 free mp3 ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a21 paxil online] [http://wc1.worldcrossing.com/WebX/.1de60a31 buy zanaflex] [http://wc1.worldcrossing.com/WebX/.1de609de cheap alprazolam] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=141&forum=13 cheap soma] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=342 order diazepam] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=157&forum=13 free wwe ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=161&forum=13 but zoloft] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=112&forum=13 lorazepam online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=124&forum=13 online norco] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=355 free ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=88&forum=13 carisoprodol online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=360 free qwest ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=167 clonazepam online] [http://wc1.worldcrossing.com/WebX/.1de60a0e celexa online] [http://wc1.worldcrossing.com/WebX/.1de609e4 cheap clonazepam] [http://wc1.worldcrossing.com/WebX/.1de60a17 buy lipitor] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=123&forum=13 free nokia ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=184 cheap lisinopril] [http://wc1.worldcrossing.com/WebX/.1de60a24 propecia online] [http://wc1.worldcrossing.com/WebX/.1de609f8 nokia ringtones] [http://wc1.worldcrossing.com/WebX/.1de609fd free punk ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=154 buy carisoprodol] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=339 cheap ultram] [http://wc1.worldcrossing.com/WebX/.1de60a34 sony ericsson ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=202 free tracfone ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=199 cheap zyban] [http://news.engin.brown.edu/forums/thread-view.asp?tid=198 cheap hoodia] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=332 cheap tramadol] [http://wc1.worldcrossing.com/WebX/.1de60a1d cingular ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=107&forum=13 jazz ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=219 alltel ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=101&forum=13 cheap flexeril] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=359 free nextel ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a15 free kyocera ringtones] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=363 free samsung ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=117&forum=13 free motorola ringtones] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=346 meridia online] [http://wc1.worldcrossing.com/WebX/.1de60a30 xenical online] [http://wc1.worldcrossing.com/WebX/.1de60a03 free sony ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=168 paxil online] [http://wc1.worldcrossing.com/WebX/.1de60a01 free sagem ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=160 buy ativan] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=136&forum=13 cheap rivotril] [http://wc1.worldcrossing.com/WebX/.1de609fb order ortho] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=89&forum=13 cheap celexa] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=139&forum=13 free sharp ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=163 cheap adipex] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=125&forum=13 cheap ortho] [http://wc1.worldcrossing.com/WebX/.1de609ee hydrocodone] [http://news.engin.brown.edu/forums/thread-view.asp?tid=177 cheap propecia] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=91&forum=13 cingular ringtones] [http://wc1.worldcrossing.com/WebX/.1de609f7 free nextel ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=215 sagem ringtones] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=347 adipex] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=132&forum=13 free punk ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=97&forum=13 buy didrex] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=144&forum=13 free sonyericsson ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=179 didrex online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=158 cheap diazepam] [http://wc1.worldcrossing.com/WebX/.1de60a25 free samsung ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a26 free sharp ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=162 meridia online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=217 free mono ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=152 valium online] [http://wc1.worldcrossing.com/WebX/.1de609ec buy hgh] [http://news.engin.brown.edu/forums/thread-view.asp?tid=205 nextel ringtones] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=357 funny ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=191 cheap lortab] [http://wc1.worldcrossing.com/WebX/.1de60a2b cheap ultracet] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=153&forum=13 viagra online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=183 albuterol] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=349 vicodin online] [http://wc1.worldcrossing.com/WebX/.1de60a18 motorola ringtones] [http://wc1.worldcrossing.com/WebX/.1de609f0 cheap lorazepam] [http://wc1.worldcrossing.com/WebX/.1de60a12 ericsson ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a19 mp3 ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=216 free sonyericsson ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=161 cheap viagra] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=95&forum=13 cyclobenzaprine online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=192 but vigrx] [http://wc1.worldcrossing.com/WebX/.1de60a0d free wwe ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=185 zoloft online] [http://wc1.worldcrossing.com/WebX/.1de609e3 clomid online] [http://wc1.worldcrossing.com/WebX/.1de60a13 order fioricet] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=138&forum=13 free samsung ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=83&forum=13 cheap albuterol] [http://wc1.worldcrossing.com/WebX/.1de60a29 tramadol online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=173 xenical online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=350 alprazolam online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=93&forum=13 cheap clonazepam] [http://news.engin.brown.edu/forums/thread-view.asp?tid=204 free mp3 ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=164 order norco] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=337 online xanax] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=119&forum=13 mtv ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=206 free qwest ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=151&forum=13 valium online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=140&forum=13 sildenafil online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=162&forum=13 cheap zyban] [http://news.engin.brown.edu/forums/thread-view.asp?tid=166 alprazolam online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=353 levitra online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=333 soma online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=189 cheap ortho] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=159&forum=13 cheap xenical] [http://wc1.worldcrossing.com/WebX/.1de60a36 zyban online] [http://wc1.worldcrossing.com/WebX/.1de60a23 free polyphonic ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=208 motorola ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a1f cheap lisinopril] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=137&forum=13 sagem ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a1b music ringtones] [http://wc1.worldcrossing.com/WebX/.1de609e0 cheap ativan] [http://news.engin.brown.edu/forums/thread-view.asp?tid=229 jazz ringtones] [http://wc1.worldcrossing.com/WebX/.1de609e5 cool ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=99&forum=13 free ericsson ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a07 tracfone ringtones] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=348 but norco] [http://wc1.worldcrossing.com/WebX/.1de60a09 cheap viagra] [http://news.engin.brown.edu/forums/thread-view.asp?tid=218 free sony ericsson ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=121&forum=13 nexium online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=126&forum=13 cheap paxil] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=94&forum=13 free cool ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=154&forum=13 cheap vicodin] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=108&forum=13 kyocera ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a14 free jazz ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=210 sprint ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a0f cialis online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=175 cyclobenzaprine online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=200 free nokia ringtones] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=352 cheap paxil] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=110&forum=13 lipitor online] [http://wc1.worldcrossing.com/WebX/.1de609e6 cyclobenzaprine online] [http://wc1.worldcrossing.com/WebX/.1de60a33 prozac online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=157 ultram online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=190 cheap pharmacy online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=195 cheap rivotril] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=143&forum=13 free sony ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=100&forum=13 fioricet online] [http://wc1.worldcrossing.com/WebX/.1de60a06 cheap tenuate] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=345 viagra online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=135&forum=13 real ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=193 zanaflex online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=115&forum=13 midi ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=87&forum=13 ativan online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=351 clonazepam online] [http://wc1.worldcrossing.com/WebX/.1de60a11 diethylpropion online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=152&forum=13 free verizon ringtones] [http://wc1.worldcrossing.com/WebX/.1de609ea free free ringtones] [http://wc1.worldcrossing.com/WebX/.1de609fa free online pharmacy] [http://news.engin.brown.edu/forums/thread-view.asp?tid=151 soma online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=102&forum=13 free free ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=155&forum=13 vigrx] [http://wc1.worldcrossing.com/WebX/.1de609f1 lortab online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=226 free sony ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a0c buy wellbutrin] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=104&forum=13 hgh online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=225 kyocera ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=227 ericsson ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=118&forum=13 mp3 ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a2c but ultram] [http://wc1.worldcrossing.com/WebX/.1de609e1 cheap carisoprodol] [http://news.engin.brown.edu/forums/thread-view.asp?tid=214 free cingular ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=171 cheap ambien] [http://news.engin.brown.edu/forums/thread-view.asp?tid=228 free mtv ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a2d valium online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=211 free music ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=116&forum=13 mono ringtones] == Parsing text with BBCodes, smilies etc. ==
+
== Database fields ==
 +
phpBB3 uses the following database fields where BBCode is allowed (forum description, forum rules, post content, ...):
 +
* '''foo''' - the text itself
 +
* '''foo_bbcode_uid''' - a randomly generated unique identifier to mark the bbcodes identified by the first pass encoding (which uses regular expressions) so they can be replaced using the quicker str_replace in the second pass.
 +
* '''foo_bbcode_bitfield''' - a [[wikipedia:Bit field|bit field]] containing the information which bbcode is used in the text so only the relavant ones need to be loaded from the database.
 +
* '''foo_options''' - a bit field containing the information whether bbcode, smilies and magic urls are enabled (OPTION_FLAG_BBCODE, OPTION_FLAG_SMILIES and OPTION_FLAG_LINKS). Sometimes you will find this separated into enable_bbcode, enable_smilies and enable_magic_url
 +
 
 +
column names vary from table to table.
 +
 
 +
== Parsing text with BBCodes, smilies etc. ==
  
 
=== Inserting text to the DB ===
 
=== Inserting text to the DB ===
Line 33: Line 42:
 
     'bbcode_bitfield'  => $bitfield,
 
     'bbcode_bitfield'  => $bitfield,
 
     'enable_bbcode'    => $allow_bbcode,
 
     'enable_bbcode'    => $allow_bbcode,
     'enable_urls'       => $allow_urls,
+
     'enable_magic_url' => $allow_urls,
 
     'enable_smilies'    => $allow_smilies,
 
     'enable_smilies'    => $allow_smilies,
 
);
 
);
Line 43: Line 52:
  
 
=== Displaying text downloaded from DB ===
 
=== Displaying text downloaded from DB ===
This example uses the bbcode_options field which is used in forums and groups description parsing.
+
This example uses the bbcode_options field which is used in forums and groups description parsing:
 
<php>
 
<php>
 
$sql = 'SELECT text, bbcode_uid, bbcode_bitfield, bbcode_options
 
$sql = 'SELECT text, bbcode_uid, bbcode_bitfield, bbcode_options
Line 56: Line 65:
 
</php>
 
</php>
  
This uses the enable_bbcode, enable_smilies and enable_magic_url flags which can be used instead of the above method and is used in parsing posts.
+
 
 +
The next one uses the enable_bbcode, enable_smilies and enable_magic_url flags which can be used instead of the above method and is used in parsing posts:
 
<php>
 
<php>
 
$sql = 'SELECT text, bbcode_uid, bbcode_bitfield, enable_bbcode, enable_smilies, enable_magic_url
 
$sql = 'SELECT text, bbcode_uid, bbcode_bitfield, enable_bbcode, enable_smilies, enable_magic_url
Line 64: Line 74:
 
$db->sql_freeresult($result);
 
$db->sql_freeresult($result);
  
$row['bbcode_options'] = (($row['enable_bbcode']) ? OPTION_FLAG_BBCODE : 0)
+
$row['bbcode_options'] = (($row['enable_bbcode']) ? OPTION_FLAG_BBCODE : 0) +
     (($row['enable_smilies']) ? OPTION_FLAG_SMILIES : 0)  
+
     (($row['enable_smilies']) ? OPTION_FLAG_SMILIES : 0) +
 
     (($row['enable_magic_url']) ? OPTION_FLAG_LINKS : 0);
 
     (($row['enable_magic_url']) ? OPTION_FLAG_LINKS : 0);
 
$text = generate_text_for_display($row['text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']);
 
$text = generate_text_for_display($row['text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']);
Line 85: Line 95:
 
echo $row['text'];
 
echo $row['text'];
 
</php>
 
</php>
 +
 +
=== The database options to use for the fields ===
 +
<highlightSyntax language="sqlnew">
 +
`bbcode_bitfield` varchar(255) collate utf8_bin NOT NULL default '',
 +
`bbcode_uid` varchar(8) collate utf8_bin NOT NULL,
 +
`bbcode_options` mediumint(4) collate utf8_bin NOT NULL,
 +
</highlightSyntax>
 
{{tutorial-stub}}
 
{{tutorial-stub}}
 +
<br>
 +
==See Also==
 +
* [[Strip_bbcode]]
 +
* [[Generate_text_for_display]]
 +
* [[Generate_text_for_storage]]
 +
<br>
  
 
[[Category:Tutorials]]
 
[[Category:Tutorials]]
 
[[Category:API]]
 
[[Category:API]]
 +
[[Category:BBCode]]

Latest revision as of 14:29, 13 February 2011

Database fields

phpBB3 uses the following database fields where BBCode is allowed (forum description, forum rules, post content, ...):

  • foo - the text itself
  • foo_bbcode_uid - a randomly generated unique identifier to mark the bbcodes identified by the first pass encoding (which uses regular expressions) so they can be replaced using the quicker str_replace in the second pass.
  • foo_bbcode_bitfield - a bit field containing the information which bbcode is used in the text so only the relavant ones need to be loaded from the database.
  • foo_options - a bit field containing the information whether bbcode, smilies and magic urls are enabled (OPTION_FLAG_BBCODE, OPTION_FLAG_SMILIES and OPTION_FLAG_LINKS). Sometimes you will find this separated into enable_bbcode, enable_smilies and enable_magic_url

column names vary from table to table.

Parsing text with BBCodes, smilies etc.

Inserting text to the DB

$text utf8_normalize_nfc(request_var('text'''true));
$uid $bitfield $options ''// will be modified by generate_text_for_storage
$allow_bbcode $allow_urls $allow_smilies true;
generate_text_for_storage($text$uid$bitfield$options$allow_bbcode$allow_urls$allow_smilies);

$sql_ary = array(
    
'text'              => $text,
    
'bbcode_uid'        => $uid,
    
'bbcode_bitfield'   => $bitfield,
    
'bbcode_options'    => $options,
);

$sql 'INSERT INTO ' YOUR_TABLE ' ' $db->sql_build_array('INSERT'$sql_ary);
$db->sql_query($sql);

The above method uses the bbcode options database field which is used in many places instead of enable_smiles, enable_bbcode and enable_magic_url

Here is how to insert it into the database using the enable_smilies, enable_bbcode and enable_magic_url tables

$text utf8_normalize_nfc(request_var('text'''true));
$uid $bitfield $options ''// will be modified by generate_text_for_storage
$allow_bbcode $allow_urls $allow_smilies true;
generate_text_for_storage($text$uid$bitfield$options$allow_bbcode$allow_urls$allow_smilies);

$sql_ary = array(
    
'text'              => $text,
    
'bbcode_uid'        => $uid,
    
'bbcode_bitfield'   => $bitfield,
    
'enable_bbcode'     => $allow_bbcode,
    
'enable_magic_url'  => $allow_urls,
    
'enable_smilies'    => $allow_smilies,
);

$sql 'INSERT INTO ' YOUR_TABLE ' ' $db->sql_build_array('INSERT'$sql_ary);
$db->sql_query($sql);

Displaying text downloaded from DB

This example uses the bbcode_options field which is used in forums and groups description parsing:

$sql 'SELECT text, bbcode_uid, bbcode_bitfield, bbcode_options
    FROM ' 
YOUR_TABLE;
$result $db->sql_query($sql);
$row $db->sql_fetchrow($result);
$db->sql_freeresult($result);

$text generate_text_for_display($row['text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']);

echo 
$text;


The next one uses the enable_bbcode, enable_smilies and enable_magic_url flags which can be used instead of the above method and is used in parsing posts:

$sql 'SELECT text, bbcode_uid, bbcode_bitfield, enable_bbcode, enable_smilies, enable_magic_url
    FROM ' 
YOUR_TABLE;
$result $db->sql_query($sql);
$row $db->sql_fetchrow($result);
$db->sql_freeresult($result);

$row['bbcode_options'] = (($row['enable_bbcode']) ? OPTION_FLAG_BBCODE 0) +
    ((
$row['enable_smilies']) ? OPTION_FLAG_SMILIES 0) + 
    ((
$row['enable_magic_url']) ? OPTION_FLAG_LINKS 0);
$text generate_text_for_display($row['text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']);

echo 
$text;

Generating text for editing

$sql 'SELECT text, bbcode_uid
    FROM ' 
YOUR_TABLE;
$result $db->sql_query_limit($sql1);
$row $db->sql_fetchrow($result);
$db->sql_freeresult($result);

decode_message($row['text'], $row['bbcode_uid']);

echo 
$row['text'];

The database options to use for the fields


`bbcode_bitfield` varchar(255) collate utf8_bin NOT NULL default '',
`bbcode_uid` varchar(8) collate utf8_bin NOT NULL,
`bbcode_options` mediumint(4) collate utf8_bin NOT NULL,


See Also