coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: firswood on October 13, 2006, 05:54:18 PM

Title: bbcode - email not working
Post by: firswood on October 13, 2006, 05:54:18 PM
Can someoen explain to me why the bbcode

EMAIL ME (test@test.com)

does not work in the category header - it just shows the code in raw state as you can see.

www.theartgallery.co.uk/cpg149 -

you can see the output in the first cat heading for emma knowles 
Title: Re: bbcode - email not working
Post by: Nibbler on October 13, 2006, 06:22:30 PM
The email tag works only as described in the documentation.

http://coppermine-gallery.net/demo/cpg14x/docs/index.htm#bbcode

I've posted how to use the alternative syntax you are attempting before, try searching the board for it.
Title: Re: bbcode - email not working
Post by: firswood on October 13, 2006, 08:44:21 PM
Thank you nibbler i assumed that cpg would recognise all basic bbcode.

Can you explain why it recognises the Url Text (http://yoursite.com/) but not when applied to the email variation?

So while I can format a 'click here' to visit a web site, I cannot do the same for an email address - i have to therefore display the email address to get it to work.
Title: Re: bbcode - email not working
Post by: Nibbler on October 13, 2006, 08:52:18 PM
It's simply not a feature of Coppermine.
Title: Re: bbcode - email not working
Post by: djpushplay on October 15, 2006, 04:39:08 AM
Quote from: firswood on October 13, 2006, 05:54:18 PM
Can someoen explain to me why the bbcode

EMAIL ME (test@test.com)

does not work in the category header - it just shows the code in raw state as you can see.


As per the previous post, the simple explaination is that the bbcode conversion code does not support this feature that you are seeking.  If you must have it, replace the bb_decode() function with the following version:


/**
* bb_decode()
*
* @param $text
* @return
**/

function bb_decode($text)
{
    $text = nl2br($text);

    static $bbcode_tpl = array();
    static $patterns = array();
    static $replacements = array();

    // First: If there isn't a "[" and a "]" in the message, don't bother.
    if ((strpos($text, "[") === false || strpos($text, "]") === false))
    {
return $text;
    }

    // [b] and [/b] for bolding text.
    $text = str_replace("[b]", '<b>', $text);
    $text = str_replace("[/b]", '</b>', $text);

    // [u] and [/u] for underlining text.
    $text = str_replace("[u]", '<u>', $text);
    $text = str_replace("[/u]", '</u>', $text);

    // [i] and [/i] for italicizing text.
    $text = str_replace("[i]", '<i>', $text);
    $text = str_replace("[/i]", '</i>', $text);

    // colours
    $text = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+)\]/", '<span style="color:$1">', $text);
    $text = str_replace("[/color]", '</span>', $text);

    // [i] and [/i] for italicizing text.
    //$text = str_replace("[i:$uid]", $bbcode_tpl['i_open'], $text);
    //$text = str_replace("[/i:$uid]", $bbcode_tpl['i_close'], $text);

if (!count($bbcode_tpl)) {
// We do URLs in several different ways..
$bbcode_tpl['url']  = '<span class="bblink"><a target="_blank" href="{URL}" rel="external">{DESCRIPTION}</a></span>'; //new code
$bbcode_tpl['email']= '<span class="bblink"><a href="mailto:{EMAIL}">{EMAIL}</a></span>';
$bbcode_tpl['email2'] = '<span class="bblink"><a href="mailto:{EMAIL}">{DESCRIPTION}</a></span>'; //new code

$bbcode_tpl['url1'] = str_replace('{URL}', '\\1\\2', $bbcode_tpl['url']);
$bbcode_tpl['url1'] = str_replace('{DESCRIPTION}', '\\1\\2', $bbcode_tpl['url1']);

$bbcode_tpl['url2'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
$bbcode_tpl['url2'] = str_replace('{DESCRIPTION}', '\\1', $bbcode_tpl['url2']);

$bbcode_tpl['url3'] = str_replace('{URL}', '\\1\\2', $bbcode_tpl['url']);
$bbcode_tpl['url3'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url3']);
$bbcode_tpl['url4'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
$bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\2', $bbcode_tpl['url4']);

$bbcode_tpl['email'] = str_replace('{EMAIL}', '\\1', $bbcode_tpl['email']); //new code
$bbcode_tpl['email2'] = str_replace('{EMAIL}', '\\1\\2', $bbcode_tpl['email2']); //new code
$bbcode_tpl['email2'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['email2']); //new code

// [url]xxxx://www.phpbb.com[/url] code..
$patterns[1] = "#\[url\]([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/url\]#si";
$replacements[1] = $bbcode_tpl['url1'];

// [url]www.phpbb.com[/url] code.. (no xxxx:// prefix).
$patterns[2] = "#\[url\]([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/url\]#si";
$replacements[2] = $bbcode_tpl['url2'];

// [url=xxxx://www.phpbb.com]phpBB[/url] code..
$patterns[3] = "#\[url=([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/url\]#si";
$replacements[3] = $bbcode_tpl['url3'];

// [url=www.phpbb.com]phpBB[/url] code.. (no xxxx:// prefix).
$patterns[4] = "#\[url=([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/url\]#si";
$replacements[4] = $bbcode_tpl['url4'];

// [email]user@domain.tld[/email] code..
$patterns[5] = "#\[email\]([a-z0-9\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/email\]#si";
$replacements[5] = $bbcode_tpl['email'];

// [img]xxxx://www.phpbb.com[/img] code..
$bbcode_tpl['img']  = '<img src="{URL}" alt="" />';
$bbcode_tpl['img']  = str_replace('{URL}', '\\1\\2', $bbcode_tpl['img']);

$patterns[6] = "#\[img\]([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/img\]#si";
$replacements[6] = $bbcode_tpl['img'];
           
// [email=user@domain.tld]email me[/email] code..
$patterns[7] = "#\[email=([a-z0-9\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\](.*?)\[/email\]#si"; //new code
$replacements[7] = $bbcode_tpl['email2']; //new code
    }

    $text = preg_replace($patterns, $replacements, $text);

    return $text;
}


I could be written better but I just wrote it quickly right now. [I noticed in the preview that tabs do not work but I'm too lazy to replace them with the proper spaces so sorry it's so hard to read.]