Author: spadkins
Date: Tue Apr 20 11:29:40 2010
New Revision: 13910
Modified:
p5ee/trunk/App-Widget-ChartDirector/lib/App/Widget/ChartDirector.pm
Log:
added graph_image_dir for report caching
Modified: p5ee/trunk/App-Widget-ChartDirector/lib/App/Widget/ChartDirector.pm
==============================================================================
--- p5ee/trunk/App-Widget-ChartDirector/lib/App/Widget/ChartDirector.pm
(original)
+++ p5ee/trunk/App-Widget-ChartDirector/lib/App/Widget/ChartDirector.pm Tue Apr
20 11:29:40 2010
@@ -103,6 +103,7 @@
sub create_graph_spec {
&App::sub_entry if ($App::trace);
my ($self) = @_;
+
my $context = $self->{context};
my $options = $context->{options};
my $spec_tempdir = $options->{tempdir} || "$options->{prefix}/tmp";
@@ -112,10 +113,21 @@
$year += 1900;
my $datetime = sprintf("%04d%02d%02d-%02d%02d%02d", $year, $mon, $mday,
$hour, $min, $sec);
my $unique_tag = $datetime . "-" . $$ . "-" . $serial;
+
+ my %spec = %$self;
+ delete $spec{context};
+
+ if ( $spec{graph_image_dir} ne "" ) {
+ $spec_tempdir = $spec{graph_image_dir};
+ $image_tempdir = $spec{graph_image_dir};
+ }
+
my $spec_file = "$unique_tag.graph";
my $spec_path = "$spec_tempdir/$spec_file";
+
my $image_file = "$unique_tag.png";
my $image_path = "$image_tempdir/$image_file";
+
while (-f $spec_path || -f $image_path) {
$serial++;
$unique_tag = $datetime . "-" . $$ . "-" . $serial;
@@ -124,8 +136,7 @@
$image_file = "$unique_tag.png";
$image_path = "$image_tempdir/$image_file";
}
- my %spec = %$self;
- delete $spec{context};
+
$spec{graphtype} ||= "bar";
if ($spec{graphtype} eq "area") {
$spec{graphtype} = "line";
@@ -141,7 +152,17 @@
$spec{spec_path} = $spec_path;
$spec{image_file} = $image_file;
$spec{image_path} = $image_path;
- $spec{image_url} = "$options->{html_url_dir}/temp/$image_file";
+
+ my $url_file = $image_path;
+ if ( $spec{graph_image_dir} ne "" ) {
+ $url_file =~ s/$options->{document_root}\///;
+ $spec{image_url} = "/$url_file";
+ }
+ else {
+ $spec{image_url} = "$options->{html_url_dir}/temp/$image_file";
+ }
+ #print STDERR "ChartDirector: create_graph_spec()
image_file=[$spec{image_file}] image_path=[$spec{image_path}]
image_url=[$spec{image_url}]\n";
+
$spec{cgi_url} = "$options->{script_url_dir}/app-cdgraph/$spec_file";
&App::sub_exit(\%spec) if ($App::trace);
return(\%spec);