* @author Tomas Mudrunka
*/
class HTML {
- function row($row) {
- $html='<tr>';
+ function row($row,$type=false) {
+ $html = '';
+ if($type) $html.="<$type>";
+ $html.='<tr>';
+ $td = $type == 'thead' ? 'th' : 'td';
foreach($row as $var) {
if(trim($var) == '') $var = ' ';
- $html.="<td>$var</td>";
+ $html.="<$td>$var</$td>";
}
$html.='</tr>';
+ if($type) $html.="</$type>";
return $html;
}
$header=true;
foreach($table as $row) {
if($header) {
- $html.=$this->row(array_keys($row));
+ $html.=$this->row(array_keys($row),'thead');
$header=false;
}
$html.=$this->row($row);
$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;
+ }
}
/**
$message = strip_tags(@trim($_GET['message']),'<a><b><u><i>');
$instance = INSTANCE_ID != '' ? '/'.INSTANCE_ID : '';
//$title = T($title); //TODO
- $html = <<<EOF
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title>SōkoMan$title</title>
-</head>
+
+ $html = $this->head("SōkoMan$title");
+ $html .= <<<EOF
<h1><a href="$script/">SōkoMan</a><small>$instance$title</small></h1>
<style type="text/css">
* { font-family: arial; }
+td,body { background-color: white; }
+table { background-color: orange; border: orange; }
+a { text-decoration:none; color: darkblue; }
+li a, a:hover { text-decoration:underline; }
.menu li {
float: left;
}
$html .= $this->ul(array(
- 'Logout' => '?logout',
'Home' => '',
+ 'Logout' => '?logout',
0 => $this->ul($assistants,'menu',$this->link('Assistants','#')),
- 1 => $this->ul($listable,'menu',$this->link('List','#')),
- 2 => $this->ul($insertable,'menu',$this->link('New','#'))
+ 1 => $this->ul($insertable,'menu',$this->link('New','#')),
+ 2 => $this->ul($listable,'menu',$this->link('List','#'))
),'menu', '', 'menu');
$html .= '<div style="float: right;">';
$action = $action ? " action='$action'" : false;
$html="<form$action method='POST'>"; //TODO: use $this->form()
- if($multi_insert) $html.='<div name="input_set" style="float:left; border:1px solid grey;">';
+ if($multi_insert) $html.='<span><div name="input_set" style="float:left; border:1px solid grey; padding: 1px; margin: 1px;">';
//$html.=$this->input('table', $class, 'hidden');
foreach($columns as $column) {
$html.=T($class).':<b>'.T($column['Field']).'</b>: ';
$html.='<br />';
}
- if($multi_insert) {
- //TODO, move to separate JS file
+ if($multi_insert) { //TODO, move to separate JS file
$html.=<<<EOF
- </div>
- <span name="input_set_next"></span><br style="clear:both" />
+ </div></span>
+ <br style="clear:both" />
<script>
function duplicate_element(what, where) {
- document.getElementsByName(where)[0].outerHTML =
- document.getElementsByName(what)[0].outerHTML
- + document.getElementsByName(where)[0].outerHTML;
+ var node = document.getElementsByName(what)[0];
+ node.parentNode.appendChild(node.cloneNode(true));
}
</script>
- <a href='#' onClick="duplicate_element('input_set', 'input_set_next')">+</a>
+ <a href='#' onClick="duplicate_element('input_set')">+</a>
EOF;
}
$html.= '-';
$html.= $this->html->link('>>', "$class/$id_next/");
$html.= '<br />';
+ $html.='<span style="float:right;">'.$this->html->render_barcode(BARCODE_PREFIX.strtoupper("$class/$id")).'</span>';
$html.= $this->html->link('edit', "$class/$id/edit/");
if($this->db->contains_history($class)) $html.= ' ][ '.$this->html->link('history', "$class/$id/history/");
- $html.='<br />'.$this->html->render_barcode(BARCODE_PREFIX.strtoupper("$class/$id"));
return $html;
}
$sklad = new Sklad_UI();
$sklad->process_http_request();
-echo("<hr/>");
+echo('<br style="clear:both;" /><hr />');