]> git.mxchange.org Git - friendica.git/commitdiff
theme infos are now bundled in a single array
authorMichael <heluecht@pirati.ca>
Sun, 25 Jul 2021 19:07:03 +0000 (19:07 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 25 Jul 2021 19:07:03 +0000 (19:07 +0000)
mod/events.php
src/App.php
src/Content/OEmbed.php
src/Content/Text/BBCode.php
src/Module/BaseProfile.php
tests/src/Content/SmiliesTest.php
tests/src/Content/Text/BBCodeTest.php
view/theme/frio/theme.php
view/theme/vier/theme.php

index aac12756edc34bf12d52a55a002d24dacd03656d..67666d670c977317d165009889dbfe1046993d7e 100644 (file)
@@ -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);
        }
 
index 7d1258c6046c3d2ab1aade05c5ed3152c50f9640..a25c9a9ea16bf1f81bcbce3458c17d2700c08e07 100644 (file)
@@ -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;
index 65b450f51e84f0b52fdcad9ce401b40cc338d7f6..7232308738f865bfbf2f4cac6bee7e00d6706318 100644 (file)
@@ -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);
index 286c9900c7028851779f60f7ad4d650dd9ed76ea..d03f83ffd8f458a4c4752fd1c49827d7dd78d680 100644 (file)
@@ -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", '<iframe width="' . $a->videowidth . '" height="' . $a->videoheight . '" src="https://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $text);
+                                       $text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="' . $a->theme_info['videowidth'] . '" height="' . $a->theme_info['videoheight'] . '" src="https://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $text);
                                } else {
                                        $text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism",
                                                '<a href="https://www.youtube.com/watch?v=$1" target="_blank" rel="noopener noreferrer">https://www.youtube.com/watch?v=$1</a>', $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", '<iframe width="' . $a->videowidth . '" height="' . $a->videoheight . '" src="https://player.vimeo.com/video/$1" frameborder="0" ></iframe>', $text);
+                                       $text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '<iframe width="' . $a->theme_info['videowidth'] . '" height="' . $a->theme_info['videoheight'] . '" src="https://player.vimeo.com/video/$1" frameborder="0" ></iframe>', $text);
                                } else {
                                        $text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism",
                                                '<a href="https://vimeo.com/$1" target="_blank" rel="noopener noreferrer">https://vimeo.com/$1</a>', $text);
index e84ebded101c4f8fcd454ab6d0022d6a1659c03e..eee9036504c65ed40dd3d0f6587339424fe5839e 100644 (file)
@@ -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',
index 8d4624298c50fb434660d07780760f07bdb7c306..803d5d6f8b739d4e858660be83dbc37d0d607559 100644 (file)
@@ -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);
index 2b5dc22a19e26000d9a9063a9827e21544b5a918..b9c26ede01634573a2c2cadfe5ca6f07da46f416 100644 (file)
@@ -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);
index 41afccc824ead11dd6190df70097d49696f9fa90..d5441691e4c6a41a81431829213f38b4e87367af 100644 (file)
@@ -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');
 
index 4d11b1cd465d043135244a73b9d7890a6fcfd89f..13caae98e2b499360cf9568c7b21d22bad52895a 100644 (file)
@@ -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');