]> git.mxchange.org Git - friendica.git/commitdiff
Add Theme::getBackgroundColor and Theme::getThemeColor methods
authorHypolite Petovan <hypolite@mrpetovan.com>
Wed, 19 Feb 2020 15:28:57 +0000 (10:28 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Wed, 19 Feb 2020 15:28:57 +0000 (10:28 -0500)
src/Core/Theme.php
view/theme/duepuntozero/theme.php
view/theme/frio/theme.php
view/theme/quattro/theme.php
view/theme/smoothly/theme.php
view/theme/vier/theme.php

index ff3265c90aea3afe1e13d724cbaa5b779eabf642..f7dce3c298413db6f41b3d3e516e34fc152c34d2 100644 (file)
@@ -257,4 +257,56 @@ class Theme
 
                return 'view/theme/' . $theme . '/style.pcss' . (!empty($query_params) ? '?' . http_build_query($query_params) : '');
        }
+
+       /**
+        * Returns the background color of the provided theme if available.
+        *
+        * @param string   $theme
+        * @param int|null $uid   Current logged-in user id
+        * @return string|null
+        */
+       public static function getBackgroundColor(string $theme, $uid = null)
+       {
+               $theme = Strings::sanitizeFilePathItem($theme);
+
+               $return = null;
+
+               // silently fail if theme was removed or if $theme is funky
+               if (file_exists("view/theme/$theme/theme.php")) {
+                       include_once "view/theme/$theme/theme.php";
+
+                       $func = "{$theme}_get_background_color";
+                       if (function_exists($func)) {
+                               $return = $func($uid);
+                       }
+               }
+
+               return $return;
+       }
+
+       /**
+        * Returns the theme color of the provided theme if available.
+        *
+        * @param string   $theme
+        * @param int|null $uid   Current logged-in user id
+        * @return string|null
+        */
+       public static function getThemeColor(string $theme, int $uid = null)
+       {
+               $theme = Strings::sanitizeFilePathItem($theme);
+
+               $return = null;
+
+               // silently fail if theme was removed or if $theme is funky
+               if (file_exists("view/theme/$theme/theme.php")) {
+                       include_once "view/theme/$theme/theme.php";
+
+                       $func = "{$theme}_get_theme_color";
+                       if (function_exists($func)) {
+                               $return = $func($uid);
+                       }
+               }
+
+               return $return;
+       }
 }
index 33ad00baffb8c6166e164f2e7895aa6c05a0242c..10427df6f002a5dbcf0413c12edab3bc0c3ed783 100644 (file)
@@ -98,3 +98,25 @@ $(document).ready(function() {
 </script>
 EOT;
 }
+
+/**
+ * @param int|null $uid
+ * @return null
+ * @see \Friendica\Core\Theme::getBackgroundColor()
+ * @TODO Implement this function
+ */
+function duepuntozero_get_background_color(int $uid = null)
+{
+       return null;
+}
+
+/**
+ * @param int|null $uid
+ * @return null
+ * @see \Friendica\Core\Theme::getThemeColor()
+ * @TODO Implement this function
+ */
+function duepuntozero_get_theme_color(int $uid = null)
+{
+       return null;
+}
index f256bec6957f8527e49fc2f9ab53a7c3c3cd7deb..daeb22a5edabcbeb3d9e8f1cfe88f416a2e20711 100644 (file)
@@ -366,3 +366,51 @@ function frio_display_item(App $a, &$arr)
        }
        $arr['output']['subthread'] = $subthread;
 }
+
+/**
+ * @param int|null $uid
+ * @return string
+ * @see \Friendica\Core\Theme::getBackgroundColor()
+ */
+function frio_get_background_color(int $uid = null)
+{
+       $background_color = DI::config()->get('frio', 'background_color') ?: '#ededed';
+
+       if ($uid) {
+               $background_color = DI::pConfig()->get($uid, 'frio', 'background_color') ?: $background_color;
+       }
+
+       $scheme = DI::config()->get('frio', 'scheme', DI::config()->get('frio', 'schema'));
+       $scheme = Strings::sanitizeFilePathItem($scheme);
+
+       if ($scheme && ($scheme != '---') && file_exists('view/theme/frio/scheme/' . $scheme . '.php')) {
+               $schemefile = 'view/theme/frio/scheme/' . $scheme . '.php';
+               require_once $schemefile;
+       }
+
+       return $background_color;
+}
+
+/**
+ * @param int|null $uid
+ * @return string
+ * @see \Friendica\Core\Theme::getThemeColor()
+ */
+function frio_get_theme_color(int $uid = null)
+{
+       $nav_bg = DI::config()->get('frio', 'nav_bg') ?: '#708fa0';
+
+       if ($uid) {
+               $nav_bg = DI::pConfig()->get($uid, 'frio', 'background_color') ?: $nav_bg;
+       }
+
+       $scheme = DI::config()->get('frio', 'scheme', DI::config()->get('frio', 'schema'));
+       $scheme = Strings::sanitizeFilePathItem($scheme);
+
+       if ($scheme && ($scheme != '---') && file_exists('view/theme/frio/scheme/' . $scheme . '.php')) {
+               $schemefile = 'view/theme/frio/scheme/' . $scheme . '.php';
+               require_once $schemefile;
+       }
+
+       return $nav_bg;
+}
index d54517de712fceaeaa7175987ae3f42c8a427baa..3ff9302c85abe199ffb7eecc92348b9c3bce5e7d 100644 (file)
@@ -14,3 +14,25 @@ function quattro_init(App $a) {
        DI::page()['htmlhead'] .= '<script src="'.DI::baseUrl().'/view/theme/quattro/tinycon.min.js"></script>';
        DI::page()['htmlhead'] .= '<script src="'.DI::baseUrl().'/view/theme/quattro/js/quattro.js"></script>';;
 }
+
+/**
+ * @param int|null $uid
+ * @return null
+ * @see \Friendica\Core\Theme::getBackgroundColor()
+ * @TODO Implement this function
+ */
+function quattro_get_background_color(int $uid = null)
+{
+       return null;
+}
+
+/**
+ * @param int|null $uid
+ * @return null
+ * @see \Friendica\Core\Theme::getThemeColor()
+ * @TODO Implement this function
+ */
+function quattro_get_theme_color(int $uid = null)
+{
+       return null;
+}
index e6f40749f9c8ad8bc0e796dce95dc28c2e1dd829..e20e9003f9c6ab9504f380015e7540bf000e4526 100644 (file)
@@ -93,3 +93,25 @@ if (! function_exists('_js_in_foot')) {
                return DI::page()['bottom'] = Renderer::replaceMacros($tpl, $bottom);
        }
 }
+
+/**
+ * @param int|null $uid
+ * @return null
+ * @see \Friendica\Core\Theme::getBackgroundColor()
+ * @TODO Implement this function
+ */
+function smoothly_get_background_color(int $uid = null)
+{
+       return null;
+}
+
+/**
+ * @param int|null $uid
+ * @return null
+ * @see \Friendica\Core\Theme::getThemeColor()
+ * @TODO Implement this function
+ */
+function smoothly_get_theme_color(int $uid = null)
+{
+       return null;
+}
index e5d5e1ce971a48a2239298f876c9bb183b3b8e04..fcbb148dc7a3518c5eacf3ac194b143e1e089a85 100644 (file)
@@ -364,3 +364,25 @@ function vier_community_info()
        $tpl = Renderer::getMarkupTemplate('communityhome.tpl');
        DI::page()['right_aside'] = Renderer::replaceMacros($tpl, $aside);
 }
+
+/**
+ * @param int|null $uid
+ * @return null
+ * @see \Friendica\Core\Theme::getBackgroundColor()
+ * @TODO Implement this function
+ */
+function vier_get_background_color(int $uid = null)
+{
+       return null;
+}
+
+/**
+ * @param int|null $uid
+ * @return null
+ * @see \Friendica\Core\Theme::getThemeColor()
+ * @TODO Implement this function
+ */
+function vier_get_theme_color(int $uid = null)
+{
+       return null;
+}