1 (edited by raul.lnx 2008-11-17 16:05)

Topic: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

Sorry, I speak english a little bit.

It's very easy add customs bbcodes to you PunBB forum througth "pun_bbcode" official extension

You must edit only 2 files.

- /extensions/pun_bbcode/bar.php
- /includes/parser.php

In first file you must put the "name" of the bbcode you are including. For example, i'm going to put bbcode for YOUTUBE, GOOGLE VIDEO, and VIMEO.

// List of tags, which may have attribute
$tags_without_attr = array('b', 'i', 'u', 'url', 'email', 'img', 'list', 'youtube','google','vimeo', 'li' => '*', 'quote', 'code');

Ok ?? Now we want transform bbcode_tags to html. We need write the pattern and the replace lines into parser.php

//
// Convert BBCodes to their HTML equivalent
//


    $replace[] = '<span style="color: $1">$2</span>';
    $replace[] = '</p><h5>$1</h5><p>';

//INSERT HERE YOUR BBCODES TAGS

//YOUTUBE 
    $pattern[] = '#\[youtube\](.*?)\[/youtube\]#s';
    $replace[] = '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>';


//GOOGLE VIDEO
        $pattern[] = '#\[google\](.*?)\[/google\]#s';
        $replace[] = '<object width="425" height="364"><param name="movie" value="http://video.google.com/googleplayer.swf?docId=$1"></param><embed src="http://video.google.com/googleplayer.swf?docId=$1" type="application/x-shockwave-flash" width="425" height="364"></embed></object>';


//VIMEO PATTERN
    $pattern[] = '#\[vimeo\](.*?)\[/vimeo\]#s';
    $replace[] = '<object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=$1&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=$1&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object><br /><a href="http://vimeo.com/$1" target="_blank">http://vimeo.com/$1</a> on <a href="http://vimeo.com" target="_blank">Vimeo</a>.';

USAGE:

You must put only the id-video bettween tags:

[youtube]Video-id[/youtube]
[video]Video-id[/video]
[google]Video-id[/google]

IMAGES:

You need put the images for bbcodes into /extensions/pun_bbcode/buttons/[template]/ and must be named as:

google.png, youtube.png, vimeo.png ........

IT's SO EASY !!!!!!!

Here a screenshot:

http://img529.imageshack.us/img529/1633/bbcodezk0.jpg

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

hello,

can u make me know how to intall your extension in more detail, and the links to download images youtube and google video like it shows in your picture.

thank u

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

mixcelebs wrote:

can u make me know how to intall your extension in more detail

It's not an extension. Please, read the post more attentively.

raul.lnx wrote:

It's very easy add customs bbcodes to you PunBB forum througth "pun_bbcode" official extension

You must edit only 2 files.

- /extensions/pun_bbcode/bar.php
- /includes/parser.php

Just follow the instructions. Any other questions?

Though one could make a nice extension based on the code above. If there is a lack of hooks in pun_bbcode, we can easily add required hooks.

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

thank you, but i have some problems . maybe i did some mistake.
can you send me the link to download bar.php and parder.php works to add videos in the post.

thank u

5 (edited by Parpalak 2008-11-28 15:48)

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

1. You have to install pun_bbcode extension (via pun_repository or from the extensions page)
2. The files mentioned above are

.../include/parser.php
.../extensions/pun_bbcode/bar.php

where '...' is the directory you have installed PunBB.

Edit: Maybe I'll make so extension on weekend if someone don't make it before smile

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

i did this but for punbb 1.3   except every time i add the link it automatically addes the  tags around the youtube link.   how do i stop the automatic url tags?

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

Are you sure that you use these features correctly?

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

delacruz wrote:

i did this but for punbb 1.3   except every time i add the link it automatically addes the  tags around the youtube link.   how do i stop the automatic url tags?

Hi, to disable automatic url tags :
go to the administration pannel ---> settings --> Features -> Topic and post content : uncheck " Allow BBCode parser to detect URLs and put them into tag. "

and btw this mods works fine with 1.3.1
thanks.

9 (edited by raul.lnx 2008-12-05 12:46)

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

(Sorry tongue i speak english a little bit.)

Now youtube supports videos in 16:9 format. If you put a 4:3 video into a 16:9 embed ..... it looks so ugly. It is very useful to have two tags for 4:3 videos and 16:9 videos.

This is the code for 16:9

//YOUTUBE 16:9
    $pattern[] = '#\[youtube_wide\](.*?)\[/youtube_wide\]#s';
    $replace[] = '<object width="640" height="380"><param name="movie" value="http://www.youtube.com/v/$1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" wmode="transpareent" width="640" height="380"></embed></object>';

You must have "youtube_wide.png" into /extensions/pun_bbcode/buttons/[template]/ .... i copy youtube.png to youtube_wide.png


http://img300.imageshack.us/img300/9462/dibujoeo6.jpg

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

i was putting the entire youtube link in the tags and not just the ID, that fixed the problem

11

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

Where can i get the icons (youtube.png, etc..)?

12 (edited by raul.lnx 2008-12-05 18:31)

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

chali wrote:

Where can i get the icons (youtube.png, etc..)?


http://www.snowboard-zamora.net/foro/extensions/pun_bbcode/buttons/Oxygen/youtube.png
Youtube

http://www.snowboard-zamora.net/foro/extensions/pun_bbcode/buttons/Oxygen/youtube_wide.png Youtube Wide

http://www.snowboard-zamora.net/foro/extensions/pun_bbcode/buttons/Oxygen/google.png Google Video

http://www.snowboard-zamora.net/foro/extensions/pun_bbcode/buttons/Oxygen/vimeo.png Vimeo

13

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

I tried exactly what you say, but it doesn't work for me...

14 (edited by gherosh 2009-02-04 22:28)

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

I had PunBB 1.2.x with youtube movies, upgraded to 1.3.  Here is how I manage the youtube links movies:

Youtube BBCode example: [youtube]http://youtube.com/watch?v=uDybmxbKf4Y[/youtube]

1. Modify $tags_without_attr = array('b', 'i', 'u', 'url', 'email', 'img', 'list', 'li' => '*', 'quote', 'code', 'youtube'); #add youtube in /extensions/pun_bbcode/bar.php

2. add youtube image button to /extensions/pun_bbcode/buttons/[your_style]/

3. In includes/parser.php modify function handle_url_tag replace:

if ($full_url == $link)
    return '[url]'.$link.'[/url]';
else
    return '[url='.$full_url.']'.$link.'[/url]';
---------------------------------------------------------
with:
if ($full_url == $link)
    if(strpos($link, 'youtube.com/watch') === 0)
        return '[url]'.$link.'[/url]';
    else
        return $link;
else
    return '[url='.$full_url.']'.$link.'[/url]';
-----------------------------------------------------
this will not transform your youtube url into a href link before inserting message into db.


4. In includes/parser.php modify function do_bbcode  add (at the end of $pattern and $replace array):
$pattern[] = '#\[youtube\]http://(?:www\.)?youtube.com/watch\?v=([0-9A-Za-z-_]{11})[^[]*\[/youtube\]#is';
and
$replace[] = '<object width="425" height="350"><param name="movie" value="$1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>';

5. If you have upgraded from 1.2 and used [youtube][/youtube] BBCode run this queries on the posts table:
- update `forum_posts` set `message` = replace(`message`, '[youtube][url]','[youtube]') WHERE message LIKE '%[youtube][url]%
- update `forum_posts` set `message` = replace(`message`, '[/url][/youtube]','[/youtube]') WHERE message LIKE '%[/url][/youtube]%''

See it in action http://www.latifa.ro/forum/post10107.html#p10107

Hope this help. roll

15

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

BTW: what kind of set of smilies are you using? Got a link to them?

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

I got those smilies from PunBB 1.2 forum, from here I guess http://punbb.informer.com/forums/post/5779/#p5779. Anyway you can download from here.

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

hey did any one maked extension out of that.

MyFootballCafe.com  is Now Online!

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

Hello theres
I was looking for upgrades in your new version of PunBB hosted at my domain forum.sawayra.com but are having issue for creating the youtube bbcode. can anyone there help me to do modifications in prser.php file?
Shall be very thankful to you.
if anyone found any extension or have update file to simply replaceable files than do me a mail at my mail address admin at sawayra.com
shall be very thankfull to you for this

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

Why would you hack the source, they made it extensible for a reason! Using this extensibility makes something like adding another bbcode really easy!

Just use this hook!

<hook id="ps_do_bbcode_replace"><![CDATA[
        
    $pattern[] = '#\[youtube\](.*?)\[/youtube\]#s';
    $replace[] = '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>';
        
]]></hook>

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

help please!
http://i34.tinypic.com/33yqkpc.jpg

the video doesn't display
My PunBB version - PunBB 1.3.4

21

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

I don't seem to get this one to work
When i edit bar.php, and refresh the all the format icons and smileys disappear.
It does not matter if i edit parser.php or not.

This is my bar.php edit:
// List of tags, which may have attribute
    $tags_without_attr = array('b', 'i', 'u', 'email', 'list', 'youtube', 'li' => '*', 'quote', 'code', 'url');

I only want YouTube.

I have tried to disable and enable the extension but it does not make any difference!

pun_bbcode extension works by itself (unedited), no problem.

Any ideas?

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

iTommy wrote:

I don't seem to get this one to work
When i edit bar.php, and refresh the all the format icons and smileys disappear.
It does not matter if i edit parser.php or not.

This is my bar.php edit:
// List of tags, which may have attribute
    $tags_without_attr = array('b', 'i', 'u', 'email', 'list', 'youtube', 'li' => '*', 'quote', 'code', 'url');

I only want YouTube.

I have tried to disable and enable the extension but it does not make any difference!

pun_bbcode extension works by itself (unedited), no problem.

Any ideas?

Change in parser to :

line 83

        // Remove empty tags
        while ($new_text = preg_replace('/\[(b|u|i|h|colou?r|quote|code|youtube|img|url|email|list)(?:\=[^\]]*)?\]\[\/\1\]/', '', $text))

line 112

    $tags = array('quote', 'code', 'youtube', 'b', 'i', 'u', 'color', 'colour', 'url', 'email', 'img', 'list', '*', 'h');

line 124

    $tags_inline = array('b', 'i', 'u', 'color', 'colour', 'h', 'youtube');

line 137

    // Tags we can automatically fix bad nesting
    $tags_fix = array('quote', 'youtube', 'b', 'i', 'u', 'color', 'colour', 'url', 'email', 'h');

then after line 739 add this

    $pattern[] = '#\[youtube\](.*?)\[/youtube\]#s';
    $replace[] = '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>';

I just tried it works.
Sorry for my poor english tongue

I don't speak English, but Google Translate is doing pretty good.

23

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

Thanks!
Ill will try it out later.

24 (edited by sohelarmanbd 2011-11-04 00:50)

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

I want to know about add 'highlight', 'indent' in bbcode button

Re: [How To] Add BBCODES into pun_bbcode OFFICIAL Extension

Is there anyone who is familiar enough with this to help me add a twitter tag?