]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Theme.php
Avoid memory issue in exception
[friendica.git] / src / Core / Theme.php
index 1524c29bacfe2a8cd878f51ad01e2944d88839d5..62dfaa51f3072f45ce8d3bc56e871b2f0f4e3d5a 100644 (file)
@@ -6,8 +6,10 @@
 
 namespace Friendica\Core;
 
-use Friendica\Core\Logger;
-use Friendica\Core\System;
+use Friendica\BaseObject;
+use Friendica\Model\Profile;
+
+require_once 'boot.php';
 
 /**
  * Some functions to handle themes
@@ -46,7 +48,7 @@ class Theme
                        return $info;
                }
 
-               $a = get_app();
+               $a = \get_app();
                $stamp1 = microtime(true);
                $theme_file = file_get_contents("view/theme/$theme/theme.php");
                $a->saveTimestamp($stamp1, "file");
@@ -88,8 +90,9 @@ class Theme
         *
         * The screenshot is expected as view/theme/$theme/screenshot.[png|jpg].
         *
-        * @param sring $theme The name of the theme
+        * @param string $theme The name of the theme
         * @return string
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function getScreenshot($theme)
        {
@@ -146,6 +149,7 @@ class Theme
         * @param string $file Filename
         * @param string $root Full root path
         * @return string Path to the file or empty string if the file isn't found
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function getPathForFile($file, $root = '')
        {
@@ -155,13 +159,13 @@ class Theme
                if ($root !== '' && $root[strlen($root) - 1] !== '/') {
                        $root = $root . '/';
                }
-               $theme_info = get_app()->theme_info;
+               $theme_info = \get_app()->theme_info;
                if (is_array($theme_info) && array_key_exists('extends', $theme_info)) {
                        $parent = $theme_info['extends'];
                } else {
                        $parent = 'NOPATH';
                }
-               $theme = get_app()->getCurrentTheme();
+               $theme = \get_app()->getCurrentTheme();
                $thname = $theme;
                $ext = substr($file, strrpos($file, '.') + 1);
                $paths = [
@@ -191,13 +195,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) : '');
        }
 }