]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 134571 - client-side image maps in showdependencygraph.cgi
authorbbaetz%student.usyd.edu.au <>
Tue, 7 May 2002 16:14:35 +0000 (16:14 +0000)
committerbbaetz%student.usyd.edu.au <>
Tue, 7 May 2002 16:14:35 +0000 (16:14 +0000)
Patch by zeroJ@null.net (John Vandenberg), r=bbaetz, justdave

showdependencygraph.cgi
template/en/default/bug/dependency-graph.html.tmpl

index dbde0edc8e8c80baf42aedeb9b3c52bfed12e813..4df71ac49f9a869506153a036d2ea26713b59c65 100755 (executable)
@@ -37,6 +37,26 @@ use vars qw($template $vars $userid $usergroupset);
 my %seen;
 my %edgesdone;
 
+sub CreateImagemap {
+    my $mapfilename = shift;
+    my $map = "<map name=\"imagemap\">\n";
+    my $default;
+
+    open MAP, "<$mapfilename";
+    while(my $line = <MAP>) {
+        if($line =~ /^default ([^ ]*)(.*)$/) {
+            $default = qq{<area shape="default" href="$1">\n};
+        }
+        if ($line =~ /^rectangle \((.*),(.*)\) \((.*),(.*)\) (http[^ ]*)(.*)?$/) {
+            $map .= qq{<area name="bug$6" shape="rect" href="$5" coords="$1,$4,$3,$2">\n};
+        }
+    }
+    close MAP;
+
+    $map .= "$default</map>";
+    return $map;
+}
+
 sub AddLink {
     my ($blocked, $dependson) = (@_);
     my $key = "$blocked,$dependson";
@@ -162,9 +182,9 @@ if ($webdotbase =~ /^https?:/) {
     my $pngfilename = "data/webdot/$$.png";
     my $mapfilename = "data/webdot/$$.map";
     system("$webdotbase","-Tpng","-o","$pngfilename","$filename");
-    system("$webdotbase","-Timap","-o","$mapfilename","$filename");
     $vars->{'image_url'} = $pngfilename;
-    $vars->{'map_url'} = $mapfilename;
+    system("$webdotbase","-Tismap","-o","$mapfilename","$filename");
+    $vars->{'image_map'} = CreateImagemap($mapfilename);
 }
 
 # Cleanup any old .dot files created from previous runs.
index 93c515bd8ba323b2b2258f5337e8eda23cf98333..3266f5fd79200ce0040424bb33a92cd6b70cfc90 100644 (file)
@@ -27,7 +27,9 @@
   # rankdir: string. "TB" if we are ranking top-to-bottom, 
                      "LR" if left-to-right.
   # image_url: string. The URL of the graphic showing the dependencies.
-  # map_url: string. The URL of the map file for the image.                   
+  # map_url: string. The URL of the map file for the image.  (Optional)
+  # image_map: string. The image map for the graphic showing the 
+                       dependencies. (Optional)
   #%]
 
 [% title = "Dependency Graph"
 
 [% PROCESS global/header.html.tmpl %]
 
+[% image_map %]
+
 <p>
   Green circles represent open bugs.
 </p>
 
-<a href="[% map_url %]">
-  <img src="[% image_url %]" ismap> 
-</a>
+[% IF image_map %]
+  <img src="[% image_url %]" usemap="#imagemap"> 
+[% ELSE %]
+  <a href="[% map_url %]">
+    <img src="[% image_url %]" ismap> 
+  </a>
+[% END %]
 
 <hr>