<?php\r
\r
-/*\r
- * To change this license header, choose License Headers in Project Properties.\r
- * To change this template file, choose Tools | Templates\r
- * and open the template in the editor.\r
+/**\r
+ * @file src/Content/OEmbed.php\r
*/\r
\r
namespace Friendica\Content;\r
require_once 'mod/proxy.php';\r
\r
/**\r
- * Description of OEmbed\r
+ * Handles all OEmbed content fetching and replacement\r
+ *\r
+ * OEmbed is a standard used to allow an embedded representation of a URL on\r
+ * third party sites\r
+ *\r
+ * @see https://oembed.com\r
*\r
- * @author benlo\r
+ * @author Hypolite Petovan <mrpetovan@gmail.com>\r
*/\r
class OEmbed\r
{\r
public static function replaceCallback($matches)\r
{\r
$embedurl = $matches[1];\r
- $j = OEmbed::fetchURL($embedurl);\r
- $s = OEmbed::formatObject($j);\r
+ $j = self::fetchURL($embedurl);\r
+ $s = self::formatObject($j);\r
\r
return $s;\r
}\r
public static function formatObject($j)\r
{\r
$embedurl = $j->embedurl;\r
- $jhtml = OEmbed::iframe($j->embedurl, (isset($j->width) ? $j->width : null), (isset($j->height) ? $j->height : null));\r
+ $jhtml = self::iframe($j->embedurl, (isset($j->width) ? $j->width : null), (isset($j->height) ? $j->height : null));\r
$ret = "<span class='oembed " . $j->type . "'>";\r
switch ($j->type) {\r
case "video":\r
}\r
$xpath = new DOMXPath($dom);\r
\r
- $xattr = OEmbed::buildXPath("class", "oembed");\r
+ $xattr = self::buildXPath("class", "oembed");\r
$entries = $xpath->query("//span[$xattr]");\r
\r
$xattr = "@rel='oembed'"; //oe_build_xpath("rel","oembed");\r
$e->parentNode->replaceChild(new DOMText("[embed]" . $href . "[/embed]"), $e);\r
}\r
}\r
- return OEmbed::getInnerHTML($dom->getElementsByTagName("body")->item(0));\r
+ return self::getInnerHTML($dom->getElementsByTagName("body")->item(0));\r
} else {\r
return $text;\r
}\r
private static function buildXPath($attr, $value)\r
{\r
// https://www.westhoffswelt.de/blog/2009/6/9/select-html-elements-with-more-than-one-css-class-using-xpath\r
- return "contains( normalize-space( @$attr ), ' $value ' ) or substring( normalize-space( @$attr ), 1, string-length( '$value' ) + 1 ) = '$value ' or substring( normalize-space( @$attr ), string-length( @$attr ) - string-length( '$value' ) ) = ' $value' or @$attr = '$value'";\r
+ return "contains(normalize-space(@$attr), ' $value ') or substring(normalize-space(@$attr), 1, string-length('$value') + 1) = '$value ' or substring(normalize-space(@$attr), string-length(@$attr) - string-length('$value')) = ' $value' or @$attr = '$value'";\r
}\r
\r
/**\r