Missing theme conf type "checkbox"

This commit is contained in:
Michael Foster 2013-08-19 02:03:54 +10:00
parent 740b710dd4
commit 5051e0572a
2 changed files with 18 additions and 6 deletions

View File

@ -2155,6 +2155,9 @@ function mod_theme_configure($theme_name) {
$query = prepare("INSERT INTO ``theme_settings`` VALUES(:theme, :name, :value)"); $query = prepare("INSERT INTO ``theme_settings`` VALUES(:theme, :name, :value)");
$query->bindValue(':theme', $theme_name); $query->bindValue(':theme', $theme_name);
$query->bindValue(':name', $conf['name']); $query->bindValue(':name', $conf['name']);
if ($conf['type'] == 'checkbox')
$query->bindValue(':value', isset($_POST[$conf['name']]) ? 1 : 0);
else
$query->bindValue(':value', $_POST[$conf['name']]); $query->bindValue(':value', $_POST[$conf['name']]);
$query->execute() or error(db_error($query)); $query->execute() or error(db_error($query));
} }

View File

@ -7,12 +7,21 @@
<tr> <tr>
<th>{{ conf.title }}</th> <th>{{ conf.title }}</th>
<td> <td>
{% if conf.type == 'checkbox' %}
<input type="checkbox" name="{{ conf.name }}"
{% if settings[conf.name] or (not settings[conf.name] is defined and conf.default) %}
checked
{% endif %}>
{% else %}
<input type="text" name="{{ conf.name }}" <input type="text" name="{{ conf.name }}"
{% if settings[conf.name] %}value="{{ settings[conf.name] }}"{% else %}{% if conf.default %}value="{{ conf.default }}"{% endif %}{% endif %} {% if settings[conf.name] %}
value="{{ settings[conf.name] }}"
{% else %}
{% if conf.default %}value="{{ conf.default }}"{% endif %}{% endif %}
{% if conf.size %} {% if conf.size %}
size="{{ conf.size }}" size="{{ conf.size }}"
{% endif %}>
{% endif %} {% endif %}
/>
{% if conf.comment %} {% if conf.comment %}
<span class="unimportant">{{ conf.comment }}</span> <span class="unimportant">{{ conf.comment }}</span>
{% endif %} {% endif %}