4 use CatalystX
::GlobalContext
'$c';
8 use CXGN
::Scrap
::AjaxPage
;
9 use CXGN
::Sunshine
::Browser
;
10 use CXGN
::Sunshine
::Node
;
11 use CXGN
::Tools
::WebImageCache
;
12 use CatalystX
::GlobalContext
'$c';
14 my $ajax_page = CXGN
::Scrap
::AjaxPage
->new("Sunshine", "Lukas");
16 my $dbh = $c->dbc->dbh;
18 my ($name, $type, $level, $force, $hide_relationships, $hilite) = $ajax_page->get_arguments("name", "type", "level", "force", "hide", "hilite");
20 my $temp_dir = File
::Spec
->catfile(
21 $c->config->{"tempfiles_subdir"},
25 my $b = CXGN
::Sunshine
::Browser
->new($dbh);
28 $b->set_level_depth($level);
31 my @hide_relationships = split /\s+/, $hide_relationships;
32 $b->set_hide_relationships(@hide_relationships);
33 $b->set_hilited_nodes($hilite);
34 $b->set_ref_node_name($name);
35 $b->set_ref_node_type($type);
38 my $ref_node = $b->get_node("$name");
40 print "Content-Type: text/xml\n\n<ajax><error>The node selected is not defined</error></ajax>";
44 if ($b->set_reference_node($ref_node)) {
45 #$page->message_page("The node ".$ref_node->get_name()." does not exist in the graph. Sorry!");
51 my $mapname = "clickmap".time(); # create some unique string so that it reloads on Safari
52 my $cache = CXGN
::Tools
::WebImageCache
->new();
53 $cache->set_key($name."-".$type."-".$level."-".(join ":", @hide_relationships));
54 $cache->set_expiration_time(86400); # seconds, this would be a day.
55 $cache->set_map_name($mapname); # what's in the <map name='map_name' tag.o
56 $cache->set_temp_dir($temp_dir);
57 $cache->set_basedir($c->config->{"basepath"});
58 $force = 1; # always force because the map name has to be unique (no caching is possible... unfortunately)
59 if (! $cache->is_valid() || $force) {
60 # generate the image and associated image map.
63 my $img_data = $b->render_string();
64 my $img_map_data = $b->get_image_map($mapname);
65 $cache->set_image_data($img_data);
66 $cache->set_image_map_data($img_map_data);
69 my $contents = "Content-Type: text/xml\n\n<ajax>".$cache->get_image_html()."</ajax>\n";