X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=index.php;h=2f92066682e8a62a4a1ac4fea6cd9b3929a6f329;hb=180fef5ada8f8d3290e2f0f6ce51a2df44132aaa;hp=ec062faa29d7c65b0884ed76a1b54c2abd90aebc;hpb=35916247a3b7ed49d0dc758ebdf76cf636763d2c;p=mirrors%2FSokoMan.git diff --git a/index.php b/index.php index ec062fa..2f92066 100755 --- a/index.php +++ b/index.php @@ -20,9 +20,11 @@ require_once('sklad.conf.php'); set_include_path(DIR_LIB.PATH_SEPARATOR.get_include_path()); -require_once('Sklad_LMS-fake.class.php'); +require_once('Sklad_Auth.class/common.php'); require_once('HTTP_Auth.class.php'); require_once('Locale.class.php'); +require_once('Barcode.class.php'); +require_once('Fortune.php'); /** * Trida poskytuje vseobecne funkce pro generovani HTML kodu @@ -33,40 +35,73 @@ require_once('Locale.class.php'); * @author Tomas Mudrunka */ class HTML { - function row($row) { - $html=''; - foreach($row as $var) { + function row($row,$type=false,$class=false,$parameters='',$colspan=array(),$rowspan=array(),$break_after=array()) { + $html = ''; + $class_br = $class ? " class='$class' " : ''; + $class = $class ? " class='$class tr_nobr' " : ''; + if($type) $html.="<$type>"; + $html.=""; + $td = $type == 'thead' ? 'th' : 'td'; + foreach($row as $id => $var) { + $tdclass = " class='cell_$id'"; if(trim($var) == '') $var = ' '; - $html.="$var"; + $rs = isset($rowspan[$id]) ? " rowspan='$rowspan[$id]'" : ''; + $cs = isset($colspan[$id]) ? " colspan='$colspan[$id]'" : ''; + $html.="<$td$rs$cs$tdclass>$var"; + if(in_array($id,$break_after,true)) $html.=''.""; } $html.=''; + if($type) $html.=""; return $html; } - function table(&$table, $params='border=1') { + function table(&$table,$colspan=array(),$rowspan=array(),$break_after=array(),$parity_class=array('tr_odd','tr_even'),$params='border=1',$row_classes_field='_row_classes') { $html=""; $header=true; + $even=false; foreach($table as $row) { + $params = isset($row[$row_classes_field]) ? $row[$row_classes_field] : ''; + unset($row[$row_classes_field]); if($header) { - $html.=$this->row(array_keys($row)); + $keys = array(); foreach($row as $key => $val) $keys[$key]=$key; + $html.=$this->row(T($keys),'thead',false,'',$colspan,$rowspan,$break_after); $header=false; } - $html.=$this->row($row); + $class = $parity_class ? $parity_class[$even] : false; + $html.=$this->row($row,false,$class.$params,'',$colspan,$rowspan,$break_after); + $even = !$even; } $html.='
'; return $html; } - function link($title='n/a', $link='#void', $internal=true) { + function link($title='n/a', $link='#void', $internal=true, $translate=true) { if($internal && (!isset($link[0]) || $link[0] != '#')) $link = $this->internal_url($link); - return "".T($title).""; + if($translate) $title = T($title); + return "".$title.""; } - function img($src='#void', $title='img') { - return "$title"; + function img($src='#void', $title='img', $options='height=64') { + if(isset($_GET['noimgs'])) return "".basename($src).''; + $options = $options ? " $options" : ''; + return "$title"; + } + + function img_link($src, $link='#void', $title='img_link', $internal=true, $translate=true, $options='height=64') { + return $this->link($this->img($src,$title,$options),$link,$internal,$translate); + } + + function textarea($name=false, $value='', $placeholder=false, $options=false, $prefix='') { + $html = T($prefix)."textarea($name, $value, $placeholder, $options, $prefix); $html = T($prefix)."'); print_r($selectbox); $html = ""; return $html; @@ -125,6 +160,20 @@ class HTML { $options = $options ? " $options" : ''; return "$html"; } + + function favicon($url='/favicon.ico') { + return ''; + + } + + function head($title=false,$charset='UTF-8',$more='') { + $title = $title ? "\n$title" : ''; + $html= ''; + $html.= ''.$title.$more; + $html.= $this->favicon(dirname($_SERVER['SCRIPT_NAME']).'/favicon.ico'); + $html.= ''; + return $html; + } } /** @@ -136,22 +185,46 @@ class HTML { * @author Tomas Mudrunka */ class Sklad_HTML extends HTML { //TODO: Split into few more methods - function header($title='') { + function header($title='', $user=array(), $headerhtml) { $home = URL_HOME; $script = $_SERVER['SCRIPT_NAME']; $search = htmlspecialchars(@trim($_GET['q'])); - $message = strip_tags(@trim($_GET['message']),''); + $message = strip_tags(@trim($_GET['message']),'
'); + $fortune = fortune(); $instance = INSTANCE_ID != '' ? '/'.INSTANCE_ID : ''; + $user_id = htmlspecialchars($user['id']); + $user_gid = htmlspecialchars($user['gid']); + $user_name = htmlspecialchars($user['name']); + $time = date('r'); //$title = T($title); //TODO - $html = << - - SōkoMan$title - -

SōkoMan$instance$title

+ + $html = $this->head("SōkoMan$title"); + $html .= <<SōkoMan$instance$title +
+ Logged in as $user_name [UID: $user_id; GID: $user_gid]
+ Page loaded at $time +