From: Hypolite Petovan Date: Sat, 12 Jan 2019 07:23:01 +0000 (-0500) Subject: Rework Profile::getThemeUid to ignore query parameter and include $a->profile_uid X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=abf20368b051f76a751b4dfbd69a49c1172cdef1;p=friendica.git Rework Profile::getThemeUid to ignore query parameter and include $a->profile_uid - Use new version in frio default.php file - Use new version in Theme::getStylesheetPath --- diff --git a/src/Core/Theme.php b/src/Core/Theme.php index 6696917490..2202780376 100644 --- a/src/Core/Theme.php +++ b/src/Core/Theme.php @@ -9,6 +9,7 @@ namespace Friendica\Core; use Friendica\BaseObject; use Friendica\Core\Logger; use Friendica\Core\System; +use Friendica\Model\Profile; /** * Some functions to handle themes @@ -196,16 +197,11 @@ class Theme $query_params = []; - // Workaround for iOS Safari not initially sending the cookie for static files - if ($a->mobileDetect->isIos() && $a->mobileDetect->isSafari()) { - $query_params['t'] = time(); + $puid = Profile::getThemeUid($a); + if ($puid) { + $query_params['puid'] = $puid; } - if ($a->profile_uid) { - $query_params['puid'] = $a->profile_uid; - } - - if (file_exists('view/theme/' . $theme . '/style.php')) { return 'view/theme/' . $theme . '/style.pcss' . (!empty($query_params) ? '?' . http_build_query($query_params) : ''); } diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 49fb868e3a..41e992aa49 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -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. diff --git a/view/theme/frio/php/default.php b/view/theme/frio/php/default.php index ce7fd4d777..b9600cc22e 100644 --- a/view/theme/frio/php/default.php +++ b/view/theme/frio/php/default.php @@ -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')) {