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

Home » General » PHP discussions » Preg replace problem (again!)
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
Preg replace problem (again!) [message #160140] Tue, 28 July 2009 17:37 Go to next message
nozafc is currently offline  nozafc   United Kingdom
Messages: 75
Registered: April 2009
Karma: 0
Member
add to buddy list
ignore all messages by this user
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);
 }
Re: Preg replace problem (again!) [message #160142 is a reply to message #160140] Tue, 28 July 2009 21:55 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3624
Registered: December 2004
Karma: 17
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
Remove the extra <iframe src=" from the last regex.
Re: Preg replace problem (again!) [message #160144 is a reply to message #160140] Wed, 29 July 2009 08:01 Go to previous message
nozafc is currently offline  nozafc   United States
Messages: 75
Registered: April 2009
Karma: 0
Member
add to buddy list
ignore all messages by this user
Laughing Laughing Laughing

I can't test it right now as I'm at work but I can't believe I missed that Laughing Embarassed
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
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: Sat Oct 21 01:08:34 EDT 2017

Total time taken to generate the page: 0.00691 seconds