FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » General » PHP discussions » Preg replace problem (again!)
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Preg replace problem (again!) [message #160140] Tue, 28 July 2009 21:37 Go to previous message
nozafc is currently offline  nozafc   United Kingdom
Messages: 75
Registered: April 2009
Karma:
Member
As usual when I'm writing a plugin I have issues with converting HTML code back to BBcode when quoted/edited

Finally got the hang of regex Surprised just need to get the hang of this

Any idea what I require to change from the code below to get a proper HTML -> BBCode. Probably something obvious, it works fine as far as embedding the video just doesn't work when quoting/editing and you end up with HTML.

<?php
 // Initialize plugin
 plugin_add_hook("BBCODE2HTML", "plugin_zshare_tag_to_html");
 plugin_add_hook("HTML2BBCODE", "plugin_zshare_html_to_tag");
 
  // Convert [zshare] to html code (post message)
 function plugin_zshare_tag_to_html($array) {
 	list($bbcode) = $array;
 
 	$bbcode = preg_replace('#\[zshare\]([a-zA-Z0-9%_=.&(?!amp;)-]+)\[/zshare\]#si', '<iframe src="http://www.zshare.net/videoplayer/player.php?\\1&iframewidth=530&iframeheight=435&width=480&height=385&H=1&ISL=1" height="435" width="530" border=0 frameborder=0 scrolling=no id="videoframe" name="videoframe"></iframe>', $bbcode);
 	return array($bbcode);
 }

 // Convert html to [zshare] tag (edit message)
 function plugin_zshare_html_to_tag($array) {
 	list($bbcode) = $array;
 
 	$bbcode = preg_replace('#<iframe src="<iframe src="http://www.zshare.net/videoplayer/player.php?([a-zA-Z0-9%_=.&(?!amp;)-]+)&iframewidth=530&iframeheight=435&width=480&height=385&H=1&ISL=1" height="435" width="530" border=0 frameborder=0 scrolling=no id="videoframe" name="videoframe"></iframe>#si', '[zshare]\\1[/zshare]', $bbcode);
 	return array($bbcode);
 }
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: java script to php
Next Topic: Launching a php script file
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Dec 03 18:38:03 GMT 2024

Total time taken to generate the page: 0.06057 seconds