1
0
mirror of https://github.com/typemill/typemill.git synced 2025-08-05 21:57:31 +02:00

2.3.0 Add default settings to themes and plugins

This commit is contained in:
trendschau
2024-03-07 22:08:50 +01:00
parent 5d2be11c3f
commit ea6ed06c69
4 changed files with 39 additions and 12 deletions

View File

@@ -73,6 +73,7 @@ class ControllerWebSystem extends Controller
$extension = new Extension();
$themeDefinitions = $extension->getThemeDetails($this->settings['theme']);
$themeSettings = $extension->getThemeSettings($this->settings['themes']);
# add userroles and other datasets
foreach($themeDefinitions as $name => $definitions)
@@ -81,9 +82,18 @@ class ControllerWebSystem extends Controller
{
$themeDefinitions[$name]['forms']['fields'] = $this->addDatasets($definitions['forms']['fields']);
}
}
$themeSettings = $extension->getThemeSettings($this->settings['themes']);
if(isset($definitions['settings']))
{
foreach($definitions['settings'] as $settingName => $settingValue)
{
if(!isset($themeSettings[$name][$settingName]))
{
$themeSettings[$name][$settingName] = $settingValue;
}
}
}
}
$license = [];
if(is_array($this->settings['license']))
@@ -141,8 +151,18 @@ class ControllerWebSystem extends Controller
{
$pluginDefinitions[$name]['forms']['fields'] = $this->addDatasets($definitions['forms']['fields']);
}
}
if(isset($definitions['settings']))
{
foreach($definitions['settings'] as $settingName => $settingValue)
{
if(!isset($pluginSettings[$name][$settingName]))
{
$pluginSettings[$name][$settingName] = $settingValue;
}
}
}
}
}
$license = [];

View File

@@ -7,6 +7,8 @@ class Field
private $type;
private $label;
private $checkboxLabel;
private $name;
@@ -70,11 +72,17 @@ class Field
'cols',
'min',
'max',
'class',
'css',
'pattern',
'steps'
);
private $helperName;
private $help;
private $description;
private $fieldsize;
/* defines additional data, that are allowed for fields */
private $helpers = array(
'help',
@@ -157,7 +165,7 @@ class Field
{
return $this->content;
}
private function setOptions(array $options)
{
foreach($options as $key => $value)
@@ -285,5 +293,5 @@ class Field
return $this->$helperName;
}
return false;
}
}
}

View File

@@ -1,4 +1,4 @@
<div class="{{ class ? class : 'cardField' }}{{ errors[field.name] ? ' errorfield' : '' }}{{field.fieldsize ? ' ' ~ field.fieldsize : ''}}">
<div class="{{ field.getAttributeValue('css') ? field.getAttributeValue('css') : 'tmField' }}{{ errors[field.name] ? ' errorfield' : '' }}{{field.fieldsize ? ' ' ~ field.fieldsize : ''}}">
<label for="{{ itemName }}[{{ field.name }}]">{{ translate( field.getLabel() ) }}
{% if field.getAttribute('required') %}<strong><abbr title="{{ translate('required') }}">*</abbr></strong>{% endif %}

View File

@@ -5,13 +5,13 @@
{% endif %}
<form method="POST" action="{{ url_for(routename) }}" enctype="multipart/form-data">
<fieldset class="card{{ errors ? ' errors' : '' }}">
<fieldset class="tmFieldset{{ errors ? ' errors' : '' }}">
{% for field in fields %}
{% if field.type == 'fieldset' %}
<fieldset class="subfield">
<fieldset class="tmSubfield">
<legend>{{ translate(field.legend) }}</legend>
{% for field in field.fields %}
@@ -55,9 +55,8 @@
<style>
.personal-mail{ display:none }
.error{ margin-top:4px; background:red; color:#FFF; padding: 2px; font-size:.9rem;}
.errorfield label{ color:red; }
.errorfield input{ outline: 1px solid red; }
.error{ margin-top:4px; background:rgb(244 63 94); color:#FFF; padding: 2px; font-size:.9rem;}
.errorfield input{ outline: 1px solid rgb(244 63 94); }
</style>
</fieldset>
</form>