]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #6428 from MrPetovan/bug/5148-get-cookies-from-safari-2
authorMichael Vogel <icarus@dabo.de>
Sat, 12 Jan 2019 08:33:35 +0000 (09:33 +0100)
committerGitHub <noreply@github.com>
Sat, 12 Jan 2019 08:33:35 +0000 (09:33 +0100)
Add variable query parameter to stylesheet URL for iOS Safari

src/App.php
src/Core/Theme.php
src/Model/Profile.php
view/theme/duepuntozero/style.php
view/theme/frio/php/default.php
view/theme/frio/style.php
view/theme/quattro/style.php
view/theme/vier/style.php

index 1045c413dca53f8e0256ce96fb3c9f056e162ef1..ac513b531aaf2605782ec04fc330cc2aae8338a2 100644 (file)
@@ -101,6 +101,11 @@ class App
         */
        private $isAjax;
 
+       /**
+        * @var MobileDetect
+        */
+       public $mobileDetect;
+
        /**
         * Register a stylesheet file path to be included in the <head> tag of every page.
         * Inclusion is done in App->initHead().
@@ -268,6 +273,9 @@ class App
 
                // Detect mobile devices
                $mobile_detect = new MobileDetect();
+
+               $this->mobileDetect = $mobile_detect;
+
                $this->is_mobile = $mobile_detect->isMobile();
                $this->is_tablet = $mobile_detect->isTablet();
 
index 91511b4d5fbc91790430c43169c387936a396fa5..de8cd496a45cd24240f247a6847e2c0e8b84903c 100644 (file)
@@ -6,8 +6,10 @@
 
 namespace Friendica\Core;
 
+use Friendica\BaseObject;
 use Friendica\Core\Logger;
 use Friendica\Core\System;
+use Friendica\Model\Profile;
 
 /**
  * Some functions to handle themes
@@ -191,13 +193,19 @@ class Theme
         */
        public static function getStylesheetPath($theme)
        {
-               $a = get_app();
+               if (!file_exists('view/theme/' . $theme . '/style.php')) {
+                       return 'view/theme/' . $theme . '/style.css';
+               }
+
+               $a = BaseObject::getApp();
+
+               $query_params = [];
 
-               $opts = (($a->profile_uid) ? '?f=&puid=' . $a->profile_uid : '');
-               if (file_exists('view/theme/' . $theme . '/style.php')) {
-                       return 'view/theme/' . $theme . '/style.pcss' . $opts;
+               $puid = Profile::getThemeUid($a);
+               if ($puid) {
+                       $query_params['puid'] = $puid;
                }
 
-               return 'view/theme/' . $theme . '/style.css';
+               return 'view/theme/' . $theme . '/style.pcss' . (!empty($query_params) ? '?' . http_build_query($query_params) : '');
        }
 }
index 49fb868e3a9f3307db49e6009dd5e8d71fd57538..41e992aa49b8b2f5f8d475faeec7e4b063d9643f 100644 (file)
@@ -1176,7 +1176,7 @@ class Profile
         * Get the user ID of the page owner.
         *
         * Used from within PCSS themes to set theme parameters. If there's a
-        * puid request variable, that is the "page owner" and normally their theme
+        * profile_uid variable set in App, that is the "page owner" and normally their theme
         * settings take precedence; unless a local user sets the "always_my_theme"
         * system pconfig, which means they don't want to see anybody else's theme
         * settings except their own while on this site.
@@ -1184,13 +1184,12 @@ class Profile
         * @brief Get the user ID of the page owner
         * @return int user ID
         *
-        * @note Returns local_user instead of user ID if "always_my_theme"
-        *      is set to true
+        * @note Returns local_user instead of user ID if "always_my_theme" is set to true
         */
-       public static function getThemeUid()
+       public static function getThemeUid(App $a)
        {
-               $uid = (!empty($_REQUEST['puid']) ? intval($_REQUEST['puid']) : 0);
-               if ((local_user()) && ((PConfig::get(local_user(), 'system', 'always_my_theme')) || (!$uid))) {
+               $uid = !empty($a->profile_uid) ? intval($a->profile_uid) : 0;
+               if (local_user() && (PConfig::get(local_user(), 'system', 'always_my_theme') || !$uid)) {
                        return local_user();
                }
 
@@ -1198,7 +1197,7 @@ class Profile
        }
 
        /**
-       * Stip zrl parameter from a string.
+       * Strip zrl parameter from a string.
        *
        * @param string $s The input string.
        * @return string The zrl.
index 6d102350cc26e6c1d687aaa6d9ec82933ba05b81..a5810f2dc131cb06237fbe253b645c8867d970c1 100644 (file)
@@ -10,7 +10,7 @@ if (file_exists("$THEMEPATH/style.css")) {
        echo file_get_contents("$THEMEPATH/style.css");
 }
 
-$uid = Profile::getThemeUid();
+$uid = defaults($_REQUEST, 'puid', 0);
 
 $s_colorset = Config::get('duepuntozero', 'colorset');
 $colorset = PConfig::get($uid, 'duepuntozero', 'colorset');
index ce7fd4d777ef39539aee13839b1041a79348fcac..b9600cc22e3b991f84d882ed2b519a8e1feef641 100644 (file)
@@ -42,10 +42,7 @@ $is_singleuser_class = $is_singleuser ? "is-singleuser" : "is-not-singleuser";
 
                // Add the theme color meta
                // It makes mobile Chrome UI match Frio's top bar color.
-               $uid = $a->profile_uid;
-               if (is_null($uid)) {
-                       $uid = Profile::getThemeUid();
-               }
+               $uid = Profile::getThemeUid($a);
                $scheme = PConfig::get($uid, 'frio', 'scheme', PConfig::get($uid, 'frio', 'schema'));
                if ($scheme && ($scheme != '---')) {
                        if (file_exists('view/theme/frio/scheme/' . $scheme . '.php')) {
index 7570ae0e5774b13ba52de1b78f39921ffea624ef..d8bffa9c645c4ff048b0b329a2927f7e32d2d4e9 100644 (file)
@@ -14,7 +14,7 @@ $scheme_modified = 0;
 
 if ($a->module !== 'install') {
        // Get the UID of the profile owner.
-       $uid = Profile::getThemeUid();
+       $uid = defaults($_REQUEST, 'puid', 0);
        if ($uid) {
                PConfig::load($uid, 'frio');
 
index 8158468327ac39ae9c10fc2eb5471da60c471000..08756ec4aa63bc16685d2b6aacccbc102d3e93d6 100644 (file)
@@ -6,7 +6,7 @@ use Friendica\Core\Config;
 use Friendica\Core\PConfig;
 use Friendica\Model\Profile;
 
-$uid = Profile::getThemeUid();
+$uid = defaults($_REQUEST, 'puid', 0);
 
 $color = false;
 $quattro_align = false;
index 196d3776561e165632fcfaa184f55ba206134fd6..4dfbe4e268f1a837c1b1f2adc15c4ee09c454fcd 100644 (file)
@@ -7,7 +7,7 @@ use Friendica\Core\Config;
 use Friendica\Core\PConfig;
 use Friendica\Model\Profile;
 
-$uid = Profile::getThemeUid();
+$uid = defaults($_REQUEST, 'puid', 0);
 
 $style = PConfig::get($uid, 'vier', 'style');