aboutsummaryrefslogtreecommitdiffstats
path: root/view/theme/redbasic/php
diff options
context:
space:
mode:
Diffstat (limited to 'view/theme/redbasic/php')
-rw-r--r--view/theme/redbasic/php/config.php155
-rw-r--r--view/theme/redbasic/php/theme.php2
-rw-r--r--view/theme/redbasic/php/theme_init.php3
3 files changed, 83 insertions, 77 deletions
diff --git a/view/theme/redbasic/php/config.php b/view/theme/redbasic/php/config.php
index 7079cc386..87915bd18 100644
--- a/view/theme/redbasic/php/config.php
+++ b/view/theme/redbasic/php/config.php
@@ -4,6 +4,7 @@ namespace Zotlabs\Theme;
use ScssPhp\ScssPhp\Compiler;
use ScssPhp\ScssPhp\OutputStyle;
+use ScssPhp\ScssPhp\ValueConverter;
class RedbasicConfig {
@@ -68,85 +69,89 @@ class RedbasicConfig {
}
if (isset($_POST['redbasic-settings-submit'])) {
- if (isset($_POST['redbasic_primary_color']) || isset($_POST['redbasic_radius'])) {
-
- $primary_color = '';
- $success_color = '';
- $info_color = '';
- $warning_color = '';
- $danger_color = '';
- $radius = floatval($_POST['redbasic_radius']);
-
- if (preg_match('/^#([A-Fa-f0-9]{3}){1,2}$/', $_POST['redbasic_primary_color'])) {
- $primary_color = $_POST['redbasic_primary_color'];
+ $primary_color = '';
+ $color_changed = false;
+ $success_color = '';
+ $info_color = '';
+ $warning_color = '';
+ $danger_color = '';
+ $radius = floatval($_POST['redbasic_radius']);
+ $radius_changed = $_POST['redbasic_radius'] !== get_pconfig(local_channel(),'redbasic', 'radius');
+
+ if (preg_match('/^#([A-Fa-f0-9]{3}){1,2}$/', $_POST['redbasic_primary_color'])) {
+ if (!$color_changed) {
+ $color_changed = $_POST['redbasic_primary_color'] !== get_pconfig(local_channel(),'redbasic', 'primary_color');
}
- if (preg_match('/^#([A-Fa-f0-9]{3}){1,2}$/', $_POST['redbasic_success_color'])) {
- $success_color = $_POST['redbasic_success_color'];
+ $primary_color = $_POST['redbasic_primary_color'];
+ }
+ if (preg_match('/^#([A-Fa-f0-9]{3}){1,2}$/', $_POST['redbasic_success_color'])) {
+ if (!$color_changed) {
+ $color_changed = $_POST['redbasic_success_color'] !== get_pconfig(local_channel(),'redbasic', 'success_color');
}
- if (preg_match('/^#([A-Fa-f0-9]{3}){1,2}$/', $_POST['redbasic_info_color'])) {
- $info_color = $_POST['redbasic_info_color'];
+ $success_color = $_POST['redbasic_success_color'];
+ }
+ if (preg_match('/^#([A-Fa-f0-9]{3}){1,2}$/', $_POST['redbasic_info_color'])) {
+ if (!$color_changed) {
+ $color_changed = $_POST['redbasic_info_color'] !== get_pconfig(local_channel(),'redbasic', 'info_color');
}
- if (preg_match('/^#([A-Fa-f0-9]{3}){1,2}$/', $_POST['redbasic_warning_color'])) {
- $warning_color = $_POST['redbasic_warning_color'];
+ $info_color = $_POST['redbasic_info_color'];
+ }
+ if (preg_match('/^#([A-Fa-f0-9]{3}){1,2}$/', $_POST['redbasic_warning_color'])) {
+ if (!$color_changed) {
+ $color_changed = $_POST['redbasic_warning_color'] !== get_pconfig(local_channel(),'redbasic', 'warning_color');
}
- if (preg_match('/^#([A-Fa-f0-9]{3}){1,2}$/', $_POST['redbasic_danger_color'])) {
- $danger_color = $_POST['redbasic_danger_color'];
+ $warning_color = $_POST['redbasic_warning_color'];
+ }
+ if (preg_match('/^#([A-Fa-f0-9]{3}){1,2}$/', $_POST['redbasic_danger_color'])) {
+ if (!$color_changed) {
+ $color_changed = $_POST['redbasic_danger_color'] !== get_pconfig(local_channel(),'redbasic', 'danger_color');
}
+ $danger_color = $_POST['redbasic_danger_color'];
+ }
+
+ if (!$primary_color && !$success_color && !$info_color && !$warning_color && !$danger_color && !$radius) {
+ set_pconfig(local_channel(), 'redbasic', 'bootstrap', '');
+ }
+ else if ($color_changed || $radius_changed) {
+ try {
+ $compiler = new Compiler();
+ $compiler->setImportPaths('vendor/twbs/bootstrap/scss');
+ $compiler->setOutputStyle(OutputStyle::COMPRESSED);
+
+ // Set Variables
+ if ($primary_color) {
+ $variables['$primary'] = ValueConverter::parseValue($primary_color);
+ }
+ if ($success_color) {
+ $variables['$success'] = ValueConverter::parseValue($success_color);
+ }
+ if ($info_color) {
+ $variables['$info'] = ValueConverter::parseValue($info_color);
+ }
+ if ($warning_color) {
+ $variables['$warning'] = ValueConverter::parseValue($warning_color);
+ }
+ if ($danger_color) {
+ $variables['$danger'] = ValueConverter::parseValue($danger_color);
+ }
+ if ($radius) {
+ $variables['$border-radius'] = ValueConverter::parseValue($radius . 'rem');
+ $variables['$border-radius-sm'] = ValueConverter::parseValue($radius/1.5 . 'rem');
+ $variables['$border-radius-lg'] = ValueConverter::parseValue($radius*1.333 . 'rem');
+ $variables['$border-radius-xl'] = ValueConverter::parseValue($radius*2.666 . 'rem');
+ $variables['$border-radius-xxl'] = ValueConverter::parseValue($radius*5.333 . 'rem');
+ }
- if ($primary_color || $success_color || $info_color || $warning_color || $danger_color || $radius) {
-
- try {
- $cache_dir = 'store/[data]/[scss]/';
- if(!is_dir($cache_dir)) {
- os_mkdir($cache_dir, STORAGE_DEFAULT_PERMISSIONS, true);
- }
-
- $options = [
- 'cacheDir' => $cache_dir,
- 'prefix' => 'redbasic_',
- 'forceRefresh' => false
- ];
-
- $compiler = new Compiler($options);
- $compiler->setImportPaths('vendor/twbs/bootstrap/scss');
- $compiler->setOutputStyle(OutputStyle::COMPRESSED);
-
- // Set Variables
- if ($primary_color) {
- $variables['$primary'] = $primary_color;
- }
- if ($success_color) {
- $variables['$success'] = $success_color;
- }
- if ($info_color) {
- $variables['$info'] = $info_color;
- }
- if ($warning_color) {
- $variables['$warning'] = $warning_color;
- }
- if ($danger_color) {
- $variables['$danger'] = $danger_color;
- }
- if ($radius) {
- $variables['$border-radius'] = $radius . 'rem';
- $variables['$border-radius-sm'] = $radius/1.5 . 'rem';
- $variables['$border-radius-lg'] = $radius*1.333 . 'rem';
- $variables['$border-radius-xl'] = $radius*2.666 . 'rem';
- $variables['$border-radius-xxl'] = $radius*5.333 . 'rem';
- }
-
- // Replace Bootstrap Variables with Customizer Variables
+ // Replace Bootstrap Variables with Customizer Variables
+ if ($variables) {
$compiler->replaceVariables($variables);
+ }
- $bs = $compiler->compileString('@import "bootstrap.scss";');
+ $bs = $compiler->compileString('@import "bootstrap.scss";');
- set_pconfig(local_channel(), 'redbasic', 'bootstrap', $bs->getCss());
- } catch (\Exception $e) {
- logger('scssphp: Unable to compile content');
- }
- }
- else {
- set_pconfig(local_channel(), 'redbasic', 'bootstrap', '');
+ set_pconfig(local_channel(), 'redbasic', 'bootstrap', $bs->getCss());
+ } catch (\Exception $e) {
+ logger('scssphp: Unable to compile content');
}
}
@@ -193,11 +198,11 @@ class RedbasicConfig {
'$dark' => t('Dark style'),
'$light' => t('Light style'),
'$common' => t('Common settings'),
- '$primary_color' => array('redbasic_primary_color', t('Primary theme color'), $arr['primary_color'], '<i class="fa fa-circle text-primary"></i> ' . t('Current color, leave empty for default')),
- '$success_color' => array('redbasic_success_color', t('Success theme color'), $arr['success_color'], '<i class="fa fa-circle text-success"></i> ' . t('Current color, leave empty for default')),
- '$info_color' => array('redbasic_info_color', t('Info theme color'), $arr['info_color'], '<i class="fa fa-circle text-info"></i> ' . t('Current color, leave empty for default')),
- '$warning_color' => array('redbasic_warning_color', t('Warning theme color'), $arr['warning_color'], '<i class="fa fa-circle text-warning"></i> ' . t('Current color, leave empty for default')),
- '$danger_color' => array('redbasic_danger_color', t('Danger theme color'), $arr['danger_color'], '<i class="fa fa-circle text-danger"></i> ' . t('Current color, leave empty for default')),
+ '$primary_color' => array('redbasic_primary_color', t('Primary theme color'), $arr['primary_color'], '<i class="bi bi-circle-fill text-primary"></i> ' . t('Current color, leave empty for default')),
+ '$success_color' => array('redbasic_success_color', t('Success theme color'), $arr['success_color'], '<i class="bi bi-circle-fill text-success"></i> ' . t('Current color, leave empty for default')),
+ '$info_color' => array('redbasic_info_color', t('Info theme color'), $arr['info_color'], '<i class="bi bi-circle-fill text-info"></i> ' . t('Current color, leave empty for default')),
+ '$warning_color' => array('redbasic_warning_color', t('Warning theme color'), $arr['warning_color'], '<i class="bi bi-circle-fill text-warning"></i> ' . t('Current color, leave empty for default')),
+ '$danger_color' => array('redbasic_danger_color', t('Danger theme color'), $arr['danger_color'], '<i class="bi bi-circle-fill text-danger"></i> ' . t('Current color, leave empty for default')),
'$dark_mode' => array('redbasic_dark_mode',t('Default to dark mode'),$arr['dark_mode'], '', array(t('No'),t('Yes'))),
'$navbar_dark_mode' => array('redbasic_navbar_dark_mode',t('Always use light icons for navbar'),$arr['navbar_dark_mode'], t('Enable this option if you use a dark navbar color in light mode'), array(t('No'),t('Yes'))),
'$narrow_navbar' => array('redbasic_narrow_navbar',t('Narrow navbar'),$arr['narrow_navbar'], '', array(t('No'),t('Yes'))),
diff --git a/view/theme/redbasic/php/theme.php b/view/theme/redbasic/php/theme.php
index 1f682634e..dcbe8c3da 100644
--- a/view/theme/redbasic/php/theme.php
+++ b/view/theme/redbasic/php/theme.php
@@ -5,7 +5,7 @@
* * Description: Hubzilla standard theme
* * Version: 2.2
* * MinVersion: 8.9
- * * MaxVersion: 10.0
+ * * MaxVersion: 11.0
* * Author: Fabrixxm
* * Maintainer: Mike Macgirvin
* * Maintainer: Mario Vavti
diff --git a/view/theme/redbasic/php/theme_init.php b/view/theme/redbasic/php/theme_init.php
index cffe22de6..c26621068 100644
--- a/view/theme/redbasic/php/theme_init.php
+++ b/view/theme/redbasic/php/theme_init.php
@@ -3,7 +3,8 @@ use Zotlabs\Lib\Config;
require_once('view/php/theme_init.php');
-head_add_css('/library/fork-awesome/css/fork-awesome.min.css');
+head_add_css('/vendor/twbs/bootstrap-icons/font/bootstrap-icons.min.css');
+
head_add_css('/library/bootstrap-tagsinput/bootstrap-tagsinput.css');
head_add_css('/library/bootstrap-colorpicker/dist/css/bootstrap-colorpicker.min.css');