* * -------------------------------------------- * * 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, $start, $phpgw_info; $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"; // --------------------------------- nextmatch --------------------------- // nextmatchs $bo = CreateObject('admin.bolog',True); if (!isset($start)) { $start = 0; } $num_rows = $phpgw_info['user']['preferences']['common']['maxmatchs']; $stop = $start + $num_rows; if ($stop > count($rows)) { $stop = count($rows); } $nextmatchs = CreateObject('phpgwapi.nextmatchs'); $total_records = $bo->get_no_errors(); $left = $nextmatchs->left('/admin/log.php',$start,$total_records,$extradata=''); $right = $nextmatchs->right('/admin/log.php',$start,$total_records,$extradata=''); $hits = $nextmatchs->show_hits($total_records,$start); // -------------------------- end nextmatch ------------------------------------ $html .= ""; $html .= ""; $html .= ""; $html .= ""; $html .= ""; $html .= "
$left $hits Edit Table format $right
"; } } 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']; } // Build Header Row... // First Get the layout arrays... $layout = $head['#layout']; if (gettype($layout) != 'array') { $layout = array_keys($cols); } // printlist, a list of all columns in a logical row, // with Row/ColSpawn values, in print order... $printlist = $this->make_printlist($layout,$cols); // $table contains data for header row.... $table = $this->make_tblhead($printlist,$head); // get GroupBy $groupby = $head['_groupby']; $supres = $head['_supres']; $lastgroup = ''; // build actual Rows... $rparms = array(); $mrow = $stop; for ($rno=0;$rno<$mrow;$rno++) { // Build GroupKey if (isset($groupby)) { $gkey = ''; reset($groupby); while (list($gname,)=each($groupby)) { $gkey .= $rows[$rno][$gname]['value']; } $rows[$rno]['#gkey'] = $gkey; } reset($printlist); while(list($pc,$pcol)=each($printlist)) { $cname = $pcol['#name']; $cparms = array_merge($head[$cname],$pcol,array('bgcolor'=>'FFFFFF'),$rows[$rno][$cname]); $rows[$rno][$cname] = $cparms; } } // Grouping Suppression if (isset($groupby)) { $grno = $start; $gkey = $rows[$start]['#gkey']; for ($rno=$start+1;$rno<$stop;$rno++) { $rowspan = 1; $rkey = $rows[$rno]['#gkey']; while ( $gkey == $rkey) { //echo "

grno:$grno ($gkey) rno:$rno ($rkey) are equal

"; $rowspan = $rowspan + 1; $row = $rows[$rno]; for ($pc=0;$pcgrno:$grno ($gkey) rno:$rno ($rkey) are not equal

"; $grno=$rno; $gkey=$rkey; } } /* ** Now Generate the Html For the Table Header */ //print_r($table); $html .= $this->html_head($head,$table,$printlist); /* ** Now (finaly) Generate the Html For the Table */ //print_r($rows); for ($rno=$start;$rno<$stop;$rno++) { // let user have a hack at the row... $row = $obj->$frtn($rno,$rows[$rno]); // $row = $rows[$rno]; // $rp = $this->makeparms($row[$rno]['#row_parms']); $rp = ''; $gkey = $row['#gkey']; // $html .= "\t \n"; $html .= "\t \n"; reset($printlist); while(list($pc,$pcol)=each($printlist)) { $cname = $pcol['#name']; $cp = $this->makeparms($row[$cname]); if($row[$cname]['#supres'] != 'yes') { $html .= "\t\t".$row[$cname]['value']."\n"; } if($pcol['#eor']=='1') { $html .= "\t\n"; // \t\n } } } $html .= "\n"; $html .= ""; return $html; } function makeparms($parmlist) { $html = ''; $comma = ' '; if (gettype($parmlist) != 'array') { return ''; } 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, $noflds, $norows, $layout, $_cols; $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 (isset($_cols)) { $cols = $_cols; } else { if ( gettype($head['_cols'])=="NULL") { $cols = array_keys($rows[0]); } else { $cols = $head['_cols']; }; } if (!isset($noflds)) { $noflds = count($cols); } if (!isset($layout)) { $layout = $head['#layout']; }; if (!isset($norows)) { $norows = count($layout); } if (!isset($nocols)) { $nocols = count($layout[0]); } // Table Excmple // Build Header Row... $html .= "

Table Size

"; // $html .= "

"; $html .= "Rows: "; $html .= ""; $html .= "Columns: "; $html .= ""; $html .= "Fields: "; $html .= ""; // $html .= "\t "; // Column Defintions... $html .= "

Column Definition

"; $html .= "\n"; $f = array(); for ($fno=0;$fno<$noflds;$fno++) { $f[]=$fno; }; // Column Headings $html .= "\t\n"; for ($cno=0;$cno<$nocols;$cno++) { $html .= "\t\t\n"; } $html .= "\t\n"; for ($rno=0;$rno<$norows;$rno++) { $html .= "\t\n"; for ($cno=0;$cno<$nocols;$cno++) { $c = $layout[$rno][$cno]; $tname = "layout[$rno][]"; $t = $this->DropDown($f,$tname,$c); $html .= "\t\t\n"; } $html .= "\t\n"; } $html .= "
$cno
$t
\n"; $html .= "

\n"; // Header of Table... $printlist = $this->make_printlist($layout,$cols); $table = $this->make_tblhead($printlist,$head); $html .= $this->html_head($head,$table,$printlist); $html .= "\n"; $html .= ""; //Field Definitions $html .= "

Field Definitions

"; $html .= "\n"; $html .= "\t\t\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 ($fno=0;$fno<$noflds;$fno++) { $name = $cols[$fno]; $values = $head[$name]; $title = $values['title']; if ($title == '') { $title = $name; } $html .= "\t\n"; $html .= "\t\t\n"; $html .= "\t\t\n"; $html .= "\t\t\n"; $value = $rows[0][$name]['value']; $html .= "\t\t\n"; $html .= "\t\n"; } $html .= "
NoDelFieldValue
$fno".$this->dropdown($cnam,'_cols[]',$name)."$value
\n"; $html .= ""; $html .= "
"; return $html; } function dropdown($opts,$name='',$sel='') { $items = $opts; $html = '\n"; return $html; } function make_printlist($layout,$cols) { // Build Printlist... (Col and Row Spans...) $tlayout = $layout; $printlist = array(); $mrows = count($tlayout); $mcols = count($tlayout[0]); for($pr=0;$pr<$mrows;$pr++) { for($pc=0;$pc<$mcols;$pc++) { if (isset($tlayout[$pr][$pc])) { $cno = $tlayout[$pr][$pc]; $cname = $cols[$cno]; $colspan=1; $rowspan=1; while(($pr + $rowspan < $mrows) && ($tlayout[$pr + $rowspan][$pc] == $cno)) { unset($tlayout[$pr + $rowspan][$pc]); $rowspan++; }; while(($pc + $colspan < $mcols) && ($tlayout[$pr][$pc+$colspan] == $cno)) { unset($tlayout[$pr][$pc+$colspan]); $colspan++; }; if ($colspan > 1 && $rowspan > 1) { for($r=$pr+1;$r<$pr+$rowspan;$r++) { for($c=$pc+1;$c<$pc+$colspan;$c++) { unset($tlayout[$r][$c]); } } } $printlist[]=array('#name' =>$cname, 'rowspan' =>$rowspan, 'colspan' =>$colspan, 'valign' =>'top', '#colno' =>$cno, '#eor' =>0 ); } } $printlist[count($printlist)-1]['#eor']='1'; } return $printlist; } function make_tblhead($printlist,$head) { // Build Title Row $table = array(); reset($printlist); while(list($pc,$pcol)=each($printlist)) { $cname = $pcol['#name']; $values = $head[$cname]; $title = $values['#title']; if ($title == '') { $title = $cname; } $cparms = array_merge($values['#parms_hdr'],$pcol); $cparms['value']=$title; $table[0][$pc] = $cparms; } return $table; } function html_head($head,$table,$printlist) { $html = ''; $tparams = $this->makeparms($head['#table_parms']); $html .= "\n"; $rp = $this->makeparms($head['#head_parms']); // $html .= "\t\n"; $html .= "\t \n"; $row = $table[0]; reset($row); $intr = true; while(list(,$col)=each($row)) { if (!$intr) { $html .= "\t\n"; $intr = true; } $cname = $col['#name']; $cp = $this->makeparms($col); $html .= "\t\t\n"; if($col['#eor']=='1') { $html .= "\t\n"; $intr = false; } } return $html; } }
".$col['value']."