Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-07-2009, 02:37 PM
matkus matkus is offline
 
Join Date: Jan 2004
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Problem with parsing BB codes in custom script

Hello.
I'm trying to write custom script, that will read news from forum. I've used code, that used to work ling time ago for me, but it does not now, and i don't know why. Heres the code:
PHP Code:
   chdir('./forum');
   require_once(
'./global.php');
   require_once(
'./includes/class_bbcode.php');
   
chdir('./..');
   
$bbcode_parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
   require_once(
'config.php');
   require_once(
'common.php');
   
$db2=new class_db($config['forum_sql_host'],$config['forum_sql_user'],$config['forum_sql_pass'],$config['forum_sql_db']);

   function 
parse_bb($tresc$par1$par2$par3$par4)
   {
      global 
$bbcode_parser;
      
$wynik=$bbcode_parser->do_parse($tresc$par1$par2$par3$par4,true,false);      
      
$wynik=str_replace ('<img src="images/smilies/','<img src="http://forum.tibiaspy.com/images/smilies/',$wynik);     
      return 
$wynik;
   }

   function 
forum_read_news($dzial,$ilosc,$szablon="news",$separator=''$sort_order='threadid DESC')
   {
      global 
$config$forum_path,$news,$db2,$tpl;
      
$query="SELECT threadid,title,postusername FROM ".$config['forum_tableprefix']."thread WHERE forumid=$dzial ORDER BY $sort_order LIMIT $ilosc";
      
$lista_q=$db2->query($query);
      
$wynik='';
      while (
$temat=mysql_fetch_array($lista_q))
      {
         
$psql $db2->query("SELECT pagetext , dateline FROM ".$config['forum_tableprefix']."post WHERE threadid=".$temat['threadid']." ORDER BY postid ASC LIMIT 1");
         
$post=mysql_fetch_array($psql);

         
$news['pagetext']=parse_bb($post['pagetext'], truetruetruetrue);
         
$news['title'] = $temat['title'];
         
$news['threadid'] = $temat['threadid'];
         
$news['postusername'] =$temat['postusername'];
         
$news['date']=date ("d.m.y H:i" ,$post['dateline']);
         
$wynik1=$tpl->loadtpl($szablon);
         if (
$wynik!=''){$wynik.=$separator;};
         
$wynik.=$wynik1;
      }
      return 
$wynik;
   } 
$db2 and $tpl are my own classes for database and templates.
When i call forum_read_news function, it have strange effects.
It parses correctly bbcodes, that are in handled by plugins.
Sometimes it also handles default bbcides, but not always, usualy it leaves most bb unparsed (like lists, [B], [URL] etc).

Sorry, that some variable names are in polish, it's easier for me like this, but if it will be problem, i can change it in code aboce.

Can someone tell me whan am i doing wrong?

I'm using 3.8 beta 2 for testing. may it be some bug with it? But in forum everything is parsed correctly, so I don't think it's forum problem.



[Edit]
Ok, one thinkg i've found - In this function, if i read more than 1 news, only 1st is parsed, 2nd and more are not. What did i do wrong???


[edit2] OK, sorry. Problem solved. I've used now $bbcode_parser->parse($tresc) insted of $bbcode_parser->do_parse($tresc), and it works. But i'm sure do_parse worked fine some time ago in some older vB version.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:17 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06755 seconds
  • Memory Usage 2,317KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete