]> git.mxchange.org Git - friendica.git/blobdiff - include/oembed.php
Split the name in the hcard
[friendica.git] / include / oembed.php
old mode 100755 (executable)
new mode 100644 (file)
index 0f3296b..b7c1616
@@ -5,8 +5,11 @@
  */
 
 use Friendica\App;
+use Friendica\Core\Cache;
+use Friendica\Core\System;
 use Friendica\ParseUrl;
 use Friendica\Core\Config;
+use Friendica\Database\DBM;
 
 function oembed_replacecb($matches){
        $embedurl=$matches[1];
@@ -25,17 +28,17 @@ function oembed_replacecb($matches){
  * @return bool|object Returns object with embed content or false if no embedable
  *      content exists
  */
-function oembed_fetch_url($embedurl, $no_rich_type = false){
+function oembed_fetch_url($embedurl, $no_rich_type = false) {
        $embedurl = trim($embedurl, "'");
        $embedurl = trim($embedurl, '"');
 
        $a = get_app();
 
-       $r = q("SELECT * FROM `oembed` WHERE `url` = '%s'",
-               dbesc(normalise_link($embedurl)));
+       $condition = array('url' => normalise_link($embedurl));
+       $r = dba::select('oembed', array('content'), $condition, array('limit' => 1));
 
-       if (dbm::is_result($r)) {
-               $txt = $r[0]["content"];
+       if (DBM::is_result($r)) {
+               $txt = $r["content"];
        } else {
                $txt = Cache::get($a->videowidth . $embedurl);
        }
@@ -82,11 +85,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);
@@ -155,7 +155,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,
@@ -252,7 +252,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 '<iframe onload="resizeIframe(this);" class="embed_rich" height="' . $height . '" width="' . $width . '" src="' . $s . '" allowfullscreen scrolling="no" frameborder="no">' . t('Embedded content') . '</iframe>';
 }