Get started with PHP-Fusion

Start a New Thread

Users Participated

  • Craig
    Post made: 1
  • PolarFox
    Post made: 2
  • miskith
    Post made: 3
  • Ankur
    Post made: 1

  1. PHP-Fusion Support Forums
  2. General Addon and Modification Support
  3. Modifications and Requests

Youtube BBCODE

Post your modification and request questions here

6 Replies 2,186 Views Last Updated on 4 years ago

miskith


Member

#1

Posted 4 years ago

Hi,
I'm sorry, if this is the wrong forum (cat) for this modification.

I am leader of the Czech official support and we had a problem that I solved modifying PHP-Fusion. I think that it would be good, if you would add this modification in the PHP-Fusion package.

It's improvements for YouTube BBCode. Now, you can write (without white space):
[ youtube]http://www.youtube.com/watch?v=C89Kb2JU4eE[/youtube]
[ youtube]http://youtu.be/C89Kb2JU4eE[/youtube]
[ youtube]C89Kb2JU4eE[/youtube]

Commented = Flash (old) version
Uncommented = Iframe (new) version
[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2011 Nick Jones
| http://www.php-fu...
+--------------------------------------------------------+
| Filename: youtube_bbcode_include.php
| Author: Wooya
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licen... Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
if (!defined("IN_FUSION")) {die("Access Denied");}

//$text = preg_replace('#\[youtube\](http:\/\/www.youtube\.com\/watch\?v=|http:\/\/youtu\.be\/)?(.*?)\[/youtube\]#si', '<strong>'.$locale['bb_youtube'].'</strong><br /><object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/\2"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/\2" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>', $text);
$text = preg_replace('#\[youtube\](http:\/\/www.youtube\.com\/watch\?v=|http:\/\/youtu\.be\/)?(.*?)\[/youtube\]#si', '<strong>'.$locale['bb_youtube'].'</strong><br /><iframe width="425" height="350" src="http://www.youtube.com/v/\2" frameborder="0"></iframe>', $text);
?>[/syntaxhighlighter]

And... I would like to ask you if I should share some improvements at this support.

PS: I'm sorry for my English.

Posts: 117

Joined: 28/07/2010

PolarFox


Admin

#2

Posted 4 years ago

I see it's a new utube code.

Is this code better and if so - why better?

Posts: 1641

Joined: 26/08/2008

Ankur


Admin

#3

Posted 4 years ago

Ok ! So I just tested it with all of them and It worked Very Nicely... Grin

Good Work Wink
Hi! Its me, Ankur Thakur! :)

Posts: 1279

Joined: 02/11/2010

miskith


Member

#4

Posted 4 years ago

PolarFox wrote:

I see it's a new utube code.

Is this code better and if so - why better?

Iframe code is a new way to share YouTube videos.
Advantages:
- 100% valid HTML
- Functionality in all browsers
- It should have more features
But I don't know if YouTube also uses a secure protocol (https). If uses, I can update the script for HTTP and HTTPS compatibility .

Posts: 117

Joined: 28/07/2010

Craig


Fusioneer

#6

Posts: 4523

Joined: 27/09/2005

miskith


Member

#7

Posted 4 years ago

Nobody answered at my question, so I tried it and youtube uses also a secure protocol (https). So, there you have a new version:
Now Support (without white space):
[ youtube]http://www.youtube.com/watch?v=C89Kb2JU4eE[/youtube]
[ youtube]http://youtu.be/C89Kb2JU4eE[/youtube]
[ youtube]https://www.youtube.com/watch?v=C89Kb2JU4eE[/youtube]
[ youtube]https://youtu.be/C89Kb2JU4eE[/youtube]
[ youtube]C89Kb2JU4eE[/youtube]

Code Gist: Download source  
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2011 Nick Jones
| http://www.php-fu...
+--------------------------------------------------------+
| Filename: youtube_bbcode_include.php
| Author: Wooya
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licen... Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
if (!defined("IN_FUSION")) {die("Access Denied");}

//$text = preg_replace('#\[youtube\](http:|https:)?(\/\/www.youtube\.com\/watch\?v=|\/\/youtu\.be\/)?(.*?)\[/youtube\]#si', '<strong>'.$locale['bb_youtube'].'</strong><object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/\3"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/\3" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>', $text);
$text = preg_replace('#\[youtube\](http:|https:)?(\/\/www.youtube\.com\/watch\?v=|\/\/youtu\.be\/)?(.*?)\[/youtube\]#si', '<strong>'.$locale['bb_youtube'].'</strong><iframe width="425" height="350" src="http://www.youtube.com/v/\3" frameborder="0"></iframe>', $text);
?>


EDITED:
Of course, you can use this modification for "movie_bbcode_include.php" too.
Code Gist: Download source  
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2011 Nick Jones
| http://www.php-fu...
+--------------------------------------------------------+
| Filename: movie_bbcode_include.php
| Author: Wooya
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licen... Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
if (!defined("IN_FUSION")) { die("Access Denied"); }

//$text = preg_replace('#\[movie=youtube\](http:|https:)?(\/\/www.youtube\.com\/watch\?v=|\/\/youtu\.be\/)?(.*?)\[/movie\]#si', '<strong>'.$locale['bb_movie_youtube'].'</strong><object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/\3"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/\3" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>', $text);
$text = preg_replace('#\[movie=youtube\](http:|https:)?(\/\/www.youtube\.com\/watch\?v=|\/\/youtu\.be\/)?(.*?)\[/movie\]#si', '<strong>'.$locale['bb_movie_youtube'].'</strong><iframe width="425" height="350" src="http://www.youtube.com/v/\3" frameborder="0"></iframe>', $text);
$text = preg_replace('#\[movie=google\](.*?)\[/movie\]#si', '<strong>'.$locale['bb_movie_googlevideo'].':</strong><br /><object width="425" height="350"><param name="movie" value="http://video.google.com/googleplayer.swf?docId=\1"></param><param name="wmode" value="transparent"></param><embed src="http://video.google.com/googleplayer.swf?docId=\1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>', $text);
?>

Edited by miskith on 05-07-2011 22:48
My projects:
PHP-Fusion Czech | miskith portfolio | theConnex (In preparation) | Online game (Future project)

Posts: 117

Joined: 28/07/2010

Jump to Forum:
11 users are online
1 member and 10 guests

Nuori