X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Foembed.php;h=715a0ba5bd6454445043bea6875bdad17a5fd112;hb=1ff217cc1373099b0e52ba8de5ab4a1335b0f184;hp=0b8b713667e7aa1faede525a5a08db1b07b03c0b;hpb=49527b70d34cfc899b8ba1a3876a14bb11ed9e8a;p=friendica.git diff --git a/include/oembed.php b/include/oembed.php index 0b8b713667..715a0ba5bd 100755 --- a/include/oembed.php +++ b/include/oembed.php @@ -4,8 +4,10 @@ * @file include/oembed.php */ -use \Friendica\ParseUrl; -use \Friendica\Core\Config; +use Friendica\App; +use Friendica\Core\System; +use Friendica\ParseUrl; +use Friendica\Core\Config; function oembed_replacecb($matches){ $embedurl=$matches[1]; @@ -81,11 +83,8 @@ function oembed_fetch_url($embedurl, $no_rich_type = false){ } else { //save in cache $j = json_decode($txt); if ($j->type != "error") { - q("INSERT INTO `oembed` (`url`, `content`, `created`) VALUES ('%s', '%s', '%s') - ON DUPLICATE KEY UPDATE `content` = '%s', `created` = '%s'", - dbesc(normalise_link($embedurl)), - dbesc($txt), dbesc(datetime_convert()), - dbesc($txt), dbesc(datetime_convert())); + dba::insert('oembed', array('url' => normalise_link($embedurl), + 'content' => $txt, 'created' => datetime_convert()), true); } Cache::set($a->videowidth.$embedurl, $txt, CACHE_DAY); @@ -107,7 +106,7 @@ function oembed_fetch_url($embedurl, $no_rich_type = false){ $j->embedurl = $embedurl; // If fetching information doesn't work, then improve via internal functions - if (($j->type == "error") OR ($no_rich_type AND ($j->type == "rich"))) { + if (($j->type == "error") || ($no_rich_type && ($j->type == "rich"))) { $data = ParseUrl::getSiteinfoCached($embedurl, true, false); $j->type = $data["type"]; @@ -154,7 +153,7 @@ function oembed_format_object($j){ $th=120; $tw = $th*$tr; $tpl=get_markup_template('oembed_video.tpl'); $ret.=replace_macros($tpl, array( - '$baseurl' => App::get_baseurl(), + '$baseurl' => System::baseUrl(), '$embedurl' => $embedurl, '$escapedhtml' => base64_encode($jhtml), '$tw' => $tw, @@ -193,7 +192,7 @@ function oembed_format_object($j){ if (isset($j->author_name)) { $ret.=" (".$j->author_name.")"; } - } elseif (isset($j->provider_name) OR isset($j->author_name)) { + } elseif (isset($j->provider_name) || isset($j->author_name)) { $embedlink = ""; if (isset($j->provider_name)) { $embedlink .= $j->provider_name; @@ -251,7 +250,7 @@ function oembed_iframe($src, $width, $height) { } $width = '100%'; - $s = App::get_baseurl() . '/oembed/' . base64url_encode($src); + $s = System::baseUrl() . '/oembed/' . base64url_encode($src); return ''; } @@ -303,9 +302,11 @@ function oembed_html2bbcode($text) { $entries = $xpath->query("//span[$xattr]"); $xattr = "@rel='oembed'";//oe_build_xpath("rel","oembed"); - foreach($entries as $e) { + foreach ($entries as $e) { $href = $xpath->evaluate("a[$xattr]/@href", $e)->item(0)->nodeValue; - if(!is_null($href)) $e->parentNode->replaceChild(new DOMText("[embed]".$href."[/embed]"), $e); + if (!is_null($href)) { + $e->parentNode->replaceChild(new DOMText("[embed]".$href."[/embed]"), $e); + } } return oe_get_inner_html( $dom->getElementsByTagName("body")->item(0) ); } else {