summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-21 23:18:32 +0300
committerAndrew Dolgov <[email protected]>2021-02-21 23:18:32 +0300
commitf6bfb89b2912933f638416135dff7bb8cb28890d (patch)
tree6764214859c4d8c90b146efb58b96e2bf9c78b85 /include
parent861a632ac7c283c55dfd947ed0152d9846fa2ac0 (diff)
pref-prefs: switch to new control shorthand in a few places
Diffstat (limited to 'include')
-rwxr-xr-xinclude/controls.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/controls.php b/include/controls.php
index e3349d31b..b65a166c2 100755
--- a/include/controls.php
+++ b/include/controls.php
@@ -5,6 +5,11 @@
$rv = "";
foreach ($attributes as $k => $v) {
+
+ // special handling for "disabled"
+ if ($k === "disabled" && !sql_bool_to_bool($v))
+ continue;
+
$rv .= "$k=\"" . htmlspecialchars($v) . "\"";
}
@@ -30,6 +35,18 @@
return "<button dojoType=\"dijit.form.Button\" ".attributes_to_string($attributes)." type=\"$type\">$value</button>";
}
+ function input_tag(string $name, string $value, string $type = "text", array $attributes = [], string $id = "") {
+ $attributes_str = attributes_to_string($attributes);
+ $dojo_type = strpos($attributes_str, "dojoType") === false ? "dojoType='dijit.form.TextBox'" : "";
+
+ return "<input name=\"".htmlspecialchars($name)."\" $dojo_type ".attributes_to_string($attributes)." id=\"".htmlspecialchars($id)."\"
+ type=\"$type\" value=\"".htmlspecialchars($value)."\">";
+ }
+
+ function number_spinner_tag(string $name, string $value, array $attributes = [], string $id = "") {
+ return input_tag($name, $value, "text", array_merge(["dojoType" => "dijit.form.NumberSpinner"], $attributes), $id);
+ }
+
function submit_tag(string $value, array $attributes = []) {
return button_tag($value, "submit", array_merge(["class" => "alt-primary"], $attributes));
}