]> git.mxchange.org Git - friendica.git/commitdiff
Move calendar/event stylesheets/scripts registration to modules
authorHypolite Petovan <hypolite@mrpetovan.com>
Sat, 15 Aug 2020 22:56:17 +0000 (18:56 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 15 Aug 2020 22:56:17 +0000 (18:56 -0400)
- Add media parameter to Page->registerStylesheet
- Fixes CSS precedence with custom theme stylesheet

mod/cal.php
mod/events.php
src/App/Page.php
view/templates/event_head.tpl
view/templates/head.tpl
view/theme/frio/templates/event_head.tpl
view/theme/frio/templates/head.tpl

index 0e8e8a2af3328d1b73db78ed18c579a2f1cafac1..1ac11dc98b80cb5d6d3798abbdc9189e41fb510f 100644 (file)
@@ -105,6 +105,11 @@ function cal_content(App $a)
        // get the translation strings for the callendar
        $i18n = Event::getStrings();
 
+       DI::page()->registerStylesheet('view/asset/fullcalendar/dist/fullcalendar.min.css');
+       DI::page()->registerStylesheet('view/asset/fullcalendar/dist/fullcalendar.print.min.css', 'print');
+       DI::page()->registerFooterScript('view/asset/moment/min/moment-with-locales.min.js');
+       DI::page()->registerFooterScript('view/asset/fullcalendar/dist/fullcalendar.min.js');
+
        $htpl = Renderer::getMarkupTemplate('event_head.tpl');
        DI::page()['htmlhead'] .= Renderer::replaceMacros($htpl, [
                '$module_url' => '/cal/' . $a->data['user']['nickname'],
index 69f6b6f326853cf2923379c94d982ce50008d57d..d82fbd818e4094058c6ab3d5bc383f74492e246f 100644 (file)
@@ -256,6 +256,11 @@ function events_content(App $a)
        // get the translation strings for the callendar
        $i18n = Event::getStrings();
 
+       DI::page()->registerStylesheet('view/asset/fullcalendar/dist/fullcalendar.min.css');
+       DI::page()->registerStylesheet('view/asset/fullcalendar/dist/fullcalendar.print.min.css', 'print');
+       DI::page()->registerFooterScript('view/asset/moment/min/moment-with-locales.min.js');
+       DI::page()->registerFooterScript('view/asset/fullcalendar/dist/fullcalendar.min.js');
+
        $htpl = Renderer::getMarkupTemplate('event_head.tpl');
        DI::page()['htmlhead'] .= Renderer::replaceMacros($htpl, [
                '$module_url' => '/events',
index d3365a16c130d2b5d0453f8618447175e6f3ddab..c2bfb388788085ccbdbdc176f0a9db74bb32b447 100644 (file)
@@ -165,11 +165,10 @@ class Page implements ArrayAccess
         * The path can be absolute or relative to the Friendica installation base folder.
         *
         * @param string $path
-        *
+        * @param string $media
         * @see Page::initHead()
-        *
         */
-       public function registerStylesheet($path)
+       public function registerStylesheet($path, string $media = 'screen')
        {
                $path = Network::appendQueryParam($path, ['v' => FRIENDICA_VERSION]);
 
@@ -177,7 +176,7 @@ class Page implements ArrayAccess
                        $path = mb_substr($path, mb_strlen($this->basePath . DIRECTORY_SEPARATOR));
                }
 
-               $this->stylesheets[] = trim($path, '/');
+               $this->stylesheets[trim($path, '/')] = $media;
        }
 
        /**
@@ -252,7 +251,7 @@ class Page implements ArrayAccess
                        '$shortcut_icon'   => $shortcut_icon,
                        '$touch_icon'      => $touch_icon,
                        '$block_public'    => intval($config->get('system', 'block_public')),
-                       '$stylesheets'     => array_unique($this->stylesheets),
+                       '$stylesheets'     => $this->stylesheets,
                ]) . $this->page['htmlhead'];
        }
 
index 463ba720e29592c76fe2a01bc51f74de264da907..8990c6fb25ba0bb81c3c0323ac0576abaae97527 100644 (file)
@@ -1,9 +1,3 @@
-
-<link rel="stylesheet" type="text/css" href="{{$baseurl}}/view/asset/fullcalendar/dist/fullcalendar.min.css?v={{$smarty.const.FRIENDICA_VERSION}}" />
-<link rel="stylesheet" type="text/css" href="{{$baseurl}}/view/asset/fullcalendar/dist/fullcalendar.print.min.css?v={{$smarty.const.FRIENDICA_VERSION}}" media="print" />
-<script type="text/javascript" src="{{$baseurl}}/view/asset/moment/min/moment-with-locales.min.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
-<script type="text/javascript" src="{{$baseurl}}/view/asset/fullcalendar/dist/fullcalendar.min.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
-
 <script>
        function showEvent(eventid) {
                $.get(
index ed87017dc4b92cccdbe90acaaf344eae44159915..707cdf79f00733114627cf4d2ac23d0952aaa581 100644 (file)
@@ -8,8 +8,8 @@
 <link rel="stylesheet" href="view/asset/jquery-datetimepicker/build/jquery.datetimepicker.min.css?v={{$smarty.const.FRIENDICA_VERSION}}" type="text/css" media="screen" />
 <link rel="stylesheet" href="view/asset/perfect-scrollbar/dist/css/perfect-scrollbar.min.css?v={{$smarty.const.FRIENDICA_VERSION}}" type="text/css" media="screen" />
 
-{{foreach $stylesheets as $stylesheetUrl}}
-<link rel="stylesheet" href="{{$stylesheetUrl}}" type="text/css" media="screen" />
+{{foreach $stylesheets as $stylesheetUrl => $media}}
+       <link rel="stylesheet" href="{{$stylesheetUrl}}" type="text/css" media="{{$media}}" />
 {{/foreach}}
 
 <link rel="shortcut icon" href="{{$shortcut_icon}}" />
index cb1a4685bd3aabb3eda2e8eac360a8407f052507..1150f3b1b610a47739530dd0583f7f11cccb2821 100644 (file)
@@ -1,9 +1,5 @@
 
-<link rel="stylesheet" type="text/css" href="{{$baseurl}}/view/asset/fullcalendar/dist/fullcalendar.min.css?v={{$smarty.const.FRIENDICA_VERSION}}" />
-<link rel="stylesheet" type="text/css" href="{{$baseurl}}/view/asset/fullcalendar/dist/fullcalendar.print.min.css?v={{$smarty.const.FRIENDICA_VERSION}}" media="print" />
 <link rel="stylesheet" type="text/css" href="view/theme/frio/css/mod_events.css?v={{$smarty.const.FRIENDICA_VERSION}}" />
-<script type="text/javascript" src="{{$baseurl}}/view/asset/moment/min/moment-with-locales.min.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
-<script type="text/javascript" src="{{$baseurl}}/view/asset/fullcalendar/dist/fullcalendar.min.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
 <script type="text/javascript" src="view/theme/frio/js/mod_events.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
 
 <script type="text/javascript">
index 4015a325a5901855b719d484b7f0a6207528e581..56c7b0534bca314560b35f52da035fabc1f8277b 100644 (file)
 <link rel="stylesheet" href="view/theme/frio/frameworks/bootstrap-toggle/css/bootstrap-toggle.min.css?v={{$smarty.const.FRIENDICA_VERSION}}" type="text/css" media="screen"/>
 <link rel="stylesheet" href="view/theme/frio/font/open_sans/open-sans.css?v={{$smarty.const.FRIENDICA_VERSION}}" type="text/css" media="screen"/>
 
-{{foreach $stylesheets as $stylesheetUrl}}
-<link rel="stylesheet" href="{{$stylesheetUrl}}" type="text/css" media="screen" />
-{{/foreach}}
-
 {{* own css files *}}
 <link rel="stylesheet" href="view/theme/frio/css/hovercard.css?v={{$smarty.const.FRIENDICA_VERSION}}" type="text/css" media="screen"/>
 <link rel="stylesheet" href="view/theme/frio/css/font-awesome.custom.css?v={{$smarty.const.FRIENDICA_VERSION}}" type="text/css" media="screen"/>
 
+{{foreach $stylesheets as $stylesheetUrl => $media}}
+<link rel="stylesheet" href="{{$stylesheetUrl}}" type="text/css" media="{{$media}}" />
+{{/foreach}}
+
 <link rel="shortcut icon" href="{{$shortcut_icon}}" />
 <link rel="apple-touch-icon" href="{{$touch_icon}}"/>