]> git.mxchange.org Git - friendica.git/blobdiff - include/oembed.php
DFRN: Improved delivery status handling
[friendica.git] / include / oembed.php
index 498d9a721248b7815c210f0fb92dcc2e96723114..cb23517cdbabbfc17b44e502437143cd05e3cc8b 100755 (executable)
@@ -4,8 +4,9 @@
  * @file include/oembed.php
  */
 
-use \Friendica\ParseUrl;
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\ParseUrl;
+use Friendica\Core\Config;
 
 function oembed_replacecb($matches){
        $embedurl=$matches[1];
@@ -81,11 +82,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 +105,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"];
 
@@ -193,7 +191,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;