📄 default.php
字号:
case 'xls': $this->print_excel_report($course, $hotpot, $tables, $options); break; default: // 'htm' (and anything else) $this->print_html_report($tables); break; } } function print_report_start(&$course, &$hotpot, &$options, &$table) { switch ($options['reportformat']) { case 'txt': $this->print_text_start($course, $hotpot, $options); break; case 'xls': $this->print_excel_start($course, $hotpot, $options); break; case 'htm': $this->print_html_start($course, $hotpot, $options); break; } } function print_report_cells(&$table, &$options, $zone) { switch ($options['reportformat']) { case 'txt': $fmt = 'text'; break; case 'xls': $fmt = 'excel'; break; default: // 'htm' (and anything else) $fmt = 'html'; break; } $fn = "print_{$fmt}_{$zone}"; $this->$fn($table, $options); } function print_report_finish(&$course, &$hotpot, &$options) { switch ($options['reportformat']) { case 'txt' : // do nothing break; case 'xls': $this->print_excel_finish($course, $hotpot, $options); break; case 'htm': $this->print_html_finish($course, $hotpot, $options); break; } }///////////////////////////////////////////// print an html report function print_html_report(&$tables) { $count = count($tables); foreach($tables as $i=>$table) { $this->print_html_start($table); $this->print_html_head($table); $this->print_html_data($table); $this->print_html_stat($table); $this->print_html_foot($table); $this->print_html_finish($table); if (($i+1)<$count) { print_spacer(30, 10, true); } } } function print_html_start(&$table) { // default class for the table if (empty($table->tableclass)) { $table->tableclass = 'generaltable'; } // default classes for TD and TH $d = $table->tableclass.'cell'; $h = $table->tableclass.'header'; $table->th_side = '<th valign="top" align="right" class="'.$h.'" scope="col">'; $table->td = array(); $table->th_top = array(); if (empty($table->colspan)) { if (isset($table->head)) { $table->colspan = count($table->head); } else if (isset($table->data)) { $table->colspan = count($table->data[0]); } else if (isset($table->stat)) { $table->colspan = count($table->stat); } else if (isset($table->foot)) { $table->colspan = count($table->foot); } else { $table->colspan = 0; } } for ($i=0; $i<$table->colspan; $i++) { $align = empty($table->align[$i]) ? '' : ' align="'.$table->align[$i].'"'; $class = empty($table->class[$i]) ? $d : ' class="'.$table->class[$i].'"'; $class = ' class="'.(empty($table->class[$i]) ? $d : $table->class[$i]).'"'; $size = empty($table->size[$i]) ? '' : ' width="'.$table->size[$i].'"'; $wrap = empty($table->wrap[$i]) ? '' : ' nowrap="nowrap"'; $table->th_top[$i] = '<th align="center"'.$size.' class="'.$h.'" nowrap="nowrap" scope="col">'; $table->td[$i] = '<td valign="top"'.$align.$class.$wrap.'>'; if (!empty($table->fontsize[$i])) { $table->td[$i] .= '<font size="'.$table->fontsize[$i].'">'; } } if (empty($table->border)) { $table->border = 0; } if (empty($table->cellpadding)) { $table->cellpadding = 5; } if (empty($table->cellspacing)) { $table->cellspacing = 1; } if (empty($table->width)) { $table->width = "80%"; // actually the width of the "simple box" } if (empty($table->tablealign)) { $table->tablealign = "center"; } if (isset($table->start)) { print $table->start."\n"; } print_simple_box_start("$table->tablealign", "$table->width", "#ffffff", 0); print '<table width="100%" border="'.$table->border.'" valign="top" align="center" cellpadding="'.$table->cellpadding.'" cellspacing="'.$table->cellspacing.'" class="'.$table->tableclass.'">'."\n"; if (isset($table->caption)) { print '<tr><td colspan="'.$table->colspan.'" class="'.$table->tableclass.'header"><b>'.$table->caption.'</b></td></tr>'."\n"; } } function print_html_head(&$table) { if (isset($table->head)) { print "<tr>\n"; foreach ($table->head as $i=>$cell) { $th = $table->th_top[$i]; print $th.$cell."</th>\n"; } print "</tr>\n"; } } function print_html_data(&$table) { if (isset($table->data)) { $skipcol = array(); foreach ($table->data as $cells) { print "<tr>\n"; if (is_array($cells)) { $i = 0; // index on $cells $col = 0; // column index while ($col<$table->colspan && isset($cells[$i])) { if (empty($skipcol[$col])) { $cell = &$cells[$i++]; $td = $table->td[$col]; if (is_object($cell)) { $text = $cell->text; if (isset($cell->rowspan) && is_numeric($cell->rowspan) && ($cell->rowspan>0)) { $td = '<td rowspan="'.$cell->rowspan.'"'.substr($td, 3); // skip cells below this one $skipcol[$col] = $cell->rowspan-1; } if (isset($cell->colspan) && is_numeric($cell->colspan) && ($cell->colspan>0)) { $td = '<td colspan="'.$cell->colspan.'"'.substr($td, 3); // skip cells to the right of this one for ($c=1; $c<$cell->colspan; $c++) { if (empty($skipcol[$col+$c])) { $skipcol[$col+$c] = 1; } else { $skipcol[$col+$c] ++; } } } } else { // $cell is a string $text = $cell; } print $td.$text.(empty($table->fontsize[$col]) ? '' : '</font>')."</td>\n"; } else { $skipcol[$col]--; } $col++; } // end while } else if ($cells=='hr') { print '<td colspan="'.$table->colspan.'"><div class="tabledivider"></div></td>'."\n"; } print "</tr>\n"; } } } function print_html_stat(&$table) { if (isset($table->stat)) { if (empty($table->statheadercols)) { $table->statheadercols = array(); } foreach ($table->stat as $cells) { print '<tr>'; foreach ($cells as $i => $cell) { if (in_array($i, $table->statheadercols)) { $th = $table->th_side; print $th.$cell."</th>\n"; } else { $td = $table->td[$i]; print $td.$cell."</td>\n"; } } print "</tr>\n"; } } } function print_html_foot(&$table) { if (isset($table->foot)) { foreach ($table->foot as $cells) { print "<tr>\n"; foreach ($cells as $i => $cell) { if ($i==0) { $th = $table->th_side; print $th.$cell."</th>\n"; } else { $th = $table->th_top[$i]; print $th.$cell."</th>\n"; } } print "</tr>\n"; } } } function print_html_finish(&$table) { print "</table>\n"; print_simple_box_end(); if (isset($table->finish)) { print $table->finish."\n"; } }///////////////////////////////////////////// print a text report function print_text_report(&$course, &$hotpot, &$tables, &$options) { $this->print_text_start($course, $hotpot, $options); foreach ($tables as $table) { $this->print_text_head($table, $options); $this->print_text_data($table, $options); $this->print_text_stat($table, $options); $this->print_text_foot($table, $options); } } function print_text_start(&$course, &$hotpot, &$options) { $downloadfilename = clean_filename("$course->shortname $hotpot->name.txt"); header("Content-Type: application/download\n"); header("Content-Disposition: attachment; filename=$downloadfilename"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0,pre-check=0"); header("Pragma: public"); } function print_text_head(&$table, &$options) { if (isset($table->caption)) { $i = strlen($table->caption); $data = array( array(str_repeat('=', $i)), array($table->caption), array(str_repeat('=', $i)), ); foreach($data as $cells) { $this->print_text_cells($cells, $options); } } if (isset($table->head)) { $this->expand_spans($table, 'head');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -