+ public static function getStylesheetPath(string $theme): string
+ {
+ $theme = Strings::sanitizeFilePathItem($theme);
+
+ if (!file_exists('view/theme/' . $theme . '/style.php')) {
+ return 'view/theme/' . $theme . '/style.css';
+ }
+
+ $a = DI::app();
+
+ $query_params = [];
+
+ $puid = Profile::getThemeUid($a);
+ if ($puid) {
+ $query_params['puid'] = $puid;
+ }
+
+ return 'view/theme/' . $theme . '/style.pcss' . (!empty($query_params) ? '?' . http_build_query($query_params) : '');
+ }
+
+ /**
+ * Returns the path of the provided theme
+ *
+ * @param string $theme Theme name
+ * @return string|null
+ */
+ public static function getConfigFile(string $theme)
+ {
+ $theme = Strings::sanitizeFilePathItem($theme);
+
+ $a = DI::app();
+ $base_theme = $a->getThemeInfoValue('extends') ?? '';
+
+ if (file_exists("view/theme/$theme/config.php")) {
+ return "view/theme/$theme/config.php";
+ }
+ if ($base_theme && file_exists("view/theme/$base_theme/config.php")) {
+ return "view/theme/$base_theme/config.php";
+ }
+ return null;
+ }
+
+ /**
+ * Returns the background color of the provided theme if available.
+ *
+ * @param string $theme Theme name
+ * @param int|null $uid Current logged-in user id
+ * @return string|null
+ */
+ public static function getBackgroundColor(string $theme, int $uid = null)