X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=include%2Fbbcode.php;h=261bdfcf660cc69034a5c927088a77a08aaf0bd8;hb=b0025745909b527127c7dd09fea0f9920158b595;hp=a14e3ee8e9b88f9377b6d9ed02adb73b1e18e59e;hpb=ad3566aeaa8825d0f0968203e48cdb66a2918049;p=friendica.git
diff --git a/include/bbcode.php b/include/bbcode.php
index a14e3ee8e9..261bdfcf66 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -1,16 +1,17 @@
' . generate_map(str_replace('/', ' ', $match[1])) . '', $match[0]);
+ return str_replace($match[0], '
' . Map::byCoordinates(str_replace('/', ' ', $match[1])) . '
', $match[0]);
}
function bb_map_location($match) {
// the extra space in the following line is intentional
- return str_replace($match[0], '' . generate_named_map($match[1]) . '
', $match[0]);
+ return str_replace($match[0], '' . Map::byLocation($match[1]) . '
', $match[0]);
}
function bb_attachment($Text, $simplehtml = false, $tryoembed = true) {
@@ -51,7 +52,10 @@ function bb_attachment($Text, $simplehtml = false, $tryoembed = true) {
$data["title"] = str_replace(array("http://", "https://"), "", $data["title"]);
}
- if (((strpos($data["text"], "[img=") !== false) || (strpos($data["text"], "[img]") !== false)) && ($data["image"] != "")) {
+ if (((strpos($data["text"], "[img=") !== false)
+ || (strpos($data["text"], "[img]") !== false)
+ || Config::get('system', 'always_show_preview'))
+ && ($data["image"] != "")) {
$data["preview"] = $data["image"];
$data["image"] = "";
}
@@ -228,7 +232,7 @@ function tryoembed($match) {
$url = str_replace(array("http://www.youtube.com/", "http://player.vimeo.com/"),
array("https://www.youtube.com/", "https://player.vimeo.com/"), $url);
- $o = oembed_fetch_url($url);
+ $o = OEmbed::fetchURL($url);
if (!is_object($o)) {
return $match[0];
@@ -242,7 +246,7 @@ function tryoembed($match) {
return $match[0];
}
- $html = oembed_format_object($o);
+ $html = OEmbed::formatObject($o);
return $html;
}
@@ -372,7 +376,6 @@ function bb_tag_preg_replace($pattern, $replace, $name, $s) {
return $string;
}
-if (! function_exists('bb_extract_images')) {
function bb_extract_images($body) {
$saved_image = array();
@@ -414,9 +417,8 @@ function bb_extract_images($body) {
$new_body = $new_body . $orig_body;
return array('body' => $new_body, 'images' => $saved_image);
-}}
+}
-if (! function_exists('bb_replace_images')) {
function bb_replace_images($body, $images) {
$newbody = $body;
@@ -431,163 +433,176 @@ function bb_replace_images($body, $images) {
}
return $newbody;
-}}
+}
-function bb_ShareAttributes($share, $simplehtml) {
+function bb_ShareAttributes($share, $simplehtml)
+{
$attributes = $share[2];
$author = "";
preg_match("/author='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
+ if (x($matches, 1)) {
+ $author = html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8');
+ }
preg_match('/author="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
+ if (x($matches, 1)) {
$author = $matches[1];
+ }
$profile = "";
preg_match("/profile='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
+ if (x($matches, 1)) {
$profile = $matches[1];
+ }
preg_match('/profile="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
+ if (x($matches, 1)) {
$profile = $matches[1];
+ }
$avatar = "";
preg_match("/avatar='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
+ if (x($matches, 1)) {
$avatar = $matches[1];
+ }
preg_match('/avatar="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
+ if (x($matches, 1)) {
$avatar = $matches[1];
+ }
$link = "";
preg_match("/link='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
+ if (x($matches, 1)) {
$link = $matches[1];
+ }
preg_match('/link="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
+ if (x($matches, 1)) {
$link = $matches[1];
+ }
$posted = "";
- $itemcache = get_itemcachepath();
-
preg_match("/posted='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
+ if (x($matches, 1)) {
$posted = $matches[1];
+ }
preg_match('/posted="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
+ if (x($matches, 1)) {
$posted = $matches[1];
-
- // relative dates only make sense when they aren't cached
- if ($itemcache == "")
- $reldate = (($posted) ? " " . relative_date($posted) : '');
+ }
// We only call this so that a previously unknown contact can be added.
// This is important for the function "get_contact_details_by_url".
// This function then can fetch an entry from the contact table.
- get_contact($profile, 0);
+ Contact::getIdForURL($profile, 0);
- $data = get_contact_details_by_url($profile);
+ $data = Contact::getDetailsByURL($profile);
- if (isset($data["name"]) && ($data["name"] != "") && isset($data["addr"]) && ($data["addr"] != ""))
- $userid_compact = $data["name"]." (".$data["addr"].")";
- else
- $userid_compact = GetProfileUsername($profile,$author, true);
+ if (x($data, "name") && x($data, "addr")) {
+ $userid_compact = $data["name"] . " (" . $data["addr"] . ")";
+ } else {
+ $userid_compact = GetProfileUsername($profile, $author, true);
+ }
- if (isset($data["addr"]) && ($data["addr"] != ""))
+ if (x($data, "addr")) {
$userid = $data["addr"];
- else
- $userid = GetProfileUsername($profile,$author, false);
+ } else {
+ $userid = GetProfileUsername($profile, $author, false);
+ }
- if (isset($data["name"]) && ($data["name"] != ""))
+ if (x($data, "name")) {
$author = $data["name"];
+ }
- if (isset($data["micro"]) && ($data["micro"] != ""))
+ if (x($data, "micro")) {
$avatar = $data["micro"];
+ }
$preshare = trim($share[1]);
- if ($preshare != "")
+ if ($preshare != "") {
$preshare .= "
";
+ }
switch ($simplehtml) {
case 1:
- $text = $preshare.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').' '.$userid.":
»".$share[3]."«";
+ $text = $preshare . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . ' ' . $userid . ":
»" . $share[3] . "«";
break;
case 2:
- $text = $preshare.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').' '.$userid_compact.":
".$share[3];
+ $text = $preshare . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . ' ' . $userid_compact . ":
" . $share[3];
break;
case 3: // Diaspora
- $headline .= ''.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').$userid.':
';
+ $headline .= '' . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . $userid . ':
';
$text = trim($share[1]);
- if ($text != "")
+ if ($text != "") {
$text .= "
";
+ }
if (substr(normalise_link($link), 0, 19) != "http://twitter.com/") {
- $text .= $headline.''.trim($share[3])."
";
+ $text .= $headline . '' . trim($share[3]) . "
";
- if ($link != "")
- $text .= '
[l]';
- } else
- $text .= '
'.$link.'';
+ if ($link != "") {
+ $text .= '
[l]';
+ }
+ } else {
+ $text .= '
' . $link . '';
+ }
break;
case 4:
- $headline .= '
'.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8');
- $headline .= sprintf(t('%2$s %3$s'), $link, $userid, $posted);
+ $headline .= '
' . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8');
+ $headline .= t('%2$s %3$s', $link, $userid, $posted);
$headline .= ":
";
$text = trim($share[1]);
- if ($text != "")
+ if ($text != "") {
$text .= "
";
+ }
- $text .= $headline.''.trim($share[3])."
";
+ $text .= $headline . '' . trim($share[3]) . "
";
break;
case 5:
- $text = $preshare.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').' '.$userid_compact.":
".$share[3];
+ $text = $preshare . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . ' ' . $userid_compact . ":
" . $share[3];
break;
case 6: // app.net
- $text = $preshare.">> @".$userid_compact.":
".$share[3];
+ $text = $preshare . ">> @" . $userid_compact . ":
" . $share[3];
break;
case 7: // statusnet/GNU Social
- $text = $preshare.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8')." @".$userid_compact.": ".$share[3];
+ $text = $preshare . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . " @" . $userid_compact . ": " . $share[3];
break;
case 8: // twitter
- $text = $preshare."RT @".$userid_compact.": ".$share[3];
+ $text = $preshare . "RT @" . $userid_compact . ": " . $share[3];
break;
case 9: // Google+/Facebook
- $text = $preshare.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').' '.$userid_compact.":
".$share[3];
+ $text = $preshare . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . ' ' . $userid_compact . ":
" . $share[3];
- if ($link != "")
- $text .= "
".$link;
+ if ($link != "") {
+ $text .= "
" . $link;
+ }
break;
default:
- $text = trim($share[1])."\n";
+ $text = trim($share[1]) . "\n";
$avatar = proxy_url($avatar, false, PROXY_SIZE_THUMB);
$tpl = get_markup_template('shared_content.tpl');
- $text .= replace_macros($tpl,
- array(
- '$profile' => $profile,
- '$avatar' => $avatar,
- '$author' => $author,
- '$link' => $link,
- '$posted' => $posted,
- '$reldate' => $reldate,
- '$content' => trim($share[3])
- )
- );
+ $text .= replace_macros($tpl, array(
+ '$profile' => $profile,
+ '$avatar' => $avatar,
+ '$author' => $author,
+ '$link' => $link,
+ '$posted' => $posted,
+ '$content' => trim($share[3])
+ )
+ );
break;
}
@@ -913,7 +928,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
$Text = str_replace("\r\n", "\n", $Text);
// removing multiplicated newlines
- if (get_config("system", "remove_multiplicated_lines")) {
+ if (Config::get("system", "remove_multiplicated_lines")) {
$search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]", "[/li]\n", "\n[li]", "\n[ul]", "[/ul]\n", "\n\n[share ", "[/attachment]\n",
"\n[h1]", "[/h1]\n", "\n[h2]", "[/h2]\n", "\n[h3]", "[/h3]\n", "\n[h4]", "[/h4]\n", "\n[h5]", "[/h5]\n", "\n[h6]", "[/h6]\n");
$replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]", "[/li]", "[li]", "[ul]", "[/ul]", "\n[share ", "[/attachment]",
@@ -940,17 +955,17 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
// Remove all hashtag addresses
if ((!$tryoembed || $simplehtml) && !in_array($simplehtml, array(3, 7))) {
- $Text = preg_replace("/([#@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $Text);
+ $Text = preg_replace("/([#@!])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $Text);
} elseif ($simplehtml == 3) {
- $Text = preg_replace("/([@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
+ $Text = preg_replace("/([@!])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
'$1$3',
$Text);
} elseif ($simplehtml == 7) {
- $Text = preg_replace("/([@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
+ $Text = preg_replace("/([@!])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
'$1$3',
$Text);
} elseif (!$simplehtml) {
- $Text = preg_replace("/([@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
+ $Text = preg_replace("/([@!])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
'$1$3',
$Text);
}
@@ -962,13 +977,13 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
"[bookmark=$1]$2[/bookmark]", $Text);
if (in_array($simplehtml, array(2, 6, 7, 8, 9))) {
- $Text = preg_replace_callback("/([^#@])\[url\=([^\]]*)\](.*?)\[\/url\]/ism", "bb_expand_links", $Text);
- //$Text = preg_replace("/[^#@]\[url\=([^\]]*)\](.*?)\[\/url\]/ism", ' $2 [url]$1[/url]', $Text);
+ $Text = preg_replace_callback("/([^#@!])\[url\=([^\]]*)\](.*?)\[\/url\]/ism", "bb_expand_links", $Text);
+ //$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) {
- $Text = preg_replace("/[^#@]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[url]$1[/url]', $Text);
+ $Text = preg_replace("/[^#@!]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[url]$1[/url]', $Text);
}
// Perform URL Search
@@ -1261,7 +1276,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
// $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", '', $Text);
// oembed tag
- $Text = oembed_bbcode2html($Text);
+ $Text = OEmbed::BBCode2HTML($Text);
// Avoid triple linefeeds through oembed
$Text = str_replace("
", "
", $Text);