summaryrefslogtreecommitdiff
path: root/utils/forms.php
diff options
context:
space:
mode:
Diffstat (limited to 'utils/forms.php')
-rw-r--r--utils/forms.php119
1 files changed, 119 insertions, 0 deletions
diff --git a/utils/forms.php b/utils/forms.php
new file mode 100644
index 0000000..4383d0a
--- /dev/null
+++ b/utils/forms.php
@@ -0,0 +1,119 @@
+<?php
+
+function beginform($action)
+{
+ global $m, $s;
+?>
+<form method="post" action="?page=admin&amp;m=<?php echo $m; ?>&amp;s=<?php echo $s; ?>&amp;a=<?php echo $action; ?>">
+<?php
+}
+
+function endform()
+{
+?>
+</form>
+<?php
+}
+
+function button($label)
+{
+?>
+ <div class="input">
+ <div class="label"></div>
+ <div class="widget"><button type="submit"><?php echo $label; ?></button></div>
+ </div>
+<?php
+}
+
+function lineedit($label, $name, $value = "")
+{
+?>
+ <div class="input">
+ <div class="label"><?php echo $label; ?></div>
+ <div class="widget"><input name="<?php echo "vars[".$name."]"; ?>" value="<?php echo $value; ?>"/></div>
+ </div>
+<?php
+}
+
+function hidden($values)
+{
+ foreach($values as $key => $value) {
+?>
+ <input type="hidden" name="<?php echo "vars[".$key."]"; ?>" value="<?php echo $value; ?>"/>
+<?php
+ }
+}
+
+function textedit($label, $name, $value = "")
+{
+?>
+ <div class="input">
+ <div class="label"><?php echo $label; ?></div>
+ <div class="widget"><textarea name="<?php echo "vars[".$name."]"; ?>"><?php echo $value; ?></textarea></div>
+ </div>
+<?php
+}
+
+function datetimeedit($label, $name, $timestamp = 0)
+{
+ if($timestamp == 0) $timestamp = time();
+
+ $second = date('s',$timestamp);
+ $minute = date('i',$timestamp);
+ $hour = date('G',$timestamp);
+ $day = date('d',$timestamp);
+ $month = date('m',$timestamp);
+ $year = date('Y',$timestamp);
+?>
+ <div class="input">
+ <div class="label"><?php echo $label; ?></div>
+ <div class="widget">
+ <input style="width: 40px;" name="<?php echo "vars[".$name."_year]"; ?>" value="<?php echo $year; ?>"/>
+ /
+ <input style="width: 20px;" name="<?php echo "vars[".$name."_month]"; ?>" value="<?php echo $month; ?>"/>
+ /
+ <input style="width: 20px;" name="<?php echo "vars[".$name."_day]"; ?>" value="<?php echo $day; ?>"/>
+ -
+ <input style="width: 20px;" name="<?php echo "vars[".$name."_hour]"; ?>" value="<?php echo $hour; ?>"/>
+ :
+ <input style="width: 20px;" name="<?php echo "vars[".$name."_minute]"; ?>" value="<?php echo $minute; ?>"/>
+ :
+ <input style="width: 20px;" name="<?php echo "vars[".$name."_second]"; ?>" value="<?php echo $second; ?>"/>
+ </div>
+ </div>
+<?php
+}
+function totimestamp($t, $name)
+{
+ $timestring = sprintf("%d", $t[$name."_year"]) ."/".
+ sprintf("%d", $t[$name."_month"]) ."/".
+ sprintf("%d", $t[$name."_day"]) ." ".
+ sprintf("%d", $t[$name."_hour"]) .":".
+ sprintf("%02d", $t[$name."_minute"]).":".
+ sprintf("%02d", $t[$name."_second"]);
+
+ echo $timestring;
+
+ return strtotime($timestring);
+}
+
+function combobox($label, $name, $value, $values)
+{
+?>
+ <div class="input">
+ <div class="label"><?php echo $label; ?></div>
+ <div class="widget">
+ <select name="<?php echo "vars[".$name."]"; ?>">
+<?php
+
+ foreach($values as $k => $v) {
+ if($v != $value) echo " <option value=\"$v\">$k</option>\n";
+ else echo " <option value=\"$v\" selected>$k</option>\n";
+ }
+?>
+ </select>
+ </div>
+ </div>
+<?php
+}
+?>