diff options
author | Filipp Lepalaan <filipp@mac.com> | 2010-05-21 21:42:39 +0300 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2010-05-21 21:42:39 +0300 |
commit | 8ec4e59bb0ddac89f36dcb48ee3f14c737e6e80f (patch) | |
tree | 951df57b4c78faaded13a50ad951edcd8df0e7dc /MainView.php | |
parent | a78ac287043f57ea81e1175ffbe2476956e04752 (diff) | |
download | main-8ec4e59bb0ddac89f36dcb48ee3f14c737e6e80f.tar.gz main-8ec4e59bb0ddac89f36dcb48ee3f14c737e6e80f.tar.bz2 main-8ec4e59bb0ddac89f36dcb48ee3f14c737e6e80f.zip |
Fixes
Diffstat (limited to 'MainView.php')
-rw-r--r-- | MainView.php | 67 |
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 |