]> git.mxchange.org Git - friendica.git/blobdiff - include/oembed.php
Cleanup /format pre-move
[friendica.git] / include / oembed.php
index 5abd03b61769587180e292d9ebdb825e12ddf757..564626317b38cc81c887b7e3a724db6a5af81c35 100755 (executable)
@@ -4,8 +4,8 @@
  * @file include/oembed.php
  */
 
-use \Friendica\ParseUrl;
-use \Friendica\Core\Config;
+use Friendica\ParseUrl;
+use Friendica\Core\Config;
 
 function oembed_replacecb($matches){
        $embedurl=$matches[1];
@@ -17,10 +17,10 @@ function oembed_replacecb($matches){
 
 /**
  * @brief Get data from an URL to embed its content.
- * 
+ *
  * @param string $embedurl The URL from which the data should be fetched.
  * @param bool $no_rich_type If set to true rich type content won't be fetched.
- * 
+ *
  * @return bool|object Returns object with embed content or false if no embedable
  *      content exists
  */
@@ -41,8 +41,8 @@ function oembed_fetch_url($embedurl, $no_rich_type = false){
        // These media files should now be caught in bbcode.php
        // left here as a fallback in case this is called from another source
 
-       $noexts = array("mp3","mp4","ogg","ogv","oga","ogm","webm");
-       $ext = pathinfo(strtolower($embedurl),PATHINFO_EXTENSION);
+       $noexts = array("mp3", "mp4", "ogg", "ogv", "oga", "ogm", "webm");
+       $ext = pathinfo(strtolower($embedurl), PATHINFO_EXTENSION);
 
 
        if (is_null($txt)) {
@@ -74,21 +74,10 @@ function oembed_fetch_url($embedurl, $no_rich_type = false){
                        }
                }
 
-               if ($txt==false || $txt=="") {
-                       $embedly = Config::get("system", "embedly");
-                       if ($embedly != "") {
-                               // try embedly service
-                               $ourl = "https://api.embed.ly/1/oembed?key=".$embedly."&url=".urlencode($embedurl);
-                               $txt = fetch_url($ourl);
-
-                               logger("oembed_fetch_url: ".$txt, LOGGER_DEBUG);
-                       }
-               }
-
-               $txt=trim($txt);
+               $txt = trim($txt);
 
-               if ($txt[0]!="{") {
-                       $txt='{"type":"error"}';
+               if ($txt[0] != "{") {
+                       $txt = '{"type":"error"}';
                } else {        //save in cache
                        $j = json_decode($txt);
                        if ($j->type != "error") {
@@ -165,12 +154,12 @@ 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(),
-                                       '$embedurl'=>$embedurl,
-                                       '$escapedhtml'=>base64_encode($jhtml),
-                                       '$tw'=>$tw,
-                                       '$th'=>$th,
-                                       '$turl'=>$j->thumbnail_url,
+                                       '$baseurl'     => App::get_baseurl(),
+                                       '$embedurl'    => $embedurl,
+                                       '$escapedhtml' => base64_encode($jhtml),
+                                       '$tw'          => $tw,
+                                       '$th'          => $th,
+                                       '$turl'        => $j->thumbnail_url,
                                ));
 
                        } else {
@@ -255,12 +244,14 @@ function oembed_format_object($j){
  * @see oembed_format_object()
  */
 function oembed_iframe($src, $width, $height) {
+       $a = get_app();
+
        if (!$height || strstr($height,'%')) {
                $height = '200';
        }
        $width = '100%';
 
-       $s = App::get_baseurl() . '/oembed/'.base64url_encode($src);
+       $s = App::get_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>';
 }