diff --git a/mod/events.php b/mod/events.php index aac12756ed..67666d670c 100644 --- a/mod/events.php +++ b/mod/events.php @@ -255,7 +255,7 @@ function events_content(App $a) ); } - if ($a->theme_events_in_profile) { + if ($a->theme_info['events_in_profile']) { Nav::setSelected('home'); } else { Nav::setSelected('events'); @@ -279,7 +279,7 @@ function events_content(App $a) $o = ''; $tabs = ''; // tabs - if ($a->theme_events_in_profile) { + if ($a->theme_info['events_in_profile']) { $tabs = BaseProfile::getTabsHTML($a, 'events', true, $a->user); } diff --git a/src/App.php b/src/App.php index 7d1258c604..a25c9a9ea1 100644 --- a/src/App.php +++ b/src/App.php @@ -57,13 +57,14 @@ use Psr\Log\LoggerInterface; class App { public $user; - public $theme_info = []; + // Allow themes to control internal parameters // by changing App values in theme.php - - public $videowidth = 425; - public $videoheight = 350; - public $theme_events_in_profile = true; + public $theme_info = [ + 'videowidth' => 425, + 'videoheight' => 350, + 'events_in_profile' => true + ]; private $timezone = ''; private $profile_owner = 0; diff --git a/src/Content/OEmbed.php b/src/Content/OEmbed.php index 65b450f51e..7232308738 100644 --- a/src/Content/OEmbed.php +++ b/src/Content/OEmbed.php @@ -73,9 +73,9 @@ class OEmbed $a = DI::app(); - $cache_key = 'oembed:' . $a->videowidth . ':' . $embedurl; + $cache_key = 'oembed:' . $a->theme_info['videowidth'] . ':' . $embedurl; - $condition = ['url' => Strings::normaliseLink($embedurl), 'maxwidth' => $a->videowidth]; + $condition = ['url' => Strings::normaliseLink($embedurl), 'maxwidth' => $a->theme_info['videowidth']]; $oembed_record = DBA::selectFirst('oembed', ['content'], $condition); if (DBA::isResult($oembed_record)) { $json_string = $oembed_record['content']; @@ -111,7 +111,7 @@ class OEmbed // but their OEmbed endpoint is only accessible by HTTPS ¯\_(ツ)_/¯ $href = str_replace(['http://www.youtube.com/', 'http://player.vimeo.com/'], ['https://www.youtube.com/', 'https://player.vimeo.com/'], $href); - $result = DI::httpRequest()->fetchFull($href . '&maxwidth=' . $a->videowidth); + $result = DI::httpRequest()->fetchFull($href . '&maxwidth=' . $a->theme_info['videowidth']); if ($result->getReturnCode() === 200) { $json_string = $result->getBody(); break; @@ -132,7 +132,7 @@ class OEmbed if (!empty($oembed->type) && $oembed->type != 'error') { DBA::insert('oembed', [ 'url' => Strings::normaliseLink($embedurl), - 'maxwidth' => $a->videowidth, + 'maxwidth' => $a->theme_info['videowidth'], 'content' => $json_string, 'created' => DateTimeFormat::utcNow() ], Database::INSERT_UPDATE); diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 286c9900c7..d03f83ffd8 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1729,7 +1729,7 @@ class BBCode $text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/ism", '[youtube]$1[/youtube]', $text); if ($try_oembed) { - $text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '', $text); + $text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '', $text); } else { $text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", 'https://www.youtube.com/watch?v=$1', $text); @@ -1744,7 +1744,7 @@ class BBCode $text = preg_replace("/\[vimeo\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/vimeo\]/ism", '[vimeo]$1[/vimeo]', $text); if ($try_oembed) { - $text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '', $text); + $text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '', $text); } else { $text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", 'https://vimeo.com/$1', $text); diff --git a/src/Module/BaseProfile.php b/src/Module/BaseProfile.php index e84ebded10..eee9036504 100644 --- a/src/Module/BaseProfile.php +++ b/src/Module/BaseProfile.php @@ -81,7 +81,7 @@ class BaseProfile extends BaseModule ]; // the calendar link for the full featured events calendar - if ($is_owner && $a->theme_events_in_profile) { + if ($is_owner && $a->theme_info['events_in_profile']) { $tabs[] = [ 'label' => DI::l10n()->t('Events'), 'url' => DI::baseUrl() . '/events', diff --git a/tests/src/Content/SmiliesTest.php b/tests/src/Content/SmiliesTest.php index 8d4624298c..803d5d6f8b 100644 --- a/tests/src/Content/SmiliesTest.php +++ b/tests/src/Content/SmiliesTest.php @@ -24,8 +24,8 @@ class SmiliesTest extends MockedTest parent::setUp(); $this->setUpVfsDir(); $this->mockApp($this->root); - $this->app->videowidth = 425; - $this->app->videoheight = 350; + $this->app->theme_info['videowidth'] = 425; + $this->app->theme_info['videoheight'] = 350; $this->configMock->shouldReceive('get') ->with('system', 'no_smilies') ->andReturn(false); diff --git a/tests/src/Content/Text/BBCodeTest.php b/tests/src/Content/Text/BBCodeTest.php index 2b5dc22a19..b9c26ede01 100644 --- a/tests/src/Content/Text/BBCodeTest.php +++ b/tests/src/Content/Text/BBCodeTest.php @@ -40,8 +40,8 @@ class BBCodeTest extends MockedTest parent::setUp(); $this->setUpVfsDir(); $this->mockApp($this->root); - $this->app->videowidth = 425; - $this->app->videoheight = 350; + $this->app->theme_info['videowidth'] = 425; + $this->app->theme_info['videoheight'] = 350; $this->configMock->shouldReceive('get') ->with('system', 'remove_multiplicated_lines') ->andReturn(false); diff --git a/view/theme/frio/theme.php b/view/theme/frio/theme.php index 41afccc824..d5441691e4 100644 --- a/view/theme/frio/theme.php +++ b/view/theme/frio/theme.php @@ -33,8 +33,8 @@ function frio_init(App $a) $frio = 'view/theme/frio'; // disable the events module link in the profile tab - $a->theme_events_in_profile = false; - $a->videowidth = 622; + $a->theme_info['events_in_profile'] = false; + $a->theme_info['videowidth'] = 622; Renderer::setActiveTemplateEngine('smarty3'); diff --git a/view/theme/vier/theme.php b/view/theme/vier/theme.php index 4d11b1cd46..13caae98e2 100644 --- a/view/theme/vier/theme.php +++ b/view/theme/vier/theme.php @@ -21,7 +21,7 @@ use Friendica\Util\Strings; function vier_init(App $a) { - $a->theme_events_in_profile = false; + $a->theme_info['events_in_profile'] = false; Renderer::setActiveTemplateEngine('smarty3');