Diaspora: Better handling of "red"-links
This commit is contained in:
parent
0f16672176
commit
35fbe3be14
|
@ -63,7 +63,8 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) {
|
||||||
/**
|
/**
|
||||||
* Transform #tags, strip off the [url] and replace spaces with underscore
|
* Transform #tags, strip off the [url] and replace spaces with underscore
|
||||||
*/
|
*/
|
||||||
$Text = preg_replace_callback('/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', create_function('$match',
|
$URLSearchString = "^\[\]";
|
||||||
|
$Text = preg_replace_callback("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/i", create_function('$match',
|
||||||
'return \'#\'. str_replace(\' \', \'_\', $match[2]);'
|
'return \'#\'. str_replace(\' \', \'_\', $match[2]);'
|
||||||
), $Text);
|
), $Text);
|
||||||
|
|
||||||
|
|
|
@ -40,11 +40,11 @@ function bb_remove_share_information($Text, $plaintext = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function bb_cleanup_share($shared) {
|
function bb_cleanup_share($shared) {
|
||||||
if ($shared[2] != "type-link")
|
if (!in_array($shared[2], array("type-link", "type-video")))
|
||||||
return($shared[3]);
|
return($shared[0]);
|
||||||
|
|
||||||
if (!preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$shared[3], $bookmark))
|
if (!preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$shared[3], $bookmark))
|
||||||
return($shared[3]);
|
return($shared[0]);
|
||||||
|
|
||||||
$title = "";
|
$title = "";
|
||||||
$link = "";
|
$link = "";
|
||||||
|
@ -747,9 +747,20 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
||||||
// Set up the parameters for a MAIL search string
|
// Set up the parameters for a MAIL search string
|
||||||
$MAILSearchString = $URLSearchString;
|
$MAILSearchString = $URLSearchString;
|
||||||
|
|
||||||
|
// Remove all hashtag addresses
|
||||||
|
if (!$tryoembed OR $simplehtml)
|
||||||
|
$Text = preg_replace("/([#@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $Text);
|
||||||
|
|
||||||
// Bookmarks in red - will be converted to bookmarks in friendica
|
// Bookmarks in red - will be converted to bookmarks in friendica
|
||||||
$Text = preg_replace("/#\^\[url\]([$URLSearchString]*)\[\/url\]/ism", '[bookmark=$1]$1[/bookmark]', $Text);
|
$Text = preg_replace("/#\^\[url\]([$URLSearchString]*)\[\/url\]/ism", '[bookmark=$1]$1[/bookmark]', $Text);
|
||||||
$Text = preg_replace("/#\^\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[bookmark=$1]$2[/bookmark]', $Text);
|
$Text = preg_replace("/#\^\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[bookmark=$1]$2[/bookmark]', $Text);
|
||||||
|
$Text = preg_replace("/#\[url\=[$URLSearchString]*\]\^\[\/url\]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/i",
|
||||||
|
"[bookmark=$1]$2[/bookmark]", $Text);
|
||||||
|
|
||||||
|
if ($simplehtml == 2) {
|
||||||
|
$Text = preg_replace("/[^#@]\[url\=([^\]]*)\](.*?)\[\/url\]/ism",' $2 [url]$1[/url]',$Text);
|
||||||
|
$Text = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",' $2 [url]$1[/url]',$Text);
|
||||||
|
}
|
||||||
|
|
||||||
if ($simplehtml == 5)
|
if ($simplehtml == 5)
|
||||||
$Text = preg_replace("/[^#@]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[url]$1[/url]', $Text);
|
$Text = preg_replace("/[^#@]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[url]$1[/url]', $Text);
|
||||||
|
@ -1063,11 +1074,11 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
||||||
// $Text = str_replace('<br /><ul','<ul ', $Text);
|
// $Text = str_replace('<br /><ul','<ul ', $Text);
|
||||||
|
|
||||||
// Remove all hashtag addresses
|
// Remove all hashtag addresses
|
||||||
if (!$tryoembed AND get_config("system", "remove_hashtags_on_export")) {
|
/* if (!$tryoembed AND get_config("system", "remove_hashtags_on_export")) {
|
||||||
$pattern = '/#<a.*?href="(.*?)".*?>(.*?)<\/a>/is';
|
$pattern = '/#<a.*?href="(.*?)".*?>(.*?)<\/a>/is';
|
||||||
$Text = preg_replace($pattern, '#$2', $Text);
|
$Text = preg_replace($pattern, '#$2', $Text);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
call_hooks('bbcode',$Text);
|
call_hooks('bbcode',$Text);
|
||||||
|
|
||||||
$a->save_timestamp($stamp1, "parser");
|
$a->save_timestamp($stamp1, "parser");
|
||||||
|
|
Loading…
Reference in a new issue