+ function form($action=false, $method=false, $inputs, $options=false) {
+ $action = $action ? " action='$action'" : '';
+ $method = $method ? " method='$method'" : '';
+ $options = $options ? " $options" : '';
+ $html = "<form$action$method$options>";
+ foreach($inputs as $input) $html .= call_user_func_array(array($this,'input'), $input);
+ $html .= "</form>";
+ return $html;
+ }
+
+ function select($name, $selectbox, $default=false) {
+ //echo('<pre>'); print_r($selectbox);
+ $html = "<select name='$name'>";
+
+ if($default) {
+ $value=$default; $title=$selectbox[$value];
+ $html .= "<option value='$value'>$value :: $title</option>";
+ unset($selectbox[$value]);
+ }
+ foreach($selectbox as $value => $title) {
+ $html .= "<option value='$value'>$value :: $title</option>";
+ }
+ $html .= "</select>";
+ return $html;
+ }
+
+ function ul($items,$tag=ul,$head='',$class=false) {
+ $class = $class ? " class='$class'" : '';
+ $html = "$head<$tag$class>";
+ foreach($items as $key => $value) {
+ $html .= '<li>';
+ if(is_numeric($key)) {
+ $html .= $value;
+ } else {
+ $html .= $this->link($key,$value);
+ }
+ $html .= '</li>';
+ }
+ $html .= "</$tag>";
+ return $html;
+ }
+
+ function div($html, $options) {
+ $options = $options ? " $options" : '';
+ return "<div$options>$html</div>";
+ }
+
+ function head($title=false,$charset='UTF-8',$more='') {
+ $title = $title ? "\n<title>$title</title>" : '';
+ $html= '<head>';
+ $html.= '<meta http-equiv="Content-Type" content="text/html; charset='.$charset.'" />'.$title.$more;
+ $html.= '</head>';
+ return $html;
+ }
+}
+
+/**
+* Trida poskytuje podpurne funkce pro generovani HTML kodu specificke pro sklad
+*
+* Tato trida by nemela sama nic vypisovat (vyjma chybovych a debugovacich hlasek)!
+*
+* @package Sklad_HTML
+* @author Tomas Mudrunka
+*/
+class Sklad_HTML extends HTML { //TODO: Split into few more methods
+ function header($title='', $user=array()) {
+ $home = URL_HOME;
+ $script = $_SERVER['SCRIPT_NAME'];
+ $search = htmlspecialchars(@trim($_GET['q']));
+ $message = strip_tags(@trim($_GET['message']),'<a><b><u><i>');
+ $instance = INSTANCE_ID != '' ? '/'.INSTANCE_ID : '';
+ $user_id = htmlspecialchars($user['id']);
+ $user_gid = htmlspecialchars($user['gid']);
+ $user_name = htmlspecialchars($user['name']);
+ //$title = T($title); //TODO
+
+ $html = $this->head("SōkoMan$title");
+ $html .= <<<EOF
+<h1 style="display: inline;"><a href="$script/">SōkoMan</a><small>$instance$title</small></h1>
+<div style="float:right">Loged in as <b>$user_name</b> [UID: <b>$user_id</b>; GID: <b>$user_gid</b>]</div>
+
+<style type="text/css">
+* { font-family: arial; }
+td,body { background-color: white; }
+table { background-color: orange; border: orange; }
+a, a img { text-decoration:none; color: darkblue; border:none; }
+li a, a:hover { text-decoration:underline; }
+
+.menu li {
+ float: left;
+ padding: 0.2em;
+}
+
+.menu * li {
+ float: none;
+}
+
+.menu * menu {
+ position: absolute;
+ padding: 0.2em;
+}
+
+.menu, .menu * menu {
+ list-style: none;
+}
+
+.menu * menu {
+ border: 1px solid orange;
+ display: none;
+ margin: 0;
+}
+
+.menu li:hover menu, .menu li:hover {
+ display: block;
+ background-color: yellow;
+}
+
+</style>
+
+<div>
+EOF;
+
+ $assistants=array();
+ foreach(scandir(DIR_ASSISTANTS) as $item) {
+ if($item == '.' || $item == '..') continue;
+ $item = preg_replace('/\.inc\.php$/','',$item);
+ $assistants[$item] = "assistant/$item";
+ }
+
+ $tables=array('item','model','category','producer','vendor','room','status');
+
+ foreach($tables as $table) {
+ $listable[$table] = $table;
+ $insertable[$table] = "$table/new";
+ }
+
+ $html .= $this->ul(array(
+ 'Home' => '',
+ 'Logout' => '?logout',
+ 0 => $this->ul($assistants,'menu',$this->link('Assistants','#')),
+ 1 => $this->ul($insertable,'menu',$this->link('New','#')),
+ 2 => $this->ul($listable,'menu',$this->link('List','#'))
+ ),'menu', '', 'menu');
+
+ $html .= '<div style="float: right;">';
+
+ $html .= $this->form("$script/assistant/go", 'GET', array(
+ array('q','','text','smart id...', 'autofocus'),
+ array(false,'go','submit')
+ ), 'style="float: left;"');
+
+ $html .= $this->form('?', 'GET', array(
+ array('q',$search,'text','regexp...'),
+ array(false,'filter','submit')
+ ), 'style="float: left;"');
+
+ $html .= '</div>';
+
+ $html .= <<<EOF
+</div>
+<hr style="clear: both;" />
+<div style="background-color:#FFDDDD;">
+ <font color="red">$message</font>
+</div>
+EOF;
+
+ return $html;
+ }
+
+ function internal_url($link) {
+ return $_SERVER['SCRIPT_NAME'].'/'.$link;