From: Thomas Mudrunka Date: Sun, 18 Mar 2012 22:18:43 +0000 (+0100) Subject: Viceradkovy tabulky X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=5a7b0bb6ca024195fb33e68e91fbe2d9ce1dd043;p=mirrors%2FSokoMan.git Viceradkovy tabulky --- diff --git a/index.php b/index.php index d6eb660..2b96628 100755 --- a/index.php +++ b/index.php @@ -35,23 +35,27 @@ require_once('Fortune.php'); * @author Tomas Mudrunka */ class HTML { - function row($row,$type=false,$class=false,$parameters='') { + function row($row,$type=false,$class=false,$parameters='',$colspan=array(),$rowspan=array(),$break_after=array()) { $html = ''; $class = $class ? $class=" class='$class' " : ''; if($type) $html.="<$type>"; - $html.=""; + $tr=""; + $html.=$tr; $td = $type == 'thead' ? 'th' : 'td'; foreach($row as $id => $var) { $tdclass = " class='cell_$id'"; if(trim($var) == '') $var = ' '; - $html.="<$td$tdclass>$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.=''.$tr; } $html.=''; if($type) $html.=""; return $html; } - function table(&$table, $parity_class=array('tr_odd','tr_even'), $params='border=1', $row_params_field='_row_parameters') { + function table(&$table,$colspan=array(),$rowspan=array(),$break_after=array(),$parity_class=array('tr_odd','tr_even'),$params='border=1',$row_params_field='_row_parameters') { $html=""; $header=true; $even=false; @@ -59,11 +63,12 @@ class HTML { $params = isset($row[$row_params_field]) ? $row[$row_params_field] : ''; unset($row[$row_params_field]); if($header) { - $html.=$this->row(T(array_keys($row)),'thead'); + $keys = array(); foreach($row as $key => $val) $keys[$key]=$key; + $html.=$this->row(T($keys),'thead',false,$params,$colspan,$rowspan,$break_after); $header=false; } $class = $parity_class ? $parity_class[$even] : false; - $html.=$this->row($row,false,$class.$params); + $html.=$this->row($row,false,$class,$params,$colspan,$rowspan,$break_after); $even = !$even; } $html.='
'; @@ -212,7 +217,7 @@ li a, a:hover { text-decoration:underline; } .item_status_destroyed td { font-style:italic; } /* table, table * { table-layout:fixed; width:100%; overflow:hidden; word-wrap:break-word; } */ /* td { position:absolute; } */ -.cell_model_name { } +/* .cell_model_name { float:left; } */ .menu li { @@ -444,6 +449,25 @@ EOF; } function render_item_table($table,$class=false) { + + $cellspan = array( + 'break_after' => array( + 'item' => array('model_name'), + 'model'=> array('model_descript') + ), + 'rowspan' => array( + 'item' => array('model_image'=>2,'item_id'=>2), + 'model'=> array('model_image'=>2) + ), + 'colspan' => array( + 'item' => array('model_name'=>'100%'), + 'model'=> array('model_name'=>4,'model_descript'=>'100%') + ) + ); + + foreach(array_keys($cellspan) as $vari) + $$vari = isset($cellspan[$vari][$class]) ? $cellspan[$vari][$class] : array(); + if(empty($table)) return '

'.T('holy primordial emptiness is all you can find here...').'


'; $this->table_add_row_parameters($table); $this->table_add_images($table); @@ -452,7 +476,7 @@ EOF; $this->table_collapse($table); if($class) $this->table_hide_columns($table,$class); $this->table_sort($table); - return $this->table($table); + return $this->table($table,$colspan,$rowspan,$break_after); } function render_insert_inputs($class,$columns,$selectbox,$current,$hidecols,$update) {