Replace calls for App:::getThemeInfoValue() with AppHelper

pull/14542/head
Art4 2024-11-08 23:23:01 +00:00
parent 536234a9c6
commit 7de79fc753
4 changed files with 20 additions and 19 deletions

View File

@ -48,11 +48,11 @@ class OEmbed
{ {
$embedurl = trim($embedurl, '\'"'); $embedurl = trim($embedurl, '\'"');
$a = DI::app(); $appHelper = DI::apphelper();
$cache_key = 'oembed:' . $a->getThemeInfoValue('videowidth') . ':' . $embedurl; $cache_key = 'oembed:' . $appHelper->getThemeInfoValue('videowidth') . ':' . $embedurl;
$condition = ['url' => Strings::normaliseLink($embedurl), 'maxwidth' => $a->getThemeInfoValue('videowidth')]; $condition = ['url' => Strings::normaliseLink($embedurl), 'maxwidth' => $appHelper->getThemeInfoValue('videowidth')];
$oembed_record = DBA::selectFirst('oembed', ['content'], $condition); $oembed_record = DBA::selectFirst('oembed', ['content'], $condition);
if (DBA::isResult($oembed_record)) { if (DBA::isResult($oembed_record)) {
$json_string = $oembed_record['content']; $json_string = $oembed_record['content'];
@ -88,7 +88,7 @@ class OEmbed
// but their OEmbed endpoint is only accessible by HTTPS ¯\_(ツ)_/¯ // but their OEmbed endpoint is only accessible by HTTPS ¯\_(ツ)_/¯
$href = str_replace(['http://www.youtube.com/', 'http://player.vimeo.com/'], $href = str_replace(['http://www.youtube.com/', 'http://player.vimeo.com/'],
['https://www.youtube.com/', 'https://player.vimeo.com/'], $href); ['https://www.youtube.com/', 'https://player.vimeo.com/'], $href);
$result = DI::httpClient()->get($href . '&maxwidth=' . $a->getThemeInfoValue('videowidth'), HttpClientAccept::DEFAULT, [HttpClientOptions::REQUEST => HttpClientRequest::SITEINFO]); $result = DI::httpClient()->get($href . '&maxwidth=' . $appHelper->getThemeInfoValue('videowidth'), HttpClientAccept::DEFAULT, [HttpClientOptions::REQUEST => HttpClientRequest::SITEINFO]);
if ($result->isSuccess()) { if ($result->isSuccess()) {
$json_string = $result->getBodyString(); $json_string = $result->getBodyString();
break; break;
@ -109,7 +109,7 @@ class OEmbed
if (!empty($oembed->type) && $oembed->type != 'error') { if (!empty($oembed->type) && $oembed->type != 'error') {
DBA::insert('oembed', [ DBA::insert('oembed', [
'url' => Strings::normaliseLink($embedurl), 'url' => Strings::normaliseLink($embedurl),
'maxwidth' => $a->getThemeInfoValue('videowidth'), 'maxwidth' => $appHelper->getThemeInfoValue('videowidth'),
'content' => $json_string, 'content' => $json_string,
'created' => DateTimeFormat::utcNow() 'created' => DateTimeFormat::utcNow()
], Database::INSERT_UPDATE); ], Database::INSERT_UPDATE);

View File

@ -1924,19 +1924,20 @@ class BBCode
private static function convertVideoPlatformsToHtml(string $text, bool $try_oembed): string private static function convertVideoPlatformsToHtml(string $text, bool $try_oembed): string
{ {
$a = DI::app(); $appHelper = DI::apphelper();
$text = self::normalizeVideoLinks($text); $text = self::normalizeVideoLinks($text);
// Youtube extensions // Youtube extensions
if ($try_oembed && OEmbed::isAllowedURL('https://www.youtube.com/embed/')) { if ($try_oembed && OEmbed::isAllowedURL('https://www.youtube.com/embed/')) {
$text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="' . $a->getThemeInfoValue('videowidth') . '" height="' . $a->getThemeInfoValue('videoheight') . '" src="https://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $text); $text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="' . $appHelper->getThemeInfoValue('videowidth') . '" height="' . $appHelper->getThemeInfoValue('videoheight') . '" src="https://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $text);
} else { } else {
$text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '[url]https://www.youtube.com/watch?v=$1[/url]', $text); $text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '[url]https://www.youtube.com/watch?v=$1[/url]', $text);
} }
// Vimeo extensions // Vimeo extensions
if ($try_oembed && OEmbed::isAllowedURL('https://player.vimeo.com/video')) { if ($try_oembed && OEmbed::isAllowedURL('https://player.vimeo.com/video')) {
$text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '<iframe width="' . $a->getThemeInfoValue('videowidth') . '" height="' . $a->getThemeInfoValue('videoheight') . '" src="https://player.vimeo.com/video/$1" frameborder="0" ></iframe>', $text); $text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '<iframe width="' . $appHelper->getThemeInfoValue('videowidth') . '" height="' . $appHelper->getThemeInfoValue('videoheight') . '" src="https://player.vimeo.com/video/$1" frameborder="0" ></iframe>', $text);
} else { } else {
$text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '[url]https://vimeo.com/$1[/url]', $text); $text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '[url]https://vimeo.com/$1[/url]', $text);
} }

View File

@ -208,11 +208,11 @@ class Theme
*/ */
public static function getPathForFile(string $file): string public static function getPathForFile(string $file): string
{ {
$a = DI::app(); $appHelper = DI::apphelper();
$theme = $a->getCurrentTheme(); $theme = $appHelper->getCurrentTheme();
$parent = Strings::sanitizeFilePathItem($a->getThemeInfoValue('extends', $theme)); $parent = Strings::sanitizeFilePathItem($appHelper->getThemeInfoValue('extends', $theme));
$paths = [ $paths = [
"view/theme/$theme/$file", "view/theme/$theme/$file",
@ -245,11 +245,11 @@ class Theme
return 'view/theme/' . $theme . '/style.css'; return 'view/theme/' . $theme . '/style.css';
} }
$a = DI::app(); $appHelper = DI::apphelper();
$query_params = []; $query_params = [];
$puid = Profile::getThemeUid($a); $puid = Profile::getThemeUid($appHelper);
if ($puid) { if ($puid) {
$query_params['puid'] = $puid; $query_params['puid'] = $puid;
} }
@ -267,8 +267,8 @@ class Theme
{ {
$theme = Strings::sanitizeFilePathItem($theme); $theme = Strings::sanitizeFilePathItem($theme);
$a = DI::app(); $appHelper = DI::apphelper();
$base_theme = $a->getThemeInfoValue('extends') ?? ''; $base_theme = $appHelper->getThemeInfoValue('extends') ?? '';
if (file_exists("view/theme/$theme/config.php")) { if (file_exists("view/theme/$theme/config.php")) {
return "view/theme/$theme/config.php"; return "view/theme/$theme/config.php";

View File

@ -3347,7 +3347,7 @@ class Item
*/ */
public static function prepareBody(array &$item, bool $attach = false, bool $is_preview = false, bool $only_cache = false): string public static function prepareBody(array &$item, bool $attach = false, bool $is_preview = false, bool $only_cache = false): string
{ {
$a = DI::app(); $appHelper = DI::apphelper();
$uid = DI::userSession()->getLocalUserId(); $uid = DI::userSession()->getLocalUserId();
Hook::callAll('prepare_body_init', $item); Hook::callAll('prepare_body_init', $item);
@ -3517,8 +3517,8 @@ class Item
} }
// Replace friendica image url size with theme preference. // Replace friendica image url size with theme preference.
if (!empty($a->getThemeInfoValue('item_image_size'))) { if (!empty($appHelper->getThemeInfoValue('item_image_size'))) {
$ps = $a->getThemeInfoValue('item_image_size'); $ps = $appHelper->getThemeInfoValue('item_image_size');
$s = preg_replace('|(<img[^>]+src="[^"]+/photo/[0-9a-f]+)-[0-9]|', "$1-" . $ps, $s); $s = preg_replace('|(<img[^>]+src="[^"]+/photo/[0-9a-f]+)-[0-9]|', "$1-" . $ps, $s);
} }