]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Theme.php
Update and rename test class
[friendica.git] / src / Core / Theme.php
index 16eb7939c5224fe9f9585dee9c09fb3255b29839..e5026904b8cef7936d4c2af75fe0ce600d8445c2 100644 (file)
@@ -6,6 +6,7 @@
 
 namespace Friendica\Core;
 
+use Friendica\Core\Logger;
 use Friendica\Core\System;
 
 require_once 'boot.php';
@@ -50,7 +51,7 @@ class Theme
                $a = get_app();
                $stamp1 = microtime(true);
                $theme_file = file_get_contents("view/theme/$theme/theme.php");
-               $a->save_timestamp($stamp1, "file");
+               $a->saveTimestamp($stamp1, "file");
 
                $result = preg_match("|/\*.*\*/|msU", $theme_file, $matches);
 
@@ -106,7 +107,7 @@ class Theme
        // install and uninstall theme
        public static function uninstall($theme)
        {
-               logger("Addons: uninstalling theme " . $theme);
+               Logger::log("Addons: uninstalling theme " . $theme);
 
                include_once "view/theme/$theme/theme.php";
                if (function_exists("{$theme}_uninstall")) {
@@ -123,7 +124,7 @@ class Theme
                        return false;
                }
 
-               logger("Addons: installing theme $theme");
+               Logger::log("Addons: installing theme $theme");
 
                include_once "view/theme/$theme/theme.php";
 
@@ -132,7 +133,7 @@ class Theme
                        $func();
                        return true;
                } else {
-                       logger("Addons: FAILED installing theme $theme");
+                       Logger::log("Addons: FAILED installing theme $theme");
                        return false;
                }
        }
@@ -162,7 +163,7 @@ class Theme
                } else {
                        $parent = 'NOPATH';
                }
-               $theme = current_theme();
+               $theme = get_app()->getCurrentTheme();
                $thname = $theme;
                $ext = substr($file, strrpos($file, '.') + 1);
                $paths = [
@@ -180,4 +181,25 @@ class Theme
                }
                return '';
        }
+
+       /**
+        * @brief Return relative path to theme stylesheet file
+        *
+        * Provide a sane default if nothing is chosen or the specified theme does not exist.
+        *
+        * @param string $theme Theme name
+        *
+        * @return string
+        */
+       public static function getStylesheetPath($theme)
+       {
+               $a = get_app();
+
+               $opts = (($a->profile_uid) ? '?f=&puid=' . $a->profile_uid : '');
+               if (file_exists('view/theme/' . $theme . '/style.php')) {
+                       return 'view/theme/' . $theme . '/style.pcss' . $opts;
+               }
+
+               return 'view/theme/' . $theme . '/style.css';
+       }
 }