* @copyright (c) 2009-2011 Filipp Lepalaan * @license * This program is free software. It comes without any warranty, to * the extent permitted by applicable law. You can redistribute it * and/or modify it under the terms of the Do What The Fuck You Want * To Public License, Version 2, as published by Sam Hocevar. See * http://sam.zoy.org/wtfpl/COPYING for more details. */ class MainView { //// // include something within the project tree function snippet($path) { $base = dirname(__FILE__).'/../..'; $base = realpath($base); include $base.'/'.$path; } //// // render a table function table($data, $cols = null) { } //// // create HTML '; return $html; } // $this->mainView->form('/some/save')-> function action($action) { $port = ($_SERVER['SERVER_PORT'] > 80) ? ':'.$_SERVER['SERVER_PORT'] : ''; $base = str_replace('index.php', '', $_SERVER['PHP_SELF']); return 'action="'.$base.$action.$port.'"'; } function form($action) { $port = ($_SERVER['SERVER_PORT'] > 80) ? ':'.$_SERVER['SERVER_PORT'] : ''; $out = '
tag('input', $params); } /** * Create an HTML tag */ function tag($name, $args = '', $content = FALSE, $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 ($content === FALSE) { return $out . $str_args . ' />'; } return "{$out}{$str_args}>{$content}\n"; } } ?>