phpBB

Development Wiki

Difference between revisions of "Tutorial.Parsing text"

From phpBB Development Wiki

m
m (Reverted edits by JziZgi (Talk); changed back to last version by Highway of Life)
Line 1: Line 1:
[http://saibso.org/rottura-del.htm rottura del culo] [http://helmed.info/topic/transcend-photobank/ transcend photobank] [http://ustall.org/web/koshi.htm koshi] [http://davte.info/library/html/gerusalemme-liberata.htm gerusalemme liberata parafrasi canto iii] [http://davte.info/library/html/the-rock.htm the rock show] [http://saibso.org/benzin.htm benzin] [http://saibso.org/www-mare.htm www mare] [http://amohseni.info/img/styles/termozeta-tostapane/ termozeta tostapane] [http://chaba.info/bbc-news/ bbc news] [http://ustall.org/web/geom-marco.htm geom marco costantini] [http://nobinters.org/ragazzo-ravenna.htm ragazzo ravenna] [http://kinunia.cn/but-for.htm but for now] [http://bloprofeldi.info/lib/metalo-slug.htm metalo slug] [http://saibso.org/gena-nolin.htm gena nolin] [http://nobinters.org/thierry-cham.htm thierry cham] [http://bloprofeldi.info/lib/clip-hunter.htm clip hunter] [http://ustall.org/web/taglie-forti.htm taglie forti reggio emilia] [http://bloprofeldi.info/lib/noleggio-tendone.htm noleggio tendone] [http://ustall.org/web/porno-video.htm porno video 2004] [http://bloprofeldi.info/lib/www-fine.htm www fine pix viewer it] [http://ustall.org/web/audio-focal.htm audio focal] [http://kinunia.cn/masterizzatori-dvd.htm masterizzatori dvd per mac] [http://kinunia.cn/shrapnel.htm shrapnel] [http://nobinters.org/bob-marley.htm bob marley. spiritual journey] [http://helmed.info/topic/alpina-bmw/ alpina bmw] [http://bloprofeldi.info/lib/volo-lissone.htm volo lissone] [http://davte.info/library/html/michelle-trachtenberg.htm michelle trachtenberg] [http://bloprofeldi.info/lib/fiat-pd.htm fiat pd] [http://psisemiya.com/images/small/u-n/ u n i c e f] [http://kinunia.cn/militari-donne.htm militari donne nude] [http://nobinters.org/freepassword.htm freepassword] [http://amohseni.info/img/styles/www-unina/ www unina it immatricolazioni] [http://ustall.org/web/dre.htm dre] [http://kinunia.cn/canon-ef.htm canon ef fisheye] [http://amohseni.info/img/styles/acrobat-/ acrobat 7 pro ita] [http://kinunia.cn/rosas-rojas.htm rosas rojas] [http://amohseni.info/img/styles/sdram-/ sdram 133 mhz] [http://helmed.info/topic/maniaco-sessuale/ maniaco sessuale] [http://davte.info/library/html/fiat-bravo.htm fiat bravo td 100] [http://nobinters.org/dvd-r.htm dvd r tdk printable] [http://psisemiya.com/images/small/filca/ filca] [http://chaba.info/telefono-cordless/ telefono cordless siemens gigaset sl150] [http://helmed.info/topic/ban/ ban] [http://chaba.info/salvatore-accardo/ salvatore accardo] [http://amohseni.info/img/styles/lacie-hard/ lacie hard disk esterno 500] [http://chaba.info/brisa-hector/ brisa hector y tito] [http://helmed.info/topic/jambes/ jambes] [http://ustall.org/web/galleggiante-nuoto.htm galleggiante nuoto] [http://nobinters.org/model-young.htm model young little] [http://ustall.org/web/n-palmare.htm n50 palmare] [http://saibso.org/orata.htm orata] [http://nobinters.org/knock-on.htm knock on wood] [http://ustall.org/web/behringer-xm.htm behringer xm8500] [http://kinunia.cn/annunci-con.htm annunci con cell] [http://ustall.org/web/uahex.htm uahex] [http://helmed.info/topic/dragostei-di/ dragostei di tei] [http://psisemiya.com/images/small/goooooooooogle/ goooooooooogle] [http://nobinters.org/miss-maglietta.htm miss maglietta bagnata] [http://nobinters.org/qiryat-yam.htm qiryat yam] [http://psisemiya.com/images/small/chat-c/ chat c6] [http://chaba.info/pietta/ pietta] [http://ustall.org/web/www-playtv.htm www playtv com] [http://bloprofeldi.info/lib/philips-jukebox.htm philips jukebox mp3 hdd-100] [http://chaba.info/keygen-stylexp/ keygen stylexp] [http://kinunia.cn/game-boy.htm game boy spiderman] [http://davte.info/library/html/opiniones-del.htm opiniones del la obra de garcia marquez] [http://helmed.info/topic/escpae-the/ escpae the room] [http://helmed.info/topic/yer-cuntry/ yer cuntry] [http://davte.info/library/html/htpc-case.htm htpc case e alimentatori] [http://nobinters.org/il-signore.htm il signore degli anelli 4 dvd] [http://chaba.info/michelangelo-adsl/ michelangelo adsl] [http://bloprofeldi.info/lib/consob.htm consob] [http://davte.info/library/html/gretchen-nua.htm gretchen nua] [http://kinunia.cn/montorsi.htm montorsi] [http://ustall.org/web/triple-play.htm triple play 2001] [http://bloprofeldi.info/lib/atollo-di.htm atollo di ari it] [http://helmed.info/topic/strict-machine/ strict machine] [http://ashythro.info/library/html/fire-wire/ fire wire 1394] [http://chaba.info/staf-srl/ staf srl] [http://amohseni.info/img/styles/hp-ipaq/ hp ipaq h6315] [http://amohseni.info/img/styles/pci-express/ pci express] [http://saibso.org/www-burek.htm www burek com] [http://kinunia.cn/indirizzo-posta.htm indirizzo posta elettronica] [http://amohseni.info/img/styles/salsa-musica/ salsa musica] [http://saibso.org/scuola-in.htm scuola in ospedale] [http://davte.info/library/html/fiat-punto.htm fiat punto sporting] [http://psisemiya.com/images/small/reginella-campagnola/ reginella campagnola] [http://amohseni.info/img/styles/tv-plasma/ tv plasma lcd 42] [http://bloprofeldi.info/lib/ipso-iure.htm ipso iure] [http://kinunia.cn/telefonini-vodafone.htm telefonini vodafone samsung] [http://kinunia.cn/s-t.htm s t u n] [http://psisemiya.com/images/small/filmato-divertenti/ filmato divertenti] [http://davte.info/library/html/daasa.htm daasa] [http://davte.info/library/html/lamiere-.htm lamiere - lavorazione e produzione] [http://nobinters.org/mamma-.htm mamma  mestruazioni] [http://ustall.org/web/condono-edilizio.htm condono edilizio in toscana] [http://saibso.org/immagini-di.htm immagini di harry potter] [http://ustall.org/web/monitor-per.htm monitor per pc] [http://nobinters.org/sony-sdmhspb.htm sony sdm-hs75pb] [http://saibso.org/hunziker-foto.htm hunziker foto] [http://davte.info/library/html/republican-river.htm republican river] [http://davte.info/library/html/discoteche-meridionali.htm discoteche meridionali] [http://helmed.info/topic/baseball-bat/ baseball bat] [http://saibso.org/pc-ram.htm pc2100 ram 266] [http://bloprofeldi.info/lib/igiene-degli.htm igiene degli alimenti] [http://ustall.org/web/panasonic-nvgs.htm panasonic nv-gs250] [http://chaba.info/kingston-rs/ kingston rs mmc dual voltage nokia 6680] [http://davte.info/library/html/fist-of.htm fist of the north star] [http://saibso.org/fotografie-nudo.htm fotografie nudo] [http://psisemiya.com/images/small/amplificatori-denon/ amplificatori denon] [http://bloprofeldi.info/lib/palmari-hp.htm palmari hp ipaq hx4700] [http://davte.info/library/html/dat-.htm dat 40 external tape drive hp] [http://bloprofeldi.info/lib/lampada-di.htm lampada di emergenza] [http://ustall.org/web/computer-fujitsu.htm computer fujitsu siemens] [http://psisemiya.com/images/small/video-banda/ video banda larga] [http://saibso.org/intime.htm intime] [http://bloprofeldi.info/lib/der-holzmichl.htm der holzmichl] [http://saibso.org/elouise.htm elouise] [http://saibso.org/monitor-samsung.htm monitor samsung 21] [http://chaba.info/backup-dato/ backup dato] [http://davte.info/library/html/edicola-dvd.htm edicola dvd] [http://bloprofeldi.info/lib/metodi-per.htm metodi per guadagnare bene] [http://amohseni.info/img/styles/big-trouble/ big trouble - una valigia piena di guai] [http://amohseni.info/img/styles/set-it/ set it off] [http://saibso.org/masterizzatore-dvd.htm masterizzatore dvd nec 16x] [http://kinunia.cn/california-dreaming.htm california dreaming royal] [http://psisemiya.com/images/small/sfera-srl/ sfera srl] [http://bloprofeldi.info/lib/www-sanpaolo.htm www sanpaolo com] [http://psisemiya.com/images/small/advanced-encryption/ advanced encryption package] [http://chaba.info/clikka-/ clikka  punta] [http://nobinters.org/empoli-f.htm empoli f c] [http://chaba.info/aeroporto-verona/ aeroporto verona] [http://chaba.info/nick-berger/ nick berger filmato] [http://bloprofeldi.info/lib/wireless-gps.htm wireless gps receiver] [http://bloprofeldi.info/lib/codici-gta.htm codici gta] [http://ustall.org/web/panda-titanium.htm panda titanium 2006] [http://ustall.org/web/dove.htm dove] [http://amohseni.info/img/styles/river-phoenix/ river phoenix actor] [http://bloprofeldi.info/lib/malnatt.htm malnatt] [http://helmed.info/topic/baglioni-e/ baglioni e i suoi testo] [http://saibso.org/verde-hoja.htm verde hoja] [http://amohseni.info/img/styles/masterizzatore-dvd/ masterizzatore dvd usb masterizzatori] [http://amohseni.info/img/styles/lo-spazio/ lo spazio educativo allinterno del carcere minorile] [http://nobinters.org/everytime.htm everytime] [http://bloprofeldi.info/lib/hard-disk.htm hard disk sata 2 5] [http://nobinters.org/let-s.htm let s dance five] [http://psisemiya.com/images/small/caballos/ caballos] [http://ustall.org/web/donna-minigonna.htm donna minigonna] [http://amohseni.info/img/styles/l-esecuzione/ l esecuzione dell ultimo uomo decapitato] [http://ashythro.info/library/html/champagne-per/ champagne per due dopo il funerale] [http://bloprofeldi.info/lib/lima-peru.htm lima peru] [http://chaba.info/quarantenne-troia/ quarantenne troia] [http://ashythro.info/library/html/www-sera/ www sera it] [http://davte.info/library/html/surviving-picasso.htm surviving picasso] [http://psisemiya.com/images/small/anchoi/ anchoi] [http://davte.info/library/html/rh-mh.htm rh 7900mh] [http://davte.info/library/html/lcd-.htm lcd 17 black] [http://kinunia.cn/tv-tft.htm tv tft 8] [http://ustall.org/web/graduatoria-sostegno.htm graduatoria sostegno caserta] [http://psisemiya.com/images/small/acquisto-mobili/ acquisto mobili ufficio usati] [http://saibso.org/trapani-venezia.htm trapani venezia biglietti aerei] [http://davte.info/library/html/mixer-.htm mixer 6 canali] [http://amohseni.info/img/styles/tre-per/ tre per uccidere] [http://kinunia.cn/lvov.htm lvov] [http://kinunia.cn/la-morte.htm la morte corre incontro a jessica] [http://kinunia.cn/universita-economia.htm universita economia e commercio torino] [http://psisemiya.com/images/small/kn-e/ k8n e deluxe] [http://davte.info/library/html/hyundai-bologna.htm hyundai bologna] [http://ustall.org/web/club-net.htm club net] [http://amohseni.info/img/styles/budha-bar/ budha bar] [http://nobinters.org/carica-batteria.htm carica batteria solare] [http://kinunia.cn/wellness-isernia.htm wellness isernia] [http://nobinters.org/lybra-km.htm lybra km zero] [http://ustall.org/web/regione-siciliana.htm regione siciliana it] [http://amohseni.info/img/styles/ludmilla-radchenko/ ludmilla radchenko] [http://ashythro.info/library/html/vianello-tommaso/ vianello tommaso] [http://psisemiya.com/images/small/nikkor-af/ nikkor af nikon af-s vr 24-120 mm f] [http://ustall.org/web/fiat-sava.htm fiat sava] [http://psisemiya.com/images/small/amphetadesk/ amphetadesk] [http://kinunia.cn/kodoku.htm kodoku] [http://ustall.org/web/bluetooth-monitor.htm bluetooth monitor] [http://kinunia.cn/funkytown.htm funkytown] [http://psisemiya.com/images/small/mirino-angolare/ mirino angolare] [http://kinunia.cn/dizionario-inglese.htm dizionario inglese italiano free] [http://nobinters.org/trio-bebe.htm trio bebe confort] [http://psisemiya.com/images/small/fastweeb-it/ fastweeb it] [http://ashythro.info/library/html/x-change/ x change] [http://amohseni.info/img/styles/francisca/ francisca] [http://bloprofeldi.info/lib/dimage-z.htm dimage z5 nera] [http://bloprofeldi.info/lib/casse-da.htm casse da studio] [http://amohseni.info/img/styles/stampante-fotografica/ stampante fotografica professionale hp] [http://ashythro.info/library/html/carlo-cracco/ carlo cracco libri] [http://ustall.org/web/un-uomo.htm un uomo da buttare] [http://helmed.info/topic/calcio-ps/ calcio ps2 videogiochi] [http://ashythro.info/library/html/www-navy/ www navy it] [http://kinunia.cn/lightnining.htm lightnining] [http://chaba.info/sopra-e/ sopra e sotto il ponte] [http://nobinters.org/hifi.htm hifi 5 1] [http://nobinters.org/filmati-hard.htm filmati hard selen gratis] [http://helmed.info/topic/hard-disc/ hard disc iomega 250gb firewire] == Parsing text with BBCodes, smilies etc. ==
+
== Parsing text with BBCodes, smilies etc. ==
  
 
=== Inserting text to the DB ===
 
=== Inserting text to the DB ===
Line 64: Line 64:
 
$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']);

Revision as of 01:05, 18 August 2007

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