Configuration: fill up the data from system configuration if user config doesn't exist

This commit is contained in:
Matias Griese
2014-10-06 14:38:14 +03:00
parent 9d1da6ccf3
commit 41821c57ab
7 changed files with 22 additions and 12 deletions

View File

@@ -222,10 +222,11 @@ class Admin
case 'configuration':
case 'system':
$type = 'system';
$blueprints = $this->blueprints($type);
$file = YamlFile::instance(USER_DIR . "config/{$type}.yaml");
$obj = new Data\Data($file->content(), $blueprints);
$blueprints = $this->blueprints("config/{$type}");
$config = $this->grav['config'];
$obj = new Data\Data($config->get('system'), $blueprints);
$obj->merge($post);
$file = YamlFile::instance(USER_DIR . "config/{$type}.yaml");
$obj->file($file);
$data[$type] = $obj;
break;
@@ -233,10 +234,11 @@ class Admin
case 'settings':
case 'site':
$type = 'site';
$blueprints = $this->blueprints($type);
$file = YamlFile::instance(USER_DIR . "config/{$type}.yaml");
$obj = new Data\Data($file->content(), $blueprints);
$blueprints = $this->blueprints("config/{$type}");
$config = $this->grav['config'];
$obj = new Data\Data($config->get('site'), $blueprints);
$obj->merge($post);
$file = YamlFile::instance(USER_DIR . "config/{$type}.yaml");
$obj->file($file);
$data[$type] = $obj;
break;

View File

@@ -15,6 +15,7 @@
{% endblock %}
{% block content %}
{% include 'partials/blueprints.html.twig' with { blueprints: admin.blueprints('config/system'), data: admin.data('system') } %}
{% set data = admin.data('system') %}
{% include 'partials/blueprints.html.twig' with { blueprints: data.blueprints, data: data } %}
{% endblock %}

View File

@@ -11,7 +11,7 @@
{% for field in field.fields %}
{% if field.type %}
{% set value = data.value(field.name) %}
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
{% endif %}
{% endfor %}
</div>

View File

@@ -1,4 +1,6 @@
<form id="blueprints" method="post">
{% set form_id = form_id ? form_id : 'blueprints' %}
<form id="{{ form_id }}" method="post">
<h1>New Page</h1>
{% for field in blueprints.fields %}
{% if field.type %}

View File

@@ -1,4 +1,6 @@
<form id="blueprints" method="post">
{% set form_id = form_id ? form_id : 'blueprints' %}
<form id="{{ form_id }}" method="post">
{% for field in blueprints.fields %}
{% if field.type %}
{% set value = data.value(field.name) %}

View File

@@ -1,4 +1,6 @@
<form id="blueprints" method="post">
{% set form_id = form_id ? form_id : 'blueprints' %}
<form id="{{ form_id }}" method="post">
{% for field in blueprints.fields %}
{% if field.type %}
{% set value = data.value(field.name) %}

View File

@@ -20,6 +20,7 @@
{% endblock %}
{% block content %}
{% include 'partials/blueprints.html.twig' with { blueprints: admin.blueprints('config/site'), data: admin.data('site') } %}
{% set data = admin.data('site') %}
{% include 'partials/blueprints.html.twig' with { blueprints: data.blueprints, data: data } %}
{% endblock %}