Webgui improve filter functions
This commit is contained in:
1 parent
b3825cb1b3
commit
9d09b1e120
17 files changed
+435
-458
No files matched your search
+37
-17
@@ -157,6 +157,9 @@ $g_db_scheme_version = $sth->fetchColumn();
|
||||
$g_db_scheme_required = 1;
|
||||
// Schema version check
|
||||
if ($g_db_scheme_version !== $g_db_scheme_required) {
|
||||
// TODO if required schema version is smaller than found version then
|
||||
// an database scheme update is neccessary
|
||||
// otherwise our program code is outdated an should be updated
|
||||
echo "<pre>\n";
|
||||
echo "Database schema is wrong: detected version $g_db_scheme_version, but required version $g_db_scheme_required!\n";
|
||||
echo "</pre>\n";
|
||||
@@ -948,20 +951,20 @@ function form_create_check($fieldname, $label, $checked) {
|
||||
|
||||
function form_create_checks($fieldname, $label, $optlist, $selected = []) {
|
||||
// create multiple combined checkboxes with title
|
||||
echo '<fieldset class="mb-3">';
|
||||
echo '<fieldset class="mb-3">', "\n";
|
||||
echo '<legend class="fs-6 mb-1 border-bottom pb-1">', $label, "</legend>\n";
|
||||
echo '<div class="d-flex flex-wrap gap-3">';
|
||||
foreach ($optlist as $k => $v) {
|
||||
echo '<div class="form-check">';
|
||||
echo '<div class="form-check">', "\n";
|
||||
$checked = in_array($k, $selected, true) ? ' checked' : '';
|
||||
echo '<label class="form-check-label">';
|
||||
echo '<input type="checkbox" class="form-check-input" name="', $fieldname, '[', $k, ']"', $checked, '>';
|
||||
echo $v;
|
||||
echo '</label>';
|
||||
echo '</div>';
|
||||
echo "</div>\n";
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</fieldset>';
|
||||
echo "</div>\n";
|
||||
echo "</fieldset>\n";
|
||||
}
|
||||
|
||||
function form_add_button($script, $id=NULL, $idname='id') {
|
||||
@@ -1025,6 +1028,20 @@ function form_tag_assignment($script, $id, $tags) {
|
||||
echo "</tr>";
|
||||
}
|
||||
|
||||
function filter_create_text($fieldname, $label, $value, $size=NULL, $maxlength=NULL) {
|
||||
echo '<div class="d-flex flex-nowrap gap-2 align-items-start">', "\n";
|
||||
echo '<label for="', $fieldname,'">', $label,'</label>', "\n";
|
||||
echo '<input class="form-control" type="text" name="', $fieldname, '"';
|
||||
if (isset($size)) {
|
||||
echo ' size="', $size,'"';
|
||||
}
|
||||
if (isset($maxlength)) {
|
||||
echo ' maxlength="', $maxlength, '"';
|
||||
}
|
||||
echo ' value="', h($value), '">', "\n";
|
||||
echo "</div>\n";
|
||||
}
|
||||
|
||||
function filter_create_select($fieldname, $label, $optlist, $selval=NULL, $multiple=FALSE) {
|
||||
// - Wenn multiple gesetzt ist, muß selval ein array sein
|
||||
// ansonsten ein einfacher String
|
||||
@@ -1032,7 +1049,7 @@ function filter_create_select($fieldname, $label, $optlist, $selval=NULL, $multi
|
||||
if (!is_array($selval)) {
|
||||
}
|
||||
} */
|
||||
echo '<div class="d-flex flex-nowrap gap-2">', "\n";
|
||||
echo '<div class="d-flex flex-nowrap gap-2 align-items-start">', "\n";
|
||||
echo '<label for="', $fieldname,'">', $label,'</label>', "\n";
|
||||
echo '<select class="form-select" id="', $fieldname, '" name="', $fieldname, '"', $multiple ? ' multiple' : '', ">\n";
|
||||
foreach ($optlist as $k => $v) {
|
||||
@@ -1043,25 +1060,25 @@ function filter_create_select($fieldname, $label, $optlist, $selval=NULL, $multi
|
||||
echo '>', $v, '</option>', "\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
echo "</div>";
|
||||
echo "</div>\n";
|
||||
}
|
||||
|
||||
function filter_create_checks($fieldname, $label, $optlist, $selected = []) {
|
||||
// TODO WIP
|
||||
echo '<fieldset class="mb-3">';
|
||||
echo '<fieldset class="mb-3">', "\n";
|
||||
echo '<legend class="fs-6 mb-1 border-bottom pb-1">', $label, "</legend>\n";
|
||||
echo '<div class="d-flex flex-wrap gap-3">';
|
||||
echo '<div class="d-flex flex-wrap gap-3">', "\n";
|
||||
foreach ($optlist as $k => $v) {
|
||||
echo '<div class="form-check">';
|
||||
echo '<div class="form-check">', "\n";
|
||||
$checked = in_array($k, $selected, true) ? ' checked' : '';
|
||||
echo '<label class="form-check-label">';
|
||||
echo '<input type="checkbox" class="form-check-input" name="', $fieldname, '[', $k, ']"', $checked, '>';
|
||||
echo $v;
|
||||
echo '</label>';
|
||||
echo '</div>';
|
||||
echo '<label class="form-check-label">', "\n";
|
||||
echo '<input type="checkbox" class="form-check-input" name="', $fieldname, '[', $k, ']"', $checked, ">\n";
|
||||
echo $v, "\n";
|
||||
echo "</label>\n";
|
||||
echo "</div>\n";
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</fieldset>';
|
||||
echo "</div>\n";
|
||||
echo "</fieldset>\n";
|
||||
}
|
||||
|
||||
// ========== FORMAT FUNCTIONS ================================================
|
||||
@@ -1179,6 +1196,9 @@ function format_measurement($n, $unit, $v1, $v2, $v3) {
|
||||
function h($value, $br=false) {
|
||||
// escape value coming from db for safe html output
|
||||
// optional convert line breaks to <br> tags
|
||||
if (!isset($value)) {
|
||||
return '';
|
||||
}
|
||||
$value = htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
return $br ? nl2br($value) : $value;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user