phpBB

Development Wiki

Tutorial.Parsing text

From phpBB Development Wiki

Revision as of 01:38, 7 July 2007 by JziZgi (Talk | contribs)

free tracfone ringtones clomid online ativan buy xanax buy nexium sonyericsson ringtones cheap clomid adipex online cialis cheap hydrocodone levitra online midi ringtones order lisinopril wwe ringtones phentermine online tracfone ringtones cheap sildenafil free verizon ringtones midi ringtones phentermine online cheap rivotril vicodin cheap celexa free funny ringtones cheap flexeril hoodia online cheap tenuate prozac online sprint ringtones order norco online meridia free sprint ringtones diazepam online fioricet free mp3 ringtones paxil online buy zanaflex cheap alprazolam cheap soma order diazepam free wwe ringtones but zoloft lorazepam online online norco free ringtones carisoprodol online free qwest ringtones clonazepam online celexa online cheap clonazepam buy lipitor free nokia ringtones cheap lisinopril propecia online nokia ringtones free punk ringtones buy carisoprodol cheap ultram sony ericsson ringtones free tracfone ringtones cheap zyban cheap hoodia cheap tramadol cingular ringtones jazz ringtones alltel ringtones cheap flexeril free nextel ringtones free kyocera ringtones free samsung ringtones free motorola ringtones meridia online xenical online free sony ringtones paxil online free sagem ringtones buy ativan cheap rivotril order ortho cheap celexa free sharp ringtones cheap adipex cheap ortho hydrocodone cheap propecia cingular ringtones free nextel ringtones sagem ringtones adipex free punk ringtones buy didrex free sonyericsson ringtones didrex online cheap diazepam free samsung ringtones free sharp ringtones meridia online free mono ringtones valium online buy hgh nextel ringtones funny ringtones cheap lortab cheap ultracet viagra online albuterol vicodin online motorola ringtones cheap lorazepam ericsson ringtones mp3 ringtones free sonyericsson ringtones cheap viagra cyclobenzaprine online but vigrx free wwe ringtones zoloft online clomid online order fioricet free samsung ringtones cheap albuterol tramadol online xenical online alprazolam online cheap clonazepam free mp3 ringtones order norco online xanax mtv ringtones free qwest ringtones valium online sildenafil online cheap zyban alprazolam online levitra online soma online cheap ortho cheap xenical zyban online free polyphonic ringtones motorola ringtones cheap lisinopril sagem ringtones music ringtones cheap ativan jazz ringtones cool ringtones free ericsson ringtones tracfone ringtones but norco cheap viagra free sony ericsson ringtones nexium online cheap paxil free cool ringtones cheap vicodin kyocera ringtones free jazz ringtones sprint ringtones cialis online cyclobenzaprine online free nokia ringtones cheap paxil lipitor online cyclobenzaprine online prozac online ultram online cheap pharmacy online cheap rivotril free sony ringtones fioricet online cheap tenuate viagra online real ringtones zanaflex online midi ringtones ativan online clonazepam online diethylpropion online free verizon ringtones free free ringtones free online pharmacy soma online free free ringtones vigrx lortab online free sony ringtones buy wellbutrin hgh online kyocera ringtones ericsson ringtones mp3 ringtones but ultram cheap carisoprodol free cingular ringtones cheap ambien free mtv ringtones valium online free music ringtones mono ringtones == 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_urls'       => $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;

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.

$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'];