aboutsummaryrefslogtreecommitdiffstats
path: root/MainView.php
diff options
context:
space:
mode:
Diffstat (limited to 'MainView.php')
-rw-r--r--MainView.php67
1 files changed, 67 insertions, 0 deletions
diff --git a/MainView.php b/MainView.php
new file mode 100644
index 0000000..d964b6c
--- /dev/null
+++ b/MainView.php
@@ -0,0 +1,67 @@
+<?php
+////
+// main/MainView.php
+// @created 31.10.2009
+// @author Filipp Lepalaan <filipp@mac.com>
+class MainView
+{
+ /**
+ * Create HTML <select> options from array
+ * @param array array
+ * @param mixed select option with this value
+ * @return string
+ */
+ function select($array, $current = null)
+ {
+ $out = '';
+
+ foreach ($array as $k => $v) {
+ $sel = ($k == $current) ? ' selected="selected" ' : '';
+ $out .= "<option value=\"{$k}\"{$sel}>{$v}</option>\n\t";
+ }
+
+ return $out;
+
+ }
+
+ function tag($name, $args = '', $content = '', $selected = '')
+ {
+ $str_args = '';
+ $out = '<' . $name;
+
+ // special treatment for certain tags
+ switch ($name)
+ {
+ case 'form':
+ break;
+ case 'img':
+ if (empty ($args['alt'])) $args['alt'] = 'Image';
+ break;
+ }
+
+ if (is_array ($args))
+ {
+ while (list ($k, $v) = each ($args)) {
+ if (!empty ($k)) $str_args .= ' ' . $k . '="' . $v . '"';
+ }
+ }
+
+ if (is_array ($content))
+ {
+ foreach ($content as $k => $v)
+ {
+ //
+ }
+ } else {
+ //
+ }
+
+ if (empty ($content)) return $out . $str_args . ' />';
+
+ return "{$out}{$str_args}>{$content}</{$name}>\n";
+
+ }
+
+}
+
+?> \ No newline at end of file