Clickable links in [code] bbcode

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Suggested Hosts
User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: Clickable links in [code] bbcode

Post by 4_seven » Fri Mar 25, 2011 6:00 pm

user751139 wrote:

Code: Select all

www.fileserve.com/[mysite.com]_my_file.rar 
i think, normally no one have those links, means, it's a bad link syntax.
personally i never seen this syntax before.

normally special-chars have nothing to do in regular links, nether it works.
but we live and learn. what's normal?..

anyway, solution is easy:

find

Code: Select all

// Make Links clickable in [ code ] Tags / AmigoJack / 4seven / 2011
$code = make_clickable( str_replace( array( ':', '.' ), array( ':', '.' ), $code ), generate_board_url() ); 
// Make Links clickable in [ code ] Tags / AmigoJack / 4seven / 2011      
replace with

Code: Select all

// Make Links clickable in [ code ] Tags / AmigoJack / 4seven / 2011
$code = make_clickable( str_replace( array( ':', '.', '[', ']' ), array( ':', '.', '[', ']' ), $code ), generate_board_url() ); 
// Make Links clickable in [ code ] Tags / AmigoJack / 4seven / 2011       
Current Mods | Mod Base | php(BB) programming | No help via PM

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: Clickable links in [code] bbcode

Post by 4_seven » Sat Mar 26, 2011 2:12 pm

bcs. some people ask me:

hide code content completely for bots and guests

first

install snippet

open

viewtopic

find

Code: Select all

include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data); 
replace with

Code: Select all

include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);

include($phpbb_root_path . 'includes/bbcode.' . $phpEx); 
open

includes/bbcode.php

find

Code: Select all

// Make Links clickable in [ code ] Tags / AmigoJack / 4seven / 2011
$code = make_clickable( str_replace( array( ':', '.' ), array( ':', '.' ), $code ), generate_board_url() );
// Make Links clickable in [ code ] Tags / AmigoJack / 4seven / 2011        
$code = $this->bbcode_tpl('code_open') . $code . $this->bbcode_tpl('code_close'); 
replace with

Code: Select all

global $user;
if (!$user->data['is_bot'] && $user->data['user_id'] != 1)
{        
// Make Links clickable in [ code ] Tags / AmigoJack / 4seven / 2011
$code = make_clickable( str_replace( array( ':', '.' ), array( ':', '.' ), $code ), generate_board_url() );
// Make Links clickable in [ code ] Tags / AmigoJack / 4seven / 2011           
$code = $this->bbcode_tpl('code_open') . $code . $this->bbcode_tpl('code_close');
}
else
{
$code = '';
} 
or replace with (if you want a code box with information for gustes and bots)

Code: Select all

global $user;
if (!$user->data['is_bot'] && $user->data['user_id'] != 1)
{        
// Make Links clickable in [ code ] Tags / AmigoJack / 4seven / 2011
$code = make_clickable( str_replace( array( ':', '.' ), array( ':', '.' ), $code ), generate_board_url() );
// Make Links clickable in [ code ] Tags / AmigoJack / 4seven / 2011           
$code = $this->bbcode_tpl('code_open') . $code . $this->bbcode_tpl('code_close');
}
else
{
$code = $this->bbcode_tpl('code_open') . 'Content only viewable by Members' . $this->bbcode_tpl('code_close');
} 
------------

@ user751139

Dont forget to add your personal patch before
http://www.phpbb.com/community/viewtopi ... #p12975025
Current Mods | Mod Base | php(BB) programming | No help via PM

User avatar
vsabah
Registered User
Posts: 357
Joined: Wed Apr 05, 2006 5:57 pm
Location: Konya / Türkiye
Contact:

Re: Clickable links in [code] bbcode

Post by vsabah » Tue Jan 10, 2012 8:54 am

4_seven wrote:4seven enterprises proudly presents the "top of the pop version" of

Make Links clickable in [ code ] Tags

open

includes/bbcode.php

find

Code: Select all

$code = $this->bbcode_tpl('code_open') . $code . $this->bbcode_tpl('code_close');   
before add

Code: Select all

// Make Links clickable in [code] Tags / AmigoJack / 4seven / 2011
$code = make_clickable( str_replace( array( ':', '.' ), array( ':', '.' ), $code ), generate_board_url() ); 
// Make Links clickable in [code] Tags / AmigoJack / 4seven / 2011              
Demo:
http://www.4seven.de/forum/1/viewtopic.php?p=389#p389

Features:
- Works recursive (no re-parsing needed)
- "Recognize e-mails links, links with login data, links with IPv6, links with ports"
- "Use already existing phpBB code"
It worked! 8-)

Thanks...

User avatar
Strappado
Registered User
Posts: 98
Joined: Sun Feb 12, 2012 11:53 am
Location: Sweden

Re: Clickable links in [code] bbcode

Post by Strappado » Fri Feb 17, 2012 10:47 am

4_seven wrote:
find

Code: Select all

$code = $this->bbcode_tpl('code_open') . $code . $this->bbcode_tpl('code_close');   
before add

Code: Select all

// Make Links clickable in [code] Tags / AmigoJack / 4seven / 2011
$code = make_clickable( str_replace( array( ':', '.' ), array( ':', '.' ), $code ), generate_board_url() ); 
// Make Links clickable in [code] Tags / AmigoJack / 4seven / 2011                 
Works great, thanks!

A small question: Any chance to make the URL DESCRIPTION BBCODE to show as a link to?
This one: Description

User avatar
AmigoJack
Registered User
Posts: 5656
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Clickable links in [code] bbcode

Post by AmigoJack » Fri Feb 17, 2012 12:15 pm

A URL is something unique, like http://www.phpbb.com
A description is a text, like click me
A link is something to click on, like in HTML <a href="[b]URL[/b]">[b]description[/b]</a>

...and you want

Code: Select all

[url=http://www.phpbb.com]click me[/url]
to turn out as

Code: Select all

[url=http://www.phpbb.com]http://phpbb.com[/url]
, which in turn would be

Code: Select all

[url]http://www.phpbb.com[/url]
? This makes so no sense an any way... On top it has nothing to do with code tags...
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

User avatar
Strappado
Registered User
Posts: 98
Joined: Sun Feb 12, 2012 11:53 am
Location: Sweden

Re: Clickable links in [code] bbcode

Post by Strappado » Fri Feb 17, 2012 1:25 pm

Look at this image: http://i.imgur.com/CRgkF.png
I want it to be possible to make a hotlink inside the [code][/code] tags using
[url=http://www.phpbb.com]click me[/url]

At this point it only results in plain text.

User avatar
AmigoJack
Registered User
Posts: 5656
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Clickable links in [code] bbcode

Post by AmigoJack » Fri Feb 17, 2012 2:29 pm

One of the main purposes of the code tag is to not parse BBCode. You seem to use the code for optical reasons. In that case I suggest to add a custom BBCode - the HTML replacement would be:

Code: Select all

<dl class="codebox"><dd><code>{TEXT}</code></dd></dl>
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

User avatar
Strappado
Registered User
Posts: 98
Joined: Sun Feb 12, 2012 11:53 am
Location: Sweden

Re: Clickable links in [code] bbcode

Post by Strappado » Fri Feb 17, 2012 3:05 pm

Yes but I am using 4_seven's code together with the "hide code (links) until reply" MOD.
Adding a custom code removes the hide feature.

User avatar
Strappado
Registered User
Posts: 98
Joined: Sun Feb 12, 2012 11:53 am
Location: Sweden

Re: Clickable links in [code] bbcode

Post by Strappado » Fri Feb 17, 2012 3:38 pm

Must be a way to just allow the [url=http://example.com]example[/url] tag to 4seven's script.

User avatar
AmigoJack
Registered User
Posts: 5656
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Clickable links in [code] bbcode

Post by AmigoJack » Fri Feb 17, 2012 7:50 pm

Strappado wrote:"hide code (links) until reply" MOD
One of the sloppiest MODs I've ever encountered: huge performance hit and it can be bypassed easily.

The following modification will add a new parameter for the code tag. Open /includes/message_parser.php and find:

Code: Select all

    function bbcode_parse_code($stx, &$code)
    {
        switch (strtolower($stx))
        { 
After, add:

Code: Select all

            /*** 2012-02-17 BEGIN AmigoJack
                Have a code box which parses BBCode. Only downside: post options are not
                considered and instead must be set here globally ***/
            case 'parse':
                $oMP= new parse_message();
                $oMP-> message= &$code;
                $oMP-> parse
                ( FALSE  // Allow BBCode at all
                , $config['allow_post_links']  // magic links
                , FALSE  // Smilies
                , TRUE  // Images
                , FALSE  // Flash
                , TRUE  // Quote
                , $config['allow_post_links']  // URL
                );
                    
                return '[code='. $stx. ':'. $this-> bbcode_uid. ']'. $code. '[/code:'. $this-> bbcode_uid. ']';
            break;
            /*** 2012-02-17 END ***/ 
Tested. Use it this way:

Code: Select all

[code=parse] here go all the [b]BBCodes[/b] I want to be [url=http://www.phpbb.com/community/viewtopic.php?f=72&t=1536535]parsed[/url] 
[/code]
Last edited by AmigoJack on Sat Feb 18, 2012 2:16 pm, edited 1 time in total.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

User avatar
Strappado
Registered User
Posts: 98
Joined: Sun Feb 12, 2012 11:53 am
Location: Sweden

Re: Clickable links in [code] bbcode

Post by Strappado » Fri Feb 17, 2012 10:01 pm

Thanks man seems to work!
How do I make

Code: Select all

 appear when clicking the "Code" button?. 
Or can you help me with a custom BB Code that works with your code?

User avatar
AmigoJack
Registered User
Posts: 5656
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Clickable links in [code] bbcode

Post by AmigoJack » Fri Feb 17, 2012 11:23 pm

It doesn't work that way and it depends on your style. For prosilver open /styles/prosilver/template/posting_buttons.html and find:

Code: Select all

	<input type="button" class="button2" accesskey="c" name="addbbcode8" value="Code" style="width: 40px" onclick="bbstyle(8)" title="{L_BBCODE_C_HELP}" />
After, add:

Code: Select all

	<input type="button" class="button2" name="addbbcodeparse" value="Code=Parse" style="width: 60px" onclick="bbfontstyle( '[code=parse]', '
' );" title="{L_BBCODE_C_HELP}" />[/code] Untested.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

User avatar
Strappado
Registered User
Posts: 98
Joined: Sun Feb 12, 2012 11:53 am
Location: Sweden

Re: Clickable links in [code] bbcode

Post by Strappado » Sat Feb 18, 2012 8:25 am

I have Subsilver2, I tested the code and tried to modify it for the template but i can't get it to work.
Any chance to help me out here? =)

I am using the "Advanced BBCode Box 3" btw. Guess it needs some edits to?

User avatar
AmigoJack
Registered User
Posts: 5656
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Clickable links in [code] bbcode

Post by AmigoJack » Sat Feb 18, 2012 9:30 am

In subsilver2 you'd have to open /styles/subsilver2/template/posting_buttons.html and find:

Code: Select all

		<input type="button" class="btnbbcode" accesskey="c" name="addbbcode8" value="Code" style="width: 40px" onclick="bbstyle(8)" onmouseover="helpline('c')" onmouseout="helpline('tip')" />
After, add:

Code: Select all

		<input type="button" class="btnbbcode" name="addbbcodeparse" value="Code=Parse" style="width: 60px" onclick="bbfontstyle( '[code=parse]', '
' );" />[/code] Untested aswell. Remember to purge the cache (refresh your templates), so modifications are carried out.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

User avatar
Strappado
Registered User
Posts: 98
Joined: Sun Feb 12, 2012 11:53 am
Location: Sweden

Re: Clickable links in [code] bbcode

Post by Strappado » Sat Feb 18, 2012 10:44 am

It works, but... it seems like I need a fix for Advanced Code Box =/.
Do you know how to edit those files?

This is how it looks now: http://i.imgur.com/65GaE.png

Locked

Return to “[3.0.x] MOD Requests”