fix [ 1489123 ] problem with graphing

This commit is contained in:
Martin Kamerbeek 2006-05-16 12:11:16 +00:00
parent 45b61ec3ac
commit 9f136ed01e
3 changed files with 48 additions and 16 deletions

View file

@ -3,6 +3,7 @@
- Bug fixes to make WebGUI work with the WRE demo system.
- Fixed a typo in the activities in the config file.
- fixed a bug that caused threadId's to be empty in new posts
- fix [ 1489123 ] problem with graphing (Martin Kamerbeek / Procolix)
6.99.0
- Added a workflow system.

View file

@ -251,19 +251,21 @@ sub getEditForm {
) if $self->session->form->process("func") ne 'add';
my $config = {};
if ($self->get('graphConfiguration')) {
$config = Storable::thaw($self->get('graphConfiguration'));
}
if (WebGUI::Image::Graph->getPluginList($self->session)) {
my $config = {};
if ($self->get('graphConfiguration')) {
$config = Storable::thaw($self->get('graphConfiguration'));
}
$tabform->addTab('graph', 'Graphing');
$tabform->getTab('graph')->yesNo(
-name => 'generateGraph',
-label => $i18n->get('generate graph'),
-hoverHelp => $i18n->get('generate graph description'),
-value => $self->getValue('generateGraph'),
);
$tabform->getTab('graph')->raw(WebGUI::Image::Graph->getGraphingTab($self->session, $config));
$tabform->addTab('graph', 'Graphing');
$tabform->getTab('graph')->yesNo(
-name => 'generateGraph',
-label => $i18n->get('generate graph'),
-hoverHelp => $i18n->get('generate graph description'),
-value => $self->getValue('generateGraph'),
);
$tabform->getTab('graph')->raw(WebGUI::Image::Graph->getGraphingTab($self->session, $config));
}
return $tabform;
}
@ -310,8 +312,10 @@ sub processPropertiesFromFormPost {
$property->{'a'.$i} = $answer[($i-1)];
}
my $graph = WebGUI::Image::Graph->processConfigurationForm($self->session);
$property->{graphConfiguration} = Storable::freeze($graph->getConfiguration);
if (WebGUI::Image::Graph->getPluginList($self->session)) {
my $graph = WebGUI::Image::Graph->processConfigurationForm($self->session);
$property->{graphConfiguration} = Storable::freeze($graph->getConfiguration);
}
$self->update($property);
$self->session->db->write("delete from Poll_answer where assetId=".$self->session->db->quote($self->getId)) if ($self->session->form->process("resetVotes"));

View file

@ -5,6 +5,7 @@ use WebGUI::Image;
use WebGUI::Image::Palette;
use WebGUI::Image::Font;
use List::Util;
use WebGUI::Utility;
our @ISA = qw(WebGUI::Image);
@ -231,6 +232,14 @@ sub getGraphingTab {
my $i18n = WebGUI::International->new($session, 'Image_Graph');
my $f = WebGUI::HTMLForm->new($session);
unless ($session->config->get("graphingPlugins")) {
$f->readOnly(
-value => "No graphing plugins are enabled in the config file."
);
return $f->printRowsOnly;
}
foreach (@{$session->config->get("graphingPlugins")}) {
my $plugin = WebGUI::Image::Graph->load($session, $_);
@ -486,6 +495,20 @@ sub getMaxValueFromDataset {
return List::Util::max(@{$self->{_dataset}});
}
#-------------------------------------------------------------------
=head2 getPluginList
Returns an arrayref containing the namespaces of the enabled graphing plugins.
=cut
sub getPluginList {
my $self = shift;
my $session = shift || $self->session;
return $session->config->get("graphingPlugins");
}
#-------------------------------------------------------------------
=head2 load ( session, namespace )
@ -558,13 +581,17 @@ The WebGUI session object.
=cut
sub processConfigurationForm {
my $self = shift;
my $class = shift;
my $session = shift;
return undef unless ($class->getPluginList($session));
my $namespace = "WebGUI::Image::".$session->form->process('graphingPlugin');
$namespace =~ s/_/::/g;
my $graph = $self->load($session, $namespace);
return undef unless (isIn($namespace, @{$class->getPluginList($session)}));
my $graph = $class->load($session, $namespace);
$graph->setConfiguration($session->form->paramsHashRef);