2010-02-10 18:18:01 +00:00
|
|
|
// $Id$
|
2011-11-29 23:37:44 +00:00
|
|
|
//<?
|
2012-05-22 07:27:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
$class = "bbcode ".e107::getBB()->getClass('link');
|
2021-01-14 14:46:49 -08:00
|
|
|
global $pref, $parm;
|
2006-12-02 04:36:16 +00:00
|
|
|
|
2010-01-24 11:45:04 +00:00
|
|
|
/**
|
|
|
|
* e107 BBCodes
|
|
|
|
*
|
|
|
|
* @package e107
|
|
|
|
* @subpackage bbcode
|
2010-02-10 18:18:01 +00:00
|
|
|
* @version $Id$;
|
2010-01-24 11:45:04 +00:00
|
|
|
*
|
|
|
|
* @todo try and avoid URLs with a language in [..]
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2007-10-13 20:48:34 +00:00
|
|
|
[link=$parm $extras]$code_text[/link]
|
|
|
|
Correct Usage:
|
|
|
|
[link=http://mysite.com external]My text[/link]
|
|
|
|
[link=http://mysite.com rel=external]My text[/link]
|
|
|
|
[link=external]http://mysite.com[/link]
|
|
|
|
[link]http://mysite.com[/link]
|
|
|
|
[link=mailto:myemail@email.com]My name[/link]
|
|
|
|
Historic usage:
|
|
|
|
[link=external=http://mysite.com]My text[/link]
|
|
|
|
*/
|
|
|
|
|
2011-11-29 23:37:44 +00:00
|
|
|
$tp = e107::getParser();
|
2021-01-14 14:46:49 -08:00
|
|
|
|
|
|
|
$parm = $tp->filter(trim($parm));
|
2007-10-13 20:48:34 +00:00
|
|
|
|
|
|
|
/* Fix for people using link=external= */
|
|
|
|
if(strpos($parm,"external=") !== FALSE)
|
|
|
|
{
|
2008-01-12 18:52:16 +00:00
|
|
|
list($extras,$parm) = explode("=",$parm,2);
|
2007-10-13 20:48:34 +00:00
|
|
|
$parm = $parm." ".$extras;
|
|
|
|
}
|
|
|
|
|
2020-12-20 11:50:10 -08:00
|
|
|
if(strpos($parm, 'mailto') === 0)
|
2007-10-13 20:48:34 +00:00
|
|
|
{
|
|
|
|
list($pre,$email) = explode(":",$parm);
|
|
|
|
list($p1,$p2) = explode("@",$email);
|
2007-12-24 16:12:37 +00:00
|
|
|
$p2=rawurlencode($p2); // Primarily to pick up spaces, which are not allowed
|
2007-10-13 20:48:34 +00:00
|
|
|
return "<a class='bbcode' rel='external' href='javascript:window.location=\"mai\"+\"lto:\"+\"$p1\"+\"@\"+\"$p2\";self.close();' onmouseover='window.status=\"mai\"+\"lto:\"+\"$p1\"+\"@\"+\"$p2\"; return true;' onmouseout='window.status=\"\";return true;'>".$code_text."</a>";
|
|
|
|
}
|
|
|
|
|
2017-01-29 18:43:52 -08:00
|
|
|
if (substr($code_text,0,1) === ']')
|
2010-01-24 11:45:04 +00:00
|
|
|
{ // Special fix for E107 urls including a language (not nice, really)
|
|
|
|
$code_text = substr($code_text,1);
|
|
|
|
$parm .= ']';
|
|
|
|
}
|
|
|
|
|
2020-01-18 13:36:45 +01:00
|
|
|
list($link,$extras) = array_pad(explode(" ",$parm), 2, null);
|
2007-10-13 20:48:34 +00:00
|
|
|
|
|
|
|
if(!$parm) $link = $code_text;
|
|
|
|
|
2020-12-12 11:32:23 -08:00
|
|
|
if($link == "external" && empty($extras))
|
2007-10-13 20:48:34 +00:00
|
|
|
{
|
|
|
|
$link = $code_text;
|
|
|
|
$extras = "rel=external";
|
|
|
|
}
|
|
|
|
|
2021-09-04 15:06:19 +02:00
|
|
|
$extras = (string) $extras;
|
2007-11-13 07:38:55 +00:00
|
|
|
if($extras == "external" || strpos($extras,"rel=external")!==FALSE)
|
|
|
|
{
|
|
|
|
$insert = "rel='external' ";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-01-29 16:30:49 +00:00
|
|
|
$insert = ($pref['links_new_window'] && strpos($link,"{e_")===FALSE && substr($link,0,1) != "#" && substr($link,0,1) != "/" && strpos($extras,"rel=internal")===FALSE) ? "rel='external' " : "";
|
2007-11-13 07:38:55 +00:00
|
|
|
}
|
2007-10-13 20:48:34 +00:00
|
|
|
if (strtolower(substr($link,0,11)) == 'javascript:') return '';
|
2021-01-14 14:46:49 -08:00
|
|
|
return "<a class='{$class}' href='".e107::getParser() -> toAttribute($link)."' ".$insert.">".$code_text."</a>";
|
2007-10-13 20:48:34 +00:00
|
|
|
|