DataCube
view release on metacpan or search on metacpan
lib/DataCube/Cube/Style/HTML.pm view on Meta::CPAN
package DataCube::Cube::Style::HTML;
use strict;
use warnings;
use DateTime;
use DataCube::Cube::Style::HTML::CSS;
sub new {
my($class,%opts) = @_;
bless { %opts }, ref($class) || $class;
}
sub html {
my($self,$cube) = @_;
my $html = "";
$html .= $self->start_html($cube);
$html .= $self->start_body($cube);
$html .= $self->top_section($cube);
$html .= $self->start_details($cube);
$html .= $self->details($cube);
$html .= $self->end_details($cube);
$html .= $self->end_body($cube);
$html .= $self->end_html($cube);
return $html;
}
sub html_from_table {
my($self,$cube,@table) = @_;
my $html = "";
$html .= $self->start_html($cube);
$html .= $self->start_body($cube);
$html .= $self->top_section($cube,@table);
$html .= $self->start_details($cube);
$html .= $self->details_from_table($cube,@table);
$html .= $self->end_details($cube);
$html .= $self->end_body($cube);
$html .= $self->end_html($cube);
return $html;
}
sub start_html {
my($self,$cube) = @_;
my $style = DataCube::Cube::Style::HTML::CSS->new;
my $html = '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<title>Cube Report</title>';
$html .= $style->css;
$html .= '</head>';
return $html;
}
sub end_html {
my($self,$cube) = @_;
my $html = '</html>';
return $html;
}
sub start_body {
my($self,$cube) = @_;
my $html = '<body>';
return $html;
}
sub end_body {
my($self,$cube) = @_;
my $dt = DateTime->now;
my $year = $dt->year;
my $html = '
<br />
<h2>
<div style="font-size:80%;">
Cube Report Generated by Project Codenamed "Blackbear"
<br />
Copyright (C) 2009-' . $year . ' David Williams
</div>
</h2>
</body>';
return $html;
}
sub top_section {
my($self,$cube,@table) = @_;
my $time = scalar(localtime());
my $rows = @table ? $#table : scalar(keys %{$cube->{cube}});
my $schema = $cube->schema;
my $dim_count = $schema->field_count;
my $mea_count = $schema->measure_count;
my $html = "
<h1>Cube Report</h1>
<p>
<span class='note'>
<strong>Report Generated at: $time</strong>
<br>
</span>
</p>";
$html .= "
<table cellpadding='2' cellspacing='0' width='98%' border='1' bordercolor='white' class='infotable'>
<tr>
<td class='header' colspan='2'>Cube Report Summary</td>
</tr>
( run in 3.065 seconds using v1.01-cache-2.11-cpan-63c85eba8c4 )