* * -------------------------------------------- * * This program is free software; you can redistribute it and/or modify it * * under the terms of the GNU General Public License as published by the * * Free Software Foundation; either version 2 of the License, or (at your * * option) any later version. * \**************************************************************************/ /* $Id$ */ class html { function hash_table($rows,$head='',$obj, $frtn) { global $phpgw; $html = ''; $edittable =$head['_edittable']; if (isset($edittable)) { if ($edittable) { // Generate the customization table... return $this->edit_table($rows,$head,$obj,$frtn); } else { $html .= "
link('/admin/log.php') . "&editable=true\">\n"; $html .= ""; } } $params = $head['_table_parms']; if ($head == '') { $frow = $rows[0]; $cnam = array_keys($frow); while(list(,$fn)=each($cnam)) { $head[$fn] = array(); } }; if ( gettype($head['_cols'])=="NULL") { $cols = array_keys($rows[0]); } else { $cols = $head['_cols']; }; $html .= "\n"; // Build Header Row... $html .= "\t "; reset($cols); while (list(,$name) = each($cols)) { $values = $head[$name]; $title = $values['title']; if ($title == '') { $title = $name; } $html .= "\t\t\n"; } $html .= "\t\n"; // get GroupBy $groupby = $head['_groupby']; $supres = $head['_supres']; $lastgroup = ''; // build actual Rows... /* ** Okay here goes nothing ** Need to build a table in an array so that I can directly access ** the diferent portions and change attributes directly... */ // Start by making an empty table, with default values! $rparms = array(); $table = array(); $mrow = count($rows); $mcol = count($cols); for ($rno=0;$rno<$mrow;$rno++) { $rparms[$rno] = array ( 'VALIGN' =>'TOP', 'bgcolor' =>'FFFFFF' ); for($cno=0;$cno<$mcol;$cno++) { $table[$rno][$cno] = array ( 'VALIGN' =>'TOP', 'colspan' =>1, 'rowspan' =>1, 'value' =>$rows[$rno][$cols[$cno]], 'bgcolor' =>'FFFFFF', '#supres' =>'no' ); } // Build GroupKey if (isset($groupby)) { $gkey = ''; reset($groupby); while (list($gname,)=each($groupby)) { $gkey .= $rows[$rno][$gname]; } $table[$rno]['#gkey'] = $gkey; } } // Grouping Suppression if (isset($groupby)) { $grno = 0; for ($rno=1;$rno<$mrow;$rno++) { $rowspan = 1; $gkey = $table[$grno]['#gkey']; $rkey = $table[$rno]['#gkey']; while ( $gkey == $rkey) { $rowspan = $rowspan + 1; for ($cno=0;$cno<$mcol;$cno++) { if ($supres[$cols[$cno]]) { $table[$rno][$cno]['#supres']='yes'; $table[$rno][$cno]['value']='  '; $table[$grno][$cno]['rowspan']=$rowspan; } } $rno++; if ($rno >= $mrow) { break; } $rkey = $table[$rno]['#gkey']; } $grno=$rno; $gkey=$rkey; } } /* ** Now (finaly) Generate the Html For the Table */ for ($rno=0;$rno<$mrow;$rno++) { // let user have a hack at the row... $table[$rno]=$obj->$frtn($rno,$table[$rno]); $rp = $this->makeparms($rparms[$rno]); $gkey = $table[$rno]['#gkey']; $html .= "\t\n"; for($cno=0;$cno<$mcol;$cno++) { if ($table[$rno][$cno]['#supres']=='no') { $cp = $this->makeparms($table[$rno][$cno]); $html .= "\t\t\n"; }; } $html .= "\t\n"; } $html .= "
".$title."
".$table[$rno][$cno]['value']."
\n"; $html .= "
"; return $html; } function makeparms($parmlist) { $html = ''; $comma = ' '; reset($parmlist); while(list($pname,$pvalue)=each($parmlist)) { switch($pname) { case 'value': break; case 'colspan': case 'rowspan': if ($pvalue != 1) { $html .= $comma . $pname . '="' . $pvalue . '"'; $comma = ', '; }; break; default: if (substr($pname,0,1) != '#') { $html .= $comma . $pname . '="' . $pvalue . '"'; $comma = ', '; } } } return $html; } function edit_table($rows,$head='',$obj, $frtn) { global $phpgw, $nocols; $html = ''; $html .= "
link('/admin/log.php') . "&editable=true" . "\">\n"; $params = $head['_table_parms']; $frow = $rows[0]; $cnam = array_keys($frow); if ($head == '') { while(list(,$fn)=each($cnam)) { $head[$fn] = array(); } }; if ( gettype($head['_cols'])=="NULL") { $cols = array_keys($rows[0]); } else { $cols = $head['_cols']; }; if (!isset($nocols)) { $nocols = count($cols); } // Build Header Row... $html .= "

Number of Columns: "; $html .= ""; $html .= ""; $html .= "

\n"; $html .= "\t "; $html .= "\n"; $html .= "\t\t\n"; $html .= "\t\t\n"; $html .= "\t\t\n"; $html .= "\t\n"; // Add Table Rows... reset($cols); // while (list($cno,$name) = each($cols)) for ($cno=0;$cno<$nocols;$cno++) { $name = $cols[$cno]; $values = $head[$name]; $title = $values['title']; if ($title == '') { $title = $name; } $html .= "\t\n"; $html .= "\t\t\n"; $html .= "\t\t\n"; $value = $rows[0][$name]; $html .= "\t\t\n"; $html .= "\t\n"; } $html .= "
DelColumnValue
".$this->dropdown($cnam,'_cols[]',$name)."$value
\n"; $html .= ""; $html .= "
"; return $html; } function dropdown($opts,$name='',$sel='') { $items = $opts; $html = '\n"; return $html; } }