summaryrefslogtreecommitdiff
path: root/includes/sys_template.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/sys_template.php')
-rw-r--r--includes/sys_template.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/includes/sys_template.php b/includes/sys_template.php
new file mode 100644
index 00000000..7524b0cb
--- /dev/null
+++ b/includes/sys_template.php
@@ -0,0 +1,36 @@
+<?php
+
+
+// Load and render template
+function template_render($file, $data) {
+ if (file_exists($file)) {
+ $template = file_get_contents($file);
+ if (is_array($data))
+ foreach ($data as $name => $content) {
+ $template = str_replace("%" . $name . "%", $content, $template);
+ }
+ return $template;
+ } else {
+ die('Cannot find template file &laquo;' . $file . '&raquo;.');
+ }
+}
+
+function html_options($name, $options, $selected = "") {
+ $html = "";
+ foreach ($options as $value => $label)
+ $html .= '<input type="radio"' . ($value == $selected ? ' checked="checked"' : '') . ' name="' . $name . '" value="' . $value . '"> ' . $label;
+
+ return $html;
+}
+
+function html_select_key($name, $rows, $selected) {
+ $html = '<select name="' . $name . '">';
+ foreach ($rows as $key => $row)
+ if (($key == $selected) || ($row == $selected))
+ $html .= '<option value="' . $key . '" selected="selected">' . $row . '</option>';
+ else
+ $html .= '<option value="' . $key . '">' . $row . '</option>';
+ $html .= '</select>';
+ return $html;
+}
+?> \ No newline at end of file