use DOMText;
use DOMXPath;
use Exception;
-use Friendica\Core\Addon;
use Friendica\Core\Cache;
use Friendica\Core\Config;
+use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
-use Friendica\Core\System;
use Friendica\Database\DBA;
+use Friendica\DI;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\ParseUrl;
use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings;
-require_once 'include/dba.php';
-
/**
* Handles all OEmbed content fetching and replacement
*
* @param bool $no_rich_type If set to true rich type content won't be fetched.
*
* @return \Friendica\Object\OEmbed
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function fetchURL($embedurl, $no_rich_type = false)
{
$embedurl = trim($embedurl, '\'"');
- $a = get_app();
+ $a = DI::app();
$cache_key = 'oembed:' . $a->videowidth . ':' . $embedurl;
if (!in_array($ext, $noexts)) {
// try oembed autodiscovery
- $redirects = 0;
- $html_text = Network::fetchUrl($embedurl, false, $redirects, 15, 'text/*');
+ $html_text = Network::fetchUrl($embedurl, false, 15, 'text/*');
if ($html_text) {
$dom = @DOMDocument::loadHTML($html_text);
if ($dom) {
}
}
- Addon::callHooks('oembed_fetch_url', $embedurl, $oembed);
+ Hook::callAll('oembed_fetch_url', $embedurl, $oembed);
return $oembed;
}
$tw = $th * $tr;
$tpl = Renderer::getMarkupTemplate('oembed_video.tpl');
$ret .= Renderer::replaceMacros($tpl, [
- '$baseurl' => System::baseUrl(),
'$embedurl' => $oembed->embed_url,
'$escapedhtml' => base64_encode($oembed->html),
'$tw' => $tw,
/**
* Find <span class='oembed'>..<a href='url' rel='oembed'>..</a></span>
* and replace it with [embed]url[/embed]
+ *
+ * @param $text
+ * @return string
*/
public static function HTML2BBCode($text)
{
* @brief Determines if rich content OEmbed is allowed for the provided URL
* @param string $url
* @return boolean
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function isAllowedURL($url)
{
* Since the iframe is automatically resized on load, there are no need for ugly
* and impractical scrollbars.
*
- * @todo This function is currently unused until someoneā¢ adds support for a separate OEmbed domain
+ * @todo This function is currently unused until someoneā¢ adds support for a separate OEmbed domain
*
* @param string $src Original remote URL to embed
* @param string $width
* @param string $height
* @return string formatted HTML
*
- * @see oembed_format_object()
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @see oembed_format_object()
*/
private static function iframe($src, $width, $height)
{
- $a = get_app();
-
if (!$height || strstr($height, '%')) {
$height = '200';
}
$width = '100%';
- $src = System::baseUrl() . '/oembed/' . Strings::base64UrlEncode($src);
+ $src = DI::baseUrl() . '/oembed/' . Strings::base64UrlEncode($src);
return '<iframe onload="resizeIframe(this);" class="embed_rich" height="' . $height . '" width="' . $width . '" src="' . $src . '" allowfullscreen scrolling="no" frameborder="no">' . L10n::t('Embedded content') . '</iframe>';
}