aboutsummaryrefslogtreecommitdiffstats
path: root/View.php
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mekanisti.fi>2009-11-10 12:46:28 +0200
committerFilipp Lepalaan <filipp@mekanisti.fi>2009-11-10 12:46:28 +0200
commit6ce2a6c65c9c9eba1e7660d151b6a709ecfa625f (patch)
tree4a0b29723bb72c470d312cd6d5e453577a5c8bc1 /View.php
parent7034b50d0d50612ca52273aacabd2b3189c968d8 (diff)
downloadmain-6ce2a6c65c9c9eba1e7660d151b6a709ecfa625f.tar.gz
main-6ce2a6c65c9c9eba1e7660d151b6a709ecfa625f.tar.bz2
main-6ce2a6c65c9c9eba1e7660d151b6a709ecfa625f.zip
Fixes, View class
Diffstat (limited to 'View.php')
-rw-r--r--View.php68
1 files changed, 68 insertions, 0 deletions
diff --git a/View.php b/View.php
new file mode 100644
index 0000000..762d75b
--- /dev/null
+++ b/View.php
@@ -0,0 +1,68 @@
+<?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